biobb-io 5.0.1__py3-none-any.whl → 5.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 +1 -1
- biobb_io/api/__init__.py +2 -0
- biobb_io/api/alphafold.py +3 -36
- biobb_io/api/api_binding_site.py +3 -36
- biobb_io/api/canonical_fasta.py +3 -36
- biobb_io/api/common.py +72 -29
- biobb_io/api/ideal_sdf.py +3 -36
- biobb_io/api/ligand.py +6 -39
- biobb_io/api/mddb.py +175 -0
- biobb_io/api/memprotmd_sim.py +3 -36
- biobb_io/api/memprotmd_sim_list.py +3 -39
- biobb_io/api/memprotmd_sim_search.py +3 -38
- biobb_io/api/mmcif.py +3 -36
- biobb_io/api/pdb.py +3 -36
- biobb_io/api/pdb_cluster_zip.py +4 -37
- biobb_io/api/pdb_variants.py +6 -47
- biobb_io/api/structure_info.py +3 -36
- {biobb_io-5.0.1.dist-info → biobb_io-5.1.1.dist-info}/METADATA +25 -13
- biobb_io-5.1.1.dist-info/RECORD +25 -0
- {biobb_io-5.0.1.dist-info → biobb_io-5.1.1.dist-info}/WHEEL +1 -1
- {biobb_io-5.0.1.dist-info → biobb_io-5.1.1.dist-info}/entry_points.txt +1 -0
- biobb_io-5.0.1.dist-info/RECORD +0 -24
- {biobb_io-5.0.1.dist-info → biobb_io-5.1.1.dist-info/licenses}/LICENSE +0 -0
- {biobb_io-5.0.1.dist-info → biobb_io-5.1.1.dist-info}/top_level.txt +0 -0
biobb_io/__init__.py
CHANGED
biobb_io/api/__init__.py
CHANGED
biobb_io/api/alphafold.py
CHANGED
|
@@ -2,10 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
"""Module containing the AlphaFold class and the command line interface."""
|
|
4
4
|
|
|
5
|
-
import argparse
|
|
6
5
|
from typing import Optional
|
|
7
|
-
|
|
8
|
-
from biobb_common.configuration import settings
|
|
9
6
|
from biobb_common.generic.biobb_object import BiobbObject
|
|
10
7
|
from biobb_common.tools.file_utils import launchlogger
|
|
11
8
|
|
|
@@ -113,41 +110,11 @@ class AlphaFold(BiobbObject):
|
|
|
113
110
|
def alphafold(output_pdb_path: str, properties: Optional[dict] = None, **kwargs) -> int:
|
|
114
111
|
"""Execute the :class:`AlphaFold <api.alphafold.AlphaFold>` class and
|
|
115
112
|
execute the :meth:`launch() <api.alphafold.AlphaFold.launch>` method."""
|
|
113
|
+
return AlphaFold(**dict(locals())).launch()
|
|
116
114
|
|
|
117
|
-
return AlphaFold(
|
|
118
|
-
output_pdb_path=output_pdb_path, properties=properties, **kwargs
|
|
119
|
-
).launch()
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
def main():
|
|
123
|
-
"""Command line execution of this building block. Please check the command line documentation."""
|
|
124
|
-
parser = argparse.ArgumentParser(
|
|
125
|
-
description="This class is a wrapper for downloading a PDB structure from the Protein Data Bank.",
|
|
126
|
-
formatter_class=lambda prog: argparse.RawTextHelpFormatter(prog, width=99999),
|
|
127
|
-
)
|
|
128
|
-
parser.add_argument(
|
|
129
|
-
"-c",
|
|
130
|
-
"--config",
|
|
131
|
-
required=False,
|
|
132
|
-
help="This file can be a YAML file, JSON file or JSON string",
|
|
133
|
-
)
|
|
134
|
-
|
|
135
|
-
# Specific args of each building block
|
|
136
|
-
required_args = parser.add_argument_group("required arguments")
|
|
137
|
-
required_args.add_argument(
|
|
138
|
-
"-o",
|
|
139
|
-
"--output_pdb_path",
|
|
140
|
-
required=True,
|
|
141
|
-
help="Path to the output PDB file. Accepted formats: pdb.",
|
|
142
|
-
)
|
|
143
|
-
|
|
144
|
-
args = parser.parse_args()
|
|
145
|
-
config = args.config if args.config else None
|
|
146
|
-
properties = settings.ConfReader(config=config).get_prop_dic()
|
|
147
|
-
|
|
148
|
-
# Specific call of each building block
|
|
149
|
-
alphafold(output_pdb_path=args.output_pdb_path, properties=properties)
|
|
150
115
|
|
|
116
|
+
alphafold.__doc__ = AlphaFold.__doc__
|
|
117
|
+
main = AlphaFold.get_main(alphafold, "This class is a wrapper for downloading a PDB structure from the Protein Data Bank.")
|
|
151
118
|
|
|
152
119
|
if __name__ == "__main__":
|
|
153
120
|
main()
|
biobb_io/api/api_binding_site.py
CHANGED
|
@@ -2,11 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
"""Module containing the ApiBindingSite class and the command line interface."""
|
|
4
4
|
|
|
5
|
-
import argparse
|
|
6
5
|
import json
|
|
7
6
|
from typing import Optional
|
|
8
|
-
|
|
9
|
-
from biobb_common.configuration import settings
|
|
10
7
|
from biobb_common.generic.biobb_object import BiobbObject
|
|
11
8
|
from biobb_common.tools import file_utils as fu
|
|
12
9
|
from biobb_common.tools.file_utils import launchlogger
|
|
@@ -125,41 +122,11 @@ def api_binding_site(
|
|
|
125
122
|
) -> int:
|
|
126
123
|
"""Execute the :class:`ApiBindingSite <api.api_binding_site.ApiBindingSite>` class and
|
|
127
124
|
execute the :meth:`launch() <api.api_binding_site.ApiBindingSite.launch>` method."""
|
|
125
|
+
return ApiBindingSite(**dict(locals())).launch()
|
|
128
126
|
|
|
129
|
-
return ApiBindingSite(
|
|
130
|
-
output_json_path=output_json_path, properties=properties, **kwargs
|
|
131
|
-
).launch()
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
def main():
|
|
135
|
-
"""Command line execution of this building block. Please check the command line documentation."""
|
|
136
|
-
parser = argparse.ArgumentParser(
|
|
137
|
-
description="This class is a wrapper for the PDBe REST API Binding Sites endpoint",
|
|
138
|
-
formatter_class=lambda prog: argparse.RawTextHelpFormatter(prog, width=99999),
|
|
139
|
-
)
|
|
140
|
-
parser.add_argument(
|
|
141
|
-
"-c",
|
|
142
|
-
"--config",
|
|
143
|
-
required=False,
|
|
144
|
-
help="This file can be a YAML file, JSON file or JSON string",
|
|
145
|
-
)
|
|
146
|
-
|
|
147
|
-
# Specific args of each building block
|
|
148
|
-
required_args = parser.add_argument_group("required arguments")
|
|
149
|
-
required_args.add_argument(
|
|
150
|
-
"-o",
|
|
151
|
-
"--output_json_path",
|
|
152
|
-
required=True,
|
|
153
|
-
help="Path to the JSON file with the binding sites for the requested structure. Accepted formats: json.",
|
|
154
|
-
)
|
|
155
|
-
|
|
156
|
-
args = parser.parse_args()
|
|
157
|
-
config = args.config if args.config else None
|
|
158
|
-
properties = settings.ConfReader(config=config).get_prop_dic()
|
|
159
|
-
|
|
160
|
-
# Specific call of each building block
|
|
161
|
-
api_binding_site(output_json_path=args.output_json_path, properties=properties)
|
|
162
127
|
|
|
128
|
+
api_binding_site.__doc__ = ApiBindingSite.__doc__
|
|
129
|
+
main = ApiBindingSite.get_main(api_binding_site, "This class is a wrapper for the PDBe REST API Binding Sites endpoint")
|
|
163
130
|
|
|
164
131
|
if __name__ == "__main__":
|
|
165
132
|
main()
|
biobb_io/api/canonical_fasta.py
CHANGED
|
@@ -2,10 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
"""Module containing the CanonicalFasta class and the command line interface."""
|
|
4
4
|
|
|
5
|
-
import argparse
|
|
6
5
|
from typing import Optional
|
|
7
|
-
|
|
8
|
-
from biobb_common.configuration import settings
|
|
9
6
|
from biobb_common.generic.biobb_object import BiobbObject
|
|
10
7
|
from biobb_common.tools.file_utils import launchlogger
|
|
11
8
|
|
|
@@ -115,41 +112,11 @@ def canonical_fasta(
|
|
|
115
112
|
) -> int:
|
|
116
113
|
"""Execute the :class:`CanonicalFasta <api.canonical_fasta.CanonicalFasta>` class and
|
|
117
114
|
execute the :meth:`launch() <api.canonical_fasta.CanonicalFasta.launch>` method."""
|
|
115
|
+
return CanonicalFasta(**dict(locals())).launch()
|
|
118
116
|
|
|
119
|
-
return CanonicalFasta(
|
|
120
|
-
output_fasta_path=output_fasta_path, properties=properties, **kwargs
|
|
121
|
-
).launch()
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
def main():
|
|
125
|
-
"""Command line execution of this building block. Please check the command line documentation."""
|
|
126
|
-
parser = argparse.ArgumentParser(
|
|
127
|
-
description="This class is a wrapper for downloading a FASTA structure from the Protein Data Bank.",
|
|
128
|
-
formatter_class=lambda prog: argparse.RawTextHelpFormatter(prog, width=99999),
|
|
129
|
-
)
|
|
130
|
-
parser.add_argument(
|
|
131
|
-
"-c",
|
|
132
|
-
"--config",
|
|
133
|
-
required=False,
|
|
134
|
-
help="This file can be a YAML file, JSON file or JSON string",
|
|
135
|
-
)
|
|
136
|
-
|
|
137
|
-
# Specific args of each building block
|
|
138
|
-
required_args = parser.add_argument_group("required arguments")
|
|
139
|
-
required_args.add_argument(
|
|
140
|
-
"-o",
|
|
141
|
-
"--output_fasta_path",
|
|
142
|
-
required=True,
|
|
143
|
-
help="Path to the canonical FASTA file. Accepted formats: fasta.",
|
|
144
|
-
)
|
|
145
|
-
|
|
146
|
-
args = parser.parse_args()
|
|
147
|
-
config = args.config if args.config else None
|
|
148
|
-
properties = settings.ConfReader(config=config).get_prop_dic()
|
|
149
|
-
|
|
150
|
-
# Specific call of each building block
|
|
151
|
-
canonical_fasta(output_fasta_path=args.output_fasta_path, properties=properties)
|
|
152
117
|
|
|
118
|
+
canonical_fasta.__doc__ = CanonicalFasta.__doc__
|
|
119
|
+
main = CanonicalFasta.get_main(canonical_fasta, "This class is a wrapper for downloading a FASTA structure from the Protein Data Bank.")
|
|
153
120
|
|
|
154
121
|
if __name__ == "__main__":
|
|
155
122
|
main()
|
biobb_io/api/common.py
CHANGED
|
@@ -4,6 +4,7 @@ import json
|
|
|
4
4
|
import os
|
|
5
5
|
import re
|
|
6
6
|
import urllib.request
|
|
7
|
+
import urllib.parse
|
|
7
8
|
from pathlib import Path, PurePath
|
|
8
9
|
|
|
9
10
|
import requests
|
|
@@ -20,14 +21,12 @@ def check_output_path(path, argument, optional, out_log, classname) -> str:
|
|
|
20
21
|
file_extension = PurePath(path).suffix
|
|
21
22
|
if not is_valid_file(file_extension[1:], argument):
|
|
22
23
|
fu.log(
|
|
23
|
-
classname
|
|
24
|
-
+ ": Format %s in %s file is not compatible"
|
|
24
|
+
classname + ": Format %s in %s file is not compatible"
|
|
25
25
|
% (file_extension[1:], argument),
|
|
26
26
|
out_log,
|
|
27
27
|
)
|
|
28
28
|
raise SystemExit(
|
|
29
|
-
classname
|
|
30
|
-
+ ": Format %s in %s file is not compatible"
|
|
29
|
+
classname + ": Format %s in %s file is not compatible"
|
|
31
30
|
% (file_extension[1:], argument)
|
|
32
31
|
)
|
|
33
32
|
return path
|
|
@@ -45,6 +44,8 @@ def is_valid_file(ext, argument):
|
|
|
45
44
|
"output_json_path": ["json"],
|
|
46
45
|
"output_fasta_path": ["fasta"],
|
|
47
46
|
"output_mmcif_path": ["mmcif", "cif"],
|
|
47
|
+
"output_top_path": ["pdb"],
|
|
48
|
+
"output_trj_path": ["mdcrd", "trr", "xtc"]
|
|
48
49
|
}
|
|
49
50
|
return ext in formats[argument]
|
|
50
51
|
|
|
@@ -84,6 +85,60 @@ def download_af(uniprot_code, out_log=None, global_log=None, classname=None):
|
|
|
84
85
|
return r.content.decode("utf-8")
|
|
85
86
|
|
|
86
87
|
|
|
88
|
+
def download_mddb_top(project_id, node_id, selection, out_log=None, global_log=None, classname=None):
|
|
89
|
+
"""
|
|
90
|
+
Returns:
|
|
91
|
+
String: Content of the pdb file.
|
|
92
|
+
"""
|
|
93
|
+
|
|
94
|
+
url = "https://" + node_id + ".mddbr.eu/api/rest/v1/projects/" + project_id + "/structure?selection=" + urllib.parse.quote(str(selection))
|
|
95
|
+
|
|
96
|
+
fu.log("Downloading %s topology from: %s" % (project_id, url), out_log, global_log)
|
|
97
|
+
|
|
98
|
+
r = requests.get(url)
|
|
99
|
+
if r.status_code == 404:
|
|
100
|
+
fu.log(classname + ": Incorrect url, check project_id, node_id and selection: %s" % (url), out_log)
|
|
101
|
+
raise SystemExit(classname + ": Incorrect url, check project_id, node_id and selection: %s" % (url))
|
|
102
|
+
|
|
103
|
+
return r.content.decode("utf-8")
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def download_mddb_trj(project_id, node_id, trj_format, frames, selection, out_log=None, global_log=None, classname=None):
|
|
107
|
+
"""
|
|
108
|
+
Returns:
|
|
109
|
+
String: Content of the trajectory file.
|
|
110
|
+
"""
|
|
111
|
+
|
|
112
|
+
url = "https://" + node_id + ".mddbr.eu/api/rest/v1/projects/" + project_id + "/trajectory?format=" + trj_format + "&frames=" + frames + "&selection=" + urllib.parse.quote(str(selection))
|
|
113
|
+
|
|
114
|
+
fu.log("Downloading %s trajectory from: %s" % (project_id, url), out_log, global_log)
|
|
115
|
+
|
|
116
|
+
r = requests.get(url)
|
|
117
|
+
if r.status_code == 404:
|
|
118
|
+
fu.log(classname + ": Incorrect url, check project_id, node_id, trj_format, frames and selection: %s" % (url), out_log)
|
|
119
|
+
raise SystemExit(classname + ": Incorrect url, check project_id, node_id, trj_format, frames and selection: %s" % (url))
|
|
120
|
+
|
|
121
|
+
return r.content
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def download_mddb_file(project_id, node_id, file_name, out_log=None, global_log=None, classname=None):
|
|
125
|
+
"""
|
|
126
|
+
Returns:
|
|
127
|
+
String: Content of the trajectory file.
|
|
128
|
+
"""
|
|
129
|
+
|
|
130
|
+
url = "https://" + node_id + ".mddbr.eu/api/rest/v1/projects/" + project_id + "/files/" + file_name
|
|
131
|
+
|
|
132
|
+
fu.log("Downloading %s file from: %s" % (project_id, url), out_log, global_log)
|
|
133
|
+
|
|
134
|
+
r = requests.get(url)
|
|
135
|
+
if r.status_code == 404:
|
|
136
|
+
fu.log(classname + ": Incorrect url, check project_id, node_id, trj_format, frames and selection: %s" % (url), out_log)
|
|
137
|
+
raise SystemExit(classname + ": Incorrect url, check project_id, node_id, trj_format, frames and selection: %s" % (url))
|
|
138
|
+
|
|
139
|
+
return r.content
|
|
140
|
+
|
|
141
|
+
|
|
87
142
|
def download_mmcif(pdb_code, api_id, out_log=None, global_log=None):
|
|
88
143
|
"""
|
|
89
144
|
Returns:
|
|
@@ -112,9 +167,7 @@ def download_ligand(ligand_code, api_id, out_log=None, global_log=None):
|
|
|
112
167
|
text = requests.get(url, verify=True).content.decode("utf-8")
|
|
113
168
|
elif api_id == "pdbe":
|
|
114
169
|
url = (
|
|
115
|
-
"https://www.ebi.ac.uk/pdbe/static/files/pdbechem_v2/"
|
|
116
|
-
+ ligand_code.upper()
|
|
117
|
-
+ "_ideal.pdb"
|
|
170
|
+
"https://www.ebi.ac.uk/pdbe/static/files/pdbechem_v2/" + ligand_code.upper() + "_ideal.pdb"
|
|
118
171
|
)
|
|
119
172
|
text = urllib.request.urlopen(url).read().decode("utf-8")
|
|
120
173
|
|
|
@@ -173,16 +226,12 @@ def download_ideal_sdf(ligand_code, api_id, out_log=None, global_log=None):
|
|
|
173
226
|
|
|
174
227
|
if api_id == "pdb":
|
|
175
228
|
url = (
|
|
176
|
-
"https://files.rcsb.org/ligands/download/"
|
|
177
|
-
+ ligand_code.upper()
|
|
178
|
-
+ "_ideal.sdf"
|
|
229
|
+
"https://files.rcsb.org/ligands/download/" + ligand_code.upper() + "_ideal.sdf"
|
|
179
230
|
)
|
|
180
231
|
text = requests.get(url, verify=True).content.decode("utf-8")
|
|
181
232
|
elif api_id == "pdbe":
|
|
182
233
|
url = (
|
|
183
|
-
"https://www.ebi.ac.uk/pdbe/static/files/pdbechem_v2/"
|
|
184
|
-
+ ligand_code.upper()
|
|
185
|
-
+ "_ideal.sdf"
|
|
234
|
+
"https://www.ebi.ac.uk/pdbe/static/files/pdbechem_v2/" + ligand_code.upper() + "_ideal.sdf"
|
|
186
235
|
)
|
|
187
236
|
text = urllib.request.urlopen(url).read().decode("utf-8")
|
|
188
237
|
|
|
@@ -230,6 +279,13 @@ def write_pdb(pdb_string, output_pdb_path, filt=None, out_log=None, global_log=N
|
|
|
230
279
|
output_pdb_file.write(pdb_string)
|
|
231
280
|
|
|
232
281
|
|
|
282
|
+
def write_bin(bin_string, output_bin_path, out_log=None, global_log=None):
|
|
283
|
+
"""Writes a BIN"""
|
|
284
|
+
fu.log("Writting bin to: %s" % (output_bin_path), out_log, global_log)
|
|
285
|
+
with open(output_bin_path, "wb") as output_bin_file:
|
|
286
|
+
output_bin_file.write(bin_string)
|
|
287
|
+
|
|
288
|
+
|
|
233
289
|
def write_mmcif(mmcif_string, output_mmcif_path, out_log=None, global_log=None):
|
|
234
290
|
"""Writes a mmcif"""
|
|
235
291
|
fu.log("Writting mmcif to: %s" % (output_mmcif_path), out_log, global_log)
|
|
@@ -268,22 +324,11 @@ def get_cluster_pdb_codes(pdb_code, cluster, out_log=None, global_log=None):
|
|
|
268
324
|
|
|
269
325
|
if out_log:
|
|
270
326
|
out_log.info(
|
|
271
|
-
"Cluster: "
|
|
272
|
-
+ str(cluster)
|
|
273
|
-
+ " of pdb_code: "
|
|
274
|
-
+ pdb_code
|
|
275
|
-
+ "\n List: "
|
|
276
|
-
+ str(pdb_codes)
|
|
327
|
+
"Cluster: " + str(cluster) + " of pdb_code: " + pdb_code + "\n List: " + str(pdb_codes)
|
|
277
328
|
)
|
|
278
329
|
if global_log:
|
|
279
330
|
global_log.info(
|
|
280
|
-
fu.get_logs_prefix()
|
|
281
|
-
+ "Cluster: "
|
|
282
|
-
+ str(cluster)
|
|
283
|
-
+ " of pdb_code: "
|
|
284
|
-
+ pdb_code
|
|
285
|
-
+ "\n List: "
|
|
286
|
-
+ str(pdb_codes)
|
|
331
|
+
fu.get_logs_prefix() + "Cluster: " + str(cluster) + " of pdb_code: " + pdb_code + "\n List: " + str(pdb_codes)
|
|
287
332
|
)
|
|
288
333
|
|
|
289
334
|
return pdb_codes
|
|
@@ -395,9 +440,7 @@ def get_memprotmd_sim(pdb_code, output_file, out_log=None, global_log=None):
|
|
|
395
440
|
fu.log("Getting simulation file from pdb code %s" % (pdb_code), out_log, global_log)
|
|
396
441
|
|
|
397
442
|
url = (
|
|
398
|
-
"http://memprotmd.bioch.ox.ac.uk/data/memprotmd/simulations/"
|
|
399
|
-
+ pdb_code
|
|
400
|
-
+ "_default_dppc/files/run/at.zip"
|
|
443
|
+
"http://memprotmd.bioch.ox.ac.uk/data/memprotmd/simulations/" + pdb_code + "_default_dppc/files/run/at.zip"
|
|
401
444
|
)
|
|
402
445
|
response = requests.get(url)
|
|
403
446
|
|
biobb_io/api/ideal_sdf.py
CHANGED
|
@@ -2,10 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
"""Module containing the IdealSdf class and the command line interface."""
|
|
4
4
|
|
|
5
|
-
import argparse
|
|
6
5
|
from typing import Optional
|
|
7
|
-
|
|
8
|
-
from biobb_common.configuration import settings
|
|
9
6
|
from biobb_common.generic.biobb_object import BiobbObject
|
|
10
7
|
from biobb_common.tools.file_utils import launchlogger
|
|
11
8
|
|
|
@@ -113,41 +110,11 @@ class IdealSdf(BiobbObject):
|
|
|
113
110
|
def ideal_sdf(output_sdf_path: str, properties: Optional[dict] = None, **kwargs) -> int:
|
|
114
111
|
"""Execute the :class:`IdealSdf <api.ideal_sdf.IdealSdf>` class and
|
|
115
112
|
execute the :meth:`launch() <api.ideal_sdf.IdealSdf.launch>` method."""
|
|
113
|
+
return IdealSdf(**dict(locals())).launch()
|
|
116
114
|
|
|
117
|
-
return IdealSdf(
|
|
118
|
-
output_sdf_path=output_sdf_path, properties=properties, **kwargs
|
|
119
|
-
).launch()
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
def main():
|
|
123
|
-
"""Command line execution of this building block. Please check the command line documentation."""
|
|
124
|
-
parser = argparse.ArgumentParser(
|
|
125
|
-
description="This class is a wrapper for downloading an ideal SDF ligand from the Protein Data Bank.",
|
|
126
|
-
formatter_class=lambda prog: argparse.RawTextHelpFormatter(prog, width=99999),
|
|
127
|
-
)
|
|
128
|
-
parser.add_argument(
|
|
129
|
-
"-c",
|
|
130
|
-
"--config",
|
|
131
|
-
required=False,
|
|
132
|
-
help="This file can be a YAML file, JSON file or JSON string",
|
|
133
|
-
)
|
|
134
|
-
|
|
135
|
-
# Specific args of each building block
|
|
136
|
-
required_args = parser.add_argument_group("required arguments")
|
|
137
|
-
required_args.add_argument(
|
|
138
|
-
"-o",
|
|
139
|
-
"--output_sdf_path",
|
|
140
|
-
required=True,
|
|
141
|
-
help="Path to the output SDF file. Accepted formats: sdf.",
|
|
142
|
-
)
|
|
143
|
-
|
|
144
|
-
args = parser.parse_args()
|
|
145
|
-
config = args.config if args.config else None
|
|
146
|
-
properties = settings.ConfReader(config=config).get_prop_dic()
|
|
147
|
-
|
|
148
|
-
# Specific call of each building block
|
|
149
|
-
ideal_sdf(output_sdf_path=args.output_sdf_path, properties=properties)
|
|
150
115
|
|
|
116
|
+
ideal_sdf.__doc__ = IdealSdf.__doc__
|
|
117
|
+
main = IdealSdf.get_main(ideal_sdf, "This class is a wrapper for downloading an ideal SDF ligand from the Protein Data Bank.")
|
|
151
118
|
|
|
152
119
|
if __name__ == "__main__":
|
|
153
120
|
main()
|
biobb_io/api/ligand.py
CHANGED
|
@@ -2,10 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
"""Module containing the Ligand class and the command line interface."""
|
|
4
4
|
|
|
5
|
-
import argparse
|
|
6
5
|
from typing import Optional
|
|
7
|
-
|
|
8
|
-
from biobb_common.configuration import settings
|
|
9
6
|
from biobb_common.generic.biobb_object import BiobbObject
|
|
10
7
|
from biobb_common.tools.file_utils import launchlogger
|
|
11
8
|
|
|
@@ -27,7 +24,7 @@ class Ligand(BiobbObject):
|
|
|
27
24
|
output_pdb_path (str): Path to the output PDB ligand file. File type: output. `Sample file <https://github.com/bioexcel/biobb_io/raw/master/biobb_io/test/reference/api/output_ligand.pdb>`_. Accepted formats: pdb (edam:format_1476).
|
|
28
25
|
properties (dic - Python dictionary object containing the tool parameters, not input/output files):
|
|
29
26
|
* **ligand_code** (*str*) - (None) RSCB PDB ligand code.
|
|
30
|
-
* **api_id** (*str*) - ("
|
|
27
|
+
* **api_id** (*str*) - ("pdbe") Identifier of the PDB REST API from which the PDB structure will be downloaded. Values: pdbe (`PDB in Europe REST API <https://www.ebi.ac.uk/pdbe/pdbe-rest-api>`_), mmb (`MMB PDB mirror API <http://mmb.irbbarcelona.org/api/>`_).
|
|
31
28
|
* **remove_tmp** (*bool*) - (True) [WF property] Remove temporal files.
|
|
32
29
|
* **restart** (*bool*) - (False) [WF property] Do not execute if output files exist.
|
|
33
30
|
* **sandbox_path** (*str*) - ("./") [WF property] Parent path to the sandbox directory.
|
|
@@ -38,7 +35,7 @@ class Ligand(BiobbObject):
|
|
|
38
35
|
from biobb_io.api.ligand import ligand
|
|
39
36
|
prop = {
|
|
40
37
|
'ligand_code': 'CPB',
|
|
41
|
-
'api_id': '
|
|
38
|
+
'api_id': 'pdbe'
|
|
42
39
|
}
|
|
43
40
|
ligand(output_pdb_path='/path/to/newLigand.pdb',
|
|
44
41
|
properties=prop)
|
|
@@ -64,7 +61,7 @@ class Ligand(BiobbObject):
|
|
|
64
61
|
self.io_dict = {"out": {"output_pdb_path": output_pdb_path}}
|
|
65
62
|
|
|
66
63
|
# Properties specific for BB
|
|
67
|
-
self.api_id = properties.get("api_id", "
|
|
64
|
+
self.api_id = properties.get("api_id", "pdbe")
|
|
68
65
|
self.ligand_code = properties.get("ligand_code", None)
|
|
69
66
|
self.properties = properties
|
|
70
67
|
|
|
@@ -113,41 +110,11 @@ class Ligand(BiobbObject):
|
|
|
113
110
|
def ligand(output_pdb_path: str, properties: Optional[dict] = None, **kwargs) -> int:
|
|
114
111
|
"""Execute the :class:`Ligand <api.ligand.Ligand>` class and
|
|
115
112
|
execute the :meth:`launch() <api.ligand.Ligand.launch>` method."""
|
|
113
|
+
return Ligand(**dict(locals())).launch()
|
|
116
114
|
|
|
117
|
-
return Ligand(
|
|
118
|
-
output_pdb_path=output_pdb_path, properties=properties, **kwargs
|
|
119
|
-
).launch()
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
def main():
|
|
123
|
-
"""Command line execution of this building block. Please check the command line documentation."""
|
|
124
|
-
parser = argparse.ArgumentParser(
|
|
125
|
-
description="Wrapper for the Protein Data Bank in Europe (https://www.ebi.ac.uk/pdbe/) and the MMB PDB mirror (http://mmb.irbbarcelona.org/api/) for downloading a single PDB ligand.",
|
|
126
|
-
formatter_class=lambda prog: argparse.RawTextHelpFormatter(prog, width=99999),
|
|
127
|
-
)
|
|
128
|
-
parser.add_argument(
|
|
129
|
-
"-c",
|
|
130
|
-
"--config",
|
|
131
|
-
required=False,
|
|
132
|
-
help="This file can be a YAML file, JSON file or JSON string",
|
|
133
|
-
)
|
|
134
|
-
|
|
135
|
-
# Specific args of each building block
|
|
136
|
-
required_args = parser.add_argument_group("required arguments")
|
|
137
|
-
required_args.add_argument(
|
|
138
|
-
"-o",
|
|
139
|
-
"--output_pdb_path",
|
|
140
|
-
required=True,
|
|
141
|
-
help="Path to the output PDB ligand file. Accepted formats: pdb.",
|
|
142
|
-
)
|
|
143
|
-
|
|
144
|
-
args = parser.parse_args()
|
|
145
|
-
config = args.config if args.config else None
|
|
146
|
-
properties = settings.ConfReader(config=config).get_prop_dic()
|
|
147
|
-
|
|
148
|
-
# Specific call of each building block
|
|
149
|
-
ligand(output_pdb_path=args.output_pdb_path, properties=properties)
|
|
150
115
|
|
|
116
|
+
ligand.__doc__ = Ligand.__doc__
|
|
117
|
+
main = Ligand.get_main(ligand, "Wrapper for the Protein Data Bank in Europe (https://www.ebi.ac.uk/pdbe/) and the MMB PDB mirror (http://mmb.irbbarcelona.org/api/) for downloading a single PDB ligand.")
|
|
151
118
|
|
|
152
119
|
if __name__ == "__main__":
|
|
153
120
|
main()
|
biobb_io/api/mddb.py
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
|
|
3
|
+
"""Module containing the MDDB class and the command line interface."""
|
|
4
|
+
|
|
5
|
+
from typing import Optional
|
|
6
|
+
from biobb_common.generic.biobb_object import BiobbObject
|
|
7
|
+
from biobb_common.tools.file_utils import launchlogger
|
|
8
|
+
|
|
9
|
+
from biobb_io.api.common import (
|
|
10
|
+
check_mandatory_property,
|
|
11
|
+
check_output_path,
|
|
12
|
+
download_mddb_top,
|
|
13
|
+
write_pdb,
|
|
14
|
+
download_mddb_trj,
|
|
15
|
+
write_bin,
|
|
16
|
+
download_mddb_file
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class MDDB(BiobbObject):
|
|
21
|
+
"""
|
|
22
|
+
| biobb_io MDDB
|
|
23
|
+
| This class is a wrapper for downloading a trajectory / topology pair from the MDDB Database.
|
|
24
|
+
| Wrapper for the `MDDB Database <https://mmb.mddbr.eu/>`_ for downloading a trajectory and its corresponding topology.
|
|
25
|
+
|
|
26
|
+
Args:
|
|
27
|
+
output_top_path (str): Path to the output toplogy file. File type: output. `Sample file <https://github.com/bioexcel/biobb_io/raw/master/biobb_io/test/reference/api/output_mddb.pdb>`_. Accepted formats: pdb (edam:format_1476).
|
|
28
|
+
output_trj_path (str): Path to the output trajectory file. File type: output. `Sample file <https://github.com/bioexcel/biobb_io/raw/master/biobb_io/test/reference/api/output_mddb.xtc>`_. Accepted formats: mdcrd (edam:format_3878), trr (edam:format_3910), xtc (edam:format_3875).
|
|
29
|
+
properties (dic - Python dictionary object containing the tool parameters, not input/output files):
|
|
30
|
+
* **project_id** (*str*) - (None) Project accession or identifier.
|
|
31
|
+
* **node_id** (*str*) - ("mmb") MDDB node identifier.
|
|
32
|
+
* **trj_format** (*str*) - ("xtc") Trajectory format. Values: mdcrd (AMBER trajectory format), trr (Trajectory of a simulation experiment used by GROMACS), xtc (Portable binary format for trajectories produced by GROMACS package).
|
|
33
|
+
* **frames** (*str*) - (None) Specify a frame range for the returned trajectory. Ranges are defined by dashes, and multiple ranges can be defined separated by commas. It can also be defined as the start:end:step format (ie: '10:20:2').
|
|
34
|
+
* **selection** (*str*) - (None) Specify a NGL-formatted selection for the returned trajectory. See here for the kind of selection that can be used: http://nglviewer.org/ngl/api/manual/usage/selection-language.html.
|
|
35
|
+
* **extra_files** (*list*) - (None) List of extra files to download. It should be a tuple with the name of the file and the path to be saved.
|
|
36
|
+
* **remove_tmp** (*bool*) - (True) [WF property] Remove temporal files.
|
|
37
|
+
* **restart** (*bool*) - (False) [WF property] Do not execute if output files exist.
|
|
38
|
+
* **sandbox_path** (*str*) - ("./") [WF property] Parent path to the sandbox directory.
|
|
39
|
+
|
|
40
|
+
Examples:
|
|
41
|
+
This is a use example of how to use the building block from Python::
|
|
42
|
+
|
|
43
|
+
from biobb_io.api.mddb import mddb
|
|
44
|
+
prop = {
|
|
45
|
+
'project_id': 'A0001',
|
|
46
|
+
'trj_format': 'xtc'
|
|
47
|
+
}
|
|
48
|
+
mddb(output_top_path='/path/to/newTopology.pdb',
|
|
49
|
+
output_trj_path='/path/to/newTrajectory.pdb',
|
|
50
|
+
properties=prop)
|
|
51
|
+
|
|
52
|
+
Info:
|
|
53
|
+
* wrapped_software:
|
|
54
|
+
* name: MDDB Database
|
|
55
|
+
* license: Apache-2.0
|
|
56
|
+
* ontology:
|
|
57
|
+
* name: EDAM
|
|
58
|
+
* schema: http://edamontology.org/EDAM.owl
|
|
59
|
+
|
|
60
|
+
"""
|
|
61
|
+
|
|
62
|
+
def __init__(self, output_top_path, output_trj_path, properties=None, **kwargs) -> None:
|
|
63
|
+
properties = properties or {}
|
|
64
|
+
|
|
65
|
+
# Call parent class constructor
|
|
66
|
+
super().__init__(properties)
|
|
67
|
+
self.locals_var_dict = locals().copy()
|
|
68
|
+
|
|
69
|
+
# Input/Output files
|
|
70
|
+
self.io_dict = {"out": {"output_top_path": output_top_path, "output_trj_path": output_trj_path}}
|
|
71
|
+
|
|
72
|
+
# Properties specific for BB
|
|
73
|
+
self.project_id = properties.get("project_id", None)
|
|
74
|
+
self.node_id = properties.get("node_id", "mmb")
|
|
75
|
+
self.trj_format = properties.get("trj_format", "xtc")
|
|
76
|
+
self.frames = properties.get("frames", "")
|
|
77
|
+
self.selection = properties.get("selection", "*")
|
|
78
|
+
self.extra_files = properties.get("extra_files", [])
|
|
79
|
+
self.properties = properties
|
|
80
|
+
|
|
81
|
+
# Check the properties
|
|
82
|
+
self.check_properties(properties)
|
|
83
|
+
self.check_arguments()
|
|
84
|
+
|
|
85
|
+
def check_data_params(self, out_log, err_log):
|
|
86
|
+
"""Checks all the input/output paths and parameters"""
|
|
87
|
+
self.output_top_path = check_output_path(
|
|
88
|
+
self.io_dict["out"]["output_top_path"],
|
|
89
|
+
"output_top_path",
|
|
90
|
+
False,
|
|
91
|
+
out_log,
|
|
92
|
+
self.__class__.__name__,
|
|
93
|
+
)
|
|
94
|
+
self.output_trj_path = check_output_path(
|
|
95
|
+
self.io_dict["out"]["output_trj_path"],
|
|
96
|
+
"output_trj_path",
|
|
97
|
+
False,
|
|
98
|
+
out_log,
|
|
99
|
+
self.__class__.__name__,
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
@launchlogger
|
|
103
|
+
def launch(self) -> int:
|
|
104
|
+
"""Execute the :class:`MDDB <api.mddb.MDDB>` api.mddb.MDDB object."""
|
|
105
|
+
|
|
106
|
+
# check input/output paths and parameters
|
|
107
|
+
self.check_data_params(self.out_log, self.err_log)
|
|
108
|
+
|
|
109
|
+
# Setup Biobb
|
|
110
|
+
if self.check_restart():
|
|
111
|
+
return 0
|
|
112
|
+
|
|
113
|
+
check_mandatory_property(
|
|
114
|
+
self.project_id, "project_id", self.out_log, self.__class__.__name__
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
self.project_id = self.project_id.strip().upper()
|
|
118
|
+
|
|
119
|
+
# Downloading topology file
|
|
120
|
+
top_string = download_mddb_top(
|
|
121
|
+
self.project_id,
|
|
122
|
+
self.node_id,
|
|
123
|
+
self.selection,
|
|
124
|
+
self.out_log,
|
|
125
|
+
self.global_log,
|
|
126
|
+
self.__class__.__name__
|
|
127
|
+
)
|
|
128
|
+
write_pdb(top_string, self.output_top_path, None, self.out_log, self.global_log)
|
|
129
|
+
|
|
130
|
+
# Downloading trajectory file
|
|
131
|
+
trj_string = download_mddb_trj(
|
|
132
|
+
self.project_id,
|
|
133
|
+
self.node_id,
|
|
134
|
+
self.trj_format,
|
|
135
|
+
self.frames,
|
|
136
|
+
self.selection,
|
|
137
|
+
self.out_log,
|
|
138
|
+
self.global_log,
|
|
139
|
+
self.__class__.__name__,
|
|
140
|
+
)
|
|
141
|
+
write_bin(trj_string, self.output_trj_path, self.out_log, self.global_log)
|
|
142
|
+
|
|
143
|
+
for (extra_file, extra_path) in self.extra_files:
|
|
144
|
+
try:
|
|
145
|
+
file_string = download_mddb_file(
|
|
146
|
+
self.project_id,
|
|
147
|
+
self.node_id,
|
|
148
|
+
extra_file,
|
|
149
|
+
self.out_log,
|
|
150
|
+
self.global_log,
|
|
151
|
+
self.__class__.__name__,
|
|
152
|
+
)
|
|
153
|
+
write_bin(file_string, extra_path, self.out_log, self.global_log)
|
|
154
|
+
except Exception:
|
|
155
|
+
pass
|
|
156
|
+
|
|
157
|
+
self.check_arguments(output_files_created=True, raise_exception=False)
|
|
158
|
+
|
|
159
|
+
return 0
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
def mddb(output_top_path: str, output_trj_path: str, properties: Optional[dict] = None, **kwargs) -> int:
|
|
163
|
+
"""Execute the :class:`MDDB <api.mddb.MDDB>` class and
|
|
164
|
+
execute the :meth:`launch() <api.mddb.MDDB.launch>` method."""
|
|
165
|
+
return MDDB(**dict(locals())).launch()
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
mddb.__doc__ = MDDB.__doc__
|
|
169
|
+
main = MDDB.get_main(
|
|
170
|
+
mddb,
|
|
171
|
+
"This class is a wrapper for downloading a trajectory / topology pair from the MDDB Database.",
|
|
172
|
+
)
|
|
173
|
+
|
|
174
|
+
if __name__ == "__main__":
|
|
175
|
+
main()
|