biobb-io 4.0.0__py3-none-any.whl → 4.1.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
biobb_io/__init__.py CHANGED
@@ -1,3 +1,3 @@
1
1
  name = "biobb_io"
2
2
  __all__ = ["api"]
3
- __version__ = "4.0.0"
3
+ __version__ = "4.1.1"
biobb_io/api/__init__.py CHANGED
@@ -1,2 +1,2 @@
1
1
  name = "api"
2
- __all__ = ["drugbank", "ligand", "pdb", "alphafold", "pdb_cluster_zip", "pdb_variants", "memprotmd_sim_list", "memprotmd_sim_search", "memprotmd_sim", "api_binding_site","canonical_fasta", "mmcif", "ideal_sdf", "structure_info"]
2
+ __all__ = ["drugbank", "ligand", "pdb", "alphafold", "pdb_cluster_zip", "pdb_variants", "memprotmd_sim_list", "memprotmd_sim_search", "memprotmd_sim", "api_binding_site", "canonical_fasta", "mmcif", "ideal_sdf", "structure_info"]
biobb_io/api/alphafold.py CHANGED
@@ -3,10 +3,9 @@
3
3
  """Module containing the AlphaFold class and the command line interface."""
4
4
  import argparse
5
5
  from biobb_common.generic.biobb_object import BiobbObject
6
- from biobb_common.configuration import settings
7
- from biobb_common.tools import file_utils as fu
6
+ from biobb_common.configuration import settings
8
7
  from biobb_common.tools.file_utils import launchlogger
9
- from biobb_io.api.common import *
8
+ from biobb_io.api.common import check_output_path, check_mandatory_property, check_uniprot_code, download_af, write_pdb
10
9
 
11
10
 
12
11
  class AlphaFold(BiobbObject):
@@ -26,10 +25,10 @@ class AlphaFold(BiobbObject):
26
25
  This is a use example of how to use the building block from Python::
27
26
 
28
27
  from biobb_io.api.alphafold import alphafold
