Skip to content

Commit

Permalink
Merge pull request #634 from marrink-lab/custom-molname
Browse files Browse the repository at this point in the history
Custom molname
  • Loading branch information
pckroon authored Nov 18, 2024
2 parents 640ad79 + 7632f6d commit 83409f1
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
19 changes: 11 additions & 8 deletions bin/martinize2
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,14 @@ def entry():
"if instead all chains in the input file should be merged.\n"
"Can be given multiple times for different groups of chains to merge.",
)
file_group.add_argument(
"-name",
dest="molname",
type=str,
default="molecule",
help="Name for the output molecule. If not specified, will default to 'molecule_{0..n}' for the number of"
" molecules in your system."
)
file_group.add_argument(
"-resid",
dest="resid_handling",
Expand Down Expand Up @@ -551,12 +559,6 @@ def entry():
default=9.414,
help=("The strength of the Go model structural bias in kJ/mol."),
)
go_group.add_argument(
"-go-moltype",
dest="govs_moltype",
default="molecule_0",
help=("Set the name of the molecule when using " "Virtual Sites GoMartini."),
)
go_group.add_argument(
"-go-low",
dest="go_low",
Expand Down Expand Up @@ -987,11 +989,12 @@ def entry():

# Generate the Go model if required
if args.go:
go_name_prefix = args.molname
LOGGER.info("Reading Go model contact map.", type="step")
go_map = read_go_map(args.go)
LOGGER.info("Generating the Go model.", type="step")
GoPipeline.run_system(system,
moltype=args.govs_moltype,
moltype=go_name_prefix,
contact_map=go_map,
cutoff_short=args.go_low,
cutoff_long=args.go_up,
Expand Down Expand Up @@ -1019,7 +1022,7 @@ def entry():
raise argparse.ArgumentError(chain_merging,
message=("Multiple conflicting merging arguments given. "
"Either specify -merge all or -merge A,B,C (+)."))
vermouth.NameMolType(deduplicate=not args.keep_duplicate_itp).run_system(system)
vermouth.NameMolType(deduplicate=not args.keep_duplicate_itp, molname=args.molname).run_system(system)
defines = ()

# Apply a rubber band elastic network is required.
Expand Down
7 changes: 4 additions & 3 deletions vermouth/processors/name_moltype.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,10 @@ class NameMolType(Processor):
the molecule.
"""
# TODO: See issue #35
def __init__(self, deduplicate=True, meta_key='moltype'):
def __init__(self, deduplicate=True, meta_key='moltype', molname='molecule'):
self.deduplicate = deduplicate
self.meta_key = meta_key
self.molname = molname
super().__init__()

def run_system(self, system):
Expand All @@ -85,8 +86,8 @@ def _name_with_deduplication(self, system):
group_id += 1
representatives.append((group_id, molecule))
match_id = group_id
molecule.meta[self.meta_key] = 'molecule_{}'.format(match_id)
molecule.meta[self.meta_key] = '{}_{}'.format(self.molname, match_id)

def _name_without_deduplication(self, system):
for molecule_id, molecule in enumerate(system.molecules):
molecule.meta[self.meta_key] = 'molecule_{}'.format(molecule_id)
molecule.meta[self.meta_key] = '{}_{}'.format(self.molname, molecule_id)
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ martinize2
-go ../map.map
-noscfix
-cys none
-name molecule_0
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ martinize2
-water-bias-eps E:-.5 C:1.0 H:-1.0
-noscfix
-cys none
-name molecule_0

0 comments on commit 83409f1

Please sign in to comment.