Coverage for biobb_amber/process/process_mdout.py: 93%
15 statements
« prev ^ index » next coverage.py v7.17.5, created at 2026-11-27 10:54 +0000
« prev ^ index » next coverage.py v7.17.5, created at 2026-11-27 10:54 +0000
1#!/usr/bin/env python3
3"""Module containing the ProcessMDOut class and the command line interface."""
5from typing import Optional
7from biobb_common.generic.biobb_object import BiobbObject, launcher
8from biobb_common.tools import file_utils as fu
10from biobb_amber.process.common import summaries_to_dat
13class ProcessMDOut(BiobbObject):
14 """
15 | biobb_amber.process.process_mdout ProcessMDOut
16 | Wrapper of the `AmberTools (AMBER MD Package) process_mdout tool <https://ambermd.org/AmberTools.php>`_ module.
17 | Parses the AMBER (sander) md output file (log) and dumps statistics that can then be plotted. Using the process_mdout.pl tool from the AmberTools MD package.
19 Args:
20 input_log_path (str): AMBER (sander) MD output (log) file. File type: input. `Sample file <https://github.com/bioexcel/biobb_amber/raw/master/biobb_amber/test/data/process/sander.heat.log>`_. Accepted formats: log (edam:format_2330), out (edam:format_2330), txt (edam:format_2330), o (edam:format_2330).
21 output_dat_path (str): Dat output file containing data from the specified terms along the minimization process. File type: output. `Sample file <https://github.com/bioexcel/biobb_amber/raw/master/biobb_amber/test/reference/process/sander.md.temp.dat>`_. Accepted formats: dat (edam:format_1637), txt (edam:format_2330), csv (edam:format_3752).
22 properties (dic - Python dictionary object containing the tool parameters, not input/output files):
23 * **terms** (*list*) - (["ETOT"]) Statistics descriptors. Values: VOLUME, TSOLVENT, TSOLUTE, TEMP, PRES, ETOT, ESCF, EPTOT, EKTOT, EKCMT, DENSITY.
24 * **binary_path** (*str*) - ("process_mdout.perl") Path to the process_mdout.perl executable binary.
25 * **remove_tmp** (*bool*) - (True) [WF property] Remove temporal files.
26 * **restart** (*bool*) - (False) [WF property] Do not execute if output files exist.
27 * **sandbox_path** (*str*) - ("./") [WF property] Parent path to the sandbox directory.
28 * **container_path** (*str*) - (None) Container path definition.
29 * **container_image** (*str*) - ('afandiadib/ambertools:serial') Container image definition.
30 * **container_volume_path** (*str*) - ('/tmp') Container volume path definition.
31 * **container_user_id** (*str*) - (None) Container user_id definition.
32 * **container_shell_path** (*str*) - ('/bin/bash') Path to default shell inside the container.
34 Examples:
35 This is a use example of how to use the building block from Python::
37 from biobb_amber.process.process_mdout import process_mdout
38 prop = {
39 'terms' : ['TEMP','VOLUME','DENSITY']
40 }
41 process_mdout(input_log_path='/path/to/ambermd.log',
42 output_dat_path='/path/to/newFeature.dat',
43 properties=prop)
45 Info:
46 * wrapped_software:
47 * name: AmberTools process_mdout
48 * version: >20.9
49 * license: LGPL 2.1
50 * ontology:
51 * name: EDAM
52 * schema: http://edamontology.org/EDAM.owl
54 """
56 def __init__(self, input_log_path: str, output_dat_path: str, properties: Optional[dict] = None, **kwargs):
57 super().__init__(**locals())
59 # Properties specific for BB
60 self.terms = fu.str_to_list(self.terms)
62 def run(self):
63 """Launches the execution of the ProcessMDOut module."""
65 # process_mdout.perl writes the summary.<term> files where it runs: in the sandbox
66 self.cmd = [self.binary_path, self.stage_io_dict["in"]["input_log_path"]]
68 # Run Biobb block
69 self.run_biobb()
71 # Write the output dat file from the summary.<term> files written by process_mdout.perl
72 summaries_to_dat(self.stage_io_dict["unique_dir"], self.terms, self.sandbox_file("output_dat_path"))
75process_mdout = launcher(ProcessMDOut)
77if __name__ == "__main__":
78 ProcessMDOut.main()