Skip to content

Commit

Permalink
update options and debug
Browse files Browse the repository at this point in the history
  • Loading branch information
SangniXun committed Jun 13, 2024
1 parent 6601565 commit 3adf5e0
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 45 deletions.
72 changes: 35 additions & 37 deletions autosolvate/FFmetalcomplex.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -612,25 +611,25 @@ 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'
method='B3LYP'
QMexe = None
solvent_off=''
solvent_frcmod = ''
basisset='6-31G*'
basisset='DEF2-TZVP'
amberhome='$AMBERHOME/bin/'
opt = 'Y'
gamessexe = None
Expand All @@ -647,80 +646,79 @@ 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 './'
'''
print(message)
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)
elif currentArgument in ('-v','--mode'):
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)


Expand Down
16 changes: 8 additions & 8 deletions autosolvate/QM_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import subprocess
import numpy as np
from glob import glob
import os
import sys
import getopt
import collections
Expand Down Expand Up @@ -499,16 +500,15 @@ 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']:
if self.opt == 'Y':
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,
Expand All @@ -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'
Expand All @@ -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'
Expand All @@ -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')
Expand All @@ -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')
Expand All @@ -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'
Expand Down

0 comments on commit 3adf5e0

Please sign in to comment.