diff --git a/bin/martinize2 b/bin/martinize2 index 893aee5f..b4d22c7d 100755 --- a/bin/martinize2 +++ b/bin/martinize2 @@ -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", @@ -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", @@ -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, @@ -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. diff --git a/vermouth/processors/name_moltype.py b/vermouth/processors/name_moltype.py index 0d6799fe..fe639930 100644 --- a/vermouth/processors/name_moltype.py +++ b/vermouth/processors/name_moltype.py @@ -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): @@ -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) diff --git a/vermouth/tests/data/integration_tests/tier-1/lysozyme_GO/martinize2/command b/vermouth/tests/data/integration_tests/tier-1/lysozyme_GO/martinize2/command index cdf20851..a0e75009 100755 --- a/vermouth/tests/data/integration_tests/tier-1/lysozyme_GO/martinize2/command +++ b/vermouth/tests/data/integration_tests/tier-1/lysozyme_GO/martinize2/command @@ -8,3 +8,4 @@ martinize2 -go ../map.map -noscfix -cys none +-name molecule_0 \ No newline at end of file diff --git a/vermouth/tests/data/integration_tests/tier-1/lysozyme_GObias/martinize2/command b/vermouth/tests/data/integration_tests/tier-1/lysozyme_GObias/martinize2/command index f0de2bf4..5626db7e 100755 --- a/vermouth/tests/data/integration_tests/tier-1/lysozyme_GObias/martinize2/command +++ b/vermouth/tests/data/integration_tests/tier-1/lysozyme_GObias/martinize2/command @@ -10,3 +10,4 @@ martinize2 -water-bias-eps E:-.5 C:1.0 H:-1.0 -noscfix -cys none +-name molecule_0 \ No newline at end of file