29
- prop = {
28
+ prop = {
30
29
  'uniprot_code': 'P00489'
31
30
  }
32
- alphafold(output_pdb_path='/path/to/newStructure.pdb',
31
+ alphafold(output_pdb_path='/path/to/newStructure.pdb',
33
32
  properties=prop)
34
33
 
35
34
  Info:
@@ -42,8 +41,8 @@ class AlphaFold(BiobbObject):
42
41
 
43
42
  """
44
43
 
45
- def __init__(self, output_pdb_path,
46
- properties=None, **kwargs) -> None:
44
+ def __init__(self, output_pdb_path,
45
+ properties=None, **kwargs) -> None:
47
46
  properties = properties or {}
48
47
 
49
48
  # Call parent class constructor
@@ -51,8 +50,8 @@ class AlphaFold(BiobbObject):
51
50
  self.locals_var_dict = locals().copy()
52
51
 
53
52
  # Input/Output files
54
- self.io_dict = {
55
- "out": { "output_pdb_path": output_pdb_path }
53
+ self.io_dict = {
54
+ "out": {"output_pdb_path": output_pdb_path}
56
55
  }
57
56
 
58
57
  # Properties specific for BB
@@ -70,13 +69,13 @@ class AlphaFold(BiobbObject):
70
69
  @launchlogger
71
70
  def launch(self) -> int:
72
71
  """Execute the :class:`AlphaFold <api.alphafold.AlphaFold>` api.alphafold.AlphaFold object."""
73
-
72
+
74
73
  # check input/output paths and parameters
75
74
  self.check_data_params(self.out_log, self.err_log)
76
75
 
77
76
  # Setup Biobb
78
- if self.check_restart(): return 0
79
- #self.stage_files()
77
+ if self.check_restart():
78
+ return 0
80
79
 
81
80
  check_mandatory_property(self.uniprot_code, 'uniprot_code', self.out_log, self.__class__.__name__)
82
81
 
@@ -92,12 +91,14 @@ class AlphaFold(BiobbObject):
92
91
 
93
92
  return 0
94
93
 
94
+
95
95
  def alphafold(output_pdb_path: str, properties: dict = None, **kwargs) -> int:
96
96
  """Execute the :class:`AlphaFold <api.alphafold.AlphaFold>` class and
97
97
  execute the :meth:`launch() <api.alphafold.AlphaFold.launch>` method."""
98
98
 
99
99
  return AlphaFold(output_pdb_path=output_pdb_path,
100
- properties=properties, **kwargs).launch()
100
+ properties=properties, **kwargs).launch()
101
+
101
102
 
102
103
  def main():
103
104
  """Command line execution of this building block. Please check the command line documentation."""
@@ -113,8 +114,9 @@ def main():
113
114
  properties = settings.ConfReader(config=config).get_prop_dic()
114
115
 
115
116
  # Specific call of each building block
116
- alphafold(output_pdb_path=args.output_pdb_path,
117
- properties=properties)
117
+ alphafold(output_pdb_path=args.output_pdb_path,
118
+ properties=properties)
119
+
118
120
 
119
121
  if __name__ == '__main__':
120
122
  main()
@@ -2,11 +2,12 @@
2
2
 
3
3
  """Module containing the ApiBindingSite class and the command line interface."""
4
4
  import argparse
5
+ import json
5
6
  from biobb_common.generic.biobb_object import BiobbObject
6
- from biobb_common.configuration import settings
7
+ from biobb_common.configuration import settings
7
8
  from biobb_common.tools import file_utils as fu
8
9
  from biobb_common.tools.file_utils import launchlogger
9
- from biobb_io.api.common import *
10
+ from biobb_io.api.common import check_output_path, check_mandatory_property, download_binding_site, write_json
10
11
 
11
12
 
12
13
  class ApiBindingSite(BiobbObject):
@@ -26,10 +27,10 @@ class ApiBindingSite(BiobbObject):
26
27
  This is a use example of how to use the building block from Python::
27
28
 
28
29
  from biobb_io.api.api_binding_site import api_binding_site
29
- prop = {
30
- 'pdb_code': '4i23'
30
+ prop = {
31
+ 'pdb_code': '4i23'
31
32
  }
32
- api_binding_site(output_json_path='/path/to/newBindingSites.json',
33
+ api_binding_site(output_json_path='/path/to/newBindingSites.json',
33
34
  properties=prop)
34
35
 
35
36
  Info:
@@ -42,8 +43,8 @@ class ApiBindingSite(BiobbObject):
42
43
 
43
44
  """
44
45
 
45
- def __init__(self, output_json_path,
46
- properties=None, **kwargs) -> None:
46
+ def __init__(self, output_json_path,
47
+ properties=None, **kwargs) -> None:
47
48
  properties = properties or {}
48
49
 
49
50
  # Call parent class constructor
@@ -51,8 +52,8 @@ class ApiBindingSite(BiobbObject):
51
52
  self.locals_var_dict = locals().copy()
52
53
 
53
54
  # Input/Output files
54
- self.io_dict = {
55
- "out": { "output_json_path": output_json_path }
55
+ self.io_dict = {
56
+ "out": {"output_json_path": output_json_path}
56
57
  }
57
58
 
58
59
  # Properties specific for BB
@@ -62,7 +63,7 @@ class ApiBindingSite(BiobbObject):
62
63
  # Check the properties
63
64
  self.check_properties(properties)
64
65
  self.check_arguments()
65
-
66
+
66
67
  def check_data_params(self, out_log, err_log):
67
68
  """ Checks all the input/output paths and parameters """
68
69
  self.output_json_path = check_output_path(self.io_dict["out"]["output_json_path"], "output_json_path", False, out_log, self.__class__.__name__)
@@ -75,8 +76,9 @@ class ApiBindingSite(BiobbObject):
75
76
  self.check_data_params(self.out_log, self.err_log)
76
77
 
77
78
  # Setup Biobb
78
- if self.check_restart(): return 0
79
- #self.stage_files()
79
+ if self.check_restart():
80
+ return 0
81
+ # self.stage_files()
80
82
 
81
83
  check_mandatory_property(self.pdb_code, 'pdb_code', self.out_log, self.__class__.__name__)
82
84
 
@@ -96,19 +98,21 @@ class ApiBindingSite(BiobbObject):
96
98
 
97
99
  return 0
98
100
 
101
+
99
102
  def api_binding_site(output_json_path: str, properties: dict = None, **kwargs) -> int:
100
103
  """Execute the :class:`ApiBindingSite <api.api_binding_site.ApiBindingSite>` class and
101
104
  execute the :meth:`launch() <api.api_binding_site.ApiBindingSite.launch>` method."""
102
105
 
103
106
  return ApiBindingSite(output_json_path=output_json_path,
104
- properties=properties, **kwargs).launch()
107
+ properties=properties, **kwargs).launch()
108
+
105
109
 
106
110
  def main():
107
111
  """Command line execution of this building block. Please check the command line documentation."""
108
112
  parser = argparse.ArgumentParser(description="This class is a wrapper for the PDBe REST API Binding Sites endpoint", formatter_class=lambda prog: argparse.RawTextHelpFormatter(prog, width=99999))
109
113
  parser.add_argument('-c', '--config', required=False, help="This file can be a YAML file, JSON file or JSON string")
110
114
 
111
- #Specific args of each building block
115
+ # Specific args of each building block
112
116
  required_args = parser.add_argument_group('required arguments')
113
117
  required_args.add_argument('-o', '--output_json_path', required=True, help="Path to the JSON file with the binding sites for the requested structure. Accepted formats: json.")
114
118
 
@@ -116,9 +120,10 @@ def main():
116
120
  config = args.config if args.config else None
117
121
  properties = settings.ConfReader(config=config).get_prop_dic()
118
122
 
119
- #Specific call of each building block
120
- api_binding_site(output_json_path=args.output_json_path,
121
- properties=properties)
123
+ # Specific call of each building block
124
+ api_binding_site(output_json_path=args.output_json_path,
125
+ properties=properties)
126
+
122
127
 
123
128
  if __name__ == '__main__':
124
129
  main()
@@ -3,10 +3,9 @@
3
3
  """Module containing the CanonicalFasta class and the command line interface."""
4
4
  import argparse
5
5
  from biobb_common.generic.biobb_object import BiobbObject
6
- from biobb_common.configuration import settings
7
- from biobb_common.tools import file_utils as fu
6
+ from biobb_common.configuration import settings
8
7
  from biobb_common.tools.file_utils import launchlogger
9
- from biobb_io.api.common import *
8
+ from biobb_io.api.common import check_output_path, check_mandatory_property, download_fasta, write_fasta
10
9
 
11
10
 
12
11
  class CanonicalFasta(BiobbObject):
@@ -27,11 +26,11 @@ class CanonicalFasta(BiobbObject):
27
26
  This is a use example of how to use the building block from Python::
28
27
 
29
28
  from biobb_io.api.canonical_fasta import canonical_fasta
30
- prop = {
29
+ prop = {
31
30
  'pdb_code': '4i23',
32
31
  'api_id': 'pdb'
33
32
  }
34
- canonical_fasta(output_fasta_path='/path/to/newFasta.fasta',
33
+ canonical_fasta(output_fasta_path='/path/to/newFasta.fasta',
35
34
  properties=prop)
36
35
 
37
36
  Info:
@@ -44,8 +43,8 @@ class CanonicalFasta(BiobbObject):
44
43
 
45
44
  """
46
45
 
47
- def __init__(self, output_fasta_path,
48
- properties=None, **kwargs) -> None:
46
+ def __init__(self, output_fasta_path,
47
+ properties=None, **kwargs) -> None:
49
48
  properties = properties or {}
50
49
 
51
50
  # Call parent class constructor
@@ -53,8 +52,8 @@ class CanonicalFasta(BiobbObject):
53
52
  self.locals_var_dict = locals().copy()
54
53
 
55
54
  # Input/Output files
56
- self.io_dict = {
57
- "out": { "output_fasta_path": output_fasta_path }
55
+ self.io_dict = {
56
+ "out": {"output_fasta_path": output_fasta_path}
58
57
  }
59
58
 
60
59
  # Properties specific for BB
@@ -65,7 +64,7 @@ class CanonicalFasta(BiobbObject):
65
64
  # Check the properties
66
65
  self.check_properties(properties)
67
66
  self.check_arguments()
68
-
67
+
69
68
  def check_data_params(self, out_log, err_log):
70
69
  """ Checks all the input/output paths and parameters """
71
70
  self.output_fasta_path = check_output_path(self.io_dict["out"]["output_fasta_path"], "output_fasta_path", False, out_log, self.__class__.__name__)
@@ -78,8 +77,8 @@ class CanonicalFasta(BiobbObject):
78
77
  self.check_data_params(self.out_log, self.err_log)
79
78
 
80
79
  # Setup Biobb
81
- if self.check_restart(): return 0
82
- #self.stage_files()
80
+ if self.check_restart():
81
+ return 0
83
82
 
84
83
  check_mandatory_property(self.pdb_code, 'pdb_code', self.out_log, self.__class__.__name__)
85
84
 
@@ -93,19 +92,21 @@ class CanonicalFasta(BiobbObject):
93
92
 
94
93
  return 0
95
94
 
95
+
96
96
  def canonical_fasta(output_fasta_path: str, properties: dict = None, **kwargs) -> int:
97
97
  """Execute the :class:`CanonicalFasta <api.canonical_fasta.CanonicalFasta>` class and
98
98
  execute the :meth:`launch() <api.canonical_fasta.CanonicalFasta.launch>` method."""
99
99
 
100
100
  return CanonicalFasta(output_fasta_path=output_fasta_path,
101
- properties=properties, **kwargs).launch()
101
+ properties=properties, **kwargs).launch()
102
+
102
103
 
103
104
  def main():
104
105
  """Command line execution of this building block. Please check the command line documentation."""
105
106
  parser = argparse.ArgumentParser(description="This class is a wrapper for downloading a FASTA structure from the Protein Data Bank.", formatter_class=lambda prog: argparse.RawTextHelpFormatter(prog, width=99999))
106
107
  parser.add_argument('-c', '--config', required=False, help="This file can be a YAML file, JSON file or JSON string")
107
108
 
108
- #Specific args of each building block
109
+ # Specific args of each building block
109
110
  required_args = parser.add_argument_group('required arguments')
110
111
  required_args.add_argument('-o', '--output_fasta_path', required=True, help="Path to the canonical FASTA file. Accepted formats: fasta.")
111
112
 
@@ -113,9 +114,10 @@ def main():
113
114
  config = args.config if args.config else None
114
115
  properties = settings.ConfReader(config=config).get_prop_dic()
115
116
 
116
- #Specific call of each building block
117
- canonical_fasta(output_fasta_path=args.output_fasta_path,
118
- properties=properties)
117
+ # Specific call of each building block
118
+ canonical_fasta(output_fasta_path=args.output_fasta_path,
119
+ properties=properties)
120
+
119
121
 
120
122
  if __name__ == '__main__':
121
123
  main()
biobb_io/api/common.py CHANGED
@@ -7,8 +7,9 @@ import urllib.request
7
7
  from pathlib import Path, PurePath
8
8
  from biobb_common.tools import file_utils as fu
9
9
 
10
+
10
11
  def check_output_path(path, argument, optional, out_log, classname):
11
- """ Checks output file """
12
+ """ Checks output file """
12
13
  if optional and not path:
13
14
  return None
14
15
  if PurePath(path).parent and not Path(PurePath(path).parent).exists():
@@ -20,6 +21,7 @@ def check_output_path(path, argument, optional, out_log, classname):
20
21
  raise SystemExit(classname + ': Format %s in %s file is not compatible' % (file_extension[1:], argument))
21
22
  return path
22
23
 
24
+
23
25
  def is_valid_file(ext, argument):
24
26
  """ Checks if file format is compatible """
25
27
  formats = {
@@ -35,6 +37,7 @@ def is_valid_file(ext, argument):
35
37
  }
36
38
  return ext in formats[argument]
37
39
 
40
+
38
41
  def download_pdb(pdb_code, api_id, out_log=None, global_log=None):
39
42
  """
40
43
  Returns:
@@ -51,6 +54,7 @@ def download_pdb(pdb_code, api_id, out_log=None, global_log=None):
51
54
  fu.log("Downloading %s from: %s" % (pdb_code, url), out_log, global_log)
52
55
  return requests.get(url).content.decode('utf-8')
53
56
 
57
+
54
58
  def download_af(uniprot_code, out_log=None, global_log=None, classname=None):
55
59
  """
56
60
  Returns:
@@ -62,12 +66,13 @@ def download_af(uniprot_code, out_log=None, global_log=None, classname=None):
62
66
  fu.log("Downloading %s from: %s" % (uniprot_code, url), out_log, global_log)
63
67
 
64
68
  r = requests.get(url)
65
- if(r.status_code == 404):
69
+ if (r.status_code == 404):
66
70
  fu.log(classname + ': Incorrect Uniprot Code: %s' % (uniprot_code), out_log)
67
71
  raise SystemExit(classname + ': Incorrect Uniprot Code: %s' % (uniprot_code))
68
72
 
69
73
  return r.content.decode('utf-8')
70
74
 
75
+
71
76
  def download_mmcif(pdb_code, api_id, out_log=None, global_log=None):
72
77
  """
73
78
  Returns:
@@ -84,6 +89,7 @@ def download_mmcif(pdb_code, api_id, out_log=None, global_log=None):
84
89
  fu.log("Downloading %s from: %s" % (pdb_code, url), out_log, global_log)
85
90
  return requests.get(url, verify=False).content.decode('utf-8')
86
91
 
92
+
87
93
  def download_ligand(ligand_code, api_id, out_log=None, global_log=None):
88
94
  """
89
95
  Returns:
@@ -94,16 +100,17 @@ def download_ligand(ligand_code, api_id, out_log=None, global_log=None):
94
100
  url = "http://mmb.irbbarcelona.org/api/pdbMonomer/" + ligand_code.lower()
95
101
  text = requests.get(url, verify=False).content.decode('utf-8')
96
102
  elif api_id == 'pdbe':
97
- url="ftp://ftp.ebi.ac.uk/pub/databases/msd/pdbechem_v2/{0}/{1}/{1}_ideal.pdb".format(ligand_code.upper()[0], ligand_code.upper(), ligand_code.upper())
103
+ url = "https://www.ebi.ac.uk/pdbe/static/files/pdbechem_v2/" + ligand_code.upper() + "_ideal.pdb"
98
104
  text = urllib.request.urlopen(url).read().decode('utf-8')
99
105
 
100
106
  fu.log("Downloading %s from: %s" % (ligand_code, url), out_log, global_log)
101
107
 
102
108
  # removing useless empty lines at the end of the file
103
109
  text = os.linesep.join([s for s in text.splitlines() if s])
104
-
110
+
105
111
  return text
106
112
 
113
+
107
114
  def download_fasta(pdb_code, api_id, out_log=None, global_log=None):
108
115
  """
109
116
  Returns:
@@ -120,6 +127,7 @@ def download_fasta(pdb_code, api_id, out_log=None, global_log=None):
120
127
  fu.log("Downloading %s from: %s" % (pdb_code, url), out_log, global_log)
121
128
  return requests.get(url, verify=False).content.decode('utf-8')
122
129
 
130
+
123
131
  def download_drugbank(drugbank_id, url="https://www.drugbank.ca/structures/small_molecule_drugs/%s.sdf?type=3d", out_log=None, global_log=None):
124
132
  """
125
133
  Returns:
@@ -130,9 +138,10 @@ def download_drugbank(drugbank_id, url="https://www.drugbank.ca/structures/small
130
138
  fu.log("Downloading %s from: %s" % (drugbank_id, url), out_log, global_log)
131
139
 
132
140
  text = requests.get(url, verify=False).content.decode('utf-8')
133
-
141
+
134
142
  return text
135
143
 
144
+
136
145
  def download_binding_site(pdb_code, url="https://www.ebi.ac.uk/pdbe/api/pdb/entry/binding_sites/%s", out_log=None, global_log=None):
137
146
  """
138
147
  Returns:
@@ -145,10 +154,11 @@ def download_binding_site(pdb_code, url="https://www.ebi.ac.uk/pdbe/api/pdb/entr
145
154
  text = urllib.request.urlopen(url).read()
146
155
  json_obj = json.loads(text)
147
156
  json_string = json.dumps(json_obj, indent=4, sort_keys=True)
148
- #json_string = json.dumps(text, indent=4)
149
-
157
+ # json_string = json.dumps(text, indent=4)
158
+
150
159
  return json_string
151
160
 
161
+
152
162
  def download_ideal_sdf(ligand_code, api_id, out_log=None, global_log=None):
153
163
  """
154
164
  Returns:
@@ -156,16 +166,17 @@ def download_ideal_sdf(ligand_code, api_id, out_log=None, global_log=None):
156
166
  """
157
167
 
158
168
  if api_id == 'pdb':
159
- url = "https://files.rcsb.org/ligands/view/" + ligand_code.upper() + "_ideal.sdf"
169
+ url = "https://files.rcsb.org/ligands/download/" + ligand_code.upper() + "_ideal.sdf"
160
170
  text = requests.get(url, verify=False).content.decode('utf-8')
161
171
  elif api_id == 'pdbe':
162
- url="ftp://ftp.ebi.ac.uk/pub/databases/msd/pdbechem_v2/{0}/{1}/{1}_ideal.sdf".format(ligand_code.upper()[0], ligand_code.upper(), ligand_code.upper())
172
+ url = "https://www.ebi.ac.uk/pdbe/static/files/pdbechem_v2/" + ligand_code.upper() + "_ideal.sdf"
163
173
  text = urllib.request.urlopen(url).read().decode('utf-8')
164
174
 
165
175
  fu.log("Downloading %s from: %s" % (ligand_code, url), out_log, global_log)
166
-
176
+
167
177
  return text
168
178
 
179
+
169
180
  def download_str_info(pdb_code, url="http://mmb.irbbarcelona.org/api/pdb/%s.json", out_log=None, global_log=None):
170
181
  """
171
182
  Returns:
@@ -178,10 +189,11 @@ def download_str_info(pdb_code, url="http://mmb.irbbarcelona.org/api/pdb/%s.json
178
189
  text = urllib.request.urlopen(url).read()
179
190
  json_obj = json.loads(text)
180
191
  json_string = json.dumps(json_obj, indent=4, sort_keys=True)
181
- #json_string = json.dumps(text, indent=4)
182
-
192
+ # json_string = json.dumps(text, indent=4)
193
+
183
194
  return json_string
184
195
 
196
+
185
197
  def write_pdb(pdb_string, output_pdb_path, filt=None, out_log=None, global_log=None):
186
198
  """ Writes and filters a PDB """
187
199
  fu.log("Writting pdb to: %s" % (output_pdb_path), out_log, global_log)
@@ -194,30 +206,34 @@ def write_pdb(pdb_string, output_pdb_path, filt=None, out_log=None, global_log=N
194
206
  else:
195
207
  output_pdb_file.write(pdb_string)
196
208
 
209
+
197
210
  def write_mmcif(mmcif_string, output_mmcif_path, out_log=None, global_log=None):
198
211
  """ Writes a mmcif """
199
212
  fu.log("Writting mmcif to: %s" % (output_mmcif_path), out_log, global_log)
200
213
  with open(output_mmcif_path, 'w') as output_mmcif_file:
201
214
  output_mmcif_file.write(mmcif_string)
202
215
 
216
+
203
217
  def write_fasta(fasta_string, output_fasta_path, out_log=None, global_log=None):
204
218
  """ Writes a FASTA """
205
219
  fu.log("Writting FASTA to: %s" % (output_fasta_path), out_log, global_log)
206
220
  with open(output_fasta_path, 'w') as output_fasta_file:
207
221
  output_fasta_file.write(fasta_string)
208
222
 
223
+
209
224
  def write_sdf(sdf_string, output_sdf_path, out_log=None, global_log=None):
210
225
  """ Writes a SDF """
211
226
  fu.log("Writting sdf to: %s" % (output_sdf_path), out_log, global_log)
212
227
  with open(output_sdf_path, 'w') as output_sdf_file:
213
228
  output_sdf_file.write(sdf_string)
214
229
 
230
+
215
231
  def get_cluster_pdb_codes(pdb_code, cluster, out_log=None, global_log=None):
216
232
  """
217
233
  Returns:
218
234
  String list: The list of pdb_codes of the selected cluster.
219
235
  """
220
- url="http://mmb.irbbarcelona.org/api/pdb/"
236
+ url = "http://mmb.irbbarcelona.org/api/pdb/"
221
237
  pdb_codes = set()
222
238
 
223
239
  url = url+pdb_code.lower()+'/clusters/cl-'+str(cluster)+".json"
@@ -232,6 +248,7 @@ def get_cluster_pdb_codes(pdb_code, cluster, out_log=None, global_log=None):
232
248
 
233
249
  return pdb_codes
234
250
 
251
+
235
252
  def get_uniprot(pdb_code, url, out_log=None, global_log=None):
236
253
  """Returns the UNIPROT code corresponding to the `pdb_code`.
237
254
 
@@ -248,6 +265,7 @@ def get_uniprot(pdb_code, url, out_log=None, global_log=None):
248
265
 
249
266
  return uniprot_id
250
267
 
268
+
251
269
  def get_variants(uniprot_id, url="http://mmb.irbbarcelona.org/api", out_log=None, global_log=None):
252
270
  """Returns the variants of the `uniprot_id` code.
253
271
 
@@ -261,12 +279,14 @@ def get_variants(uniprot_id, url="http://mmb.irbbarcelona.org/api", out_log=None
261
279
  fu.log('Found: %d variants for uniprot id: %s' % (len(variants), uniprot_id), out_log, global_log)
262
280
  return variants if variants else []
263
281
 
282
+
264
283
  def write_json(json_string, output_json_path, out_log=None, global_log=None):
265
284
  """ Writes a JSON """
266
285
  fu.log("Writting json to: %s" % (output_json_path), out_log, global_log)
267
286
  with open(output_json_path, 'w') as output_json_file:
268
287
  output_json_file.write(json_string)
269
288
 
289
+
270
290
  def get_memprotmd_sim_list(out_log=None, global_log=None):
271
291
  """ Returns all available membrane-protein systems (simulations) from the MemProtMD DB using its REST API """
272
292
 
@@ -280,6 +300,7 @@ def get_memprotmd_sim_list(out_log=None, global_log=None):
280
300
 
281
301
  return json_string
282
302
 
303
+
283
304
  def get_memprotmd_sim_search(collection_name, keyword, out_log=None, global_log=None):
284
305
  """ Performs advanced searches in the MemProtMD DB using its REST API and a given keyword """
285
306
 
@@ -287,14 +308,14 @@ def get_memprotmd_sim_search(collection_name, keyword, out_log=None, global_log=
287
308
 
288
309
  url = "http://memprotmd.bioch.ox.ac.uk/api/search/advanced"
289
310
  json_query = {
290
- "collectionName" : collection_name,
291
- "query" : {
292
- "keywords" : keyword
311
+ "collectionName": collection_name,
312
+ "query": {
313
+ "keywords": keyword
293
314
  },
294
- "projection" : {
295
- "simulations" : 1
315
+ "projection": {
316
+ "simulations": 1
296
317
  },
297
- "options" : {}
318
+ "options": {}
298
319
  }
299
320
 
300
321
  json_obj = requests.post(url, json=json_query).json()
@@ -310,18 +331,20 @@ def get_memprotmd_sim_search(collection_name, keyword, out_log=None, global_log=
310
331
 
311
332
  return json_string
312
333
 
334
+
313
335
  def get_memprotmd_sim(pdb_code, output_file, out_log=None, global_log=None):
314
336
  """ Gets a single simulation from MemProtMD DB """
315
337
 
316
338
  fu.log('Getting simulation file from pdb code %s' % (pdb_code), out_log, global_log)
317
339
 
318
- url = "http://memprotmd.bioch.ox.ac.uk/data/memprotmd/simulations/"+ pdb_code + "_default_dppc/files/run/at.zip"
340
+ url = "http://memprotmd.bioch.ox.ac.uk/data/memprotmd/simulations/" + pdb_code + "_default_dppc/files/run/at.zip"
319
341
  response = requests.get(url)
320
342
 
321
343
  open(output_file, 'wb').write(response.content)
322
-
344
+
323
345
  fu.log("Saving output %s file" % (output_file), out_log, global_log)
324
346
 
347
+
325
348
  def check_mandatory_property(property, name, out_log, classname):
326
349
  """ Checks mandatory properties """
327
350
 
@@ -330,6 +353,7 @@ def check_mandatory_property(property, name, out_log, classname):
330
353
  raise SystemExit(classname + ': Unexisting %s property' % name)
331
354
  return property
332
355
 
356
+
333
357
  def check_uniprot_code(code, out_log, classname):
334
358
  """ Checks uniprot code """
335
359
 
@@ -339,4 +363,4 @@ def check_uniprot_code(code, out_log, classname):
339
363
  fu.log(classname + ': Incorrect uniprot code for %s' % code, out_log)
340
364
  raise SystemExit(classname + ': Incorrect uniprot code for %s' % code)
341
365
 
342
- return True
366
+ return True