Coverage for biobb_mem/gorder/gorder_ua.py: 94%
32 statements
« prev ^ index » next coverage.py v7.10.7, created at 2025-10-03 16:03 +0000
« prev ^ index » next coverage.py v7.10.7, created at 2025-10-03 16:03 +0000
1#!/usr/bin/env python3
3"""Module containing the gorder united atom class and the command line interface."""
4from biobb_common.generic.biobb_object import BiobbObject
5from biobb_common.tools.file_utils import launchlogger
6import gorder
9class GorderUA(BiobbObject):
10 """
11 | biobb_mem GorderUA
12 | Wrapper of the gorder united atom module for computing lipid order parameters per atom for carbon tails.
13 | `gorder <https://ladme.github.io/gorder-manual/uaorder_basics.html>`_ uses `GSL <https://ladme.github.io/gsl-guide/>`_ for all its selections.
15 Args:
16 input_top_path (str): Path to the input structure or topology file. File type: input. `Sample file <https://github.com/bioexcel/biobb_mem/raw/main/biobb_mem/test/data/A01JP/A01JP.tpr>`_. Accepted formats: tpr (edam:format_2333).
17 input_traj_path (str): Path to the input trajectory to be processed. File type: input. `Sample file <https://github.com/bioexcel/biobb_mem/raw/main/biobb_mem/test/data/A01JP/A01JP.xtc>`_. Accepted formats: xtc (edam:format_3875), trr (edam:format_3910), gro (edam:format_2033).
18 output_order_path (str): Path to results of the order analysis. File type: output. `Sample file <https://github.com/bioexcel/biobb_mem/raw/main/biobb_mem/test/reference/gorder/order_ua.yaml>`_. Accepted formats: yaml (edam:format_3570), xvg (edam:format_2330), csv (edam:format_3752).
19 properties (dic - Python dictionary object containing the tool parameters, not input/output files):
20 * **saturated** (*str*) - ("@membrane") Selection query specifying the saturated carbons.
21 * **unsaturated** (*str*) - (None) Selection query specifying the unsaturated carbons.
22 * **handle_pbc** (*bool*) - (True) If False, ignores periodic boundary conditions (PBC).
23 * **remove_tmp** (*bool*) - (True) [WF property] Remove temporal files.
24 * **restart** (*bool*) - (False) [WF property] Do not execute if output files exist.
25 * **sandbox_path** (*str*) - ("./") [WF property] Parent path to the sandbox directory.
27 Examples:
28 This is a use example of how to use the building block from Python::
30 from biobb_mem.gorder.gorder_ua import gorder_ua
31 prop = {
32 'handle_pbc': False
33 }
34 gorder_ua(input_top_path='/path/to/myTopology.tpr',
35 input_traj_path='/path/to/myTrajectory.xtc',
36 output_order_path='/path/to/orderAnalysis.yaml',
37 properties=prop)
39 Info:
40 * wrapped_software:
41 * name: gorder
42 * version: 1.1.0
43 * license: MIT
44 * ontology:
45 * name: EDAM
46 * schema: http://edamontology.org/EDAM.owl
48 """
50 def __init__(self,
51 input_top_path,
52 input_traj_path,
53 output_order_path=None,
54 properties=None,
55 **kwargs) -> None:
56 properties = properties or {}
58 # Call parent class constructor
59 super().__init__(properties)
60 self.locals_var_dict = locals().copy()
62 # Input/Output files
63 self.io_dict = {
64 "in": {
65 "input_top_path": input_top_path,
66 "input_traj_path": input_traj_path,
67 },
68 "out": {
69 "output_order_path": output_order_path
70 }
71 }
73 # Properties specific for BB
74 self.saturated = properties.get('saturated', "@membrane")
75 self.unsaturated = properties.get('unsaturated', None)
76 self.handle_pbc = properties.get('handle_pbc', True)
77 self.properties = properties
79 # Check the properties
80 self.check_properties(properties)
81 self.check_arguments()
83 @launchlogger
84 def launch(self) -> int:
85 """Execute the :class:`GorderUA <gorder.gorder_ua.GorderUA>` object."""
87 # Setup Biobb
88 if self.check_restart():
89 return 0
90 self.stage_files()
92 # Run Biobb block
93 analysis = gorder.Analysis(
94 structure=self.stage_io_dict["in"]["input_top_path"],
95 trajectory=self.stage_io_dict["in"]["input_traj_path"],
96 analysis_type=gorder.analysis_types.UAOrder(self.saturated, self.unsaturated),
97 output_yaml=self.stage_io_dict["out"]["output_order_path"],
98 handle_pbc=False,
99 )
101 results = analysis.run()
102 results.write()
104 # Copy files to host
105 self.copy_to_host()
106 self.remove_tmp_files()
108 return self.return_code
111def gorder_ua(input_top_path: str,
112 input_traj_path: str,
113 output_order_path: str = None,
114 properties: dict = None,
115 **kwargs) -> int:
116 """Create :class:`GorderUA <gorder.gorder_ua.GorderUA>` class and
117 execute :meth:`launch() <gorder.gorder_ua.GorderUA.launch>` method"""
118 return GorderUA(**dict(locals())).launch()
121gorder_ua.__doc__ = GorderUA.__doc__
122main = GorderUA.get_main(gorder_ua, "Compute united atom lipid order parameters using gorder order tool.")
124if __name__ == '__main__':
125 main()