def AverageBoxSizeFromNPTArc(annihilator, arcpath, firstframe, lastframe, framestep, totalnumberframes): firstline = True framecount = 0 framestoextract = np.arange(firstframe, lastframe + 1, framestep) framearray = [] extractingframe = False aaxisarray = [] baxisarray = [] caxisarray = [] with open(arcpath) as infile: for line in infile: if firstline == True: firstlinesplit = line.split() framestring = firstlinesplit[0].lstrip().rstrip() firstline = False linesplit = line.split() if '90.000000' in line and framecount in framestoextract: aaxis = float(linesplit[0]) baxis = float(linesplit[1]) caxis = float(linesplit[2]) aaxisarray.append(aaxis) baxisarray.append(baxis) caxisarray.append(caxis) if framestring in line and (len(linesplit) == 1): extractingframe = False framecount += 1 aaxisaverage = np.mean(np.array(aaxisarray)) baxisaverage = np.mean(np.array(baxisarray)) caxisaverage = np.mean(np.array(caxisarray)) annihilator.tabledict['Average Box Size'] = aaxisaverage tables.WriteTableUpdateToLog(annihilator) return aaxisaverage, baxisaverage, caxisaverage
def ComputeNeutralizingIonNumber( annihilator, systemcharge ): # this can be just ligand charge or ligand and receptor charge depending on whether this is complexation or solvation tinktypetoelementsym = { v: k for k, v in annihilator.elementsymtotinktype.items() } if systemcharge > 0: cltinktype = annihilator.elementsymtotinktype['Cl'] annihilator.iontypetoionnumberneut[cltinktype] = np.abs( int(systemcharge)) if 'Cl' not in annihilator.tabledict.keys(): annihilator.tabledict['Cl'] = 0 annihilator.tabledict['Cl'] += np.abs(int(systemcharge)) elif systemcharge < 0: ktinktype = annihilator.elementsymtotinktype['K'] annihilator.iontypetoionnumberneut[ktinktype] = np.abs( int(systemcharge)) if 'K' not in annihilator.tabledict.keys(): annihilator.tabledict['K'] = 0 annihilator.tabledict['K'] += np.abs(int(systemcharge)) annihilator.tabledict['Neut Counterions'] = np.abs(int(systemcharge)) tables.WriteTableUpdateToLog(annihilator)
def ComputePhysiologicalIonNumber(annihilator): if annihilator.addphysioions == True: commasplit = annihilator.listofsaltcons.split(',') for ioncomplex in commasplit: ioncomplex = ioncomplex.lstrip().rstrip() equalsignsplit = ioncomplex.split('=') ioncomplexstring = equalsignsplit[0].lstrip().rstrip() conc = float(equalsignsplit[1].lstrip().rstrip()) # in mM complexnum = conc * 6.022 * 10**-7 * annihilator.volume Sum = 0 for el in annihilator.elementsymtotinktype.keys(): if el in ioncomplexstring: nextindex = ioncomplexstring.find(el) + len( el ) # if K returns K index +1, if Cl returns Cl index +2, want to know if there is 2 or 3... after element, nextindex should always be defined because last elemt will be ] if ioncomplexstring[nextindex].isdigit(): multfactor = int(ioncomplexstring[nextindex]) else: multfactor = 1 tinktype = annihilator.elementsymtotinktype[el] if el not in annihilator.tabledict.keys(): annihilator.tabledict[el] = 0 annihilator.tabledict[el] += int( round(complexnum * multfactor)) Sum += int(round(complexnum * multfactor)) if tinktype in annihilator.iontypetoionnumberphysio.keys(): annihilator.iontypetoionnumberphysio[tinktype] += int( round(complexnum * multfactor)) else: annihilator.iontypetoionnumberphysio[tinktype] = int( round(complexnum * multfactor)) annihilator.tabledict['Physio Counterions'] = Sum tables.WriteTableUpdateToLog(annihilator)
def ComputeBoxSize(annihilator): longestdim = FindDimensionsOfMoleculeTinker( annihilator, annihilator.outputpath + annihilator.xyzfilename) if annihilator.fixedboxsize is None: annihilator.aaxis = round( longestdim + 2 * annihilator.boxbufferlength + 2 * float(annihilator.vdwcutoff), 1) else: annihilator.aaxis = annihilator.fixedboxsize annihilator.WriteToLog('Initial Box Length' + ' ' + str(annihilator.aaxis)) annihilator.tabledict['Initial Box Length'] = annihilator.aaxis tables.WriteTableUpdateToLog(annihilator) annihilator.volume = annihilator.aaxis**3 keymods.AddKeyWord(annihilator, annihilator.outputpath + annihilator.configkeyfilename, 'a-axis ' + str(annihilator.aaxis) + '\n')
def __init__(self, equilonly=False, binding=False, proddyngrprests=False, equilrestrainsphereradius=2, restrainpositionconstant=1, ligandfilename=None, tightmincriteria=1, loosemincriteria=10, rescorrection=0, anglerestraintconstant=0.003046, pdbxyzpath='pdbxyz.x', distancerestraintconstant=10, minimizepath='minimize.x', tinkerdir=None, averageenergies=False, roomtemp=300, complexedproteinpdbname=None, uncomplexedproteinpdbname=None, addphysioions=True, equilibriatescheme=[50, 100, 150, 200, 300], equilibriaterestscheme=[5, 2, 1, .1, 0], prmfilepath=None, keyfilename=None, xyzfilename=None, externalapi=None, bashrcpath=None, restrainatomsduringminimization=True, restrainatomgroup1=None, restrainatomgroup2=None, ligandxyzfilename=None, receptorligandxyzfilename=None, xyzeditpath='xyzedit.x', lowerperf=7, upperperf=12, simpathlist=None, fixedboxsize=None, extendelelambdaoneside=[], estatlambdascheme=[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, .1, .2, .3, .4, .5, .6, .7, .8, .9, 1, 1 ], extendelelambdazeroside=[], vdwlambdascheme=[ 0, .45, .52, .56, .58, .6, .62, .64, .67, .7, .75, .8, .85, .9, .95, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ], extendvdwlambdaoneside=[], extendvdwlambdazeroside=[], restlambdascheme=[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 ], extendrestlambdaoneside=[], extendrestlambdazeroside=[], waitingtime=5, boxbufferlength=3, receptorcharge=0, ligandcharge=0, barpath='bar.x', dynamicpath='dynamic.x', barommpath='bar_omm.x', dynamicommpath='dynamic_omm.x', complexation=False, solvation=False, flatbotrest=True, outputpath=None, logname='TINKER.log', equilwritefreq=100, proddynwritefreq=2, equiltimeNVT=5, equiltimeNPT=2, equiltimestep=2, proddyntimestep=2, proddyntime=5, pressure=1, NVTensem=2, NPTensem=4, vdwcutoff=12, ewaldcutoff=7, polareps=0.0001, barostatmethod='montecarlo', integrator='RESPA', thermostat='BUSSI', listofsaltcons='[KCl]=100'): self.equilonly = equilonly self.binding = binding self.proddyngrprests = proddyngrprests self.equilrestrainsphereradius = equilrestrainsphereradius self.equilibriaterestscheme = equilibriaterestscheme self.restrainpositionconstant = restrainpositionconstant self.ligandfilename = ligandfilename self.loosemincriteria = loosemincriteria self.tightmincriteria = tightmincriteria self.rescorrection = rescorrection self.anglerestraintconstant = anglerestraintconstant self.pdbxyzpath = pdbxyzpath self.distancerestraintconstant = distancerestraintconstant self.minimizepath = minimizepath self.tinkerdir = tinkerdir self.averageenergies = averageenergies self.roomtemp = roomtemp self.complexedproteinpdbname = complexedproteinpdbname self.uncomplexedproteinpdbname = uncomplexedproteinpdbname self.addphysioions = addphysioions self.equilibriatescheme = equilibriatescheme self.prmfilepath = prmfilepath self.keyfilename = keyfilename self.xyzfilename = xyzfilename self.bashrcpath = bashrcpath self.externalapi = externalapi self.restrainatomgroup1 = restrainatomgroup1 self.restrainatomgroup2 = restrainatomgroup2 self.restrainatomsduringminimization = restrainatomsduringminimization self.tabledict = {} self.ligandxyzfilename = ligandxyzfilename self.receptorligandxyzfilename = receptorligandxyzfilename self.lowerperf = lowerperf self.upperperf = upperperf self.simpathlist = simpathlist self.barommpath = barommpath self.dynamicommpath = dynamicommpath self.barpath = barpath self.dynamicpath = dynamicpath self.xyzeditpath = xyzeditpath self.simpath = os.getcwd() self.simname = os.path.basename(self.simpath) self.complexation = complexation self.solvation = solvation self.flatbotrest = flatbotrest self.outputpath = outputpath self.logname = logname self.equilwritefreq = equilwritefreq # in picoseconds self.proddynwritefreq = proddynwritefreq # in picoseconds self.equiltimeNVT = equiltimeNVT # in ns self.equiltimeNPT = equiltimeNPT # ns self.equiltimestep = equiltimestep # fs self.proddyntimestep = proddyntimestep # fs self.proddyntime = proddyntime # ns self.pressure = pressure self.NVTensem = NVTensem self.NPTensem = NPTensem self.proddynensem = NVTensem self.vdwcutoff = vdwcutoff self.ewaldcutoff = ewaldcutoff self.polareps = polareps self.barostatmethod = barostatmethod self.integrator = integrator self.thermostat = thermostat self.listofsaltcons = listofsaltcons # default physiological concentrations self.ligandcharge = ligandcharge self.receptorcharge = receptorcharge self.boxbufferlength = boxbufferlength # angstroms self.waitingtime = waitingtime # time in minutes, to wait to check if all jobs have terminated self.fixedboxsize = None self.extendelelambdaoneside = extendelelambdaoneside self.estatlambdascheme = estatlambdascheme self.extendelelambdazeroside = extendelelambdazeroside self.vdwlambdascheme = vdwlambdascheme self.extendvdwlambdaoneside = extendvdwlambdaoneside self.extendvdwlambdazeroside = extendvdwlambdazeroside self.restlambdascheme = restlambdascheme self.extendrestlambdaoneside = extendrestlambdaoneside self.extendrestlambdazeroside = extendrestlambdazeroside self.elementsymtocharge = { 'K': 1, 'Cl': -1, 'Mg': 2, 'Li': 1, 'Na': 1, 'Rb': 1, 'Cs': 1, 'Be': 2, 'Ca': 2, 'Zn': 2 } self.elementsymtomass = { 'H': 1.00794, 'HN': 1.00794, 'HO': 1.00794, 'O': 15.9994, 'OH': 15.9994, 'N': 14.0067, 'C': 12.0107, 'CA': 12.0107, 'F': 18.9984032, 'Cl': 35.453, 'Cl-': 35.453, 'S': 32.065, 'P': 30.9737, 'Na': 22.98976, 'K': 39.0983, 'Ca': 40.078, 'Mg': 24.305, 'Mg+': 24.305, 'K+': 39.0983 } temp = open(os.getcwd() + r'/' + 'AMOEBA.ini', 'r') results = temp.readlines() temp.close() for line in results: if '#' in line: continue if '=' in line: linesplit = line.split('=', 1) a = linesplit[1].replace('\n', '').rstrip().lstrip() commalist = a.split(',') commalist = [i.rstrip().lstrip() for i in commalist] if 'prmfilepath' in line: self.prmfilepath = a elif 'uncomplexedproteinpdbname' in line: self.uncomplexedproteinpdbname = a elif 'complexedproteinpdbname' in line: self.complexedproteinpdbname = a elif 'externalapi' in line: self.externalapi = a elif 'bashrcpath' in line: self.bashrcpath = a elif 'restrainatomgroup1' in line: self.restrainatomgroup1 = [int(i) for i in commalist] elif 'restrainatomgroup2' in line: self.restrainatomgroup2 = [int(i) for i in commalist] elif 'simpathlist' in line: self.simpathlist = commalist templist = [] for ele in self.simpathlist: paths = ele.lstrip().rstrip().split() temp = [] for e in paths: temp.append(e) templist.append(temp) self.simpathlist = templist elif "flatbotrest" in line: self.flatbotrest = False elif "proddyngrprests" in line: self.proddyngrprests = True elif "extendelelambdaoneside" in line: self.extendelelambdaoneside = commalist elif "extendvdwlambdaoneside" in line: self.extendvdwlambdaoneside = commalist elif "extendrestlambdaoneside" in line: self.extendrestlambdaoneside = commalist elif "extendprmsetoneside" in line: self.extendprmsetoneside = commalist elif "extendelelambdazeroside" in line: self.extendelelambdazeroside = commalist elif "extendvdwlambdazeroside" in line: self.extendvdwlambdazeroside = commalist elif "extendrestlambdazeroside" in line: self.extendrestlambdazeroside = commalist elif "proddynensem" in line: self.proddynensem = a elif ("keyfilename") in line: self.keyfilename = a elif ("ligandcharge") in line: self.ligandcharge = int(a) elif ("fixedboxsize") in line: self.fixedboxsize = float(a) elif ("tightmincriteria") in line: self.tightmincriteria = float(a) elif ("restrainpositionconstant") in line: self.restrainpositionconstant = float(a) elif ("loosemincriteria") in line: self.loosemincriteria = float(a) elif ("equilrestrainsphereradius") in line: self.equilrestrainsphereradius = float(a) elif ("barostatmethod") in line: self.barostatmethod = a elif ("receptorcharge") in line: self.receptorcharge = float(a) elif ("waitingtime") in line: self.waitingtime = float(a) elif ("listofsaltcons") in line: self.listofsaltcons = a elif ("ligandxyzfilename") in line: self.ligandxyzfilename = a elif ("ligandfilename") in line: self.ligandfilename = a elif ("receptorligandxyzfilename") in line: self.receptorligandxyzfilename = a elif ("boxbufferlength") in line: self.boxbufferlength = float(a) elif ("integrator") in line: self.integrator = a elif ("thermostat") in line: self.thermostat = a elif ("vdwcutoff") in line: self.vdwcutoff = a elif ("ewaldcutoff") in line: self.ewaldcutoff = a elif ("polareps") in line: self.polareps = a elif ("outputpath") in line: self.outputpath = a elif ("distancerestraintconstant") in line: self.distancerestraintconstant = float(a) elif ("anglerestraintconstant") in line: self.anglerestraintconstant = float(a) elif ("equilibriatescheme") in line: self.equilibriatescheme = commalist elif ("restlambdascheme") in line: self.restlambdascheme = commalist elif ("vdwlambdascheme") in line: self.vdwlambdascheme = commalist elif ("estatlambdascheme") in line: self.estatlambdascheme = commalist elif ("equilwritefreq") in line: self.equilwritefreq = a elif ("equiltimestep") in line: self.equiltimestep = int(a) elif ("proddyntimestep") in line: self.proddyntimestep = int(a) elif ("equiltimeNPT") in line: self.equiltimeNPT = float(a) elif ("proddynwritefreq") in line: self.proddynwritefreq = a elif ("proddyntime") in line: self.proddyntime = float(a) elif ("complexation") in line: self.complexation = True elif ("solvation") in line: self.solvation = True elif ("equiltimeNVT") in line: self.equiltimeNVT = float(a) elif ("equilonly") in line: self.equilonly = True elif ("equilrestlambdascheme") in line: self.equilrestlambdascheme = commalist self.logfh = open(self.outputpath + self.logname, 'a+') self.SanitizeMMExecutables() if self.simpathlist != None: self.binding = True tables.GrabSimDataFromPathList(self) plots.PlotEnergyData(self) sys.exit() if self.complexation == True and self.uncomplexedproteinpdbname != None and self.complexedproteinpdbname != None: self.uncomplexedxyzname = self.uncomplexedproteinpdbname.replace( '.pdb', '.xyz') self.complexedxyzname = self.uncomplexedxyzname.replace( '.xyz', '_comp.xyz') self.receptorligandxyzfilename = self.complexedxyzname self.ReadReceptorCharge() pdbxyz.GenerateProteinTinkerXYZFile(self) elif self.complexation == True and self.uncomplexedproteinpdbname == None and self.complexedproteinpdbname == None: raise ValueError( 'Missing either uncomplexed or complexed proteinpdbname') if self.ligandfilename != None: self.ReadLigandCharge() if self.complexation == True: self.systemcharge = self.receptorcharge + self.ligandcharge elif self.solvation == True: self.systemcharge = self.ligandcharge if self.solvation == True: self.xyzfilename = self.ligandxyzfilename elif self.complexation == True: self.xyzfilename = self.receptorligandxyzfilename self.elementsymtotinktype = { 'K': box.GrabTypeNumber(self, 'Potassium Ion K+'), 'Cl': box.GrabTypeNumber(self, 'Chloride Ion Cl-'), 'Mg': box.GrabTypeNumber(self, 'Magnesium Ion Mg+2'), 'Li': box.GrabTypeNumber(self, 'Lithium Ion Li+'), 'Na': box.GrabTypeNumber(self, 'Sodium Ion Na+'), 'Rb': box.GrabTypeNumber(self, 'Rubidium Ion Rb+'), 'Cs': box.GrabTypeNumber(self, 'Cesium Ion Cs+'), 'Be': box.GrabTypeNumber(self, 'Beryllium Ion Be+2'), 'Ca': box.GrabTypeNumber(self, 'Calcium Ion Ca+2'), 'Zn': box.GrabTypeNumber(self, 'Zinc Ion Zn+2'), 'Mg+': box.GrabTypeNumber(self, 'Magnesium Ion Mg+2') } self.waterOtypenum = 349 self.waterHtypenum = 350 self.estatlambdascheme = self.extendelelambdaoneside + self.estatlambdascheme + self.extendelelambdazeroside self.vdwlambdascheme = self.extendvdwlambdaoneside + self.vdwlambdascheme + self.extendvdwlambdazeroside self.restlambdascheme = self.extendrestlambdaoneside + self.restlambdascheme + self.extendrestlambdazeroside self.equilstepsNVT = str( int((self.equiltimeNVT * 1000000) / self.equiltimestep / len(self.equilibriatescheme)) ) # convert ns to fs divide by the length of temperature scheme self.equilstepsNPT = str( int((self.equiltimeNPT * 1000000) / self.equiltimestep)) self.proddynframenum = str( int( float(self.proddyntime) / (float(self.proddynwritefreq) * 0.001))) self.proddynsteps = str( int((self.proddyntime * 1000000) / self.proddyntimestep)) self.equilframenumNPT = int( (float(self.equiltimeNPT)) / (float(self.equilwritefreq) * 0.001)) self.equilframenumNVT = int( (float(self.equiltimeNVT)) / (float(self.equilwritefreq) * 0.001)) self.equilframenum = self.equilframenumNPT + self.equilframenumNVT self.proddynframenum = int( (self.proddyntime) / float(self.proddynwritefreq) * 0.001) self.simfoldname = 'Sim' self.waterboxfilename = 'waterbox.xyz' if self.complexation == True: self.simfoldname = 'Comp' + self.simfoldname self.waterboxfilename = 'comp' + self.waterboxfilename self.WriteToLog('Complexation job') elif self.solvation == True: self.simfoldname = 'Solv' + self.simfoldname self.waterboxfilename = 'solv' + self.waterboxfilename self.WriteToLog('Solvation job') self.minwaterboxfilename = self.waterboxfilename.replace( '.xyz', 'min.xyz') self.equilwaterboxfilename = self.waterboxfilename.replace( '.xyz', 'equil.xyz') self.proddynwaterboxfilename = self.waterboxfilename.replace( '.xyz', 'proddyn.xyz') self.equilarcwaterboxfilename = self.equilwaterboxfilename.replace( '.xyz', '.arc') self.proddynarcwaterboxfilename = self.proddynwaterboxfilename.replace( '.xyz', '.arc') self.proddynwaterboxkeyfilename = self.proddynwaterboxfilename.replace( '.xyz', '.key') self.equiljobsfilename = 'equiljobs.txt' self.proddynjobsfilename = 'proddynamicsjobs.txt' self.barjobsfilename = 'barjobs.txt' self.freeenergyjobsfilename = 'freeenergyjobs.txt' self.tightminjobsfilename = 'tightboxminjobs.txt' self.looseminjobsfilename = 'looseboxminjobs.txt' self.analyzejobsfilename = 'analyzejobs.txt' self.configkeyfilename = self.keyfilename.replace( '.key', '_config.key') self.lambdakeyfilename = self.keyfilename.replace( '.key', '_lambda.key') self.tightminoutput = 'tightmin.out' self.looseminoutput = 'loosemin.out' self.iontypetoionnumberphysio = { } # key is ion type (string), value is number of computed ions self.iontypetoionnumberneut = { } # key is ion type (string), value is number of computed ions self.equiloutputarray = [] for temp in self.equilibriatescheme: self.equiloutputarray.append(self.outputpath + self.simname + '_' + temp + '_' + self.equilstepsNVT + '.out') self.nextfiletofinish = self.equiloutputarray[0] self.lambdafolderlist = [] self.proddynoutfilepath = [] for i in range(len(self.vdwlambdascheme)): elelamb = self.estatlambdascheme[i] vdwlamb = self.vdwlambdascheme[i] if 'Comp' in self.simfoldname: rest = self.restlambdascheme[i] fold = self.simfoldname + "Ele%s_Vdw%s_Res%s" % (elelamb, vdwlamb, rest) else: fold = self.simfoldname + "Ele%s_Vdw%s" % (elelamb, vdwlamb) self.lambdafolderlist.append(fold) outputfilepath = os.getcwd( ) + '/' + self.simfoldname + '/' + fold + '/' outputfilepath += fold + '.out' self.proddynoutfilepath.append(outputfilepath) self.baroutputfilepath = [] self.barfilepath = [] self.thermooutputfilepath = [] self.secondarcpaths = [] self.firstarcpaths = [] for i in range( len(self.lambdafolderlist) - 1 ): # stop before last one because using i+1 for grabbing next index firstfoldname = self.lambdafolderlist[i] secondfoldname = self.lambdafolderlist[i + 1] firstarcpath = self.outputpath + self.simfoldname + r'/' + firstfoldname + '/' + self.proddynarcwaterboxfilename secondarcpath = self.outputpath + self.simfoldname + r'/' + secondfoldname + '/' + self.proddynarcwaterboxfilename self.secondarcpaths.append(secondarcpath) self.firstarcpaths.append(firstarcpath) baroutputfilepath = self.outputpath + self.simfoldname + r'/' + secondfoldname + '/' + firstfoldname + secondfoldname + 'BAR1.out' thermooutputfilepath = baroutputfilepath.replace( 'BAR1.out', 'BAR2.out') barfilepath = secondarcpath.replace('.arc', '.bar') self.barfilepath.append(barfilepath) self.baroutputfilepath.append(baroutputfilepath) self.thermooutputfilepath.append(thermooutputfilepath) self.tabledictkeysused = [] self.tabledict['Prod MD Ensemb'] = self.proddynensem self.tabledict['Prod MD Time'] = self.proddyntime self.tabledict['Prod MD Steps'] = self.proddynsteps self.tabledict[ 'Dynamic Writeout Frequency (ps)'] = self.proddynwritefreq self.tabledict['Dynamic Time Step (fs)'] = self.equiltimestep self.tabledict['Equil Time NPT'] = self.equiltimeNPT self.tabledict['Equil Time NVT'] = self.equiltimeNVT self.tabledict['Ligand Charge'] = self.ligandcharge self.tabledict['Ligand Name'] = self.ligandxyzfilename.replace( '.xyz', '') if self.complexation == True: self.tabledict['Receptor Charge'] = self.receptorcharge self.tabledict[ 'Receptor Name'] = self.uncomplexedproteinpdbname.replace( '.pdb', '') tables.WriteTableUpdateToLog(self)
def SumTheFreeEnergyStepsFromBAR(annihilator): firststate = False laststate = False annihilator.freeenergy = 0 annihilator.freeenergylist = [] annihilator.freeenergyerrorlist = [] annihilator.enthalpy = 0 annihilator.enthalpylist = [] annihilator.enthalpyerrorlist = [] annihilator.enthalpyerrorlisttotal = [] annihilator.entropy = 0 annihilator.entropylist = [] annihilator.entropyerrorlist = [] annihilator.entropyerrorlisttotal = [] os.chdir(annihilator.outputpath + annihilator.simfoldname) for i in range(len(annihilator.thermooutputfilepath)): outputfilepath = annihilator.thermooutputfilepath[i] temp = open(outputfilepath, 'r') foundfreeenergyline = False for line in temp.readlines(): if 'Free Energy via BAR Iteration' in line: foundfreeenergyline = True linesplit = line.split() freeenergy = float(linesplit[5]) index = line.find('+/-') newstring = line[index + 3:] newstringlinesplit = newstring.split() freenergyerror = float(newstringlinesplit[0]) annihilator.freeenergy += freeenergy annihilator.freeenergylist.append(freeenergy) annihilator.freeenergyerrorlist.append(freenergyerror) elif 'Free Energy via BAR Bootstrap' in line and foundfreeenergyline == False: # for some cases Free Energy via BAR Iteration does not appear foundfreeenergyline = True linesplit = line.split() freeenergy = float(linesplit[5]) index = line.find('+/-') newstring = line[index + 3:] newstringlinesplit = newstring.split() freenergyerror = float(newstringlinesplit[0]) annihilator.freeenergy += freeenergy annihilator.freeenergylist.append(freeenergy) annihilator.freeenergyerrorlist.append(freenergyerror) elif 'Enthalpy via BAR Estimate' in line: linesplit = line.split() enthalpy = float(linesplit[4]) index = line.find('+/-') newstring = line[index + 3:] newstringlinesplit = newstring.split() enthalpyerror = float(newstringlinesplit[0]) annihilator.enthalpy += enthalpy annihilator.enthalpylist.append(enthalpy) annihilator.enthalpyerrorlisttotal.append(enthalpyerror) elif 'Entropy via BAR Estimate' in line: linesplit = line.split() entropy = float(linesplit[4]) entropyerror = np.sqrt((enthalpyerror)**2 + (freenergyerror)**2) annihilator.entropy += entropy annihilator.entropylist.append(entropy) annihilator.entropyerrorlisttotal.append(entropyerror) temp.close() annihilator.freeenergyerror = np.sqrt( np.sum(np.square(annihilator.freeenergyerrorlist))) annihilator.enthalpyerror = np.sqrt( np.sum(np.square(annihilator.enthalpyerrorlist))) annihilator.entropyerror = np.sqrt( np.sum(np.square(annihilator.entropyerrorlist))) if annihilator.solvation == True: annihilator.tabledict[u'ΔGˢᵒˡᵛ'] = annihilator.freeenergy annihilator.tabledict[u'ΔGˢᵒˡᵛᵉʳʳ'] = annihilator.freeenergyerror annihilator.tabledict[u'ΔHˢᵒˡᵛ'] = annihilator.enthalpy annihilator.tabledict[u'ΔHˢᵒˡᵛᵉʳʳ'] = annihilator.enthalpyerror annihilator.tabledict[u'ΔSˢᵒˡᵛ'] = annihilator.entropy annihilator.tabledict[u'ΔSˢᵒˡᵛᵉʳʳ'] = annihilator.entropyerror elif annihilator.complexation == True: annihilator.tabledict[u'ΔGᶜᵒᵐᵖᵘⁿᶜᵒʳʳ'] = annihilator.freeenergy annihilator.tabledict[ u'ΔGᶜᵒᵐᵖᶜᵒʳʳᵉʳʳ'] = annihilator.freeenergyerror annihilator.tabledict[u'ΔHᶜᵒᵐᵖ'] = annihilator.enthalpy annihilator.tabledict[u'ΔHᶜᵒᵐᵖᵉʳʳ'] = annihilator.enthalpyerror annihilator.tabledict[u'ΔSᶜᵒᵐᵖ'] = annihilator.entropy annihilator.tabledict[u'ΔSᶜᵒᵐᵖᵉʳʳ'] = annihilator.entropyerror tables.WriteTableUpdateToLog(annihilator) tempname = 'BARResults.csv' with open(annihilator.outputpath + tempname, mode='w') as energy_file: energy_writer = csv.writer(energy_file, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL) energy_writer.writerow(['Ele-Lambda'] + annihilator.estatlambdascheme) energy_writer.writerow(['Vdw-Lambda'] + annihilator.vdwlambdascheme) energy_writer.writerow(['Rest-Lambda'] + annihilator.restlambdascheme) if annihilator.solvation == True: energy_writer.writerow([u'ΔGˢᵒˡᵛ'] + annihilator.freeenergylist) energy_writer.writerow([u'ΔGˢᵒˡᵛᵉʳʳ'] + annihilator.freeenergyerrorlist) energy_writer.writerow([u'ΔHˢᵒˡᵛ'] + annihilator.enthalpylist) energy_writer.writerow([u'ΔHˢᵒˡᵛᵉʳʳ'] + annihilator.enthalpyerrorlisttotal) energy_writer.writerow([u'ΔSˢᵒˡᵛ'] + annihilator.entropylist) energy_writer.writerow([u'ΔSˢᵒˡᵛᵉʳʳ'] + annihilator.entropyerrorlisttotal) elif annihilator.complexation == True: energy_writer.writerow([u'ΔGᶜᵒᵐᵖ'] + annihilator.freeenergylist) energy_writer.writerow([u'ΔGᶜᵒᵐᵖᵉʳʳ'] + annihilator.freeenergyerrorlist) energy_writer.writerow([u'ΔHᶜᵒᵐᵖ'] + annihilator.enthalpylist) energy_writer.writerow([u'ΔHᶜᵒᵐᵖᵉʳʳ'] + annihilator.enthalpyerrorlisttotal) energy_writer.writerow([u'ΔSᶜᵒᵐᵖ'] + annihilator.entropylist) energy_writer.writerow([u'ΔSᶜᵒᵐᵖᵉʳʳ'] + annihilator.entropyerrorlisttotal)
def TotalAtomNumber(annihilator, xyzfilename): atomnum = FindNumberTinkerXYZAtoms(annihilator, xyzfilename) annihilator.totalatomnumberxyzfilename = atomnum totalatomnum = atomnum + 3 * annihilator.waternum annihilator.tabledict['Total Atom Number'] = totalatomnum tables.WriteTableUpdateToLog(annihilator)