1# !/usr/bin/env python3
+1#!/usr/bin/env python3
3"""Module containing the PMX ligand_hybrid class and the command line interface."""
4import os
@@ -88,7 +88,7 @@6from pathlib import Path
7import shutil
8import argparse
-9from typing import Dict, Optional
+9from typing import Optional
10from biobb_common.generic.biobb_object import BiobbObject
11from biobb_common.configuration import settings
12from biobb_common.tools.file_utils import launchlogger
@@ -166,7 +166,7 @@84 def __init__(self, input_structure1_path: str, input_structure2_path: str, input_topology1_path: str, input_topology2_path: str,
85 output_log_path: str, output_structure1_path: str, output_structure2_path: str, output_topology_path: str, output_atomtypes_path: str,
86 input_scaffold1_path: Optional[str] = None, input_scaffold2_path: Optional[str] = None, input_pairs_path: Optional[str] = None,
-87 properties: Optional[Dict] = None, **kwargs) -> None:
+87 properties: Optional[dict] = None, **kwargs) -> None:
89 properties = properties or {}
@@ -291,7 +291,7 @@209def pmxligand_hybrid(input_structure1_path: str, input_structure2_path: str, input_topology1_path: str, input_topology2_path: str,
210 output_log_path: str, output_structure1_path: str, output_structure2_path: str, output_topology_path: str, output_atomtypes_path: str,
211 input_scaffold1_path: Optional[str] = None, input_scaffold2_path: Optional[str] = None, input_pairs_path: Optional[str] = None,
-212 properties: Optional[Dict] = None, **kwargs) -> int:
+212 properties: Optional[dict] = None, **kwargs) -> int:
213 """Execute the :class:`Pmxligand_hybrid <pmx.pmxmutate.Pmxligand_hybrid>` class and
214 execute the :meth:`launch() <pmx.pmxligand_hybrid.Pmxligand_hybrid.launch> method."""
@@ -302,7 +302,7 @@220 output_topology_path=output_topology_path, output_atomtypes_path=output_atomtypes_path,
221 input_scaffold1_path=input_scaffold1_path, input_scaffold2_path=input_scaffold2_path,
222 input_pairs_path=input_pairs_path,
-223 properties=properties, **kwargs).launch()
+223 properties=properties).launch()
226def main():
@@ -350,8 +350,8 @@
^ index
» next
- coverage.py v7.5.3,
- created at 2024-06-14 18:54 +0000
+ coverage.py v7.6.4,
+ created at 2024-11-04 14:30 +0000
diff --git a/coverage/z_d938f4eecb54a579_pmxmerge_ff_py.html b/coverage/z_d938f4eecb54a579_pmxmerge_ff_py.html
index c323c57..7ce737a 100644
--- a/coverage/z_d938f4eecb54a579_pmxmerge_ff_py.html
+++ b/coverage/z_d938f4eecb54a579_pmxmerge_ff_py.html
@@ -64,8 +64,8 @@
^ index
» next
- coverage.py v7.5.3,
- created at 2024-06-14 18:54 +0000
+ coverage.py v7.6.4,
+ created at 2024-11-04 14:30 +0000
@@ -88,8 +88,8 @@
6from pathlib import Path
7import glob
8import argparse
- 9from pmx import ligand_alchemy # type: ignore
- 10from typing import Dict, Optional
+ 9from typing import Optional
+ 10from pmx import ligand_alchemy # type: ignore
11from biobb_common.generic.biobb_object import BiobbObject
12from biobb_common.configuration import settings
13from biobb_common.tools import file_utils as fu
@@ -139,7 +139,7 @@
58 """
- 60 def __init__(self, input_topology_path: str, output_topology_path: str, properties: Optional[Dict] = None, **kwargs) -> None:
+ 60 def __init__(self, input_topology_path: str, output_topology_path: str, properties: Optional[dict] = None, **kwargs) -> None:
61 properties = properties or {}
63 # Call parent class constructor
@@ -210,7 +210,7 @@
128 return self.return_code
- 131def pmxmerge_ff(input_topology_path: str, output_topology_path: str, properties: Optional[Dict] = None, **kwargs) -> int:
+ 131def pmxmerge_ff(input_topology_path: str, output_topology_path: str, properties: Optional[dict] = None, **kwargs) -> int:
132 """Execute the :class:`Pmxmerge_ff <pmx.pmxmerge_ff.Pmxmerge_ff>` class and
133 execute the :meth:`launch() <pmx.pmxmerge_ff.Pmxmerge_ff.launch> method."""
@@ -250,8 +250,8 @@
^ index
» next
- coverage.py v7.5.3,
- created at 2024-06-14 18:54 +0000
+ coverage.py v7.6.4,
+ created at 2024-11-04 14:30 +0000
diff --git a/coverage/z_d938f4eecb54a579_pmxmutate_py.html b/coverage/z_d938f4eecb54a579_pmxmutate_py.html
index e6a1a49..dc8d198 100644
--- a/coverage/z_d938f4eecb54a579_pmxmutate_py.html
+++ b/coverage/z_d938f4eecb54a579_pmxmutate_py.html
@@ -64,8 +64,8 @@
^ index
» next
- coverage.py v7.5.3,
- created at 2024-06-14 18:54 +0000
+ coverage.py v7.6.4,
+ created at 2024-11-04 14:30 +0000
@@ -88,7 +88,7 @@
6import sys
7import shutil
8import argparse
- 9from typing import Dict, Optional
+ 9from typing import Optional
10from biobb_pmx.pmxbiobb.common import create_mutations_file, MUTATION_DICT
11from biobb_common.generic.biobb_object import BiobbObject
12from biobb_common.configuration import settings
@@ -148,7 +148,7 @@
66 """
68 def __init__(self, input_structure_path: str, output_structure_path: str, input_b_structure_path: Optional[str] = None,
- 69 properties: Optional[Dict] = None, **kwargs) -> None:
+ 69 properties: Optional[dict] = None, **kwargs) -> None:
70 properties = properties or {}
72 # Call parent class constructor
@@ -240,7 +240,7 @@
160def pmxmutate(input_structure_path: str, output_structure_path: str,
- 161 input_b_structure_path: Optional[str] = None, properties: Optional[Dict] = None,
+ 161 input_b_structure_path: Optional[str] = None, properties: Optional[dict] = None,
162 **kwargs) -> int:
163 """Execute the :class:`Pmxmutate <pmx.pmxmutate.Pmxmutate>` class and
164 execute the :meth:`launch() <pmx.pmxmutate.Pmxmutate.launch> method."""
@@ -284,8 +284,8 @@
^ index
» next
- coverage.py v7.5.3,
- created at 2024-06-14 18:54 +0000
+ coverage.py v7.6.4,
+ created at 2024-11-04 14:30 +0000
diff --git a/flake8/biobb_pmx.pmxbiobb.pmxgentop.report.html b/flake8/biobb_pmx.pmxbiobb.pmxgentop.report.html
new file mode 100644
index 0000000..b5e1725
--- /dev/null
+++ b/flake8/biobb_pmx.pmxbiobb.pmxgentop.report.html
@@ -0,0 +1,73 @@
+
+
+
+ flake8 violations: biobb_pmx/pmxbiobb/pmxgentop.py
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ biobb_pmx/pmxbiobb/pmxgentop.py
+
+
+
+
+
+ -
+
+
+ 1
+
+ F811: redefinition of unused 'Optional' from line 7
+
+
+
+ -
+
+
+ 10 from typing import Optional
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/flake8/biobb_pmx.pmxbiobb.pmxgentop.source.html b/flake8/biobb_pmx.pmxbiobb.pmxgentop.source.html
new file mode 100644
index 0000000..d18e51e
--- /dev/null
+++ b/flake8/biobb_pmx.pmxbiobb.pmxgentop.source.html
@@ -0,0 +1,674 @@
+
+
+
+ biobb_pmx/pmxbiobb/pmxgentop.py - flake8 annotated source
+
+
+
+
+
+
+
+
+
+ biobb_pmx/pmxbiobb/pmxgentop.py source
+
+
+
+
+ 1 #!/usr/bin/env python3
+
+ 2
+
+ 3 """Module containing the PMX gentop class and the command line interface."""
+
+ 4 import os
+
+ 5 import sys
+
+ 6 import argparse
+
+ 7 from typing import Optional
+
+ 8 import shutil
+
+ 9 from pathlib import Path
+
+
+
+
+ -
+
+ F811
+
+ Redefinition of unused 'Optional' from line 7
+
+
10 from typing import Optional
+
+ 11 from biobb_common.generic.biobb_object import BiobbObject
+
+ 12 from biobb_common.configuration import settings
+
+ 13 from biobb_common.tools import file_utils as fu
+
+ 14 from biobb_common.tools.file_utils import launchlogger
+
+ 15
+
+ 16
+
+ 17 class Pmxgentop(BiobbObject):
+
+ 18 """
+
+ 19 | biobb_pmx Pmxgentop
+
+ 20 | Wrapper class for the `PMX gentop <https://github.com/deGrootLab/pmx>`_ module.
+
+ 21 | Generate a topology file for a morphing simulation.
+
+ 22
+
+ 23 Args:
+
+ 24 input_top_zip_path (str): Path the input GROMACS topology TOP and ITP files in zip format. File type: input. `Sample file <https://github.com/bioexcel/biobb_pmx/raw/master/biobb_pmx/test/data/pmx/topology.zip>`_. Accepted formats: zip (edam:format_3987).
+
+ 25 output_top_zip_path (str): Path the output TOP topology in zip format. File type: output. `Sample file <https://github.com/bioexcel/biobb_pmx/raw/master/biobb_pmx/test/reference/pmx/ref_output_topology.zip>`_. Accepted formats: zip (edam:format_3987).
+
+ 26 properties (dic):
+
+ 27 * **force_field** (*str*) - ("amber99sb-star-ildn-mut") Force field to use. If **input_top_zip_path** is a top file, it's not necessary to specify the forcefield, as it will be determined automatically. If **input_top_zip_path** is an itp file, then it's needed.
+
+ 28 * **split** (*bool*) - (False) Write separate topologies for the vdW and charge transformations.
+
+ 29 * **scale_mass** (*bool*) - (False) Scale the masses of morphing atoms so that dummies have a mass of 1.
+
+ 30 * **gmx_lib** (*str*) - ("$CONDA_PREFIX/lib/python3.7/site-packages/pmx/data/mutff/") Path to the GMXLIB folder in your computer.
+
+ 31 * **binary_path** (*str*) - ("pmx") Path to the PMX command line interface.
+
+ 32 * **remove_tmp** (*bool*) - (True) [WF property] Remove temporal files.
+
+ 33 * **restart** (*bool*) - (False) [WF property] Do not execute if output files exist.
+
+ 34 * **sandbox_path** (*str*) - ("./") [WF property] Parent path to the sandbox directory.
+
+ 35 * **container_path** (*str*) - (None) Path to the binary executable of your container.
+
+ 36 * **container_image** (*str*) - ("gromacs/gromacs:latest") Container Image identifier.
+
+ 37 * **container_volume_path** (*str*) - ("/inout") Path to an internal directory in the container.
+
+ 38 * **container_working_dir** (*str*) - (None) Path to the internal CWD in the container.
+
+ 39 * **container_user_id** (*str*) - (None) User number id to be mapped inside the container.
+
+ 40 * **container_shell_path** (*str*) - ("/bin/bash") Path to the binary executable of the container shell.
+
+ 41
+
+ 42 Examples:
+
+ 43 This is a use example of how to use the building block from Python::
+
+ 44
+
+ 45 from biobb_pmx.pmxbiobb.pmxgentop import pmxgentop
+
+ 46 prop = {
+
+ 47 'gmx_lib': '/path/to/myGMXLIB/',
+
+ 48 'force_field': 'amber99sb-star-ildn-mut'
+
+ 49 }
+
+ 50 pmxgentop(input_top_zip_path='/path/to/myTopology.zip',
+
+ 51 output_top_zip_path='/path/to/newTopology.zip',
+
+ 52 properties=prop)
+
+ 53
+
+ 54 Info:
+
+ 55 * wrapped_software:
+
+ 56 * name: PMX gentop
+
+ 57 * version: >=1.0.1
+
+ 58 * license: GNU
+
+ 59 * ontology:
+
+ 60 * name: EDAM
+
+ 61 * schema: http://edamontology.org/EDAM.owl
+
+ 62
+
+ 63 """
+
+ 64
+
+ 65 def __init__(self, input_top_zip_path: str, output_top_zip_path: str,
+
+ 66 properties: Optional[dict] = None, **kwargs) -> None:
+
+ 67 properties = properties or {}
+
+ 68
+
+ 69 # Call parent class constructor
+
+ 70 super().__init__(properties)
+
+ 71 self.locals_var_dict = locals().copy()
+
+ 72
+
+ 73 # Input/Output files
+
+ 74 self.io_dict = {
+
+ 75 "in": {},
+
+ 76 "out": {"output_top_zip_path": output_top_zip_path}
+
+ 77 }
+
+ 78 # Should not be copied inside container
+
+ 79 self.input_top_zip_path = input_top_zip_path
+
+ 80
+
+ 81 # Properties specific for BB
+
+ 82 self.force_field = properties.get('force_field', "amber99sb-star-ildn-mut")
+
+ 83 self.split = properties.get('split', False)
+
+ 84 self.scale_mass = properties.get('scale_mass', False)
+
+ 85
+
+ 86 # Properties common in all PMX BB
+
+ 87 self.gmx_lib = properties.get('gmx_lib', None)
+
+ 88 if not self.gmx_lib and os.environ.get('CONDA_PREFIX', ''):
+
+ 89 python_version = f"{sys.version_info.major}.{sys.version_info.minor}"
+
+ 90 self.gmx_lib = str(
+
+ 91 Path(os.environ.get('CONDA_PREFIX', '')).joinpath(f"lib/python{python_version}/site-packages/pmx/data/mutff/"))
+
+ 92 if properties.get('container_path'):
+
+ 93 self.gmx_lib = str(Path('/usr/local/').joinpath("lib/python3.8/site-packages/pmx/data/mutff/"))
+
+ 94 self.binary_path = properties.get('binary_path', 'pmx')
+
+ 95
+
+ 96 # Check the properties
+
+ 97 self.check_properties(properties)
+
+ 98 self.check_arguments()
+
+ 99
+
+ 100 @launchlogger
+
+ 101 def launch(self) -> int:
+
+ 102 """Execute the :class:`Pmxgentop <pmx.pmxgentop.Pmxgentop>` pmx.pmxgentop.Pmxgentop object."""
+
+ 103
+
+ 104 # Setup Biobb
+
+ 105 if self.check_restart():
+
+ 106 return 0
+
+ 107 self.stage_files()
+
+ 108
+
+ 109 # Check if executable exists
+
+ 110 if not self.container_path:
+
+ 111 if not Path(self.binary_path).is_file():
+
+ 112 if not shutil.which(self.binary_path):
+
+ 113 raise FileNotFoundError('Executable %s not found. Check if it is installed in your system and correctly defined in the properties' % self.binary_path)
+
+ 114
+
+ 115 # Unzip topology to topology_out
+
+ 116 top_file = fu.unzip_top(zip_file=self.input_top_zip_path, out_log=self.out_log)
+
+ 117 top_dir = str(Path(top_file).parent)
+
+ 118
+
+ 119 # Copy extra files to container: topology folder
+
+ 120 if self.container_path:
+
+ 121 fu.log('Container execution enabled', self.out_log)
+
+ 122 fu.log(f"Unique dir: {self.stage_io_dict['unique_dir']}", self.out_log)
+
+ 123 fu.log(f"{self.stage_io_dict['unique_dir']} files: {os.listdir(self.stage_io_dict['unique_dir'])}", self.out_log)
+
+ 124 fu.log(f"Copy all files of the unzipped original topology to unique dir: {self.out_log}")
+
+ 125 shutil.copytree(top_dir, str(Path(self.stage_io_dict.get("unique_dir", "")).joinpath(Path(top_dir).name)))
+
+ 126 top_file = str(Path(self.container_volume_path).joinpath(Path(top_dir).name, Path(top_file).name))
+
+ 127
+
+ 128 output_file_name = fu.create_name(prefix=self.prefix, step=self.step, name=str(Path(top_file).name))
+
+ 129 unique_dir_output_file = str(Path(fu.create_unique_dir()).joinpath(output_file_name))
+
+ 130 fu.log(f"unique_dir_output_file: {unique_dir_output_file}", self.out_log)
+
+ 131
+
+ 132 if self.container_path:
+
+ 133 fu.log("Change references for container:", self.out_log)
+
+ 134 unique_dir_output_file = str(Path(self.container_volume_path).joinpath(Path(output_file_name)))
+
+ 135 fu.log(f" unique_dir_output_file: {unique_dir_output_file}", self.out_log)
+
+ 136
+
+ 137 self.cmd = [self.binary_path, 'gentop',
+
+ 138 '-o', str(Path(unique_dir_output_file)),
+
+ 139 '-ff', self.force_field,
+
+ 140 '-p', top_file]
+
+ 141
+
+ 142 if self.split:
+
+ 143 self.cmd.append('--split')
+
+ 144 if self.scale_mass:
+
+ 145 self.cmd.append('--scale_mass')
+
+ 146
+
+ 147 if self.gmx_lib:
+
+ 148 self.env_vars_dict['GMXLIB'] = self.gmx_lib
+
+ 149
+
+ 150 # Run Biobb block
+
+ 151 self.run_biobb()
+
+ 152
+
+ 153 # Copy files to host
+
+ 154 self.copy_to_host()
+
+ 155
+
+ 156 if self.container_path:
+
+ 157 unique_dir_output_file = str(Path(self.stage_io_dict.get("unique_dir", "")).joinpath(Path(unique_dir_output_file).name))
+
+ 158
+
+ 159 # Remove paths from top file
+
+ 160 with open(Path(unique_dir_output_file)) as top_fh:
+
+ 161 top_lines = top_fh.readlines()
+
+ 162 with open(Path(unique_dir_output_file), 'w') as top_fh:
+
+ 163 for line in top_lines:
+
+ 164 top_fh.write(line.replace(str(Path(unique_dir_output_file).parent)+'/', ''))
+
+ 165 # Copy the not modified itp files
+
+ 166 for orig_itp_file in Path(top_dir).iterdir():
+
+ 167 fu.log(f'Check if {str(Path(unique_dir_output_file).parent.joinpath(Path(orig_itp_file).name))} exists', self.out_log, self.global_log)
+
+ 168 if not Path(unique_dir_output_file).parent.joinpath(Path(orig_itp_file).name).exists():
+
+ 169 shutil.copy(orig_itp_file, Path(unique_dir_output_file).parent)
+
+ 170 fu.log(f'Copying {str(orig_itp_file)} to: {str(Path(unique_dir_output_file).parent)}', self.out_log, self.global_log)
+
+ 171
+
+ 172 # zip topology
+
+ 173 fu.log('Compressing topology to: %s' % self.io_dict["out"]["output_top_zip_path"], self.out_log, self.global_log)
+
+ 174 fu.zip_top(zip_file=self.io_dict["out"]["output_top_zip_path"], top_file=str(Path(unique_dir_output_file)), out_log=self.out_log)
+
+ 175
+
+ 176 self.tmp_files.extend([self.stage_io_dict.get("unique_dir", ""), top_dir])
+
+ 177 # self.remove_tmp_files()
+
+ 178
+
+ 179 self.check_arguments(output_files_created=True, raise_exception=False)
+
+ 180 return self.return_code
+
+ 181
+
+ 182
+
+ 183 def pmxgentop(input_top_zip_path: str, output_top_zip_path: str, properties: Optional[dict] = None, **kwargs) -> int:
+
+ 184 """Execute the :class:`Pmxgentop <pmx.pmxgentop.Pmxgentop>` class and
+
+ 185 execute the :meth:`launch() <pmx.pmxgentop.Pmxgentop.launch> method."""
+
+ 186
+
+ 187 return Pmxgentop(input_top_zip_path=input_top_zip_path,
+
+ 188 output_top_zip_path=output_top_zip_path,
+
+ 189 properties=properties, **kwargs).launch()
+
+ 190
+
+ 191
+
+ 192 def main():
+
+ 193 """Command line execution of this building block. Please check the command line documentation."""
+
+ 194 parser = argparse.ArgumentParser(description="Wrapper class for the PMX gentop module",
+
+ 195 formatter_class=lambda prog: argparse.RawTextHelpFormatter(prog, width=99999))
+
+ 196 parser.add_argument('-c', '--config', required=False, help="This file can be a YAML file, JSON file or JSON string")
+
+ 197
+
+ 198 # Specific args of each building block
+
+ 199 required_args = parser.add_argument_group('required arguments')
+
+ 200 required_args.add_argument('--input_top_zip_path', required=True, help="Path to the input topology zip file")
+
+ 201 required_args.add_argument('--output_top_zip_path', required=True, help="Path to the output topology zip file")
+
+ 202
+
+ 203 args = parser.parse_args()
+
+ 204 config = args.config if args.config else None
+
+ 205 properties = settings.ConfReader(config=config).get_prop_dic()
+
+ 206
+
+ 207 # Specific call of each building block
+
+ 208 pmxgentop(input_top_zip_path=args.input_top_zip_path,
+
+ 209 output_top_zip_path=args.output_top_zip_path,
+
+ 210 properties=properties)
+
+ 211
+
+ 212
+
+ 213 if __name__ == '__main__':
+
+ 214 main()
+
+
+
+
+
+
\ No newline at end of file
diff --git a/flake8/flake8badge.svg b/flake8/flake8badge.svg
index 58d5817..0687468 100644
--- a/flake8/flake8badge.svg
+++ b/flake8/flake8badge.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/flake8/flake8stats.txt b/flake8/flake8stats.txt
index e69de29..6783e8b 100644
--- a/flake8/flake8stats.txt
+++ b/flake8/flake8stats.txt
@@ -0,0 +1 @@
+1 F811 redefinition of unused 'Optional' from line 7
diff --git a/flake8/index.html b/flake8/index.html
index 392068e..8fbc00f 100644
--- a/flake8/index.html
+++ b/flake8/index.html
@@ -6,22 +6,21 @@
-
+
flake8 violations
- Generated on 2024-06-14 18:53
- with Installed plugins: flake8-html: 0.4.3, mccabe: 0.7.0, pycodestyle: 2.11.1, pyflakes: 3.2.0
+
Generated on 2024-11-04 14:29
+ with Installed plugins: flake8-html: 0.4.3, mccabe: 0.7.0, pycodestyle: 2.12.1, pyflakes: 3.2.0
-
-
+ biobb_pmx/pmxbiobb/pmxgentop.py
+
diff --git a/junit/junit.xml b/junit/junit.xml
index dbcf794..1ffa107 100644
--- a/junit/junit.xml
+++ b/junit/junit.xml
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/junit/report.html b/junit/report.html
index e8b82e5..08a23d2 100644
--- a/junit/report.html
+++ b/junit/report.html
@@ -7,7 +7,7 @@
report.html
- Report generated on 14-Jun-2024 at 18:54:42 by pytest-html
+
Report generated on 04-Nov-2024 at 14:30:27 by pytest-html
v4.1.1
Environment
@@ -108,7 +108,7 @@ Summary
6from pathlib import Path
7import glob
8import argparse
-9from pmx import ligand_alchemy # type: ignore
-10from typing import Dict, Optional
+9from typing import Optional
+10from pmx import ligand_alchemy # type: ignore
11from biobb_common.generic.biobb_object import BiobbObject
12from biobb_common.configuration import settings
13from biobb_common.tools import file_utils as fu
@@ -139,7 +139,7 @@58 """
-60 def __init__(self, input_topology_path: str, output_topology_path: str, properties: Optional[Dict] = None, **kwargs) -> None:
+60 def __init__(self, input_topology_path: str, output_topology_path: str, properties: Optional[dict] = None, **kwargs) -> None:
61 properties = properties or {}
63 # Call parent class constructor
@@ -210,7 +210,7 @@128 return self.return_code
-131def pmxmerge_ff(input_topology_path: str, output_topology_path: str, properties: Optional[Dict] = None, **kwargs) -> int:
+131def pmxmerge_ff(input_topology_path: str, output_topology_path: str, properties: Optional[dict] = None, **kwargs) -> int:
132 """Execute the :class:`Pmxmerge_ff <pmx.pmxmerge_ff.Pmxmerge_ff>` class and
133 execute the :meth:`launch() <pmx.pmxmerge_ff.Pmxmerge_ff.launch> method."""
@@ -250,8 +250,8 @@
^ index
» next
- coverage.py v7.5.3,
- created at 2024-06-14 18:54 +0000
+ coverage.py v7.6.4,
+ created at 2024-11-04 14:30 +0000
diff --git a/coverage/z_d938f4eecb54a579_pmxmutate_py.html b/coverage/z_d938f4eecb54a579_pmxmutate_py.html
index e6a1a49..dc8d198 100644
--- a/coverage/z_d938f4eecb54a579_pmxmutate_py.html
+++ b/coverage/z_d938f4eecb54a579_pmxmutate_py.html
@@ -64,8 +64,8 @@
^ index
» next
- coverage.py v7.5.3,
- created at 2024-06-14 18:54 +0000
+ coverage.py v7.6.4,
+ created at 2024-11-04 14:30 +0000
@@ -88,7 +88,7 @@
6import sys
7import shutil
8import argparse
- 9from typing import Dict, Optional
+ 9from typing import Optional
10from biobb_pmx.pmxbiobb.common import create_mutations_file, MUTATION_DICT
11from biobb_common.generic.biobb_object import BiobbObject
12from biobb_common.configuration import settings
@@ -148,7 +148,7 @@
66 """
68 def __init__(self, input_structure_path: str, output_structure_path: str, input_b_structure_path: Optional[str] = None,
- 69 properties: Optional[Dict] = None, **kwargs) -> None:
+ 69 properties: Optional[dict] = None, **kwargs) -> None:
70 properties = properties or {}
72 # Call parent class constructor
@@ -240,7 +240,7 @@
160def pmxmutate(input_structure_path: str, output_structure_path: str,
- 161 input_b_structure_path: Optional[str] = None, properties: Optional[Dict] = None,
+ 161 input_b_structure_path: Optional[str] = None, properties: Optional[dict] = None,
162 **kwargs) -> int:
163 """Execute the :class:`Pmxmutate <pmx.pmxmutate.Pmxmutate>` class and
164 execute the :meth:`launch() <pmx.pmxmutate.Pmxmutate.launch> method."""
@@ -284,8 +284,8 @@
^ index
» next
- coverage.py v7.5.3,
- created at 2024-06-14 18:54 +0000
+ coverage.py v7.6.4,
+ created at 2024-11-04 14:30 +0000
diff --git a/flake8/biobb_pmx.pmxbiobb.pmxgentop.report.html b/flake8/biobb_pmx.pmxbiobb.pmxgentop.report.html
new file mode 100644
index 0000000..b5e1725
--- /dev/null
+++ b/flake8/biobb_pmx.pmxbiobb.pmxgentop.report.html
@@ -0,0 +1,73 @@
+
+
+
+ flake8 violations: biobb_pmx/pmxbiobb/pmxgentop.py
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ biobb_pmx/pmxbiobb/pmxgentop.py
+
+
+
+
+
+ -
+
+
+ 1
+
+ F811: redefinition of unused 'Optional' from line 7
+
+
+
+ -
+
+
+ 10 from typing import Optional
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/flake8/biobb_pmx.pmxbiobb.pmxgentop.source.html b/flake8/biobb_pmx.pmxbiobb.pmxgentop.source.html
new file mode 100644
index 0000000..d18e51e
--- /dev/null
+++ b/flake8/biobb_pmx.pmxbiobb.pmxgentop.source.html
@@ -0,0 +1,674 @@
+
+
+
+ biobb_pmx/pmxbiobb/pmxgentop.py - flake8 annotated source
+
+
+
+
+
+
+
+
+
+ biobb_pmx/pmxbiobb/pmxgentop.py source
+
+
+
+
+ 1 #!/usr/bin/env python3
+
+ 2
+
+ 3 """Module containing the PMX gentop class and the command line interface."""
+
+ 4 import os
+
+ 5 import sys
+
+ 6 import argparse
+
+ 7 from typing import Optional
+
+ 8 import shutil
+
+ 9 from pathlib import Path
+
+
+
+
+ -
+
+ F811
+
+ Redefinition of unused 'Optional' from line 7
+
+
10 from typing import Optional
+
+ 11 from biobb_common.generic.biobb_object import BiobbObject
+
+ 12 from biobb_common.configuration import settings
+
+ 13 from biobb_common.tools import file_utils as fu
+
+ 14 from biobb_common.tools.file_utils import launchlogger
+
+ 15
+
+ 16
+
+ 17 class Pmxgentop(BiobbObject):
+
+ 18 """
+
+ 19 | biobb_pmx Pmxgentop
+
+ 20 | Wrapper class for the `PMX gentop <https://github.com/deGrootLab/pmx>`_ module.
+
+ 21 | Generate a topology file for a morphing simulation.
+
+ 22
+
+ 23 Args:
+
+ 24 input_top_zip_path (str): Path the input GROMACS topology TOP and ITP files in zip format. File type: input. `Sample file <https://github.com/bioexcel/biobb_pmx/raw/master/biobb_pmx/test/data/pmx/topology.zip>`_. Accepted formats: zip (edam:format_3987).
+
+ 25 output_top_zip_path (str): Path the output TOP topology in zip format. File type: output. `Sample file <https://github.com/bioexcel/biobb_pmx/raw/master/biobb_pmx/test/reference/pmx/ref_output_topology.zip>`_. Accepted formats: zip (edam:format_3987).
+
+ 26 properties (dic):
+
+ 27 * **force_field** (*str*) - ("amber99sb-star-ildn-mut") Force field to use. If **input_top_zip_path** is a top file, it's not necessary to specify the forcefield, as it will be determined automatically. If **input_top_zip_path** is an itp file, then it's needed.
+
+ 28 * **split** (*bool*) - (False) Write separate topologies for the vdW and charge transformations.
+
+ 29 * **scale_mass** (*bool*) - (False) Scale the masses of morphing atoms so that dummies have a mass of 1.
+
+ 30 * **gmx_lib** (*str*) - ("$CONDA_PREFIX/lib/python3.7/site-packages/pmx/data/mutff/") Path to the GMXLIB folder in your computer.
+
+ 31 * **binary_path** (*str*) - ("pmx") Path to the PMX command line interface.
+
+ 32 * **remove_tmp** (*bool*) - (True) [WF property] Remove temporal files.
+
+ 33 * **restart** (*bool*) - (False) [WF property] Do not execute if output files exist.
+
+ 34 * **sandbox_path** (*str*) - ("./") [WF property] Parent path to the sandbox directory.
+
+ 35 * **container_path** (*str*) - (None) Path to the binary executable of your container.
+
+ 36 * **container_image** (*str*) - ("gromacs/gromacs:latest") Container Image identifier.
+
+ 37 * **container_volume_path** (*str*) - ("/inout") Path to an internal directory in the container.
+
+ 38 * **container_working_dir** (*str*) - (None) Path to the internal CWD in the container.
+
+ 39 * **container_user_id** (*str*) - (None) User number id to be mapped inside the container.
+
+ 40 * **container_shell_path** (*str*) - ("/bin/bash") Path to the binary executable of the container shell.
+
+ 41
+
+ 42 Examples:
+
+ 43 This is a use example of how to use the building block from Python::
+
+ 44
+
+ 45 from biobb_pmx.pmxbiobb.pmxgentop import pmxgentop
+
+ 46 prop = {
+
+ 47 'gmx_lib': '/path/to/myGMXLIB/',
+
+ 48 'force_field': 'amber99sb-star-ildn-mut'
+
+ 49 }
+
+ 50 pmxgentop(input_top_zip_path='/path/to/myTopology.zip',
+
+ 51 output_top_zip_path='/path/to/newTopology.zip',
+
+ 52 properties=prop)
+
+ 53
+
+ 54 Info:
+
+ 55 * wrapped_software:
+
+ 56 * name: PMX gentop
+
+ 57 * version: >=1.0.1
+
+ 58 * license: GNU
+
+ 59 * ontology:
+
+ 60 * name: EDAM
+
+ 61 * schema: http://edamontology.org/EDAM.owl
+
+ 62
+
+ 63 """
+
+ 64
+
+ 65 def __init__(self, input_top_zip_path: str, output_top_zip_path: str,
+
+ 66 properties: Optional[dict] = None, **kwargs) -> None:
+
+ 67 properties = properties or {}
+
+ 68
+
+ 69 # Call parent class constructor
+
+ 70 super().__init__(properties)
+
+ 71 self.locals_var_dict = locals().copy()
+
+ 72
+
+ 73 # Input/Output files
+
+ 74 self.io_dict = {
+
+ 75 "in": {},
+
+ 76 "out": {"output_top_zip_path": output_top_zip_path}
+
+ 77 }
+
+ 78 # Should not be copied inside container
+
+ 79 self.input_top_zip_path = input_top_zip_path
+
+ 80
+
+ 81 # Properties specific for BB
+
+ 82 self.force_field = properties.get('force_field', "amber99sb-star-ildn-mut")
+
+ 83 self.split = properties.get('split', False)
+
+ 84 self.scale_mass = properties.get('scale_mass', False)
+
+ 85
+
+ 86 # Properties common in all PMX BB
+
+ 87 self.gmx_lib = properties.get('gmx_lib', None)
+
+ 88 if not self.gmx_lib and os.environ.get('CONDA_PREFIX', ''):
+
+ 89 python_version = f"{sys.version_info.major}.{sys.version_info.minor}"
+
+ 90 self.gmx_lib = str(
+
+ 91 Path(os.environ.get('CONDA_PREFIX', '')).joinpath(f"lib/python{python_version}/site-packages/pmx/data/mutff/"))
+
+ 92 if properties.get('container_path'):
+
+ 93 self.gmx_lib = str(Path('/usr/local/').joinpath("lib/python3.8/site-packages/pmx/data/mutff/"))
+
+ 94 self.binary_path = properties.get('binary_path', 'pmx')
+
+ 95
+
+ 96 # Check the properties
+
+ 97 self.check_properties(properties)
+
+ 98 self.check_arguments()
+
+ 99
+
+ 100 @launchlogger
+
+ 101 def launch(self) -> int:
+
+ 102 """Execute the :class:`Pmxgentop <pmx.pmxgentop.Pmxgentop>` pmx.pmxgentop.Pmxgentop object."""
+
+ 103
+
+ 104 # Setup Biobb
+
+ 105 if self.check_restart():
+
+ 106 return 0
+
+ 107 self.stage_files()
+
+ 108
+
+ 109 # Check if executable exists
+
+ 110 if not self.container_path:
+
+ 111 if not Path(self.binary_path).is_file():
+
+ 112 if not shutil.which(self.binary_path):
+
+ 113 raise FileNotFoundError('Executable %s not found. Check if it is installed in your system and correctly defined in the properties' % self.binary_path)
+
+ 114
+
+ 115 # Unzip topology to topology_out
+
+ 116 top_file = fu.unzip_top(zip_file=self.input_top_zip_path, out_log=self.out_log)
+
+ 117 top_dir = str(Path(top_file).parent)
+
+ 118
+
+ 119 # Copy extra files to container: topology folder
+
+ 120 if self.container_path:
+
+ 121 fu.log('Container execution enabled', self.out_log)
+
+ 122 fu.log(f"Unique dir: {self.stage_io_dict['unique_dir']}", self.out_log)
+
+ 123 fu.log(f"{self.stage_io_dict['unique_dir']} files: {os.listdir(self.stage_io_dict['unique_dir'])}", self.out_log)
+
+ 124 fu.log(f"Copy all files of the unzipped original topology to unique dir: {self.out_log}")
+
+ 125 shutil.copytree(top_dir, str(Path(self.stage_io_dict.get("unique_dir", "")).joinpath(Path(top_dir).name)))
+
+ 126 top_file = str(Path(self.container_volume_path).joinpath(Path(top_dir).name, Path(top_file).name))
+
+ 127
+
+ 128 output_file_name = fu.create_name(prefix=self.prefix, step=self.step, name=str(Path(top_file).name))
+
+ 129 unique_dir_output_file = str(Path(fu.create_unique_dir()).joinpath(output_file_name))
+
+ 130 fu.log(f"unique_dir_output_file: {unique_dir_output_file}", self.out_log)
+
+ 131
+
+ 132 if self.container_path:
+
+ 133 fu.log("Change references for container:", self.out_log)
+
+ 134 unique_dir_output_file = str(Path(self.container_volume_path).joinpath(Path(output_file_name)))
+
+ 135 fu.log(f" unique_dir_output_file: {unique_dir_output_file}", self.out_log)
+
+ 136
+
+ 137 self.cmd = [self.binary_path, 'gentop',
+
+ 138 '-o', str(Path(unique_dir_output_file)),
+
+ 139 '-ff', self.force_field,
+
+ 140 '-p', top_file]
+
+ 141
+
+ 142 if self.split:
+
+ 143 self.cmd.append('--split')
+
+ 144 if self.scale_mass:
+
+ 145 self.cmd.append('--scale_mass')
+
+ 146
+
+ 147 if self.gmx_lib:
+
+ 148 self.env_vars_dict['GMXLIB'] = self.gmx_lib
+
+ 149
+
+ 150 # Run Biobb block
+
+ 151 self.run_biobb()
+
+ 152
+
+ 153 # Copy files to host
+
+ 154 self.copy_to_host()
+
+ 155
+
+ 156 if self.container_path:
+
+ 157 unique_dir_output_file = str(Path(self.stage_io_dict.get("unique_dir", "")).joinpath(Path(unique_dir_output_file).name))
+
+ 158
+
+ 159 # Remove paths from top file
+
+ 160 with open(Path(unique_dir_output_file)) as top_fh:
+
+ 161 top_lines = top_fh.readlines()
+
+ 162 with open(Path(unique_dir_output_file), 'w') as top_fh:
+
+ 163 for line in top_lines:
+
+ 164 top_fh.write(line.replace(str(Path(unique_dir_output_file).parent)+'/', ''))
+
+ 165 # Copy the not modified itp files
+
+ 166 for orig_itp_file in Path(top_dir).iterdir():
+
+ 167 fu.log(f'Check if {str(Path(unique_dir_output_file).parent.joinpath(Path(orig_itp_file).name))} exists', self.out_log, self.global_log)
+
+ 168 if not Path(unique_dir_output_file).parent.joinpath(Path(orig_itp_file).name).exists():
+
+ 169 shutil.copy(orig_itp_file, Path(unique_dir_output_file).parent)
+
+ 170 fu.log(f'Copying {str(orig_itp_file)} to: {str(Path(unique_dir_output_file).parent)}', self.out_log, self.global_log)
+
+ 171
+
+ 172 # zip topology
+
+ 173 fu.log('Compressing topology to: %s' % self.io_dict["out"]["output_top_zip_path"], self.out_log, self.global_log)
+
+ 174 fu.zip_top(zip_file=self.io_dict["out"]["output_top_zip_path"], top_file=str(Path(unique_dir_output_file)), out_log=self.out_log)
+
+ 175
+
+ 176 self.tmp_files.extend([self.stage_io_dict.get("unique_dir", ""), top_dir])
+
+ 177 # self.remove_tmp_files()
+
+ 178
+
+ 179 self.check_arguments(output_files_created=True, raise_exception=False)
+
+ 180 return self.return_code
+
+ 181
+
+ 182
+
+ 183 def pmxgentop(input_top_zip_path: str, output_top_zip_path: str, properties: Optional[dict] = None, **kwargs) -> int:
+
+ 184 """Execute the :class:`Pmxgentop <pmx.pmxgentop.Pmxgentop>` class and
+
+ 185 execute the :meth:`launch() <pmx.pmxgentop.Pmxgentop.launch> method."""
+
+ 186
+
+ 187 return Pmxgentop(input_top_zip_path=input_top_zip_path,
+
+ 188 output_top_zip_path=output_top_zip_path,
+
+ 189 properties=properties, **kwargs).launch()
+
+ 190
+
+ 191
+
+ 192 def main():
+
+ 193 """Command line execution of this building block. Please check the command line documentation."""
+
+ 194 parser = argparse.ArgumentParser(description="Wrapper class for the PMX gentop module",
+
+ 195 formatter_class=lambda prog: argparse.RawTextHelpFormatter(prog, width=99999))
+
+ 196 parser.add_argument('-c', '--config', required=False, help="This file can be a YAML file, JSON file or JSON string")
+
+ 197
+
+ 198 # Specific args of each building block
+
+ 199 required_args = parser.add_argument_group('required arguments')
+
+ 200 required_args.add_argument('--input_top_zip_path', required=True, help="Path to the input topology zip file")
+
+ 201 required_args.add_argument('--output_top_zip_path', required=True, help="Path to the output topology zip file")
+
+ 202
+
+ 203 args = parser.parse_args()
+
+ 204 config = args.config if args.config else None
+
+ 205 properties = settings.ConfReader(config=config).get_prop_dic()
+
+ 206
+
+ 207 # Specific call of each building block
+
+ 208 pmxgentop(input_top_zip_path=args.input_top_zip_path,
+
+ 209 output_top_zip_path=args.output_top_zip_path,
+
+ 210 properties=properties)
+
+ 211
+
+ 212
+
+ 213 if __name__ == '__main__':
+
+ 214 main()
+
+
+
+
+
+
\ No newline at end of file
diff --git a/flake8/flake8badge.svg b/flake8/flake8badge.svg
index 58d5817..0687468 100644
--- a/flake8/flake8badge.svg
+++ b/flake8/flake8badge.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/flake8/flake8stats.txt b/flake8/flake8stats.txt
index e69de29..6783e8b 100644
--- a/flake8/flake8stats.txt
+++ b/flake8/flake8stats.txt
@@ -0,0 +1 @@
+1 F811 redefinition of unused 'Optional' from line 7
diff --git a/flake8/index.html b/flake8/index.html
index 392068e..8fbc00f 100644
--- a/flake8/index.html
+++ b/flake8/index.html
@@ -6,22 +6,21 @@
-
+
flake8 violations
- Generated on 2024-06-14 18:53
- with Installed plugins: flake8-html: 0.4.3, mccabe: 0.7.0, pycodestyle: 2.11.1, pyflakes: 3.2.0
+
Generated on 2024-11-04 14:29
+ with Installed plugins: flake8-html: 0.4.3, mccabe: 0.7.0, pycodestyle: 2.12.1, pyflakes: 3.2.0
-
-
+ biobb_pmx/pmxbiobb/pmxgentop.py
+
diff --git a/junit/junit.xml b/junit/junit.xml
index dbcf794..1ffa107 100644
--- a/junit/junit.xml
+++ b/junit/junit.xml
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/junit/report.html b/junit/report.html
index e8b82e5..08a23d2 100644
--- a/junit/report.html
+++ b/junit/report.html
@@ -7,7 +7,7 @@
report.html
- Report generated on 14-Jun-2024 at 18:54:42 by pytest-html
+
Report generated on 04-Nov-2024 at 14:30:27 by pytest-html
v4.1.1
Environment
@@ -108,7 +108,7 @@ Summary
6import sys
7import shutil
8import argparse
-9from typing import Dict, Optional
+9from typing import Optional
10from biobb_pmx.pmxbiobb.common import create_mutations_file, MUTATION_DICT
11from biobb_common.generic.biobb_object import BiobbObject
12from biobb_common.configuration import settings
@@ -148,7 +148,7 @@66 """
68 def __init__(self, input_structure_path: str, output_structure_path: str, input_b_structure_path: Optional[str] = None,
-69 properties: Optional[Dict] = None, **kwargs) -> None:
+69 properties: Optional[dict] = None, **kwargs) -> None:
70 properties = properties or {}
72 # Call parent class constructor
@@ -240,7 +240,7 @@160def pmxmutate(input_structure_path: str, output_structure_path: str,
-161 input_b_structure_path: Optional[str] = None, properties: Optional[Dict] = None,
+161 input_b_structure_path: Optional[str] = None, properties: Optional[dict] = None,
162 **kwargs) -> int:
163 """Execute the :class:`Pmxmutate <pmx.pmxmutate.Pmxmutate>` class and
164 execute the :meth:`launch() <pmx.pmxmutate.Pmxmutate.launch> method."""
@@ -284,8 +284,8 @@
^ index
» next
- coverage.py v7.5.3,
- created at 2024-06-14 18:54 +0000
+ coverage.py v7.6.4,
+ created at 2024-11-04 14:30 +0000
diff --git a/flake8/biobb_pmx.pmxbiobb.pmxgentop.report.html b/flake8/biobb_pmx.pmxbiobb.pmxgentop.report.html
new file mode 100644
index 0000000..b5e1725
--- /dev/null
+++ b/flake8/biobb_pmx.pmxbiobb.pmxgentop.report.html
@@ -0,0 +1,73 @@
+
+
+
+ flake8 violations: biobb_pmx/pmxbiobb/pmxgentop.py
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ biobb_pmx/pmxbiobb/pmxgentop.py
+
+
+
+
+
+ -
+
+
+ 1
+
+ F811: redefinition of unused 'Optional' from line 7
+
+
+
+ -
+
+
+ 10 from typing import Optional
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/flake8/biobb_pmx.pmxbiobb.pmxgentop.source.html b/flake8/biobb_pmx.pmxbiobb.pmxgentop.source.html
new file mode 100644
index 0000000..d18e51e
--- /dev/null
+++ b/flake8/biobb_pmx.pmxbiobb.pmxgentop.source.html
@@ -0,0 +1,674 @@
+
+
+
+ biobb_pmx/pmxbiobb/pmxgentop.py - flake8 annotated source
+
+
+
+
+
+
+
+
+
+ biobb_pmx/pmxbiobb/pmxgentop.py source
+
+
+
+
+ 1 #!/usr/bin/env python3
+
+ 2
+
+ 3 """Module containing the PMX gentop class and the command line interface."""
+
+ 4 import os
+
+ 5 import sys
+
+ 6 import argparse
+
+ 7 from typing import Optional
+
+ 8 import shutil
+
+ 9 from pathlib import Path
+
+
+
+
+ -
+
+ F811
+
+ Redefinition of unused 'Optional' from line 7
+
+
10 from typing import Optional
+
+ 11 from biobb_common.generic.biobb_object import BiobbObject
+
+ 12 from biobb_common.configuration import settings
+
+ 13 from biobb_common.tools import file_utils as fu
+
+ 14 from biobb_common.tools.file_utils import launchlogger
+
+ 15
+
+ 16
+
+ 17 class Pmxgentop(BiobbObject):
+
+ 18 """
+
+ 19 | biobb_pmx Pmxgentop
+
+ 20 | Wrapper class for the `PMX gentop <https://github.com/deGrootLab/pmx>`_ module.
+
+ 21 | Generate a topology file for a morphing simulation.
+
+ 22
+
+ 23 Args:
+
+ 24 input_top_zip_path (str): Path the input GROMACS topology TOP and ITP files in zip format. File type: input. `Sample file <https://github.com/bioexcel/biobb_pmx/raw/master/biobb_pmx/test/data/pmx/topology.zip>`_. Accepted formats: zip (edam:format_3987).
+
+ 25 output_top_zip_path (str): Path the output TOP topology in zip format. File type: output. `Sample file <https://github.com/bioexcel/biobb_pmx/raw/master/biobb_pmx/test/reference/pmx/ref_output_topology.zip>`_. Accepted formats: zip (edam:format_3987).
+
+ 26 properties (dic):
+
+ 27 * **force_field** (*str*) - ("amber99sb-star-ildn-mut") Force field to use. If **input_top_zip_path** is a top file, it's not necessary to specify the forcefield, as it will be determined automatically. If **input_top_zip_path** is an itp file, then it's needed.
+
+ 28 * **split** (*bool*) - (False) Write separate topologies for the vdW and charge transformations.
+
+ 29 * **scale_mass** (*bool*) - (False) Scale the masses of morphing atoms so that dummies have a mass of 1.
+
+ 30 * **gmx_lib** (*str*) - ("$CONDA_PREFIX/lib/python3.7/site-packages/pmx/data/mutff/") Path to the GMXLIB folder in your computer.
+
+ 31 * **binary_path** (*str*) - ("pmx") Path to the PMX command line interface.
+
+ 32 * **remove_tmp** (*bool*) - (True) [WF property] Remove temporal files.
+
+ 33 * **restart** (*bool*) - (False) [WF property] Do not execute if output files exist.
+
+ 34 * **sandbox_path** (*str*) - ("./") [WF property] Parent path to the sandbox directory.
+
+ 35 * **container_path** (*str*) - (None) Path to the binary executable of your container.
+
+ 36 * **container_image** (*str*) - ("gromacs/gromacs:latest") Container Image identifier.
+
+ 37 * **container_volume_path** (*str*) - ("/inout") Path to an internal directory in the container.
+
+ 38 * **container_working_dir** (*str*) - (None) Path to the internal CWD in the container.
+
+ 39 * **container_user_id** (*str*) - (None) User number id to be mapped inside the container.
+
+ 40 * **container_shell_path** (*str*) - ("/bin/bash") Path to the binary executable of the container shell.
+
+ 41
+
+ 42 Examples:
+
+ 43 This is a use example of how to use the building block from Python::
+
+ 44
+
+ 45 from biobb_pmx.pmxbiobb.pmxgentop import pmxgentop
+
+ 46 prop = {
+
+ 47 'gmx_lib': '/path/to/myGMXLIB/',
+
+ 48 'force_field': 'amber99sb-star-ildn-mut'
+
+ 49 }
+
+ 50 pmxgentop(input_top_zip_path='/path/to/myTopology.zip',
+
+ 51 output_top_zip_path='/path/to/newTopology.zip',
+
+ 52 properties=prop)
+
+ 53
+
+ 54 Info:
+
+ 55 * wrapped_software:
+
+ 56 * name: PMX gentop
+
+ 57 * version: >=1.0.1
+
+ 58 * license: GNU
+
+ 59 * ontology:
+
+ 60 * name: EDAM
+
+ 61 * schema: http://edamontology.org/EDAM.owl
+
+ 62
+
+ 63 """
+
+ 64
+
+ 65 def __init__(self, input_top_zip_path: str, output_top_zip_path: str,
+
+ 66 properties: Optional[dict] = None, **kwargs) -> None:
+
+ 67 properties = properties or {}
+
+ 68
+
+ 69 # Call parent class constructor
+
+ 70 super().__init__(properties)
+
+ 71 self.locals_var_dict = locals().copy()
+
+ 72
+
+ 73 # Input/Output files
+
+ 74 self.io_dict = {
+
+ 75 "in": {},
+
+ 76 "out": {"output_top_zip_path": output_top_zip_path}
+
+ 77 }
+
+ 78 # Should not be copied inside container
+
+ 79 self.input_top_zip_path = input_top_zip_path
+
+ 80
+
+ 81 # Properties specific for BB
+
+ 82 self.force_field = properties.get('force_field', "amber99sb-star-ildn-mut")
+
+ 83 self.split = properties.get('split', False)
+
+ 84 self.scale_mass = properties.get('scale_mass', False)
+
+ 85
+
+ 86 # Properties common in all PMX BB
+
+ 87 self.gmx_lib = properties.get('gmx_lib', None)
+
+ 88 if not self.gmx_lib and os.environ.get('CONDA_PREFIX', ''):
+
+ 89 python_version = f"{sys.version_info.major}.{sys.version_info.minor}"
+
+ 90 self.gmx_lib = str(
+
+ 91 Path(os.environ.get('CONDA_PREFIX', '')).joinpath(f"lib/python{python_version}/site-packages/pmx/data/mutff/"))
+
+ 92 if properties.get('container_path'):
+
+ 93 self.gmx_lib = str(Path('/usr/local/').joinpath("lib/python3.8/site-packages/pmx/data/mutff/"))
+
+ 94 self.binary_path = properties.get('binary_path', 'pmx')
+
+ 95
+
+ 96 # Check the properties
+
+ 97 self.check_properties(properties)
+
+ 98 self.check_arguments()
+
+ 99
+
+ 100 @launchlogger
+
+ 101 def launch(self) -> int:
+
+ 102 """Execute the :class:`Pmxgentop <pmx.pmxgentop.Pmxgentop>` pmx.pmxgentop.Pmxgentop object."""
+
+ 103
+
+ 104 # Setup Biobb
+
+ 105 if self.check_restart():
+
+ 106 return 0
+
+ 107 self.stage_files()
+
+ 108
+
+ 109 # Check if executable exists
+
+ 110 if not self.container_path:
+
+ 111 if not Path(self.binary_path).is_file():
+
+ 112 if not shutil.which(self.binary_path):
+
+ 113 raise FileNotFoundError('Executable %s not found. Check if it is installed in your system and correctly defined in the properties' % self.binary_path)
+
+ 114
+
+ 115 # Unzip topology to topology_out
+
+ 116 top_file = fu.unzip_top(zip_file=self.input_top_zip_path, out_log=self.out_log)
+
+ 117 top_dir = str(Path(top_file).parent)
+
+ 118
+
+ 119 # Copy extra files to container: topology folder
+
+ 120 if self.container_path:
+
+ 121 fu.log('Container execution enabled', self.out_log)
+
+ 122 fu.log(f"Unique dir: {self.stage_io_dict['unique_dir']}", self.out_log)
+
+ 123 fu.log(f"{self.stage_io_dict['unique_dir']} files: {os.listdir(self.stage_io_dict['unique_dir'])}", self.out_log)
+
+ 124 fu.log(f"Copy all files of the unzipped original topology to unique dir: {self.out_log}")
+
+ 125 shutil.copytree(top_dir, str(Path(self.stage_io_dict.get("unique_dir", "")).joinpath(Path(top_dir).name)))
+
+ 126 top_file = str(Path(self.container_volume_path).joinpath(Path(top_dir).name, Path(top_file).name))
+
+ 127
+
+ 128 output_file_name = fu.create_name(prefix=self.prefix, step=self.step, name=str(Path(top_file).name))
+
+ 129 unique_dir_output_file = str(Path(fu.create_unique_dir()).joinpath(output_file_name))
+
+ 130 fu.log(f"unique_dir_output_file: {unique_dir_output_file}", self.out_log)
+
+ 131
+
+ 132 if self.container_path:
+
+ 133 fu.log("Change references for container:", self.out_log)
+
+ 134 unique_dir_output_file = str(Path(self.container_volume_path).joinpath(Path(output_file_name)))
+
+ 135 fu.log(f" unique_dir_output_file: {unique_dir_output_file}", self.out_log)
+
+ 136
+
+ 137 self.cmd = [self.binary_path, 'gentop',
+
+ 138 '-o', str(Path(unique_dir_output_file)),
+
+ 139 '-ff', self.force_field,
+
+ 140 '-p', top_file]
+
+ 141
+
+ 142 if self.split:
+
+ 143 self.cmd.append('--split')
+
+ 144 if self.scale_mass:
+
+ 145 self.cmd.append('--scale_mass')
+
+ 146
+
+ 147 if self.gmx_lib:
+
+ 148 self.env_vars_dict['GMXLIB'] = self.gmx_lib
+
+ 149
+
+ 150 # Run Biobb block
+
+ 151 self.run_biobb()
+
+ 152
+
+ 153 # Copy files to host
+
+ 154 self.copy_to_host()
+
+ 155
+
+ 156 if self.container_path:
+
+ 157 unique_dir_output_file = str(Path(self.stage_io_dict.get("unique_dir", "")).joinpath(Path(unique_dir_output_file).name))
+
+ 158
+
+ 159 # Remove paths from top file
+
+ 160 with open(Path(unique_dir_output_file)) as top_fh:
+
+ 161 top_lines = top_fh.readlines()
+
+ 162 with open(Path(unique_dir_output_file), 'w') as top_fh:
+
+ 163 for line in top_lines:
+
+ 164 top_fh.write(line.replace(str(Path(unique_dir_output_file).parent)+'/', ''))
+
+ 165 # Copy the not modified itp files
+
+ 166 for orig_itp_file in Path(top_dir).iterdir():
+
+ 167 fu.log(f'Check if {str(Path(unique_dir_output_file).parent.joinpath(Path(orig_itp_file).name))} exists', self.out_log, self.global_log)
+
+ 168 if not Path(unique_dir_output_file).parent.joinpath(Path(orig_itp_file).name).exists():
+
+ 169 shutil.copy(orig_itp_file, Path(unique_dir_output_file).parent)
+
+ 170 fu.log(f'Copying {str(orig_itp_file)} to: {str(Path(unique_dir_output_file).parent)}', self.out_log, self.global_log)
+
+ 171
+
+ 172 # zip topology
+
+ 173 fu.log('Compressing topology to: %s' % self.io_dict["out"]["output_top_zip_path"], self.out_log, self.global_log)
+
+ 174 fu.zip_top(zip_file=self.io_dict["out"]["output_top_zip_path"], top_file=str(Path(unique_dir_output_file)), out_log=self.out_log)
+
+ 175
+
+ 176 self.tmp_files.extend([self.stage_io_dict.get("unique_dir", ""), top_dir])
+
+ 177 # self.remove_tmp_files()
+
+ 178
+
+ 179 self.check_arguments(output_files_created=True, raise_exception=False)
+
+ 180 return self.return_code
+
+ 181
+
+ 182
+
+ 183 def pmxgentop(input_top_zip_path: str, output_top_zip_path: str, properties: Optional[dict] = None, **kwargs) -> int:
+
+ 184 """Execute the :class:`Pmxgentop <pmx.pmxgentop.Pmxgentop>` class and
+
+ 185 execute the :meth:`launch() <pmx.pmxgentop.Pmxgentop.launch> method."""
+
+ 186
+
+ 187 return Pmxgentop(input_top_zip_path=input_top_zip_path,
+
+ 188 output_top_zip_path=output_top_zip_path,
+
+ 189 properties=properties, **kwargs).launch()
+
+ 190
+
+ 191
+
+ 192 def main():
+
+ 193 """Command line execution of this building block. Please check the command line documentation."""
+
+ 194 parser = argparse.ArgumentParser(description="Wrapper class for the PMX gentop module",
+
+ 195 formatter_class=lambda prog: argparse.RawTextHelpFormatter(prog, width=99999))
+
+ 196 parser.add_argument('-c', '--config', required=False, help="This file can be a YAML file, JSON file or JSON string")
+
+ 197
+
+ 198 # Specific args of each building block
+
+ 199 required_args = parser.add_argument_group('required arguments')
+
+ 200 required_args.add_argument('--input_top_zip_path', required=True, help="Path to the input topology zip file")
+
+ 201 required_args.add_argument('--output_top_zip_path', required=True, help="Path to the output topology zip file")
+
+ 202
+
+ 203 args = parser.parse_args()
+
+ 204 config = args.config if args.config else None
+
+ 205 properties = settings.ConfReader(config=config).get_prop_dic()
+
+ 206
+
+ 207 # Specific call of each building block
+
+ 208 pmxgentop(input_top_zip_path=args.input_top_zip_path,
+
+ 209 output_top_zip_path=args.output_top_zip_path,
+
+ 210 properties=properties)
+
+ 211
+
+ 212
+
+ 213 if __name__ == '__main__':
+
+ 214 main()
+
+
+
+
+
+
\ No newline at end of file
diff --git a/flake8/flake8badge.svg b/flake8/flake8badge.svg
index 58d5817..0687468 100644
--- a/flake8/flake8badge.svg
+++ b/flake8/flake8badge.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/flake8/flake8stats.txt b/flake8/flake8stats.txt
index e69de29..6783e8b 100644
--- a/flake8/flake8stats.txt
+++ b/flake8/flake8stats.txt
@@ -0,0 +1 @@
+1 F811 redefinition of unused 'Optional' from line 7
diff --git a/flake8/index.html b/flake8/index.html
index 392068e..8fbc00f 100644
--- a/flake8/index.html
+++ b/flake8/index.html
@@ -6,22 +6,21 @@
-
+
flake8 violations
- Generated on 2024-06-14 18:53
- with Installed plugins: flake8-html: 0.4.3, mccabe: 0.7.0, pycodestyle: 2.11.1, pyflakes: 3.2.0
+
Generated on 2024-11-04 14:29
+ with Installed plugins: flake8-html: 0.4.3, mccabe: 0.7.0, pycodestyle: 2.12.1, pyflakes: 3.2.0
-
-
+ biobb_pmx/pmxbiobb/pmxgentop.py
+
diff --git a/junit/junit.xml b/junit/junit.xml
index dbcf794..1ffa107 100644
--- a/junit/junit.xml
+++ b/junit/junit.xml
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/junit/report.html b/junit/report.html
index e8b82e5..08a23d2 100644
--- a/junit/report.html
+++ b/junit/report.html
@@ -7,7 +7,7 @@
report.html
- Report generated on 14-Jun-2024 at 18:54:42 by pytest-html
+
Report generated on 04-Nov-2024 at 14:30:27 by pytest-html
v4.1.1
Environment
@@ -108,7 +108,7 @@ Summary
+ + +
++ + + biobb_pmx/pmxbiobb/pmxgentop.py + +
+ +-
+
+
-
+
+
+ 1
+
+ F811: redefinition of unused 'Optional' from line 7
+
+
+
-
+
- + + + 10 from typing import Optional + + +
+
+
+ + + biobb_pmx/pmxbiobb/pmxgentop.py source + +
+ +-
+
+
- + + F811 + + Redefinition of unused 'Optional' from line 7 + +
flake8 violations
-Generated on 2024-06-14 18:53 - with Installed plugins: flake8-html: 0.4.3, mccabe: 0.7.0, pycodestyle: 2.11.1, pyflakes: 3.2.0 +
Generated on 2024-11-04 14:29 + with Installed plugins: flake8-html: 0.4.3, mccabe: 0.7.0, pycodestyle: 2.12.1, pyflakes: 3.2.0
- - + biobb_pmx/pmxbiobb/pmxgentop.py +
report.html
-Report generated on 14-Jun-2024 at 18:54:42 by pytest-html +
Report generated on 04-Nov-2024 at 14:30:27 by pytest-html v4.1.1