Coverage for biobb_pdb_tools/pdb_tools/biobb_pdb_fetch.py: 88%
16 statements
« prev ^ index » next coverage.py v7.18.0, created at 2026-12-03 15:44 +0000
« prev ^ index » next coverage.py v7.18.0, created at 2026-12-03 15:44 +0000
1#!/usr/bin/env python3
3"""Module containing the Pdbfetch class and the command line interface."""
5import shlex
6from typing import Optional
7from biobb_common.generic.biobb_object import BiobbObject, launcher
10class Pdbfetch(BiobbObject):
11 """
12 | biobb_pdb_tools Pdbfetch
13 | Downloads a structure in PDB format from the RCSB website.
14 | This tool downloads a structure in PDB format from the RCSB website. It can be used to download a structure in PDB format from the RCSB website.
16 Args:
17 output_file_path (str): PDB file of the protein selected. File type: output. `Sample file <https://raw.githubusercontent.com/bioexcel/biobb_pdb_tools/master/biobb_pdb_tools/test/reference/pdb_tools/ref_pdb_fetch.pdb>`_. Accepted formats: pdb (edam:format_1476).
18 properties (dic):
19 * **pdbid** (*string*) - ('1aki') ID of the protein.
20 * **biounit** (*bool*) - (False) Allows downloading the (first) biological structure if selected.
21 * **binary_path** (*str*) - ("pdb_fetch") Path to the pdb_fetch executable binary.
22 * **remove_tmp** (*bool*) - (True) [WF property] Remove temporal files.
23 * **restart** (*bool*) - (False) [WF property] Do not execute if output files exist.
25 Examples:
26 This is a use example of how to use the building block from Python::
28 from biobb_pdb_tools.pdb_tools.biobb_pdb_fetch import biobb_pdb_fetch
30 prop = {
31 'biounit': False,
32 'pdbid': '1aki'
33 }
34 biobb_pdb_fetch(output_file_path='/path/to/file.pdb',
35 properties=prop)
37 Info:
38 * wrapped_software:
39 * name: pdb_tools
40 * version: >=2.5.0
41 * license: Apache-2.0
42 * ontology:
43 * name: EDAM
44 * schema: http://edamontology.org/EDAM.owl
46 """
48 def __init__(self, output_file_path: str, properties: Optional[dict] = None, **kwargs) -> None:
49 super().__init__(**locals())
51 def stage_files(self) -> None:
52 """The block does not use the sandbox: there are no files to stage."""
54 def run(self) -> None:
55 """Run pdb_fetch with the PDB code and the output file as its stdout, both quoted for the shell."""
56 self.cmd = [self.binary_path]
57 if self.biounit:
58 self.cmd.append("-biounit")
59 self.cmd += [shlex.quote(self.pdbid), ">", shlex.quote(self.io_dict["out"]["output_file_path"])]
60 self.run_biobb()
63biobb_pdb_fetch = launcher(Pdbfetch)
65if __name__ == "__main__":
66 Pdbfetch.main()