Commit ceb30afd authored by Berk Onat's avatar Berk Onat
Browse files

Adding restricted_uri info.

parent 8eae4ba5
Pipeline #27138 failed with stage
in 7 minutes and 30 seconds
...@@ -643,6 +643,49 @@ def get_updateDictionary(self, defname): ...@@ -643,6 +643,49 @@ def get_updateDictionary(self, defname):
activeSections=['section_energy_van_der_Waals'] activeSections=['section_energy_van_der_Waals']
), ),
} }
# Info for section_restricted_uri
restrictions = {
'number_of_restricted_uri_files' : MetaInfoMap(startpage,
value=int(1),
#autoSections=True,
activeInfo=True,
activeSections=['section_restricted_uri']
),
'restricted_uri_files' : MetaInfoMap(startpage,
#autoSections=True,
activeInfo=True,
activeSections=['section_restricted_uri'],
subfunction={
'function' : self.parameter_file_name,
'supportDict' : self.cntrlDict,
},
),
'restricted_uri_license' : MetaInfoMap(startpage,
value='TINKER License',
#autoSections=True,
activeInfo=True,
activeSections=['section_restricted_uri']
),
'restricted_uri_restriction' : MetaInfoMap(startpage,
value='any access',
#autoSections=True,
activeInfo=True,
activeSections=['section_restricted_uri']
),
'restricted_uri_reason' : MetaInfoMap(startpage,
value='propriety license',
#autoSections=True,
activeInfo=True,
activeSections=['section_restricted_uri']
),
'restricted_uri_issue_authority' : MetaInfoMap(startpage,
value='TINKER',
#autoSections=True,
activeInfo=True,
activeSections=['section_restricted_uri']
),
}
# ------------------------------------------ # ------------------------------------------
# Definitions for section_frame_sequence # Definitions for section_frame_sequence
...@@ -1289,6 +1332,8 @@ def get_updateDictionary(self, defname): ...@@ -1289,6 +1332,8 @@ def get_updateDictionary(self, defname):
dictionary = topology dictionary = topology
elif defname == 'singleconfcalc': elif defname == 'singleconfcalc':
dictionary = singleconfcalc dictionary = singleconfcalc
elif defname == 'restrictions':
dictionary = restrictions
elif defname == 'frameseq': elif defname == 'frameseq':
dictionary = frameseq dictionary = frameseq
elif defname == 'frameseqend': elif defname == 'frameseqend':
......
...@@ -276,8 +276,24 @@ class TINKERParser(SmartParser.ParserBase): ...@@ -276,8 +276,24 @@ class TINKERParser(SmartParser.ParserBase):
#self.initialize_values() #self.initialize_values()
self.secRunOpen = False self.secRunOpen = False
self.metaStorage.reset({'startSection' : [['section_run']]}) self.metaStorage.reset({'startSection' : [['section_run']]})
self.metaStorageRestrict.reset({'startSection' : [['section_restricted_uri']]})
self.reset_values() self.reset_values()
def parameter_file_name(self, cntrldict, itemdict):
""" Function to generate data for parameter files list
"""
working_dir_name = os.path.dirname(os.path.normpath(os.path.abspath(self.fName)))
parmmeta = isMetaStrInDict("parameters",self.cntrlDict)
filename = []
if parmmeta is not None:
if self.cntrlDict[parmmeta].value is not None:
fname = self.cntrlDict[parmmeta].value
filename.append(fname.replace(working_dir_name, '.'+os.path.sep))
if filename:
return False, filename, itemdict
else:
return False, None, itemdict
def tinker_input_output_files(self, backend, gIndex, section, call_level): def tinker_input_output_files(self, backend, gIndex, section, call_level):
"""Called with onClose_x_tinker_section_control_parameters to setup """Called with onClose_x_tinker_section_control_parameters to setup
topology and trajectory inputs/outputs topology and trajectory inputs/outputs
...@@ -599,6 +615,30 @@ class TINKERParser(SmartParser.ParserBase): ...@@ -599,6 +615,30 @@ class TINKERParser(SmartParser.ParserBase):
#self.stepcontrolDict.update({"follow" : followsteps}) #self.stepcontrolDict.update({"follow" : followsteps})
self.onOpen_section_sampling_method(backend, None, None) self.onOpen_section_sampling_method(backend, None, None)
self.onClose_section_sampling_method(backend, None, None) self.onClose_section_sampling_method(backend, None, None)
section_file_Dict = {}
section_file_Dict.update(self.fileDict)
updateDict = {
'startSection' : [[PARSERTAG+'_section_control_parameters']],
'dictionary' : section_file_Dict
}
self.metaStorage.update(updateDict)
self.metaStorage.updateBackend(backend.superBackend,
startsection=[PARSERTAG+'_section_control_parameters'],
autoopenclose=False)
parmmeta = isMetaStrInDict("parameters",self.cntrlDict)
if parmmeta is not None:
if self.cntrlDict[parmmeta].value is not None:
self.secRestrictGIndex = backend.superBackend.openSection("section_restricted_uri")
restrictionsDict = get_updateDictionary(self, 'restrictions')
updateDict = {
'startSection' : [['section_restricted_uri']],
'dictionary' : restrictionsDict
}
self.metaStorageRestrict.update(updateDict)
self.metaStorageRestrict.updateBackend(backend.superBackend,
startsection=['section_restricted_uri'],
autoopenclose=False)
backend.superBackend.closeSection("section_restricted_uri", self.secRestrictGIndex)
def onOpen_section_method(self, backend, gIndex, section): def onOpen_section_method(self, backend, gIndex, section):
# keep track of the latest method section # keep track of the latest method section
...@@ -1158,6 +1198,17 @@ class TINKERParser(SmartParser.ParserBase): ...@@ -1158,6 +1198,17 @@ class TINKERParser(SmartParser.ParserBase):
item = self.prune_list(item) item = self.prune_list(item)
oList.append(item) oList.append(item)
return oList return oList
def checkTinkerParam(self, cmdLine, prmName):
try:
prm = cmdLine.split()[-1]
if "NONE" in prm.upper() or prmName.upper() in prm.upper():
prm = None
else:
prm = ' '.join(cmdLine.split()[1:])
except ValueError:
prm = None
return prm
def readTinkerParameterFile(self, parser, fileName, cntrlDict): def readTinkerParameterFile(self, parser, fileName, cntrlDict):
success = False success = False
...@@ -1170,296 +1221,515 @@ class TINKERParser(SmartParser.ParserBase): ...@@ -1170,296 +1221,515 @@ class TINKERParser(SmartParser.ParserBase):
improper=[] improper=[]
ureybond=[] ureybond=[]
charge=[] charge=[]
mutate=[]
if fileName is not None: if fileName is not None:
with open(fileName, 'r') as fin: with open(fileName, 'r') as fin:
for line in fin: for line in fin:
prm = None
if emptyLine.findall(line): if emptyLine.findall(line):
continue continue
cmdLine = ' '.join([x for x in line.strip().split() if x]).upper() cmdLine = ' '.join([x for x in line.strip().split() if x])
if cmdLine.startswith('#'): cmdLineUp = cmdLine.upper()
if cmdLine.startswith('#') or cmdLine.startswith('echo'):
continue
elif cmdLineUp.startswith('PARAMETERS'):
prm = self.checkTinkerParam(cmdLine, 'parameters')
rtn = setMetaStrInDict(self, 'cntrlDict', 'parameters', prm)
success = rtn[0] if success is False else True
continue
elif cmdLineUp.startswith('VERBOSE'):
rtn = setMetaStrInDict(self, 'cntrlDict', 'verbose', True)
success = rtn[0] if success is False else True
continue
elif cmdLineUp.startswith('ARCHIVE'):
rtn = setMetaStrInDict(self, 'cntrlDict', 'archive', True)
success = rtn[0] if success is False else True
continue
elif cmdLineUp.startswith('LIGHTS'):
rtn = setMetaStrInDict(self, 'cntrlDict', 'lights', True)
success = rtn[0] if success is False else True
continue
elif cmdLineUp.startswith('SADDLEPOINT'):
rtn = setMetaStrInDict(self, 'cntrlDict', 'saddlepoint', True)
success = rtn[0] if success is False else True
continue
elif cmdLineUp.startswith('ENFORCE-CHIRALITY'):
rtn = setMetaStrInDict(self, 'cntrlDict', 'enforce-chirality', True)
success = rtn[0] if success is False else True
continue
elif cmdLineUp.startswith('NEIGHBOR-LIST'):
rtn = setMetaStrInDict(self, 'cntrlDict', 'neighbor-list', True)
success = rtn[0] if success is False else True
continue
elif cmdLineUp.startswith('PRINTOUT'):
prm = self.checkTinkerParam(cmdLine, 'printout')
rtn = setMetaStrInDict(self, 'cntrlDict', 'printout', prm)
success = rtn[0] if success is False else True
continue
elif cmdLineUp.startswith('DIGITS'):
prm = self.checkTinkerParam(cmdLine, 'digits')
rtn = setMetaStrInDict(self, 'cntrlDict', 'digit', prm)
success = rtn[0] if success is False else True
continue
elif cmdLineUp.startswith('SPACEGROUP'):
prm = self.checkTinkerParam(cmdLine, 'spacegroup')
rtn = setMetaStrInDict(self, 'cntrlDict', 'spacegroup', prm)
success = rtn[0] if success is False else True
continue
elif cmdLineUp.startswith('VDWTYPE'):
prm = self.checkTinkerParam(cmdLine, 'vdwtype')
rtn = setMetaStrInDict(self, 'cntrlDict', 'vdwtype', prm)
success = rtn[0] if success is False else True
continue
elif cmdLineUp.startswith('VDW-CUTOFF'):
prm = self.checkTinkerParam(cmdLine, 'vdw-cutoff')
rtn = setMetaStrInDict(self, 'cntrlDict', 'vdw-cutoff', prm)
success = rtn[0] if success is False else True
continue
elif cmdLineUp.startswith('VDW-CORRECTION'):
rtn = setMetaStrInDict(self, 'cntrlDict', 'vdw-correction', True)
success = rtn[0] if success is False else True
continue
elif cmdLineUp.startswith('EWALD'):
rtn = setMetaStrInDict(self, 'cntrlDict', 'ewald', True)
success = rtn[0] if success is False else True
continue
elif cmdLineUp.startswith('ANISO-PRESSURE'):
rtn = setMetaStrInDict(self, 'cntrlDict', 'aniso-pressure', True)
success = rtn[0] if success is False else True
continue
elif cmdLineUp.startswith('EWALD-CUTOFF'):
prm = self.checkTinkerParam(cmdLine, 'ewald-cutoff')
rtn = setMetaStrInDict(self, 'cntrlDict', 'ewald-cutoff', prm)
success = rtn[0] if success is False else True
continue
elif cmdLineUp.startswith('PME-GRID'):
prm = self.checkTinkerParam(cmdLine, 'pme-grid')
if prm is not None:
prm = ','.join(prm.split())
rtn = setMetaStrInDict(self, 'cntrlDict', 'pme-grid', prm)
success = rtn[0] if success is False else True
continue
elif cmdLineUp.startswith('PME-ORDER'):
prm = self.checkTinkerParam(cmdLine, 'pme-order')
rtn = setMetaStrInDict(self, 'cntrlDict', 'pme-order', prm)
success = rtn[0] if success is False else True
continue
elif cmdLineUp.startswith('RADIUSRULE'):
prm = self.checkTinkerParam(cmdLine, 'radiusrule')
rtn = setMetaStrInDict(self, 'cntrlDict', 'radiusrule', prm)
success = rtn[0] if success is False else True
continue
elif cmdLineUp.startswith('RADIUSRULE'):
prm = self.checkTinkerParam(cmdLine, 'radiusrule')
rtn = setMetaStrInDict(self, 'cntrlDict', 'radiusrule', prm)
success = rtn[0] if success is False else True
continue
elif cmdLineUp.startswith('RADIUSTYPE'):
prm = self.checkTinkerParam(cmdLine, 'radiustype')
rtn = setMetaStrInDict(self, 'cntrlDict', 'radiustype', prm)
success = rtn[0] if success is False else True
continue
elif cmdLineUp.startswith('RADIUSSIZE'):
prm = self.checkTinkerParam(cmdLine, 'radiussize')
rtn = setMetaStrInDict(self, 'cntrlDict', 'radiussize', prm)
success = rtn[0] if success is False else True
continue continue
elif cmdLine.startswith('PARAMETERS'): elif cmdLineUp.startswith('EPSILONRULE'):
rtn = setMetaStrInDict(self, 'cntrlDict', 'parameters', cmdLine.split()[-1]) prm = self.checkTinkerParam(cmdLine, 'epsilonrule')
rtn = setMetaStrInDict(self, 'cntrlDict', 'epsilonrule', prm)
success = rtn[0] if success is False else True success = rtn[0] if success is False else True
continue continue
elif cmdLine.startswith('ENERGYMIN'): elif cmdLineUp.startswith('DIELECTRIC'):
rtn = setMetaStrInDict(self, 'cntrlDict', 'parameters', cmdLine.split()[-1]) prm = self.checkTinkerParam(cmdLine, 'dielectric')
rtn = setMetaStrInDict(self, 'cntrlDict', 'dielectric', prm)
success = rtn[0] if success is False else True success = rtn[0] if success is False else True
continue continue
elif cmdLine.startswith('SYSTEM'): elif cmdLineUp.startswith('A-AXIS'):
prm = self.checkTinkerParam(cmdLine, 'a-axis')
rtn = setMetaStrInDict(self, 'cntrlDict', 'a-axis', prm)
success = rtn[0] if success is False else True
continue continue
elif cmdLine.startswith('INITIALISE'): elif cmdLineUp.startswith('B-AXIS'):
prm = self.checkTinkerParam(cmdLine, 'b-axis')
rtn = setMetaStrInDict(self, 'cntrlDict', 'b-axis', prm)
success = rtn[0] if success is False else True
continue continue
elif cmdLine.startswith('STEP'): elif cmdLineUp.startswith('C-AXIS'):
prm = self.checkTinkerParam(cmdLine, 'c-axis')
rtn = setMetaStrInDict(self, 'cntrlDict', 'c-axis', prm)
success = rtn[0] if success is False else True
continue continue
elif cmdLine.startswith('BOUNDCOND'): elif cmdLineUp.startswith('ALPHA'):
prm = self.checkTinkerParam(cmdLine, 'alpha')
rtn = setMetaStrInDict(self, 'cntrlDict', 'alpha', prm)
success = rtn[0] if success is False else True
continue continue
elif cmdLine.startswith('MULTIBATH'): elif cmdLineUp.startswith('BETA'):
prm = self.checkTinkerParam(cmdLine, 'beta')
rtn = setMetaStrInDict(self, 'cntrlDict', 'beta', prm)
success = rtn[0] if success is False else True
continue continue
elif cmdLine.startswith('PRESSURESCALE'): elif cmdLineUp.startswith('GAMMA'):
prm = self.checkTinkerParam(cmdLine, 'gamma')
rtn = setMetaStrInDict(self, 'cntrlDict', 'gamma', prm)
success = rtn[0] if success is False else True
continue continue
elif cmdLine.startswith('COVALENTFORM'): elif cmdLineUp.startswith('INTEGRATOR'):
prm = self.checkTinkerParam(cmdLine, 'integrator')
rtn = setMetaStrInDict(self, 'cntrlDict', 'integrator', prm)
success = rtn[0] if success is False else True
continue continue
elif cmdLine.startswith('COMTRANSROT'): elif cmdLineUp.startswith('BAROSTAT'):
prm = self.checkTinkerParam(cmdLine, 'barostat')
rtn = setMetaStrInDict(self, 'cntrlDict', 'barostat', prm)
success = rtn[0] if success is False else True
continue continue
elif cmdLine.startswith('PRINTOUT'): elif cmdLineUp.startswith('TAU-PRESSURE'):
prm = self.checkTinkerParam(cmdLine, 'tau-pressure')
rtn = setMetaStrInDict(self, 'cntrlDict', 'tau-pressure', prm)
success = rtn[0] if success is False else True
continue continue
elif cmdLine.startswith('WRITETRAJ'): elif cmdLineUp.startswith('TAU-TEMPERATURE'):
prm = self.checkTinkerParam(cmdLine, 'tau-temperature')
rtn = setMetaStrInDict(self, 'cntrlDict', 'tau-temperature', prm)
success = rtn[0] if success is False else True
continue continue
elif cmdLine.startswith('CONSTRAINT'): elif cmdLineUp.startswith('RATTLE'):
prm = self.checkTinkerParam(cmdLine, 'rattle')
rtn = setMetaStrInDict(self, 'cntrlDict', 'rattle', prm)
success = rtn[0] if success is False else True
continue continue
elif cmdLine.startswith('FORCE'): elif cmdLineUp.startswith('LAMBDA'):
prm = self.checkTinkerParam(cmdLine, 'lambda')
rtn = setMetaStrInDict(self, 'cntrlDict', 'lambda', prm)
success = rtn[0] if success is False else True
continue continue
elif cmdLine.startswith('PAIRLIST'): elif cmdLineUp.startswith('POLAR-EPS'):
prm = self.checkTinkerParam(cmdLine, 'polar-eps')
rtn = setMetaStrInDict(self, 'cntrlDict', 'polar-eps', prm)
success = rtn[0] if success is False else True
continue continue
elif cmdLine.startswith('NONBONDED'): elif cmdLineUp.startswith('VIB-ROOTS'):
prm = self.checkTinkerParam(cmdLine, 'vib-roots')
rtn = setMetaStrInDict(self, 'cntrlDict', 'vib-roots', prm)
success = rtn[0] if success is False else True
continue continue
rtn = setMetaStrInDict(self, 'cntrlDict', 'TITLE', line.strip()) return success
elif section == 'ENERGYMIN':
for item in cmdLine.split(): def findFileInDir(self, parser, fileMetaName, cntrlDictName):
addok = False filecntrlDict = getattr(self, cntrlDictName)
if enid == 0: if filecntrlDict is not None:
addok = True infileKey = isMetaStrInDict(fileMetaName, filecntrlDict)
rtn = setMetaStrInDict(self, 'cntrlDict', 'EMIN-NTEM', item) infile = None
elif enid == 1: paramFile = None
addok = True if infileKey is not None:
rtn = setMetaStrInDict(self, 'cntrlDict', 'EMIN-NCYC', item) if filecntrlDict[infileKey].value is not None:
elif enid == 2: infile = filecntrlDict[infileKey].value
addok = True if infile is not None:
rtn = setMetaStrInDict(self, 'cntrlDict', 'EMIN-DELE', item) #self.working_dir_name
elif enid == 3: #working_dir_name = os.path.dirname(os.path.abspath(os.getcwd()))
addok = True thisfile=os.path.normpath(infile)
rtn = setMetaStrInDict(self, 'cntrlDict', 'EMIN-DX0', item) findfile=os.path.basename(thisfile)
elif enid == 4: dirlisti=thisfile.split(os.path.sep)
addok = True dirlist=self.prune_list(dirlisti)
rtn = setMetaStrInDict(self, 'cntrlDict', 'EMIN-DXM', item) sepp=os.path.sep
elif enid == 5:
addok = True subdirlist = [sepp.join(dirlist[dr:-1]) for dr in range(len(dirlist))]
rtn = setMetaStrInDict(self, 'cntrlDict', 'EMIN-NMIN', item) for sid, sdir in enumerate(subdirlist):
elif enid == 6: if sdir == '':
addok = True subdirlist[sid] = os.curdir
rtn = setMetaStrInDict(self, 'cntrlDict', 'EMIN-FLIM', item)
if addok: matchdirs = []
enid += 1 for root, dirnames, filenames in os.walk(self.working_dir_name):
success = rtn[0] if success is False else True for possubdir in subdirlist:
elif section == 'SYSTEM': for subdir in fnmatch.filter(dirnames, possubdir):
for item in cmdLine.split(): matchdirs.append(os.path.join(root, subdir))
addok = False if matchdirs:
if syid == 0: pass
addok = True else:
rtn = setMetaStrInDict(self, 'cntrlDict', 'SYS-NPM', item) matchdirs.append(self.working_dir_name)
elif syid == 1:
addok = True matches = []
rtn = setMetaStrInDict(self, 'cntrlDict', 'SYS-NSM', item) for root, dirnames, filenames in os.walk(self.working_dir_name):
if addok: if root == self.working_dir_name:
syid += 1 for filename in fnmatch.filter(filenames, findfile):
success = rtn[0] if success is False else True matches.append(os.path.join(root, filename))
elif section == 'STEP': break
for item in cmdLine.split(): if matches:
addok = False pass
if stid == 0: else:
addok = True for root, dirnames, filenames in os.walk(self.working_dir_name):
rtn = setMetaStrInDict(self, 'cntrlDict', 'STEP-NSTLIM', item) for mdir in matchdirs:
elif stid == 1: if mdir+sepp+findfile == root+sepp+findfile:
addok = True for filename in fnmatch.filter(filenames, findfile):
rtn = setMetaStrInDict(self, 'cntrlDict', 'STEP-T', item) matches.append(os.path.join(root, filename))
elif stid == 2: break
addok = True
rtn = setMetaStrInDict(self, 'cntrlDict', 'STEP-DT', item) inputFile = None
if addok: if matches:
stid += 1 inputFile = matches[0]
success = rtn[0] if success is False else True
elif section == 'MULTIBATH': if inputFile is not None:
for item in cmdLine.split(): paramFile = os.path.normpath(os.path.abspath(inputFile))
addok = False
if mbid == 0: return paramFile
addok = True
rtn = setMetaStrInDict(self, 'cntrlDict', 'BATH-ALG', item) def generateARCfileFromSequenceFiles(self, parser, fileListInDir, arcname):
try: xyzSeqList = []
bathalg=int(item) working_dir_name = os.path.dirname(os.path.abspath(self.fName))
except (ValueError, TypeError): addfile = os.path.normpath(working_dir_name+os.path.sep+arcname)
pass for fname in self.tinkerFiles:
elif(mbid == 1 and bathalg>1): if('.arc' not in fname and
addok = True '.xyz' not in fname and
rtn = setMetaStrInDict(self, 'cntrlDict', 'BATH-NUM', item) fname in fileListInDir):
elif((mbid == 1 and bathalg<2) or (mbid == 2 and bathalg>1)): xyzSeqList.append(working_dir_name+os.path.sep+fname)
addok = True anyFileExist=False
rtn = setMetaStrInDict(self, 'cntrlDict', 'BATH-NBATHS', item) for fname in xyzSeqList:
numbaths=int(item) with open(fname, 'rb') as fin:
elif((mbid >= 2 and mbid < 2+(2*numbaths) and bathalg<2) or if fin.read():
(mbid >= 3 and mbid < 3+(2*numbaths) and bathalg>1)): anyFileExist=True
addok = True fin.close()
if(((mbid-1)%2==1 and bathalg<2) or if anyFileExist:
((mbid-2)%2==1 and bathalg>1)): with open(addfile, 'wb') as fout:
if temp == None: for fname in xyzSeqList:
temp = item with open(fname, 'rb') as fin:
else: fout.write(fin.read())
temp = temp + ', ' + item
rtn = setMetaStrInDict(self, 'cntrlDict', 'BATH-TEMP', temp) def fetchInfoFromInputOutput(self, parser):
elif(((mbid-1)%2==0 and bathalg<2) or self.recordList.write(' ####################################### ')
((mbid-2)%2==0 and bathalg>1)): working_dir_name = os.path.dirname(os.path.abspath(self.fName))
if tau == None: fileList = [x for x in os.walk(os.path.abspath(working_dir_name))]
tau = item filesListInDir = []
else: try:
tau = tau + ', ' + item getattr(self, "filesInOutputDir")
rtn = setMetaStrInDict(self, 'cntrlDict', 'BATH-TAU', tau) except AttributeError:
elif((mbid == 2+(2*numbaths) and bathalg<2) or self.filesInOutputDir = {}
(mbid == 3+(2*numbaths) and bathalg>1)): for fdir, fchilds, fnames in fileList:
addok = True for fname in fnames:
rtn = setMetaStrInDict(self, 'cntrlDict', 'BATH-DOFSET', item) fkeyname = os.path.normpath(os.path.join(fdir, fname))
try: self.filesInOutputDir.update({fkeyname.upper():fkeyname})
dofset=int(item) for fdir, fchilds, fnames in fileList:
except (ValueError, TypeError): for fname in fnames:
pass filesListInDir.append(fname)
elif((mbid >= 3+(2*numbaths) and mbid < 3+(2*numbaths)+dofset and bathalg<2) or self.tinkerRunFiles = {}
(mbid >= 4+(2*numbaths) and mbid < 4+(2*numbaths)+dofset and bathalg>1)): self.tinkerFiles = []
addok = True self.tinkerFileSteps = []
if last == None: self.tinkerFileTimes = []
last = item