diff --git a/autosolvate/FFmetalcomplex.py b/autosolvate/FFmetalcomplex.py index 707f193..2d32b4e 100644 --- a/autosolvate/FFmetalcomplex.py +++ b/autosolvate/FFmetalcomplex.py @@ -26,7 +26,6 @@ def __init__(self, filename,metal_charge, chargefile, solvent,slv_count,folder, self.basisset = basisset self.method = method self.totalcharge = totalcharge - # print('################ totalcharge is ',self.totalcharge) self.nprocs = nprocs self.QMexe = QMexe self.amberhome = amberhome @@ -563,7 +562,7 @@ def build(self): outputFile='',amberhome=self.amberhome,cube_size=self.cubesize,slv_count=self.slv_count) step9.build() solvated_prmtop = self.filename +'_solvated.prmtop' - if solvated_prmtop in glob('*.prmtop'): + if os.path.exists(solvated_prmtop): print('******************** Autosolvate successfully generates', solvated_prmtop,'******************** ') else: raise TypeError('Erorr: can not find ' + solvated_prmtop + ', please check tleap.log') @@ -612,17 +611,17 @@ def build(self): """ def startFFgen(argumentList): - options = 'hm:c:u:v:f:x:k:r:G:n:l:p:s:A:Q:e:b:t:z:' - long_options = ["help",'filename=','metal_charge=','spin=','mode=', 'folder=', - 'chargefile=','totalcharge=','software=','nprocs=','method=','cubesize=','closeness=' - 'qmexe=','basisset=','solventoff=','solventfrcmod=','amberhome=','opt=','solvent='] - arguments, values = getopt.getopt(argumentList,options,long_options) + options = 'hm:k:u:v:f:e:c:y:d:i:l:p:j:a:w:s:b:t:D:' + long_options = ["help", 'filename=', 'metal_charge=', 'spin=', 'mode=', 'folder=', 'rundir=', + 'chargefile=', 'charge=', 'nprocs=', 'method=', 'cubesize=', 'closeness=', 'qmdir=', + 'qmexe=', 'basisset=', 'solventoff=', 'solventfrcmod=', 'amberhome=', 'opt=', 'solvent='] + arguments, values = getopt.getopt(argumentList, options, long_options) filename = None metal_charge = None mode='A' spinmult=None chargefile = None - software = 'gms' + software = 'orca' spinmult = '1' totalcharge= 'default' nprocs='8' @@ -630,7 +629,7 @@ def startFFgen(argumentList): QMexe = None solvent_off='' solvent_frcmod = '' - basisset='6-31G*' + basisset='DEF2-TZVP' amberhome='$AMBERHOME/bin/' opt = 'Y' gamessexe = None @@ -647,26 +646,26 @@ def startFFgen(argumentList): Options: -h, --help Display this help message. -m, --main metalcomplex xyz file including extension. - -c, --metal_charge Set the metal charge. + -k, --metal_charge Set the metal charge. -u, --spin Set the spin default: 1 - -v, --mode Set the mode (A/M). + -v, --mode Set the mode (A/M). default: A . A is automode for charge assignment of ligands, M is manual -f, --chargefile Specify the charge file if --mode is M. chargefile example: LG1 -1 #ligand name charge - -x, --software gau,g09,g16,gms,orca, default:gms - -k, --totalcharge total charge of the whole system, the default is caluated after charge assignment - -r, --nprocs procs to run orca QM calculation, if -x orca - -G --qmexe path to QM exe e.g. /opt/orca/5.0.2/orca - -n --method method of QM default:B3LYP + -e, --qmexe name of the quantum chemistry package executable'gau,g09,g16,gms,orca, default:orca + -c, --charge total charge of the whole complex, the default is caluated after charge assignment + -y, --nprocs procs to run orca QM calculation, if -x orca + -d --qmdir full path to QM exe e.g. /opt/orca/5.0.2/orca + -i --method method of QM default:B3LYP -l --solventoff path to the custom solvent .off library file -p --solventfrcmod path to the custom solvent .frcmod file - -s --basisset basisset used in QM calculation, default: 6-31G* - -A --amberhome path of AmberTools bin default: $AMBERHOME/bin/ - -Q --opt use(Y) or not use(N) the QM optimized structure for charge calculation default: Y - -e --solvent name of solvent (water, methanol, chloroform, nma, acetonitrile) - -b --cubesize size of solvent cube in angstroms default: 56 + -j --basisset basisset used in QM calculation, default: DEF2-TZVP (for GAMES-US only 6-31G,6-31G*,LANL2DZ are supported) + -a --amberhome path of AmberTools bin default: $AMBERHOME/bin/ + -w --opt use(Y) or not use(N) the QM optimized structure for charge calculation default: Y + -s --solvent name of solvent (water, methanol, chloroform, nma, acetonitrile) + -b --cubesize size of solvent cube in angstroms default: 54 -t --closeness Solute-solvent closeness setting default value is used if the option is not specified - -z --folder the path of outputfiles, default: the current folder './' + -D, --rundir running directory where temporary files are stored, default: the current folder './' ''' @@ -674,7 +673,7 @@ def startFFgen(argumentList): sys.exit() elif currentArgument in ("-m","--main"): filename = os.path.splitext(str(currentValue))[0] - elif currentArgument in ("-c",'--metal_charge'): + elif currentArgument in ("-k",'--metal_charge'): metal_charge = int(currentValue) elif currentArgument in ('-u','--spin'): spinmult=int(currentValue) @@ -682,45 +681,44 @@ def startFFgen(argumentList): mode = str(currentValue) elif currentArgument in ('-f','--chargefile'): chargefile = str(currentValue) - elif currentArgument in ('-x','--software'): + elif currentArgument in ('-e','--qmexe'): software = str(currentValue) - elif currentArgument in ('-k','--totalcharge'): + elif currentArgument in ('-c','--charge'): totalcharge = str(currentValue) - elif currentArgument in ('-r','--nprocs'): + elif currentArgument in ('-y','--nprocs'): nprocs = str(currentValue) - elif currentArgument in ('-G','--qmexe'): + elif currentArgument in ('-d','--qmdir'): QMexe = str(currentValue) - elif currentArgument in ('-n','--method'): + elif currentArgument in ('-i','--method'): method = str(currentValue) elif currentArgument in ('-l','--solventoff'): solvent_off = str(currentValue) elif currentArgument in ('-p','--solventfrcmod'): solvent_frcmod = str(currentValue) - elif currentArgument in ('-s','--basisset'): + elif currentArgument in ('-j','--basisset'): basisset = str(currentValue) - elif currentArgument in ('-A','--amberhome'): + elif currentArgument in ('-a','--amberhome'): amberhome = str(currentValue) - elif currentArgument in ('-Q','-opt'): + elif currentArgument in ('-w','--opt'): opt = str(currentValue) - elif currentArgument in ('-e','-solvent'): + elif currentArgument in ('-s','--solvent'): solvent = str(currentValue) - elif currentArgument in ('-b','-cubesize'): + elif currentArgument in ('-b','--cubesize'): cubesize = str(currentValue) - elif currentArgument in ('-t','-closeness'): + elif currentArgument in ('-t','--closeness'): closeness = str(currentValue) - elif currentArgument in ('-z','-folder'): + elif currentArgument in ('-D','--rundir'): folder = str(currentValue) + builder = genFF(filename=filename,metal_charge=metal_charge, spinmult=spinmult,basisset=basisset,closeness=closeness,folder = folder, mode=mode,chargefile=chargefile,software=software,solvent_frcmod=solvent_frcmod,amberhome=amberhome,cubesize=cubesize, totalcharge=totalcharge,nprocs=nprocs,QMexe=QMexe,method=method,solvent_off=solvent_off,opt=opt,solvent=solvent,slv_count=slv_count) - # print(arguments) builder.build() if __name__ == '__main__': argumentList = sys.argv[1:] - # print(argumentList) startFFgen(argumentList) diff --git a/autosolvate/QM_gen.py b/autosolvate/QM_gen.py index 5f46948..b7fd176 100644 --- a/autosolvate/QM_gen.py +++ b/autosolvate/QM_gen.py @@ -2,6 +2,7 @@ import subprocess import numpy as np from glob import glob +import os import sys import getopt import collections @@ -499,7 +500,7 @@ def build(self): for line in crds_origin: new_crds.append([line.split()[0],line.split()[2],line.split()[3],line.split()[4]]) self.write_orca_mk( out=out, crds=new_crds,multi=self.multi, nprocs=self.nprocs, - totalcharge=self.totalcharge,basiset=self.basisset,method=self.method) + totalcharge=self.totalcharge,basisset=self.basisset,method=self.method) elif self.software in ['gms','GAMESS']: if self.caltype in ['MK','mk','Mk']: @@ -507,8 +508,7 @@ def build(self): out = self.filename + '_large_mk.inp' inp = self.filename + '_small_opt.log' crds = get_crds_from_gmsopt(inp) - # print(crds) - if self.filename+'_small_opt.logback' not in glob('*'): + if os.path.exists(self.filename+'_small_opt.logback') == False: cmd = 'cp ' + inp + ' ' + self.filename+'_small_opt.logback' subprocess.call(cmd,shell=True) self.write_gms_mk(out=out,multi=self.multi,crds=crds, @@ -522,7 +522,7 @@ def build(self): elif self.caltype in ['opt','OPT']: inp=self.filename+'_small_opt.inpback' - if inp not in glob('*'): + if os.path.exists(inp) == False: cmd = 'cp ' + self.filename+'_small_opt.inp ' + inp subprocess.call(cmd,shell=True) out = self.filename+'_small_opt.inp' @@ -531,7 +531,7 @@ def build(self): elif self.caltype in ['FC','fc']: inp=self.filename+'_small_opt.log' - if self.filename+'_small_opt.logback' not in glob('*'): + if os.path.exists(self.filename+'_small_opt.logback') == False: cmd = 'cp ' + inp + ' ' + self.filename+'_small_opt.logback' subprocess.call(cmd,shell=True) out = self.filename+'_small_fc.inp' @@ -541,7 +541,7 @@ def build(self): elif self.software in ['gau','g09','g03']: if self.caltype in ['opt','OPT']: inp = self.filename + '_small_opt.inp' - if self.filename + '_small_opt.inpback' not in glob('*'): + if os.path.exists(self.filename + '_small_opt.inpback') == False: cmd = 'cp ' + inp + ' ' + self.filename + '_small_opt.inpback' subprocess.call(cmd,shell=True) crds = get_crds_from_gmsinp(inp + 'back') @@ -568,7 +568,7 @@ def build(self): self.write_gaussian_mk_from_opt(out=out,nprocs=self.nprocs,basisset=self.basisset,method=self.method) elif self.opt == 'N': inp = self.filename + '_small_opt.inp' - if self.filename + '_small_opt.inpback' not in glob('*'): + if os.path.exists(self.filename + '_small_opt.inpback') == False: cmd = 'cp ' + inp + ' ' + self.filename + '_small_opt.logback' subprocess.call(cmd,shell=True) crds = get_crds_from_gmsinp(inp + 'back') @@ -593,7 +593,7 @@ def startautoQM(argumentList): options = "hn:c:u:x:t:m:b:p:l:Q:" long_options = ["help",'filename=','totalcharge=','multi=','software=','caltype=','metal=','basisset=','nprocs=','orcapath=','opt='] arguments, values = getopt.getopt(argumentList,options,long_options) - software = 'gms' + software = 'orca' filename = None totalcharge = 'default' multi = '1'