Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Makebonds molecule #234

Closed
wants to merge 11 commits into from
Prev Previous commit
Next Next commit
Added CLI flag "nproc" to optionally enable multiprocessing
  • Loading branch information
Matthijs Tadema authored and Matthijs Tadema committed Mar 4, 2020
commit 89df2577701c8f98bf7e32ca59f5d49ea2bc034d
14 changes: 11 additions & 3 deletions bin/martinize2
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def read_system(path, ignore_resnames=(), ignh=None, modelidx=None):

def pdb_to_universal(system, delete_unknown=False, force_field=None,
bonds_from_name=True, bonds_from_dist=True, bonds_fudge=1,
write_graph=None, write_repair=None, write_canon=None):
write_graph=None, write_repair=None, write_canon=None, nproc=1):
"""
Convert a system read from the PDB to a clean canonical atomistic system.
"""
Expand All @@ -106,7 +106,7 @@ def pdb_to_universal(system, delete_unknown=False, force_field=None,
LOGGER.info('Guessing the bonds.', type='step')
vermouth.MakeBonds(allow_name=bonds_from_name,
allow_dist=bonds_from_dist,
fudge=bonds_fudge).run_system(canonicalized)
fudge=bonds_fudge, nproc=nproc).run_system(canonicalized)
vermouth.MergeNucleicStrands().run_system(canonicalized)
if write_graph is not None:
vermouth.pdb.write_pdb(canonicalized, str(write_graph), omit_charges=True)
Expand All @@ -121,7 +121,7 @@ def pdb_to_universal(system, delete_unknown=False, force_field=None,
vermouth.pdb.write_pdb(canonicalized, str(write_canon),
omit_charges=True, nan_missing_pos=True)
vermouth.AttachMass(attribute='mass').run_system(canonicalized)
vermouth.SortMoleculeAtoms().run_system(canonicalized) # was system
vermouth.SortMoleculeAtoms().run_system(canonicalized)
return canonicalized


Expand Down Expand Up @@ -376,6 +376,13 @@ def entry():
type=_cys_argument,
default='none', help='Cystein bonds')

exp_group = parser.add_argument_group('Experimental options')
exp_group.add_argument('-nproc', dest='nproc', type=int, default=1,
help='Optionally use multiprocessing to speed'
'up bond creation. Only use when you\'re'
'very sure that your input file is correct.'
'Very likely to break something.')

debug_group = parser.add_argument_group('Debugging options')
debug_group.add_argument('-write-graph', type=Path, default=None,
help='Write the graph as PDB after the MakeBonds step.')
Expand Down Expand Up @@ -490,6 +497,7 @@ def entry():
write_graph=args.write_graph,
write_repair=args.write_repair,
write_canon=args.write_canon,
nproc=args.nproc
)

LOGGER.info('Read input.', type='step')
Expand Down