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

Custom molname #623

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
pckroon marked this conversation as resolved.
Show resolved Hide resolved
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
Loading