Coverage for biobb_io/api/memprotmd_sim_search.py: 91%

33 statements  

« prev     ^ index     » next       coverage.py v7.10.6, created at 2025-09-04 08:31 +0000

1#!/usr/bin/env python 

2 

3"""Module containing the MemProtMDSimSearch class and the command line interface.""" 

4 

5from typing import Optional 

6from biobb_common.generic.biobb_object import BiobbObject 

7from biobb_common.tools.file_utils import launchlogger 

8 

9from biobb_io.api.common import check_output_path, get_memprotmd_sim_search, write_json 

10 

11 

12class MemProtMDSimSearch(BiobbObject): 

13 """ 

14 | biobb_io MemProtMDSimSearch 

15 | This class is a wrapper of the MemProtMD to perform advanced searches in the MemProtMD DB using its REST API. 

16 | Wrapper for the `MemProtMD DB REST API <http://memprotmd.bioch.ox.ac.uk/>`_ to perform advanced searches. 

17 

18 Args: 

19 output_simulations (str): Path to the output JSON file. File type: output. `Sample file <https://github.com/bioexcel/biobb_io/raw/master/biobb_io/test/reference/api/output_sim_search.json>`_. Accepted formats: json (edam:format_3464). 

20 properties (dic - Python dictionary object containing the tool parameters, not input/output files): 

21 * **collection_name** (*str*) - ("refs") Name of the collection to query. 

22 * **keyword** (*str*) - (None) String to search for in the database metadata. Examples are families like gpcr or porin. Values: porin, outer membrane protein, membrane protein, gpcr (7-transmembrane domain receptors transducing extracellular signals into cells), ion channels, rhodopsin (The most famous GPCRs), abc, mip (Major Intrinsic Protein (MIP)/FNT superfamily: specific for the transport of water and small neutral solutes), ligand-gated (Ligand-dependent signal conversion from chemical signals to electric signals), ammonia (Regulating transepithelial ammonia secretion), mapeg (Eicosanoid and Glutathione metabolism proteins), transmembrane (Heme biosynthesis), protein, kinase (Tyrosine-protein kinases: regulate central nervous system; gene transcription and cell differentiation), glycoprotein (Expression of TCR complex), immunoglobulin (Recognition; binding and adhesion process of cells), integrin (Bridges for cell-cell and cell-extracellular matrix interaction), bnip3 (BNip3 protein family: protect cell from apoptosis), bcl-2 (Regulating cell-death; either induce apoptotic or inhibit apoptosis), atpase (ATPase regulators; P-P-bond hydrolysis-driven transporter), cytochrome (Terminal oxidase enzyme in electron transfer chain), nadp (Transmembrane proteins with NAD(P)-binding Rossmann-fold domains: monoamine oxidase; deaminates norepinephrine; epinephrine; serotonin and dopamine), a4 (Amyloid beta A4 protein; involved in alzheimer's diseases), lysosome (Lysosome-associated membrane glycoprotein: specific to lysosomes; CD107), necrosis (Tumor necrosis factor recepto: binding with TNF and NGF; interacting with a variety of signal molecules; highly associated with apoptosis), oxidoreductase (DHODH; biosynthesis of orotate), ceramidase (Neutral/alkaline ceramidase: converting sphingolipid to sphingosine), dehydrogenase (Aldehyde dehydrogenase:ALDH; Oxidation of aldehydes), mitochondrial, plastid. 

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. 

26 

27 Examples: 

28 This is a use example of how to use the building block from Python:: 

29 

30 from biobb_io.api.memprotmd_sim_search import memprotmd_sim_search 

31 prop = { 

32 'collection_name': 'refs', 

33 'keyword': 'porin' 

34 } 

35 memprotmd_sim_search(output_simulations='/path/to/newSimulationSearch.json', 

36 properties=prop).launch() 

37 

38 Info: 

39 * wrapped_software: 

40 * name: MemProtMD DB 

41 * license: Creative Commons 

42 * ontology: 

43 * name: EDAM 

44 * schema: http://edamontology.org/EDAM.owl 

45 

46 """ 

47 

48 def __init__(self, output_simulations, properties=None, **kwargs) -> None: 

49 properties = properties or {} 

50 

51 # Call parent class constructor 

52 super().__init__(properties) 

53 self.locals_var_dict = locals().copy() 

54 

55 # Input/Output files 

56 self.io_dict = {"out": {"output_simulations": output_simulations}} 

57 

58 # Properties specific for BB 

59 self.collection_name = properties.get("collection_name", "refs") 

60 self.keyword = properties.get("keyword", None) 

61 self.properties = properties 

62 

63 # Check the properties 

64 self.check_properties(properties) 

65 self.check_arguments() 

66 

67 def check_data_params(self, out_log, err_log): 

68 """Checks all the input/output paths and parameters""" 

69 self.output_simulations = check_output_path( 

70 self.io_dict["out"]["output_simulations"], 

71 "output_simulations", 

72 False, 

73 out_log, 

74 self.__class__.__name__, 

75 ) 

76 

77 @launchlogger 

78 def launch(self) -> int: 

79 """Execute the :class:`MemProtMDSimSearch <api.memprotmd_sim_search.MemProtMDSimSearch>` api.memprotmd_sim_search.MemProtMDSimSearch object.""" 

80 

81 # check input/output paths and parameters 

82 self.check_data_params(self.out_log, self.err_log) 

83 

84 # Setup Biobb 

85 if self.check_restart(): 

86 return 0 

87 

88 self.keyword = self.keyword.strip().lower() 

89 

90 # get JSON object 

91 json_string = get_memprotmd_sim_search( 

92 self.collection_name, self.keyword, self.out_log, self.global_log 

93 ) 

94 

95 # write JSON file 

96 write_json(json_string, self.output_simulations, self.out_log, self.global_log) 

97 

98 self.check_arguments(output_files_created=True, raise_exception=False) 

99 

100 return 0 

101 

102 

103def memprotmd_sim_search( 

104 output_simulations: str, properties: Optional[dict] = None, **kwargs 

105) -> int: 

106 """Execute the :class:`MemProtMDSimSearch <api.memprotmd_sim_search.MemProtMDSimSearch>` class and 

107 execute the :meth:`launch() <api.memprotmd_sim_search.MemProtMDSimSearch.launch>` method.""" 

108 return MemProtMDSimSearch(**dict(locals())).launch() 

109 

110 

111memprotmd_sim_search.__doc__ = MemProtMDSimSearch.__doc__ 

112main = MemProtMDSimSearch.get_main(memprotmd_sim_search, "Wrapper for the MemProtMD DB REST API (http://memprotmd.bioch.ox.ac.uk/) to perform advanced searches.") 

113 

114if __name__ == "__main__": 

115 main()