Coverage for biobb_io/api/memprotmd_sim_list.py: 43%

30 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 MemProtMDSimList 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 

8from biobb_io.api.common import check_output_path, get_memprotmd_sim_list, write_json 

9 

10 

11class MemProtMDSimList(BiobbObject): 

12 """ 

13 | biobb_io MemProtMDSimList 

14 | This class is a wrapper of the MemProtMD to get all available membrane-protein systems from its REST API. 

15 | Wrapper for the `MemProtMD DB REST API <http://memprotmd.bioch.ox.ac.uk/>`_ to get all available membrane-protein systems (simulations). 

16 

17 Args: 

18 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_list.json>`_. Accepted formats: json (edam:format_3464). 

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

20 * **remove_tmp** (*bool*) - (True) [WF property] Remove temporal files. 

21 * **restart** (*bool*) - (False) [WF property] Do not execute if output files exist. 

22 * **sandbox_path** (*str*) - ("./") [WF property] Parent path to the sandbox directory. 

23 

24 Examples: 

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

26 

27 from biobb_io.api.memprotmd_sim_list import memprotmd_sim_list 

28 prop = { } 

29 memprotmd_sim_list(output_simulations='/path/to/newSimulationlist.json', 

30 properties=prop) 

31 

32 Info: 

33 * wrapped_software: 

34 * name: MemProtMD DB 

35 * license: Creative Commons 

36 * ontology: 

37 * name: EDAM 

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

39 

40 """ 

41 

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

43 properties = properties or {} 

44 

45 # Call parent class constructor 

46 super().__init__(properties) 

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

48 

49 # Input/Output files 

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

51 

52 # Properties specific for BB 

53 self.properties = properties 

54 

55 # Check the properties 

56 self.check_properties(properties) 

57 self.check_arguments() 

58 

59 def check_data_params(self, out_log, err_log): 

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

61 self.output_simulations = check_output_path( 

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

63 "output_simulations", 

64 False, 

65 out_log, 

66 self.__class__.__name__, 

67 ) 

68 

69 @launchlogger 

70 def launch(self) -> int: 

71 """Execute the :class:`MemProtMDSimList <api.memprotmd_sim_list.MemProtMDSimList>` api.memprotmd_sim_list.MemProtMDSimList object.""" 

72 

73 # check input/output paths and parameters 

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

75 

76 # Setup Biobb 

77 if self.check_restart(): 

78 return 0 

79 

80 # get JSON object 

81 json_string = get_memprotmd_sim_list(self.out_log, self.global_log) 

82 

83 # write JSON file 

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

85 

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

87 

88 return 0 

89 

90 

91def memprotmd_sim_list( 

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

93) -> int: 

94 """Execute the :class:`MemProtMDSimList <api.memprotmd_sim_list.MemProtMDSimList>` class and 

95 execute the :meth:`launch() <api.memprotmd_sim_list.MemProtMDSimList.launch>` method.""" 

96 return MemProtMDSimList(**dict(locals())).launch() 

97 

98 

99memprotmd_sim_list.__doc__ = MemProtMDSimList.__doc__ 

100main = MemProtMDSimList.get_main(memprotmd_sim_list, "Wrapper for the MemProtMD DB REST API (http://memprotmd.bioch.ox.ac.uk/) to get all available membrane-protein systems (simulations).") 

101 

102if __name__ == "__main__": 

103 main()