Coverage for biobb_amber/test/unitests/test_sander/test_sander_mdrun.py: 100%
41 statements
« prev ^ index » next coverage.py v7.16.0, created at 2026-11-13 14:49 +0000
« prev ^ index » next coverage.py v7.16.0, created at 2026-11-13 14:49 +0000
1# type: ignore
2import re
3from pathlib import Path
4from biobb_common.tools import test_fixtures as fx
5from biobb_amber.sander.sander_mdrun import SanderMDRun, sander_mdrun
8class TestSanderMDRunParameterFiles():
9 # The mdin is written without executing sander (provenance of the executions skipped by restart)
10 def setup_class(self):
11 fx.test_setup(self, 'sander_mdrun')
13 def teardown_class(self):
14 fx.test_teardown(self)
16 def test_write_parameter_files(self, tmp_path):
17 paths = {k: v for k, v in self.paths.items() if not k.startswith('ref_')}
18 mdin_path, = SanderMDRun(properties=self.properties, **paths).write_parameter_files(str(tmp_path))
19 assert Path(mdin_path) == tmp_path / 'sander.mdin'
20 mdin = Path(mdin_path).read_text()
21 assert re.search(r"imin = 1", mdin) and re.search(r"maxcyc = 500", mdin)
23 def test_write_parameter_files_input_mdin(self, tmp_path):
24 # Nothing is staged when the execution is skipped: the input mdin is read from its path
25 input_mdin_path = str(Path(self.paths['input_top_path']).parent / 'min.mdin')
26 paths = {k: v for k, v in self.paths.items() if not k.startswith('ref_')}
27 mdin_path, = SanderMDRun(properties=self.properties, input_mdin_path=input_mdin_path, **paths).write_parameter_files(str(tmp_path))
28 mdin = Path(mdin_path).read_text()
29 assert f"Mdin read from input file: {input_mdin_path}" in mdin and re.search(r"maxcyc = 500", mdin)
32class TestSanderMDRun():
33 def setup_class(self):
34 fx.test_setup(self, 'sander_mdrun')
36 def teardown_class(self):
37 fx.test_teardown(self)
38 # pass
40 def test_sander_mdrun(self):
41 sander_mdrun(properties=self.properties, **self.paths)
42 assert fx.not_empty(self.paths['output_log_path'])
43 assert fx.not_empty(self.paths['output_rst_path'])
44 assert fx.not_empty(self.paths['output_traj_path'])
45 # assert fx.equal(self.paths['output_traj_path'], self.paths['ref_output_traj_path'])
46 # assert fx.equal(self.paths['output_rst_path'], self.paths['ref_output_rst_path'])
49class TestSanderMDRunDirectMDin():
50 def setup_class(self):
51 fx.test_setup(self, 'sander_mdrun_direct_mdin')
53 def teardown_class(self):
54 fx.test_teardown(self)
55 # pass
57 def test_sander_mdrun(self):
58 sander_mdrun(properties=self.properties, **self.paths)
59 assert fx.not_empty(self.paths['output_log_path'])
60 assert fx.not_empty(self.paths['output_rst_path'])
61 assert fx.not_empty(self.paths['output_traj_path'])
62 # assert fx.equal(self.paths['output_traj_path'], self.paths['ref_output_traj_path'])
63 # assert fx.equal(self.paths['output_rst_path'], self.paths['ref_output_rst_path'])