From 17175faa49085a0890db2ec10f6a3f8484d42d32 Mon Sep 17 00:00:00 2001 From: "M. Eric Irrgang" Date: Wed, 2 Oct 2019 16:53:52 +0300 Subject: [PATCH] Add trajectory output to mdrun operation. Fixes #3144 Change-Id: Ic9e1eb988bc9c934eb8e9cd6009008e6e60d8342 --- python_packaging/src/gmxapi/simulation/mdrun.py | 8 ++++++++ python_packaging/src/test/test_mdrun.py | 3 +++ 2 files changed, 11 insertions(+) diff --git a/python_packaging/src/gmxapi/simulation/mdrun.py b/python_packaging/src/gmxapi/simulation/mdrun.py index 1994f4177c..642bdaa369 100644 --- a/python_packaging/src/gmxapi/simulation/mdrun.py +++ b/python_packaging/src/gmxapi/simulation/mdrun.py @@ -71,6 +71,7 @@ logger.info('Importing {}'.format(__name__)) # attributes of the data proxies. _output_descriptors = ( _op.OutputDataDescriptor('_work_dir', str), + _op.OutputDataDescriptor('trajectory', str) ) _publishing_descriptors = {desc._name: gmxapi.operation.Publisher(desc._name, desc._dtype) for desc in _output_descriptors} @@ -308,6 +309,13 @@ class SubscriptionPublishingRunner(object): """Operation implementation in the gmxapi.operation module context.""" publisher = self.resources.output publisher._work_dir = self.resources.workdir + # TODO: Make the return value a trajectory handle rather than a file path. + # TODO: Decide how to handle append vs. noappend output. + # TODO: More rigorous handling of the trajectory file(s) + # We have no way to query the name of the trajectory produced, and we + # have avoided exposing the ability to specify it, so we have to assume + # GROMACS default behavior. + publisher.trajectory = os.path.join(self.resources.workdir, 'traj.trr') _next_uid = 0 diff --git a/python_packaging/src/test/test_mdrun.py b/python_packaging/src/test/test_mdrun.py index b84c725de4..eff605804f 100644 --- a/python_packaging/src/test/test_mdrun.py +++ b/python_packaging/src/test/test_mdrun.py @@ -114,6 +114,7 @@ def test_run_trivial_ensemble(spc_water_box, caplog): # important use case outside of testing. assert output_directory[0] != output_directory[1] assert os.path.exists(output_directory[current_rank]) + assert os.path.exists(md.output.trajectory.result()[current_rank]) @pytest.mark.usefixtures('cleandir') @@ -122,6 +123,8 @@ def test_run_from_read_tpr_op(spc_water_box): md = gmx.mdrun(input=simulation_input) md.run() + assert os.path.exists(md.output.trajectory.result()) + @pytest.mark.usefixtures('cleandir') def test_run_from_modify_input_op(spc_water_box, caplog): -- 2.22.0