Coverage for biobb_flexdyn/flexdyn/nolb_nma.py: 96%
25 statements
« prev ^ index » next coverage.py v7.18.0, created at 2026-12-03 15:50 +0000
« prev ^ index » next coverage.py v7.18.0, created at 2026-12-03 15:50 +0000
1#!/usr/bin/env python3
3"""Module containing the nolb class and the command line interface."""
4from typing import Optional
5import os
6from pathlib import Path
7from biobb_common.generic.biobb_object import BiobbObject, launcher
10class Nolb_nma(BiobbObject):
11 """
12 | biobb_flexdyn Nolb_nma
13 | Wrapper of the NOLB tool
14 | Generate an ensemble of structures using the NOLB (NOn-Linear rigid Block) NMA tool.
16 Args:
17 input_pdb_path (str): Input PDB file. File type: input. `Sample file <https://github.com/bioexcel/biobb_flexdyn/raw/master/biobb_flexdyn/test/data/flexdyn/structure.pdb>`_. Accepted formats: pdb (edam:format_1476).
18 output_pdb_path (str): Output multi-model PDB file with the generated ensemble. File type: output. `Sample file <https://github.com/bioexcel/biobb_flexdyn/raw/master/biobb_flexdyn/test/reference/flexdyn/nolb_output.pdb>`_. Accepted formats: pdb (edam:format_1476).
19 properties (dict - Python dictionary object containing the tool parameters, not input/output files):
20 * **binary_path** (*str*) - ("NOLB") NOLB binary path to be used.
21 * **num_structs** (*int*) - (500) Number of structures to be generated
22 * **cutoff** (*float*) - (5.0) This options specifies the interaction cutoff distance for the elastic network models (in angstroms), 5 by default. The Hessian matrix is constructed according to this interaction distance. Some artifacts should be expected for too short distances (< 5 Å).
23 * **rmsd** (*float*) - (1.0) Maximum RMSd for decoy generation.
24 * **remove_tmp** (*bool*) - (True) [WF property] Remove temporal files.
25 * **restart** (*bool*) - (False) [WF property] Do not execute if output files exist.
26 * **sandbox_path** (*str*) - ("./") [WF property] Parent path to the sandbox directory.
27 * **container_path** (*str*) - (None) Path to the binary executable of your container.
28 * **container_image** (*str*) - (None) Container Image identifier.
29 * **container_volume_path** (*str*) - ("/data") Path to an internal directory in the container.
30 * **container_user_id** (*str*) - (None) User number id to be mapped inside the container.
31 * **container_shell_path** (*str*) - ("/bin/bash") Path to the binary executable of the container shell.
33 Examples:
34 This is a use example of how to use the building block from Python::
36 from biobb_flexdyn.flexdyn.nolb_nma import nolb_nma
37 prop = {
38 'num_structs' : 20
39 }
40 nolb_nma( input_pdb_path='/path/to/structure.pdb',
41 output_pdb_path='/path/to/output.pdb',
42 properties=prop)
44 Info:
45 * wrapped_software:
46 * name: NOLB
47 * version: >=1.9
48 * license: other
49 * ontology:
50 * name: EDAM
51 * schema: http://edamontology.org/EDAM.owl
53 """
55 def __init__(self, input_pdb_path: str, output_pdb_path: str,
56 properties: Optional[dict] = None, **kwargs) -> None:
57 super().__init__(**locals())
59 def run(self):
60 """Launches the execution of the FlexDyn NOLB module."""
62 # Command line
63 # ./NOLB 1ake_monomer.pdb -s 100 --rmsd 5 -m -o 1ake_decoys.pdb # Output: 1ake_decoys_nlb_decoys.pdb
64 # NOLB removes the extension of -o (after the last dot of the path): -o is the output path
65 self.cmd = [self.binary_path,
66 self.stage_io_dict["in"]["input_pdb_path"],
67 "-o", self.stage_io_dict["out"]["output_pdb_path"],
68 "-m" # Minimizing the generated structures by default
69 ]
71 # Properties
72 if self.num_structs:
73 self.cmd.append('-s')
74 self.cmd.append(str(self.num_structs))
76 if self.cutoff:
77 self.cmd.append('-c')
78 self.cmd.append(str(self.cutoff))
80 if self.rmsd:
81 self.cmd.append('--rmsd')
82 self.cmd.append(str(self.rmsd))
84 # --dist 1 -m --nSteps 5000 --tol 0.001
85 self.cmd.append("--dist 1 --nSteps 5000 --tol 0.001")
87 # Run Biobb block
88 self.run_biobb()
90 # The decoys file is the output
91 decoys = str(Path(self.stage_io_dict["out"]["output_pdb_path"]).with_suffix('')) + "_nlb_decoys.pdb"
92 os.replace(Path(self.stage_io_dict["unique_dir"], decoys), self.sandbox_file("output_pdb_path"))
95nolb_nma = launcher(Nolb_nma)
97if __name__ == '__main__':
98 Nolb_nma.main()