Add trajectory output to mdrun operation.
authorM. Eric Irrgang <ericirrgang@gmail.com>
Wed, 2 Oct 2019 13:53:52 +0000 (16:53 +0300)
committerPaul Bauer <paul.bauer.q@gmail.com>
Mon, 21 Oct 2019 07:25:02 +0000 (09:25 +0200)
Fixes #3144

Change-Id: Ic9e1eb988bc9c934eb8e9cd6009008e6e60d8342

python_packaging/src/gmxapi/simulation/mdrun.py
python_packaging/src/test/test_mdrun.py

index 1994f4177cf4a5868a0e2088485400576cca439b..642bdaa369184b6229ed95d352124ce43abb66d9 100644 (file)
@@ -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
index b84c725de4b1a7c45e9d692e000ba53adc33b465..eff605804f705a79c899c105fb4915988c0c727f 100644 (file)
@@ -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):