Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
sys.stderr.write('CPEIN generation complete!\n')
if __name__ == '__main__':
opt = parser.parse_args()
# List all residues
if opt.list:
list_residues()
sys.exit(0)
# Describe requested residues
if opt.descres is not None:
if len(opt.descres) == 0 or (len(opt.descres) == 1 and
opt.descres[0].upper() == 'ALL'):
print_residues(residues.titratable_residues,0)
else:
opt.descres = process_arglist(opt.descres, str)
print_residues(opt.descres,1)
sys.exit(0)
# Go ahead and make the CPEIN file.
try:
main(opt)
except ParmedError as e:
sys.exit('%s: %s' % (type(e).__name__, e))
sys.exit(0)
sys.stderr.write('CEIN generation complete!\n')
if __name__ == '__main__':
opt = parser.parse_args()
# List all residues
if opt.list:
list_residues()
sys.exit(0)
# Describe requested residues
if opt.descres is not None:
if len(opt.descres) == 0 or (len(opt.descres) == 1 and
opt.descres[0].upper() == 'ALL'):
print_residues(residues.titratable_residues,0)
else:
opt.descres = process_arglist(opt.descres, str)
print_residues(opt.descres,1)
sys.exit(0)
# Go ahead and make the CEIN file.
try:
main(opt)
except ParmedError as e:
sys.exit('%s: %s' % (type(e).__name__, e))
sys.exit(0)
sys.stderr.write('CPIN generation complete!\n')
if __name__ == '__main__':
opt = parser.parse_args()
# List all residues
if opt.list:
list_residues()
sys.exit(0)
# Describe requested residues
if opt.descres is not None:
if len(opt.descres) == 0 or (len(opt.descres) == 1 and
opt.descres[0].upper() == 'ALL'):
print_residues(residues.titratable_residues,0)
else:
opt.descres = process_arglist(opt.descres, str)
print_residues(opt.descres,1)
sys.exit(0)
# Go ahead and make the CPIN file.
try:
main(opt)
except ParmedError as e:
sys.exit('%s: %s' % (type(e).__name__, e))
sys.exit(0)
def list_residues():
""" Lists all titratable residues defined in residues.py """
line = LineBuffer(sys.stdout)
strarray = []
for resname in residues.titratable_residues:
if getattr(residues, resname).typ == "ph":
strarray.append(resname)
line.add_words(', '.join(strarray).split(),
space_delimited=True)
line.flush()
raise AmberError('-intdiel must be either 1 or 2 currently')
# Print warning about old format
if opt.oldfmt:
sys.stderr.write('Warning: The old format of the CPIN file can only be used for simulations with temp0=300.0!\n'
' You should use the new format for simulations with temperatures other than 300.0 Kelvins\n')
# Set the list of residue names we will be willing to titrate
titratable_residues = []
if notresnames is not None:
for resname in residues.titratable_residues:
if resname in notresnames: continue
titratable_residues.append(resname)
elif resnames is not None:
for resname in resnames:
if not resname in residues.titratable_residues:
raise AmberError('%s is not a titratable residue!' % resname)
elif not getattr(residues, resname).typ == "ph":
raise AmberError('%s is not a pH-active titratable residue!' % resname)
titratable_residues.append(resname)
else:
for resname in residues.titratable_residues:
if getattr(residues, resname).typ == "ph":
titratable_residues.append(resname)
solvent_ions = ['WAT', 'Na+', 'Br-', 'Cl-', 'Cs+', 'F-', 'I-', 'K+', 'Li+',
'Mg+', 'Rb+', 'CIO', 'IB', 'MG2']
# Filter titratable residues based on min and max pKa
new_reslist = []
for res in titratable_residues:
if getattr(residues, res).pKa < minpka: continue
if resnames is not None and notresnames is not None:
raise AmberError('Cannot specify -resnames and -notresnames together')
if opt.intdiel != 1 and opt.intdiel != 2:
raise AmberError('-intdiel must be either 1 or 2 currently')
# Set the list of residue names we will be willing to titrate
titratable_residues = []
if notresnames is not None:
for resname in residues.titratable_residues:
if resname in notresnames: continue
titratable_residues.append(resname)
elif resnames is not None:
for resname in resnames:
if not resname in residues.titratable_residues:
raise AmberError('%s is not a titratable residue!' % resname)
elif not getattr(residues, resname).typ == "redox":
raise AmberError('%s is not a redox-active titratable residue!' % resname)
titratable_residues.append(resname)
else:
for resname in residues.titratable_residues:
if getattr(residues, resname).typ == "redox":
titratable_residues.append(resname)
solvent_ions = ['WAT', 'Na+', 'Br-', 'Cl-', 'Cs+', 'F-', 'I-', 'K+', 'Li+',
'Mg+', 'Rb+', 'CIO', 'IB', 'MG2']
# Filter titratable residues based on min and max pKa
new_reslist = []
for res in titratable_residues:
if getattr(residues, res).Eo < mineo: continue
if opt.intdiel != 1 and opt.intdiel != 2:
raise AmberError('-intdiel must be either 1 or 2 currently')
# Set the list of residue names we will be willing to titrate
titratable_residues = []
if notresnames is not None:
for resname in residues.titratable_residues:
if resname in notresnames: continue
titratable_residues.append(resname)
elif resnames is not None:
for resname in resnames:
if not resname in residues.titratable_residues:
raise AmberError('%s is not a titratable residue!' % resname)
titratable_residues.append(resname)
else:
for resname in residues.titratable_residues:
titratable_residues.append(resname)
solvent_ions = ['WAT', 'Na+', 'Br-', 'Cl-', 'Cs+', 'F-', 'I-', 'K+', 'Li+',
'Mg+', 'Rb+', 'CIO', 'IB', 'MG2']
# Make sure we still have a couple residues
if len(titratable_residues) == 0:
raise AmberError('No titratable residues fit your criteria!')
# Load the topology file
parm = AmberParm(opt.prmtop)
# Replace an un-set notresnums with an empty list so we get __contains__()
if notresnums is None:
notresnums = []
# Set the list of residue names we will be willing to titrate
titratable_residues = []
if notresnames is not None:
for resname in residues.titratable_residues:
if resname in notresnames: continue
titratable_residues.append(resname)
elif resnames is not None:
for resname in resnames:
if not resname in residues.titratable_residues:
raise AmberError('%s is not a titratable residue!' % resname)
elif not getattr(residues, resname).typ == "redox":
raise AmberError('%s is not a redox-active titratable residue!' % resname)
titratable_residues.append(resname)
else:
for resname in residues.titratable_residues:
if getattr(residues, resname).typ == "redox":
titratable_residues.append(resname)
solvent_ions = ['WAT', 'Na+', 'Br-', 'Cl-', 'Cs+', 'F-', 'I-', 'K+', 'Li+',
'Mg+', 'Rb+', 'CIO', 'IB', 'MG2']
# Filter titratable residues based on min and max pKa
new_reslist = []
for res in titratable_residues:
if getattr(residues, res).Eo < mineo: continue
if getattr(residues, res).Eo > maxeo: continue
new_reslist.append(res)
titratable_residues = new_reslist
del new_reslist
# Make sure we still have a couple residues
if resnames is not None and notresnames is not None:
raise AmberError('Cannot specify -resnames and -notresnames together')
if opt.intdiel != 1 and opt.intdiel != 2:
raise AmberError('-intdiel must be either 1 or 2 currently')
# Set the list of residue names we will be willing to titrate
titratable_residues = []
if notresnames is not None:
for resname in residues.titratable_residues:
if resname in notresnames: continue
titratable_residues.append(resname)
elif resnames is not None:
for resname in resnames:
if not resname in residues.titratable_residues:
raise AmberError('%s is not a titratable residue!' % resname)
titratable_residues.append(resname)
else:
for resname in residues.titratable_residues:
titratable_residues.append(resname)
solvent_ions = ['WAT', 'Na+', 'Br-', 'Cl-', 'Cs+', 'F-', 'I-', 'K+', 'Li+',
'Mg+', 'Rb+', 'CIO', 'IB', 'MG2']
# Make sure we still have a couple residues
if len(titratable_residues) == 0:
raise AmberError('No titratable residues fit your criteria!')
# Load the topology file
parm = AmberParm(opt.prmtop)