Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"""
This script will validate the torsions specified in a particular database and
will highlight any specific torsions that need additional terms to explicitly
override generic torsions
"""
import os
import parmed as pmd
import sys
if len(sys.argv) < 2:
sys.exit('%s [ [ ...]]' %
os.path.split(sys.argv[0])[1])
params = pmd.amber.AmberParameterSet(sys.argv[1:])
# First separate the generic terms and the specific terms. Store the generics as
# *just* the middle terms, and do both permutations
generics = dict()
generic_type_ids = set()
specifics = dict()
specific_type_ids = set()
for key, dihtype in params.dihedral_types.items():
if key[0] == 'X' and key[3] == 'X':
if id(dihtype) in generic_type_ids:
continue
generics[(key[1], key[2])] = generics[(key[2], key[1])] = dihtype
generic_type_ids.add(id(dihtype))
else:
if id(dihtype) in specific_type_ids:
# del ATOM_TYPE_DICT2
if options.fopt not in [1, 2]:
raise ValueError('-f should be followed by 1 or 2!')
if options.newtype not in [0, 1]:
raise ValueError('--nat should be followed by 0 or 1!')
# Setting the option to re-arrange the improper torsion order
imp_rearg = 1
# Generate an empty CHARMM parameter set
params = pmd.charmm.CharmmParameterSet()
# Update the parameter files
if options.fopt == 1:
params1 = pmd.amber.AmberParameterSet(options.inputf)
params = params_update(params, params1, options.newtype, imp_rearg)
elif options.fopt == 2:
frc_files = []
with open(options.inputf, 'r') as f:
for rline in f:
line = rline.strip('\n')
line = line.strip()
frc_files.append(line)
for i in frc_files:
params1 = pmd.amber.AmberParameterSet(i)
params = params_update(params, params1, options.newtype, imp_rearg)
# Write the output parameter file
params.write(par=options.outputf)
quit()
# Generate an empty CHARMM parameter set
params = pmd.charmm.CharmmParameterSet()
# Update the parameter files
if options.fopt == 1:
params1 = pmd.amber.AmberParameterSet(options.inputf)
params = params_update(params, params1, options.newtype, imp_rearg)
elif options.fopt == 2:
frc_files = []
with open(options.inputf, 'r') as f:
for rline in f:
line = rline.strip('\n')
line = line.strip()
frc_files.append(line)
for i in frc_files:
params1 = pmd.amber.AmberParameterSet(i)
params = params_update(params, params1, options.newtype, imp_rearg)
# Write the output parameter file
params.write(par=options.outputf)
quit()