Skip to content
Snippets Groups Projects
Verified Commit 81c6efcf authored by James Graham's avatar James Graham
Browse files

refactor: rename top and traj inputs

parent 4aa4d83a
No related branches found
No related tags found
No related merge requests found
......@@ -42,7 +42,7 @@ def measure_bonds(frame: Frame, mapping: typing.Optional[Mapping],
logger.info("Bond measurements will be made")
bonds.apply(frame)
if config.map and config.xtc:
if config.map and config.trajectory:
# Only perform Boltzmann Inversion if we have a mapping and a trajectory.
# Otherwise we get infinite force constants.
logger.info("Beginning Boltzmann Inversion")
......@@ -87,8 +87,8 @@ def full_run(config):
:param config: Program arguments from argparse
"""
frame = Frame(
topology_file=config.gro,
trajectory_file=config.xtc, # May be None
topology_file=config.topology,
trajectory_file=config.trajectory, # May be None
frame_start=config.begin,
frame_end=config.end)
......@@ -110,18 +110,20 @@ def full_run(config):
def parse_arguments(arg_list):
parser = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
description="Perform coarse-grain mapping of atomistic trajectory")
description=
"Generate coarse-grained molecular dynamics models from atomistic trajectories."
)
# yapf: disable
# Input files
input_files = parser.add_argument_group("input files")
input_files.add_argument('-g', '--gro', type=str, required=True,
help="GROMACS GRO file")
input_files.add_argument('topology', type=str,
help="AA simulation topology - e.g. PDB, GRO, etc.")
input_files.add_argument('trajectory', type=str, nargs='?',
help="AA simulation trajectory - e.g. XTC, DCD, etc.")
input_files.add_argument('-m', '--map', type=str,
help="Mapping file")
input_files.add_argument('-x', '--xtc', type=str,
help="GROMACS XTC file")
input_files.add_argument('-b', '--bnd', type=str,
help="Bonds file")
input_files.add_argument('-i', '--itp', type=str,
......@@ -222,8 +224,8 @@ def validate_arguments(args):
def main():
args = parse_arguments(sys.argv[1:])
print("Using GRO: {0}".format(args.gro))
print("Using XTC: {0}".format(args.xtc))
print("Using GRO: {0}".format(args.topology))
print("Using XTC: {0}".format(args.trajectory))
if args.profile:
with cProfile.Profile() as profiler:
......
......@@ -14,16 +14,20 @@ import pycgtool.__main__ as main
def get_args(name, out_dir, extra: typing.Optional[typing.Mapping] = None):
data_dir = pathlib.Path('test/data')
args = {
'-g': data_dir.joinpath(f'{name}.gro'),
'-x': data_dir.joinpath(f'{name}.xtc'),
args = [
data_dir.joinpath(f'{name}.gro'),
data_dir.joinpath(f'{name}.xtc'),
]
kwargs = {
'-m': data_dir.joinpath(f'{name}.map'),
'-b': data_dir.joinpath(f'{name}.bnd'),
'--out-dir': out_dir,
}
parsed_args = main.parse_arguments(
itertools.chain(*[[key, str(value)] for key, value in args.items()]))
itertools.chain(map(str, args),
*[[key, str(value)] for key, value in kwargs.items()]))
if extra is not None:
for key, value in extra.items():
......@@ -45,15 +49,14 @@ class PycgtoolTest(unittest.TestCase):
def test_parse_arguments(self):
args = main.parse_arguments([
'-g',
'GRO',
'TOPOLOGY',
'-m',
'MAP',
'--begin',
'1000',
])
self.assertEqual('GRO', args.gro)
self.assertEqual('TOPOLOGY', args.topology)
self.assertEqual('MAP', args.map)
self.assertEqual(1000, args.begin)
......@@ -97,7 +100,7 @@ class PycgtoolTest(unittest.TestCase):
with tempfile.TemporaryDirectory() as tmpdir:
tmp_path = pathlib.Path(tmpdir)
args = get_args('sugar', tmp_path, extra={
'xtc': None,
'trajectory': None,
})
main.full_run(args)
......@@ -115,7 +118,7 @@ class PycgtoolTest(unittest.TestCase):
tmp_path = pathlib.Path(tmpdir)
args = get_args('sugar', tmp_path, extra={
'map': None,
'xtc': None,
'trajectory': None,
})
main.full_run(args)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment