1
|
|
|
""" |
|
|
|
|
2
|
|
|
Run searches and write files. |
3
|
|
|
""" |
4
|
|
|
|
5
|
|
|
from __future__ import annotations |
6
|
|
|
|
7
|
|
|
import abc |
8
|
|
|
from pathlib import Path |
9
|
|
|
from typing import TypeVar, Generic, Union, Mapping, Set, Sequence, Type, Optional |
10
|
|
|
|
11
|
|
|
import typer |
|
|
|
|
12
|
|
|
from typer.models import OptionInfo |
|
|
|
|
13
|
|
|
|
14
|
|
|
from mandos.entries import EntryMeta |
15
|
|
|
from mandos.entries.args import EntryArgs |
16
|
|
|
from mandos.model import ReflectionUtils, InjectionError |
17
|
|
|
from mandos.model.chembl_api import ChemblApi |
18
|
|
|
from mandos.model.chembl_support import DataValidityComment |
19
|
|
|
from mandos.model.chembl_support.chembl_targets import TargetType |
20
|
|
|
from mandos.model.pubchem_support.pubchem_models import ( |
21
|
|
|
ClinicalTrialsGovUtils, |
22
|
|
|
CoOccurrenceType, |
23
|
|
|
DrugbankTargetType, |
24
|
|
|
) |
25
|
|
|
from mandos.model.searches import Search |
26
|
|
|
from mandos.model.settings import MANDOS_SETTINGS |
27
|
|
|
from mandos.model.taxonomy import Taxonomy |
28
|
|
|
from mandos.model.taxonomy_caches import TaxonomyFactories |
29
|
|
|
from mandos.entries.api_singletons import Apis |
30
|
|
|
from mandos.search.pubchem.acute_effects_search import AcuteEffectSearch, Ld50Search |
31
|
|
|
from mandos.search.pubchem.bioactivity_search import BioactivitySearch |
32
|
|
|
from mandos.search.pubchem.computed_property_search import ComputedPropertySearch |
33
|
|
|
from mandos.search.pubchem.dgidb_search import DgiSearch |
34
|
|
|
from mandos.search.pubchem.ctd_gene_search import CtdGeneSearch |
35
|
|
|
from mandos.entries.searcher import Searcher |
36
|
|
|
from mandos.search.pubchem.drugbank_ddi_search import DrugbankDdiSearch |
37
|
|
|
from mandos.search.pubchem.drugbank_interaction_search import ( |
38
|
|
|
DrugbankTargetSearch, |
39
|
|
|
DrugbankGeneralFunctionSearch, |
40
|
|
|
) |
41
|
|
|
|
42
|
|
|
from mandos import logger |
43
|
|
|
from mandos.search.chembl.binding_search import BindingSearch |
44
|
|
|
from mandos.search.chembl.atc_search import AtcSearch |
45
|
|
|
from mandos.search.chembl.go_search import GoType, GoSearch |
46
|
|
|
from mandos.search.chembl.indication_search import IndicationSearch |
47
|
|
|
from mandos.search.chembl.mechanism_search import MechanismSearch |
48
|
|
|
from mandos.search.pubchem.cooccurrence_search import ( |
49
|
|
|
GeneCoOccurrenceSearch, |
50
|
|
|
ChemicalCoOccurrenceSearch, |
51
|
|
|
CoOccurrenceSearch, |
52
|
|
|
DiseaseCoOccurrenceSearch, |
53
|
|
|
) |
54
|
|
|
from mandos.search.pubchem.disease_search import DiseaseSearch |
55
|
|
|
|
56
|
|
|
S = TypeVar("S", bound=Search, covariant=True) |
|
|
|
|
57
|
|
|
U = TypeVar("U", covariant=True, bound=CoOccurrenceSearch) |
|
|
|
|
58
|
|
|
|
59
|
|
|
|
60
|
|
|
class Utils: |
|
|
|
|
61
|
|
|
"""""" |
62
|
|
|
|
63
|
|
|
@staticmethod |
64
|
|
|
def split(st: str) -> Set[str]: |
|
|
|
|
65
|
|
|
return {s.strip() for s in st.split(",")} |
66
|
|
|
|
67
|
|
|
@staticmethod |
68
|
|
|
def get_taxa(taxa: str) -> Sequence[Taxonomy]: |
|
|
|
|
69
|
|
|
return [ |
70
|
|
|
TaxonomyFactories.from_uniprot(MANDOS_SETTINGS.taxonomy_cache_path).load( |
71
|
|
|
str(taxon).strip() |
72
|
|
|
) |
73
|
|
|
for taxon in taxa.split(",") |
74
|
|
|
] |
75
|
|
|
|
76
|
|
|
@staticmethod |
77
|
|
|
def get_trial_statuses(st: str) -> Set[str]: |
|
|
|
|
78
|
|
|
return ClinicalTrialsGovUtils.resolve_statuses(st) |
79
|
|
|
|
80
|
|
|
@staticmethod |
81
|
|
|
def get_target_types(st: str) -> Set[str]: |
|
|
|
|
82
|
|
|
return {s.name for s in TargetType.resolve(st)} |
83
|
|
|
|
84
|
|
|
@staticmethod |
85
|
|
|
def get_flags(st: str) -> Set[str]: |
|
|
|
|
86
|
|
|
return {s.name for s in DataValidityComment.resolve(st)} |
87
|
|
|
|
88
|
|
|
|
89
|
|
|
class Entry(Generic[S], metaclass=abc.ABCMeta): |
|
|
|
|
90
|
|
|
@classmethod |
91
|
|
|
def cmd(cls) -> str: |
|
|
|
|
92
|
|
|
key = cls._get_default_key() |
93
|
|
|
if isinstance(key, typer.models.OptionInfo): |
94
|
|
|
key = key.default |
95
|
|
|
if key is None or not isinstance(key, str): |
96
|
|
|
raise AssertionError(f"Key for {cls.__name__} is {key}") |
97
|
|
|
return key |
98
|
|
|
|
99
|
|
|
@classmethod |
100
|
|
|
def run(cls, path: Path, **params) -> None: |
|
|
|
|
101
|
|
|
raise NotImplementedError() |
102
|
|
|
|
103
|
|
|
@classmethod |
104
|
|
|
def get_search_type(cls) -> Type[S]: |
|
|
|
|
105
|
|
|
# noinspection PyTypeChecker |
106
|
|
|
return ReflectionUtils.get_generic_arg(cls, Search) |
107
|
|
|
|
108
|
|
|
# noinspection PyUnusedLocal |
109
|
|
|
@classmethod |
110
|
|
|
def test(cls, path: Path, **params) -> None: |
|
|
|
|
111
|
|
|
cls.run(path, **{**params, **dict(check=True)}) |
112
|
|
|
|
113
|
|
|
@classmethod |
114
|
|
|
def _run( |
|
|
|
|
115
|
|
|
cls, |
|
|
|
|
116
|
|
|
built: S, |
|
|
|
|
117
|
|
|
path: Path, |
|
|
|
|
118
|
|
|
to: Optional[Path], |
|
|
|
|
119
|
|
|
check: bool, |
|
|
|
|
120
|
|
|
log: Optional[Path], |
|
|
|
|
121
|
|
|
quiet: bool, |
|
|
|
|
122
|
|
|
verbose: bool, |
|
|
|
|
123
|
|
|
no_setup: bool, |
|
|
|
|
124
|
|
|
): |
125
|
|
|
if not no_setup: |
126
|
|
|
level = EntryMeta.set_logging(verbose, quiet, log) |
127
|
|
|
logger.notice(f"Ready. Set log level to {level}") |
128
|
|
|
searcher = cls._get_searcher(built, path, to) |
129
|
|
|
logger.notice(f"Searching {built.key} [{built.search_class}] on {path}") |
130
|
|
|
out = searcher.output_paths[built.key] |
131
|
|
|
if not check: |
132
|
|
|
searcher.search() |
133
|
|
|
logger.notice(f"Done! Wrote to {out}") |
134
|
|
|
return searcher |
135
|
|
|
|
136
|
|
|
@classmethod |
137
|
|
|
def _get_searcher( |
|
|
|
|
138
|
|
|
cls, |
|
|
|
|
139
|
|
|
built: S, |
|
|
|
|
140
|
|
|
path: Path, |
|
|
|
|
141
|
|
|
to: Optional[Path], |
|
|
|
|
142
|
|
|
): |
143
|
|
|
return Searcher([built], [to], path) |
144
|
|
|
|
145
|
|
|
@classmethod |
146
|
|
|
def default_param_values(cls) -> Mapping[str, Union[str, float, int, Path]]: |
|
|
|
|
147
|
|
|
return { |
148
|
|
|
param: (value.default if isinstance(value, OptionInfo) else value) |
149
|
|
|
for param, value in ReflectionUtils.default_arg_values(cls.run).items() |
150
|
|
|
if param not in {"key", "path"} |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
@classmethod |
154
|
|
|
def _get_default_key(cls) -> str: |
155
|
|
|
vals = ReflectionUtils.default_arg_values(cls.run) |
156
|
|
|
try: |
157
|
|
|
return vals["key"] |
158
|
|
|
except KeyError: |
159
|
|
|
logger.error(f"key not in {vals.keys()} for {cls.__name__}") |
160
|
|
|
raise |
161
|
|
|
|
162
|
|
|
|
163
|
|
|
class EntryChemblBinding(Entry[BindingSearch]): |
|
|
|
|
164
|
|
|
@classmethod |
165
|
|
|
def run( |
|
|
|
|
166
|
|
|
cls, |
|
|
|
|
167
|
|
|
path: Path = EntryArgs.path, |
|
|
|
|
168
|
|
|
key: str = EntryArgs.key("chembl:binding"), |
|
|
|
|
169
|
|
|
to: Optional[Path] = EntryArgs.to, |
|
|
|
|
170
|
|
|
taxa: str = EntryArgs.taxa, |
|
|
|
|
171
|
|
|
traversal: str = EntryArgs.traversal_strategy, |
|
|
|
|
172
|
|
|
target_types: str = EntryArgs.target_types, |
|
|
|
|
173
|
|
|
confidence: int = EntryArgs.min_confidence, |
|
|
|
|
174
|
|
|
binding: float = EntryArgs.binds_cutoff, |
|
|
|
|
175
|
|
|
nonbinding: float = EntryArgs.does_not_bind_cutoff, |
|
|
|
|
176
|
|
|
relations: str = EntryArgs.relations, |
|
|
|
|
177
|
|
|
min_pchembl: float = EntryArgs.min_pchembl, |
|
|
|
|
178
|
|
|
banned_flags: str = EntryArgs.banned_flags, |
|
|
|
|
179
|
|
|
check: bool = EntryArgs.test, |
|
|
|
|
180
|
|
|
log: Optional[Path] = EntryArgs.log_path, |
|
|
|
|
181
|
|
|
quiet: bool = EntryArgs.quiet, |
|
|
|
|
182
|
|
|
verbose: bool = EntryArgs.verbose, |
|
|
|
|
183
|
|
|
no_setup: bool = EntryArgs.no_setup, |
|
|
|
|
184
|
|
|
) -> Searcher: |
185
|
|
|
""" |
186
|
|
|
Binding data from ChEMBL. |
187
|
|
|
These are 'activity' annotations of the type 'B' that have a pCHEMBL value. |
188
|
|
|
There is extended documentation on this search; see: |
189
|
|
|
|
190
|
|
|
https://mandos-chem.readthedocs.io/en/latest/binding.html |
191
|
|
|
|
192
|
|
|
OBJECT: ChEMBL preferred target name |
193
|
|
|
|
194
|
|
|
PREDICATE: Either "binds", "does not bind", or "binding <relation> at" |
195
|
|
|
|
196
|
|
|
OTHER COLUMNS: |
197
|
|
|
|
198
|
|
|
- taxon_id: From UniProt |
199
|
|
|
|
200
|
|
|
- taxon_name: From Uniprot (scientific name) |
201
|
|
|
|
202
|
|
|
- pchembl: Negative base-10 log of activity value (see docs on ChEMBL) |
203
|
|
|
|
204
|
|
|
- standard_relation: One of '<', '<=', '=', '>=', '>', '~'. Consider using <, <=, and = to indicate hits. |
|
|
|
|
205
|
|
|
|
206
|
|
|
- std_type: e.g. EC50, Kd |
207
|
|
|
""" |
208
|
|
|
built = BindingSearch( |
209
|
|
|
key=key, |
210
|
|
|
api=Apis.Chembl, |
211
|
|
|
taxa=Utils.get_taxa(taxa), |
212
|
|
|
traversal_strategy=traversal, |
213
|
|
|
allowed_target_types=Utils.get_target_types(target_types), |
214
|
|
|
min_confidence_score=confidence, |
215
|
|
|
allowed_relations=Utils.split(relations), |
216
|
|
|
min_pchembl=min_pchembl, |
217
|
|
|
banned_flags=Utils.get_flags(banned_flags), |
218
|
|
|
binds_cutoff=binding, |
219
|
|
|
does_not_bind_cutoff=nonbinding, |
220
|
|
|
) |
221
|
|
|
return cls._run(built, path, to, check, log, quiet, verbose, no_setup) |
222
|
|
|
|
223
|
|
|
|
224
|
|
|
class EntryChemblMechanism(Entry[MechanismSearch]): |
|
|
|
|
225
|
|
|
@classmethod |
226
|
|
|
def run( |
|
|
|
|
227
|
|
|
cls, |
|
|
|
|
228
|
|
|
path: Path = EntryArgs.path, |
|
|
|
|
229
|
|
|
key: str = EntryArgs.key("chembl:mechanism"), |
|
|
|
|
230
|
|
|
to: Optional[Path] = EntryArgs.to, |
|
|
|
|
231
|
|
|
taxa: Optional[str] = EntryArgs.taxa, |
|
|
|
|
232
|
|
|
traversal: str = EntryArgs.traversal_strategy, |
|
|
|
|
233
|
|
|
target_types: str = EntryArgs.target_types, |
|
|
|
|
234
|
|
|
min_confidence: Optional[int] = EntryArgs.min_confidence, |
|
|
|
|
235
|
|
|
check: bool = EntryArgs.test, |
|
|
|
|
236
|
|
|
log: Optional[Path] = EntryArgs.log_path, |
|
|
|
|
237
|
|
|
quiet: bool = EntryArgs.quiet, |
|
|
|
|
238
|
|
|
verbose: bool = EntryArgs.verbose, |
|
|
|
|
239
|
|
|
no_setup: bool = EntryArgs.no_setup, |
|
|
|
|
240
|
|
|
) -> Searcher: |
241
|
|
|
""" |
242
|
|
|
Mechanism of action (MoA) data from ChEMBL. |
243
|
|
|
|
244
|
|
|
OBJECT: ChEMBL preferred target name |
245
|
|
|
|
246
|
|
|
PREDICATE: Target action; e.g. "agonist of" or "positive allosteric modulator of" |
247
|
|
|
|
248
|
|
|
OTHER COLUMNS: |
249
|
|
|
|
250
|
|
|
- direct_interaction: true or false |
251
|
|
|
|
252
|
|
|
- description: From ChEMBL |
253
|
|
|
|
254
|
|
|
- exact_target_id: the specifically annotated target, before traversal |
255
|
|
|
""" |
256
|
|
|
built = MechanismSearch( |
257
|
|
|
key=key, |
258
|
|
|
api=Apis.Chembl, |
259
|
|
|
taxa=Utils.get_taxa(taxa), |
260
|
|
|
traversal_strategy=traversal, |
261
|
|
|
allowed_target_types=Utils.get_target_types(target_types), |
262
|
|
|
min_confidence_score=min_confidence, |
263
|
|
|
) |
264
|
|
|
return cls._run(built, path, to, check, log, quiet, verbose, no_setup) |
265
|
|
|
|
266
|
|
|
|
267
|
|
|
class EntryChemblTrials(Entry[IndicationSearch]): |
|
|
|
|
268
|
|
|
@classmethod |
269
|
|
|
def run( |
|
|
|
|
270
|
|
|
cls, |
|
|
|
|
271
|
|
|
path: Path = EntryArgs.path, |
|
|
|
|
272
|
|
|
key: str = EntryArgs.key("chembl:trial"), |
|
|
|
|
273
|
|
|
to: Optional[Path] = EntryArgs.to, |
|
|
|
|
274
|
|
|
min_phase: Optional[int] = EntryArgs.chembl_trial, |
|
|
|
|
275
|
|
|
check: bool = EntryArgs.test, |
|
|
|
|
276
|
|
|
log: Optional[Path] = EntryArgs.log_path, |
|
|
|
|
277
|
|
|
quiet: bool = EntryArgs.quiet, |
|
|
|
|
278
|
|
|
verbose: bool = EntryArgs.verbose, |
|
|
|
|
279
|
|
|
no_setup: bool = EntryArgs.no_setup, |
|
|
|
|
280
|
|
|
) -> Searcher: |
281
|
|
|
""" |
282
|
|
|
Diseases from clinical trials listed in ChEMBL. |
283
|
|
|
|
284
|
|
|
OBJECT: MeSH code |
285
|
|
|
|
286
|
|
|
PREDICATE: "phase <level> trial" |
287
|
|
|
""" |
288
|
|
|
built = IndicationSearch(key=key, api=Apis.Chembl, min_phase=min_phase) |
289
|
|
|
return cls._run(built, path, to, check, log, quiet, verbose, no_setup) |
290
|
|
|
|
291
|
|
|
|
292
|
|
|
class EntryChemblAtc(Entry[AtcSearch]): |
|
|
|
|
293
|
|
|
@classmethod |
294
|
|
|
def run( |
|
|
|
|
295
|
|
|
cls, |
|
|
|
|
296
|
|
|
path: Path = EntryArgs.path, |
|
|
|
|
297
|
|
|
key: str = EntryArgs.key("chembl:atc"), |
|
|
|
|
298
|
|
|
to: Optional[Path] = EntryArgs.to, |
|
|
|
|
299
|
|
|
levels: str = EntryArgs.atc_level, |
|
|
|
|
300
|
|
|
check: bool = EntryArgs.test, |
|
|
|
|
301
|
|
|
log: Optional[Path] = EntryArgs.log_path, |
|
|
|
|
302
|
|
|
quiet: bool = EntryArgs.quiet, |
|
|
|
|
303
|
|
|
verbose: bool = EntryArgs.verbose, |
|
|
|
|
304
|
|
|
no_setup: bool = EntryArgs.no_setup, |
|
|
|
|
305
|
|
|
) -> Searcher: |
306
|
|
|
""" |
307
|
|
|
ATC codes from ChEMBL. |
308
|
|
|
|
309
|
|
|
OBJECT: ATC Code |
310
|
|
|
|
311
|
|
|
PREDICATE: "ATC L<leveL> code" |
312
|
|
|
""" |
313
|
|
|
built = AtcSearch( |
314
|
|
|
key=key, api=Apis.Chembl, levels={int(x.strip()) for x in levels.split(",")} |
315
|
|
|
) |
316
|
|
|
return cls._run(built, path, to, check, log, quiet, verbose, no_setup) |
317
|
|
|
|
318
|
|
|
|
319
|
|
|
class _EntryChemblGo(Entry[GoSearch], metaclass=abc.ABCMeta): |
320
|
|
|
@classmethod |
321
|
|
|
def go_type(cls) -> GoType: |
|
|
|
|
322
|
|
|
raise NotImplementedError() |
323
|
|
|
|
324
|
|
|
@classmethod |
325
|
|
|
def cmd(cls) -> str: |
|
|
|
|
326
|
|
|
me = str(cls.go_type().name) |
|
|
|
|
327
|
|
|
return f"chembl:go.{me.lower()}" |
328
|
|
|
|
329
|
|
|
@classmethod |
330
|
|
|
def run( |
|
|
|
|
331
|
|
|
cls, |
|
|
|
|
332
|
|
|
path: Path = EntryArgs.path, |
|
|
|
|
333
|
|
|
key: str = EntryArgs.key("<see above>"), |
|
|
|
|
334
|
|
|
to: Optional[Path] = EntryArgs.to, |
|
|
|
|
335
|
|
|
taxa: Optional[str] = EntryArgs.taxa, |
|
|
|
|
336
|
|
|
traversal_strategy: str = EntryArgs.traversal_strategy, |
|
|
|
|
337
|
|
|
target_types: str = EntryArgs.target_types, |
|
|
|
|
338
|
|
|
confidence: Optional[int] = EntryArgs.min_confidence, |
|
|
|
|
339
|
|
|
relations: str = EntryArgs.relations, |
|
|
|
|
340
|
|
|
min_pchembl: float = EntryArgs.min_pchembl, |
|
|
|
|
341
|
|
|
banned_flags: Optional[str] = EntryArgs.banned_flags, |
|
|
|
|
342
|
|
|
binding_search: Optional[str] = EntryArgs.binding_search_name, |
|
|
|
|
343
|
|
|
check: bool = EntryArgs.test, |
|
|
|
|
344
|
|
|
log: Optional[Path] = EntryArgs.log_path, |
|
|
|
|
345
|
|
|
quiet: bool = EntryArgs.quiet, |
|
|
|
|
346
|
|
|
verbose: bool = EntryArgs.verbose, |
|
|
|
|
347
|
|
|
no_setup: bool = EntryArgs.no_setup, |
|
|
|
|
348
|
|
|
) -> Searcher: |
349
|
|
|
""" |
350
|
|
|
GO terms associated with ChEMBL binding targets. |
351
|
|
|
|
352
|
|
|
OBJECT: GO Term name |
353
|
|
|
|
354
|
|
|
PREDICATE: "associated with ""Function"|"Process"|"Component"" term" |
355
|
|
|
|
356
|
|
|
OTHER COLUMNS: |
357
|
|
|
See the docs for ``mandos chembl:binding`` |
358
|
|
|
|
359
|
|
|
Note: |
360
|
|
|
|
361
|
|
|
By default, the key is the "chembl:go.function", "chembl:go.process", or "chembl:go.component". |
|
|
|
|
362
|
|
|
|
363
|
|
|
""" |
364
|
|
|
if key is None or key == "<see above>": |
365
|
|
|
key = cls.cmd() |
366
|
|
|
api = ChemblApi.wrap(Apis.Chembl) |
367
|
|
|
if binding_search is None: |
368
|
|
|
binding_clazz = BindingSearch |
369
|
|
|
else: |
370
|
|
|
binding_clazz = ReflectionUtils.injection(binding_search, BindingSearch) |
371
|
|
|
logger.info(f"NOTICE: Passing parameters to {binding_clazz.__qualname__}") |
372
|
|
|
try: |
373
|
|
|
binding_search = binding_clazz( |
374
|
|
|
key=key, |
375
|
|
|
api=Apis.Chembl, |
376
|
|
|
taxa=Utils.get_taxa(taxa), |
377
|
|
|
traversal_strategy=traversal_strategy, |
378
|
|
|
allowed_target_types=Utils.get_target_types(target_types), |
379
|
|
|
min_confidence_score=confidence, |
380
|
|
|
allowed_relations=Utils.split(relations), |
381
|
|
|
min_pchembl=min_pchembl, |
382
|
|
|
banned_flags=Utils.get_flags(banned_flags), |
383
|
|
|
) |
384
|
|
|
except (TypeError, ValueError): |
385
|
|
|
raise InjectionError(f"Failed to build {binding_clazz.__qualname__}") |
386
|
|
|
built = GoSearch(key, api, cls.go_type(), binding_search) |
387
|
|
|
return cls._run(built, path, to, check, log, quiet, verbose, no_setup) |
388
|
|
|
|
389
|
|
|
|
390
|
|
|
class EntryGoFunction(_EntryChemblGo): |
|
|
|
|
391
|
|
|
@classmethod |
392
|
|
|
def go_type(cls) -> GoType: |
393
|
|
|
return GoType.function |
394
|
|
|
|
395
|
|
|
|
396
|
|
|
class EntryGoProcess(_EntryChemblGo): |
|
|
|
|
397
|
|
|
@classmethod |
398
|
|
|
def go_type(cls) -> GoType: |
399
|
|
|
return GoType.process |
400
|
|
|
|
401
|
|
|
|
402
|
|
|
class EntryGoComponent(_EntryChemblGo): |
|
|
|
|
403
|
|
|
@classmethod |
404
|
|
|
def go_type(cls) -> GoType: |
405
|
|
|
return GoType.component |
406
|
|
|
|
407
|
|
|
|
408
|
|
|
class EntryPubchemDisease(Entry[DiseaseSearch]): |
|
|
|
|
409
|
|
|
@classmethod |
410
|
|
|
def run( |
|
|
|
|
411
|
|
|
cls, |
|
|
|
|
412
|
|
|
path: Path = EntryArgs.path, |
|
|
|
|
413
|
|
|
key: str = EntryArgs.key("disease.ctd:mesh"), |
|
|
|
|
414
|
|
|
to: Optional[Path] = EntryArgs.to, |
|
|
|
|
415
|
|
|
check: bool = EntryArgs.test, |
|
|
|
|
416
|
|
|
log: Optional[Path] = EntryArgs.log_path, |
|
|
|
|
417
|
|
|
quiet: bool = EntryArgs.quiet, |
|
|
|
|
418
|
|
|
verbose: bool = EntryArgs.verbose, |
|
|
|
|
419
|
|
|
no_setup: bool = EntryArgs.no_setup, |
|
|
|
|
420
|
|
|
) -> Searcher: |
421
|
|
|
""" |
422
|
|
|
Diseases in the CTD. |
423
|
|
|
|
424
|
|
|
Comparative Toxicogenomics Database. |
425
|
|
|
|
426
|
|
|
OBJECT: MeSH code of disease |
427
|
|
|
|
428
|
|
|
PREDICATE: "marker/mechanism evidence for" or "disease evidence for" |
429
|
|
|
""" |
430
|
|
|
built = DiseaseSearch(key, Apis.Pubchem) |
431
|
|
|
return cls._run(built, path, to, check, log, quiet, verbose, no_setup) |
432
|
|
|
|
433
|
|
|
|
434
|
|
|
class _EntryPubchemCoOccurrence(Entry[U], metaclass=abc.ABCMeta): |
435
|
|
|
@classmethod |
436
|
|
|
def cmd(cls) -> str: |
|
|
|
|
437
|
|
|
me = str(cls.get_cooccurrence_type().name) |
|
|
|
|
438
|
|
|
return f"lit.pubchem:{me.lower()}" |
439
|
|
|
|
440
|
|
|
@classmethod |
441
|
|
|
def get_cooccurrence_type(cls) -> CoOccurrenceType: |
|
|
|
|
442
|
|
|
s: CoOccurrenceSearch = cls.get_search_type() |
|
|
|
|
443
|
|
|
return s.cooccurrence_type() |
444
|
|
|
|
445
|
|
|
@classmethod |
446
|
|
|
def run( |
|
|
|
|
447
|
|
|
cls, |
|
|
|
|
448
|
|
|
path: Path = EntryArgs.path, |
|
|
|
|
449
|
|
|
key: str = EntryArgs.key("<see above>"), |
|
|
|
|
450
|
|
|
to: Optional[Path] = EntryArgs.to, |
|
|
|
|
451
|
|
|
min_score: float = EntryArgs.min_cooccurrence_score, |
|
|
|
|
452
|
|
|
min_articles: int = EntryArgs.min_cooccurring_articles, |
|
|
|
|
453
|
|
|
log: Optional[Path] = EntryArgs.log_path, |
|
|
|
|
454
|
|
|
check: bool = EntryArgs.test, |
|
|
|
|
455
|
|
|
quiet: bool = EntryArgs.quiet, |
|
|
|
|
456
|
|
|
verbose: bool = EntryArgs.verbose, |
|
|
|
|
457
|
|
|
no_setup: bool = EntryArgs.no_setup, |
|
|
|
|
458
|
|
|
) -> Searcher: |
459
|
|
|
""" |
460
|
|
|
Co-occurrences from PubMed articles. |
461
|
|
|
There is extended documentation on this search. |
462
|
|
|
Also refer to https://pubchemdocs.ncbi.nlm.nih.gov/knowledge-panels |
463
|
|
|
|
464
|
|
|
OBJECT: Name of gene/chemical/disease |
465
|
|
|
|
466
|
|
|
PREDICATE: "co-occurs with <gene/chemical/disease>" |
467
|
|
|
|
468
|
|
|
OTHER COLUMNS: |
469
|
|
|
|
470
|
|
|
- score: enrichment score; see PubChem docs |
471
|
|
|
|
472
|
|
|
- intersect_count: Number of articles co-occurring |
473
|
|
|
|
474
|
|
|
- query_count: Total number of articles for query compound |
475
|
|
|
|
476
|
|
|
- neighbor_count: Total number of articles for target (co-occurring) compound |
477
|
|
|
""" |
478
|
|
|
if key is None or key == "<see above>": |
479
|
|
|
key = cls.cmd() |
480
|
|
|
clazz = cls.get_search_type() |
481
|
|
|
built = clazz(key, Apis.Pubchem, min_score=min_score, min_articles=min_articles) |
482
|
|
|
return cls._run(built, path, to, check, log, quiet, verbose, no_setup) |
483
|
|
|
|
484
|
|
|
|
485
|
|
|
class EntryPubchemGeneCoOccurrence(_EntryPubchemCoOccurrence[GeneCoOccurrenceSearch]): |
|
|
|
|
486
|
|
|
"""""" |
487
|
|
|
|
488
|
|
|
|
489
|
|
|
class EntryPubchemDiseaseCoOccurrence(_EntryPubchemCoOccurrence[DiseaseCoOccurrenceSearch]): |
|
|
|
|
490
|
|
|
"""""" |
491
|
|
|
|
492
|
|
|
|
493
|
|
|
class EntryPubchemChemicalCoOccurrence(_EntryPubchemCoOccurrence[ChemicalCoOccurrenceSearch]): |
|
|
|
|
494
|
|
|
"""""" |
495
|
|
|
|
496
|
|
|
|
497
|
|
|
class EntryPubchemDgi(Entry[DgiSearch]): |
|
|
|
|
498
|
|
|
@classmethod |
499
|
|
|
def run( |
|
|
|
|
500
|
|
|
cls, |
|
|
|
|
501
|
|
|
path: Path = EntryArgs.path, |
|
|
|
|
502
|
|
|
key: str = EntryArgs.key("inter.dgidb:gene"), |
|
|
|
|
503
|
|
|
to: Optional[Path] = EntryArgs.to, |
|
|
|
|
504
|
|
|
log: Optional[Path] = EntryArgs.log_path, |
|
|
|
|
505
|
|
|
check: bool = EntryArgs.test, |
|
|
|
|
506
|
|
|
quiet: bool = EntryArgs.quiet, |
|
|
|
|
507
|
|
|
verbose: bool = EntryArgs.verbose, |
|
|
|
|
508
|
|
|
no_setup: bool = EntryArgs.no_setup, |
|
|
|
|
509
|
|
|
) -> Searcher: |
510
|
|
|
""" |
511
|
|
|
Drug/gene interactions in the DGIDB. |
512
|
|
|
|
513
|
|
|
Drug Gene Interaction Database. |
514
|
|
|
Also see ``disease.dgidb:int``. |
515
|
|
|
|
516
|
|
|
OBJECT: Name of the gene |
517
|
|
|
|
518
|
|
|
PREDICATE: "interacts with gene" |
519
|
|
|
""" |
520
|
|
|
built = DgiSearch(key, Apis.Pubchem) |
521
|
|
|
return cls._run(built, path, to, check, log, quiet, verbose, no_setup) |
522
|
|
|
|
523
|
|
|
|
524
|
|
|
class EntryPubchemCgi(Entry[CtdGeneSearch]): |
|
|
|
|
525
|
|
|
@classmethod |
526
|
|
|
def run( |
|
|
|
|
527
|
|
|
cls, |
|
|
|
|
528
|
|
|
path: Path = EntryArgs.path, |
|
|
|
|
529
|
|
|
key: str = EntryArgs.key("inter.ctd:gene"), |
|
|
|
|
530
|
|
|
to: Optional[Path] = EntryArgs.to, |
|
|
|
|
531
|
|
|
log: Optional[Path] = EntryArgs.log_path, |
|
|
|
|
532
|
|
|
check: bool = EntryArgs.test, |
|
|
|
|
533
|
|
|
quiet: bool = EntryArgs.quiet, |
|
|
|
|
534
|
|
|
verbose: bool = EntryArgs.verbose, |
|
|
|
|
535
|
|
|
no_setup: bool = EntryArgs.no_setup, |
|
|
|
|
536
|
|
|
) -> Searcher: |
537
|
|
|
""" |
538
|
|
|
Compound/gene interactions in the DGIDB. |
539
|
|
|
|
540
|
|
|
Drug Gene Interaction Database. |
541
|
|
|
Also see ``interact.dgidb:int``. |
542
|
|
|
|
543
|
|
|
OBJECT: Name of the gene |
544
|
|
|
|
545
|
|
|
PREDICATE: "compound/gene interaction" |
546
|
|
|
|
547
|
|
|
""" |
548
|
|
|
built = CtdGeneSearch(key, Apis.Pubchem) |
549
|
|
|
return cls._run(built, path, to, check, log, quiet, verbose, no_setup) |
550
|
|
|
|
551
|
|
|
|
552
|
|
|
class EntryDrugbankTarget(Entry[DrugbankTargetSearch]): |
|
|
|
|
553
|
|
View Code Duplication |
@classmethod |
|
|
|
|
554
|
|
|
def run( |
|
|
|
|
555
|
|
|
cls, |
|
|
|
|
556
|
|
|
path: Path = EntryArgs.path, |
|
|
|
|
557
|
|
|
key: str = EntryArgs.key("inter.drugbank:target"), |
|
|
|
|
558
|
|
|
to: Optional[Path] = EntryArgs.to, |
|
|
|
|
559
|
|
|
check: bool = EntryArgs.test, |
|
|
|
|
560
|
|
|
log: Optional[Path] = EntryArgs.log_path, |
|
|
|
|
561
|
|
|
quiet: bool = EntryArgs.quiet, |
|
|
|
|
562
|
|
|
verbose: bool = EntryArgs.verbose, |
|
|
|
|
563
|
|
|
no_setup: bool = EntryArgs.no_setup, |
|
|
|
|
564
|
|
|
) -> Searcher: |
565
|
|
|
""" |
566
|
|
|
Protein targets from DrugBank. |
567
|
|
|
|
568
|
|
|
OBJECT: Target name (e.g. "Solute carrier family 22 member 11") from DrugBank |
569
|
|
|
|
570
|
|
|
PREDICATE: Action (e.g. "binder", "downregulator", or "agonist") |
571
|
|
|
""" |
572
|
|
|
built = DrugbankTargetSearch(key, Apis.Pubchem, {DrugbankTargetType.target}) |
573
|
|
|
return cls._run(built, path, to, check, log, quiet, verbose, no_setup) |
574
|
|
|
|
575
|
|
|
|
576
|
|
|
class EntryGeneralFunction(Entry[DrugbankGeneralFunctionSearch]): |
|
|
|
|
577
|
|
View Code Duplication |
@classmethod |
|
|
|
|
578
|
|
|
def run( |
|
|
|
|
579
|
|
|
cls, |
|
|
|
|
580
|
|
|
path: Path = EntryArgs.path, |
|
|
|
|
581
|
|
|
key: str = EntryArgs.key("inter.drugbank:target-fn"), |
|
|
|
|
582
|
|
|
to: Optional[Path] = EntryArgs.to, |
|
|
|
|
583
|
|
|
check: bool = EntryArgs.test, |
|
|
|
|
584
|
|
|
log: Optional[Path] = EntryArgs.log_path, |
|
|
|
|
585
|
|
|
quiet: bool = EntryArgs.quiet, |
|
|
|
|
586
|
|
|
verbose: bool = EntryArgs.verbose, |
|
|
|
|
587
|
|
|
no_setup: bool = EntryArgs.no_setup, |
|
|
|
|
588
|
|
|
) -> Searcher: |
589
|
|
|
""" |
590
|
|
|
General functions from DrugBank targets. |
591
|
|
|
|
592
|
|
|
OBJECT: Name of the general function (e.g. "Toxic substance binding") |
593
|
|
|
|
594
|
|
|
PREDICATE: against on target (e.g. "binder", "downregulator", or "agonist"). |
595
|
|
|
""" |
596
|
|
|
built = DrugbankGeneralFunctionSearch(key, Apis.Pubchem, {DrugbankTargetType.target}) |
597
|
|
|
return cls._run(built, path, to, check, log, quiet, verbose, no_setup) |
598
|
|
|
|
599
|
|
|
|
600
|
|
|
class EntryDrugbankTransporter(Entry[DrugbankTargetSearch]): |
|
|
|
|
601
|
|
View Code Duplication |
@classmethod |
|
|
|
|
602
|
|
|
def run( |
|
|
|
|
603
|
|
|
cls, |
|
|
|
|
604
|
|
|
path: Path = EntryArgs.path, |
|
|
|
|
605
|
|
|
key: str = EntryArgs.key("inter.drugbank:pk"), |
|
|
|
|
606
|
|
|
to: Optional[Path] = EntryArgs.to, |
|
|
|
|
607
|
|
|
check: bool = EntryArgs.test, |
|
|
|
|
608
|
|
|
log: Optional[Path] = EntryArgs.log_path, |
|
|
|
|
609
|
|
|
quiet: bool = EntryArgs.quiet, |
|
|
|
|
610
|
|
|
verbose: bool = EntryArgs.verbose, |
|
|
|
|
611
|
|
|
no_setup: bool = EntryArgs.no_setup, |
|
|
|
|
612
|
|
|
) -> Searcher: |
613
|
|
|
""" |
614
|
|
|
PK-related proteins from DrugBank. |
615
|
|
|
|
616
|
|
|
OBJECT: Transporter name (e.g. "Solute carrier family 22 member 11") from DrugBank |
617
|
|
|
|
618
|
|
|
PREDICATE: "transported by", "carried by", or "metabolized by" |
619
|
|
|
""" |
620
|
|
|
target_types = { |
621
|
|
|
DrugbankTargetType.transporter, |
622
|
|
|
DrugbankTargetType.carrier, |
623
|
|
|
DrugbankTargetType.enzyme, |
624
|
|
|
} |
625
|
|
|
built = DrugbankTargetSearch(key, Apis.Pubchem, target_types) |
626
|
|
|
return cls._run(built, path, to, check, log, quiet, verbose, no_setup) |
627
|
|
|
|
628
|
|
|
|
629
|
|
|
class EntryTransporterGeneralFunction(Entry[DrugbankGeneralFunctionSearch]): |
|
|
|
|
630
|
|
View Code Duplication |
@classmethod |
|
|
|
|
631
|
|
|
def run( |
|
|
|
|
632
|
|
|
cls, |
|
|
|
|
633
|
|
|
path: Path = EntryArgs.path, |
|
|
|
|
634
|
|
|
key: str = EntryArgs.key("inter.drugbank:pk-fn"), |
|
|
|
|
635
|
|
|
to: Optional[Path] = EntryArgs.to, |
|
|
|
|
636
|
|
|
check: bool = EntryArgs.test, |
|
|
|
|
637
|
|
|
log: Optional[Path] = EntryArgs.log_path, |
|
|
|
|
638
|
|
|
quiet: bool = EntryArgs.quiet, |
|
|
|
|
639
|
|
|
verbose: bool = EntryArgs.verbose, |
|
|
|
|
640
|
|
|
no_setup: bool = EntryArgs.no_setup, |
|
|
|
|
641
|
|
|
) -> Searcher: |
642
|
|
|
""" |
643
|
|
|
DrugBank PK-related protein functions. |
644
|
|
|
|
645
|
|
|
OBJECT: Name of the general function (e.g. "Toxic substance binding") |
646
|
|
|
|
647
|
|
|
PREDICATE: "transported by", "carried by", or "metabolized by" |
648
|
|
|
""" |
649
|
|
|
target_types = { |
650
|
|
|
DrugbankTargetType.transporter, |
651
|
|
|
DrugbankTargetType.carrier, |
652
|
|
|
DrugbankTargetType.enzyme, |
653
|
|
|
} |
654
|
|
|
built = DrugbankGeneralFunctionSearch(key, Apis.Pubchem, target_types) |
655
|
|
|
return cls._run(built, path, to, check, log, quiet, verbose, no_setup) |
656
|
|
|
|
657
|
|
|
|
658
|
|
|
class EntryDrugbankDdi(Entry[DrugbankDdiSearch]): |
|
|
|
|
659
|
|
|
@classmethod |
660
|
|
|
def run( |
|
|
|
|
661
|
|
|
cls, |
|
|
|
|
662
|
|
|
path: Path = EntryArgs.path, |
|
|
|
|
663
|
|
|
key: str = EntryArgs.key("inter.drugbank:ddi"), |
|
|
|
|
664
|
|
|
to: Optional[Path] = EntryArgs.to, |
|
|
|
|
665
|
|
|
check: bool = EntryArgs.test, |
|
|
|
|
666
|
|
|
log: Optional[Path] = EntryArgs.log_path, |
|
|
|
|
667
|
|
|
quiet: bool = EntryArgs.quiet, |
|
|
|
|
668
|
|
|
verbose: bool = EntryArgs.verbose, |
|
|
|
|
669
|
|
|
no_setup: bool = EntryArgs.no_setup, |
|
|
|
|
670
|
|
|
) -> Searcher: |
671
|
|
|
""" |
672
|
|
|
Drug/drug interactions listed by DrugBank. |
673
|
|
|
|
674
|
|
|
The 'description' column includes useful information about the interaction, |
675
|
|
|
such as diseases and whether a risk is increased or decreased. |
676
|
|
|
|
677
|
|
|
OBJECT: name of the drug (e.g. "ibuprofen") |
678
|
|
|
|
679
|
|
|
PREDICATE: "ddi" |
680
|
|
|
""" |
681
|
|
|
built = DrugbankDdiSearch(key, Apis.Pubchem) |
682
|
|
|
return cls._run(built, path, to, check, log, quiet, verbose, no_setup) |
683
|
|
|
|
684
|
|
|
|
685
|
|
|
class EntryPubchemAssay(Entry[BioactivitySearch]): |
|
|
|
|
686
|
|
|
@classmethod |
687
|
|
|
def run( |
|
|
|
|
688
|
|
|
cls, |
|
|
|
|
689
|
|
|
path: Path = EntryArgs.path, |
|
|
|
|
690
|
|
|
key: str = EntryArgs.key("assay.pubchem:activity"), |
|
|
|
|
691
|
|
|
to: Optional[Path] = EntryArgs.to, |
|
|
|
|
692
|
|
|
name_must_match: bool = EntryArgs.name_must_match, |
|
|
|
|
693
|
|
|
ban_sources: Optional[str] = None, |
|
|
|
|
694
|
|
|
check: bool = EntryArgs.test, |
|
|
|
|
695
|
|
|
log: Optional[Path] = EntryArgs.log_path, |
|
|
|
|
696
|
|
|
quiet: bool = EntryArgs.quiet, |
|
|
|
|
697
|
|
|
verbose: bool = EntryArgs.verbose, |
|
|
|
|
698
|
|
|
no_setup: bool = EntryArgs.no_setup, |
|
|
|
|
699
|
|
|
) -> Searcher: |
700
|
|
|
""" |
701
|
|
|
PubChem bioactivity results. |
702
|
|
|
|
703
|
|
|
Note: The species name, if present, is taken from the target name. |
704
|
|
|
The taxon ID is what was curated in PubChem. |
705
|
|
|
|
706
|
|
|
OBJECT: Name of the target without species suffix (e.g. "Slc6a3 - solute carrier family 6 member 3") |
|
|
|
|
707
|
|
|
|
708
|
|
|
PREDICATE: "active"|"inactive"|"inconclusive"|"undetermined" |
709
|
|
|
|
710
|
|
|
SOURCE: "PubChem: <referrer> "(""confirmatory"|"literature"|"other"")" |
711
|
|
|
""" |
712
|
|
|
built = BioactivitySearch(key, Apis.Pubchem, compound_name_must_match=name_must_match) |
713
|
|
|
return cls._run(built, path, to, check, log, quiet, verbose, no_setup) |
714
|
|
|
|
715
|
|
|
|
716
|
|
|
class EntryDeaSchedule(Entry[BioactivitySearch]): |
|
|
|
|
717
|
|
|
@classmethod |
718
|
|
|
def run( |
|
|
|
|
719
|
|
|
cls, |
|
|
|
|
720
|
|
|
path: Path = EntryArgs.path, |
|
|
|
|
721
|
|
|
key: str = EntryArgs.key("drug.dea:schedule"), |
|
|
|
|
722
|
|
|
to: Optional[Path] = EntryArgs.to, |
|
|
|
|
723
|
|
|
check: bool = EntryArgs.test, |
|
|
|
|
724
|
|
|
log: Optional[Path] = EntryArgs.log_path, |
|
|
|
|
725
|
|
|
quiet: bool = EntryArgs.quiet, |
|
|
|
|
726
|
|
|
verbose: bool = EntryArgs.verbose, |
|
|
|
|
727
|
|
|
no_setup: bool = EntryArgs.no_setup, |
|
|
|
|
728
|
|
|
) -> Searcher: |
729
|
|
|
""" |
730
|
|
|
DEA schedules (PENDING). |
731
|
|
|
|
732
|
|
|
OBJECT: (1 to 4, or "unscheduled") |
733
|
|
|
|
734
|
|
|
PREDICATE: "has DEA schedule" |
735
|
|
|
""" |
736
|
|
|
pass |
|
|
|
|
737
|
|
|
|
738
|
|
|
|
739
|
|
|
class EntryDeaClass(Entry[BioactivitySearch]): |
|
|
|
|
740
|
|
|
@classmethod |
741
|
|
|
def run( |
|
|
|
|
742
|
|
|
cls, |
|
|
|
|
743
|
|
|
path: Path = EntryArgs.path, |
|
|
|
|
744
|
|
|
key: str = EntryArgs.key("drug.dea:class"), |
|
|
|
|
745
|
|
|
to: Optional[Path] = EntryArgs.to, |
|
|
|
|
746
|
|
|
check: bool = EntryArgs.test, |
|
|
|
|
747
|
|
|
log: Optional[Path] = EntryArgs.log_path, |
|
|
|
|
748
|
|
|
quiet: bool = EntryArgs.quiet, |
|
|
|
|
749
|
|
|
verbose: bool = EntryArgs.verbose, |
|
|
|
|
750
|
|
|
no_setup: bool = EntryArgs.no_setup, |
|
|
|
|
751
|
|
|
) -> Searcher: |
752
|
|
|
""" |
753
|
|
|
DEA classes (PENDING). |
754
|
|
|
|
755
|
|
|
OBJECT: e.g. "hallucinogen" |
756
|
|
|
|
757
|
|
|
PREDICATE: "is in DEA class" |
758
|
|
|
""" |
759
|
|
|
pass |
|
|
|
|
760
|
|
|
|
761
|
|
|
|
762
|
|
|
class EntryChemidPlusAcute(Entry[AcuteEffectSearch]): |
|
|
|
|
763
|
|
|
@classmethod |
764
|
|
|
def run( |
|
|
|
|
765
|
|
|
cls, |
|
|
|
|
766
|
|
|
path: Path = EntryArgs.path, |
|
|
|
|
767
|
|
|
key: str = EntryArgs.key("tox.chemidplus:acute"), |
|
|
|
|
768
|
|
|
to: Optional[Path] = EntryArgs.to, |
|
|
|
|
769
|
|
|
level: int = EntryArgs.acute_effect_level, |
|
|
|
|
770
|
|
|
check: bool = EntryArgs.test, |
|
|
|
|
771
|
|
|
log: Optional[Path] = EntryArgs.log_path, |
|
|
|
|
772
|
|
|
quiet: bool = EntryArgs.quiet, |
|
|
|
|
773
|
|
|
verbose: bool = EntryArgs.verbose, |
|
|
|
|
774
|
|
|
no_setup: bool = EntryArgs.no_setup, |
|
|
|
|
775
|
|
|
) -> Searcher: |
776
|
|
|
""" |
777
|
|
|
Acute effect codes from ChemIDPlus. |
778
|
|
|
|
779
|
|
|
OBJECT: E.g. "behavioral: excitement" |
780
|
|
|
|
781
|
|
|
PREDICATE: "causes acute effect" |
782
|
|
|
|
783
|
|
|
OTHER COLUMNS: |
784
|
|
|
|
785
|
|
|
- organism: e.g. 'women', 'infant', 'men', 'human', 'dog', 'domestic animals - sheep and goats' |
|
|
|
|
786
|
|
|
- human: true or false |
787
|
|
|
- test_type: e.g. 'TDLo' |
788
|
|
|
- route: e.g. 'skin' |
789
|
|
|
- mg_per_kg: e.g. 17.5 |
790
|
|
|
""" |
791
|
|
|
built = AcuteEffectSearch( |
792
|
|
|
key, |
793
|
|
|
Apis.Pubchem, |
794
|
|
|
top_level=level == 1, |
795
|
|
|
) |
796
|
|
|
return cls._run(built, path, to, check, log, quiet, verbose, no_setup) |
797
|
|
|
|
798
|
|
|
|
799
|
|
|
class EntryChemidPlusLd50(Entry[Ld50Search]): |
|
|
|
|
800
|
|
|
@classmethod |
801
|
|
|
def run( |
|
|
|
|
802
|
|
|
cls, |
|
|
|
|
803
|
|
|
path: Path = EntryArgs.path, |
|
|
|
|
804
|
|
|
key: str = EntryArgs.key("tox.chemidplus:ld50"), |
|
|
|
|
805
|
|
|
to: Optional[Path] = EntryArgs.to, |
|
|
|
|
806
|
|
|
check: bool = EntryArgs.test, |
|
|
|
|
807
|
|
|
log: Optional[Path] = EntryArgs.log_path, |
|
|
|
|
808
|
|
|
quiet: bool = EntryArgs.quiet, |
|
|
|
|
809
|
|
|
verbose: bool = EntryArgs.verbose, |
|
|
|
|
810
|
|
|
no_setup: bool = EntryArgs.no_setup, |
|
|
|
|
811
|
|
|
) -> Searcher: |
812
|
|
|
""" |
813
|
|
|
LD50 acute effects from ChemIDPlus. |
814
|
|
|
|
815
|
|
|
OBJECT: A dose in mg/kg (e.g. 3100) |
816
|
|
|
|
817
|
|
|
PREDICATE: "LD50 :: <route>" (e.g. "LD50 :: intravenous) |
818
|
|
|
|
819
|
|
|
OTHER COLUMNS: |
820
|
|
|
|
821
|
|
|
- organism: e.g. 'women', 'infant', 'men', 'human', 'dog', 'domestic animals - sheep and goats' |
|
|
|
|
822
|
|
|
- human: true or false |
823
|
|
|
""" |
824
|
|
|
built = Ld50Search(key, Apis.Pubchem) |
825
|
|
|
return cls._run(built, path, to, check, log, quiet, verbose, no_setup) |
826
|
|
|
|
827
|
|
|
|
828
|
|
|
class EntryHmdbTissue(Entry[BioactivitySearch]): |
|
|
|
|
829
|
|
|
@classmethod |
830
|
|
|
def run( |
|
|
|
|
831
|
|
|
cls, |
|
|
|
|
832
|
|
|
path: Path = EntryArgs.path, |
|
|
|
|
833
|
|
|
key: str = EntryArgs.key("hmdb:tissue"), |
|
|
|
|
834
|
|
|
to: Optional[Path] = EntryArgs.to, |
|
|
|
|
835
|
|
|
min_nanomolar: Optional[float] = None, |
|
|
|
|
836
|
|
|
check: bool = EntryArgs.test, |
|
|
|
|
837
|
|
|
log: Optional[Path] = EntryArgs.log_path, |
|
|
|
|
838
|
|
|
quiet: bool = EntryArgs.quiet, |
|
|
|
|
839
|
|
|
verbose: bool = EntryArgs.verbose, |
|
|
|
|
840
|
|
|
no_setup: bool = EntryArgs.no_setup, |
|
|
|
|
841
|
|
|
) -> Searcher: |
842
|
|
|
""" |
843
|
|
|
Tissue concentrations from HMDB (PENDING). |
844
|
|
|
|
845
|
|
|
OBJECT: |
846
|
|
|
|
847
|
|
|
PREDICATE: "tissue" |
848
|
|
|
""" |
849
|
|
|
pass |
|
|
|
|
850
|
|
|
|
851
|
|
|
|
852
|
|
|
class EntryHmdbComputed(Entry[BioactivitySearch]): |
|
|
|
|
853
|
|
|
@classmethod |
854
|
|
|
def run( |
|
|
|
|
855
|
|
|
cls, |
|
|
|
|
856
|
|
|
path: Path = EntryArgs.path, |
|
|
|
|
857
|
|
|
key: str = EntryArgs.key("hmdb:computed"), |
|
|
|
|
858
|
|
|
to: Optional[Path] = EntryArgs.to, |
|
|
|
|
859
|
|
|
min_nanomolar: Optional[float] = None, |
|
|
|
|
860
|
|
|
check: bool = EntryArgs.test, |
|
|
|
|
861
|
|
|
log: Optional[Path] = EntryArgs.log_path, |
|
|
|
|
862
|
|
|
quiet: bool = EntryArgs.quiet, |
|
|
|
|
863
|
|
|
verbose: bool = EntryArgs.verbose, |
|
|
|
|
864
|
|
|
no_setup: bool = EntryArgs.no_setup, |
|
|
|
|
865
|
|
|
) -> Searcher: |
866
|
|
|
""" |
867
|
|
|
Computed properties from HMDB (PENDING). |
868
|
|
|
|
869
|
|
|
Keys include pKa, logP, logS, etc. |
870
|
|
|
|
871
|
|
|
OBJECT: A number; booleans are converted to 0/1 |
872
|
|
|
|
873
|
|
|
PREDICATE: The name of the property |
874
|
|
|
""" |
875
|
|
|
pass |
|
|
|
|
876
|
|
|
|
877
|
|
|
|
878
|
|
|
class EntryPubchemReact(Entry[BioactivitySearch]): |
|
|
|
|
879
|
|
|
@classmethod |
880
|
|
|
def run( |
|
|
|
|
881
|
|
|
cls, |
|
|
|
|
882
|
|
|
path: Path = EntryArgs.path, |
|
|
|
|
883
|
|
|
key: str = EntryArgs.key("inter.pubchem:react"), |
|
|
|
|
884
|
|
|
to: Optional[Path] = EntryArgs.to, |
|
|
|
|
885
|
|
|
check: bool = EntryArgs.test, |
|
|
|
|
886
|
|
|
log: Optional[Path] = EntryArgs.log_path, |
|
|
|
|
887
|
|
|
quiet: bool = EntryArgs.quiet, |
|
|
|
|
888
|
|
|
verbose: bool = EntryArgs.verbose, |
|
|
|
|
889
|
|
|
no_setup: bool = EntryArgs.no_setup, |
|
|
|
|
890
|
|
|
) -> Searcher: |
891
|
|
|
""" |
892
|
|
|
Metabolic reactions (PENDING). |
893
|
|
|
|
894
|
|
|
OBJECT: Equation |
895
|
|
|
|
896
|
|
|
PREDICATE: "<pathway>" |
897
|
|
|
""" |
898
|
|
|
pass |
|
|
|
|
899
|
|
|
|
900
|
|
|
|
901
|
|
|
class EntryPubchemComputed(Entry[ComputedPropertySearch]): |
|
|
|
|
902
|
|
|
@classmethod |
903
|
|
|
def run( |
|
|
|
|
904
|
|
|
cls, |
|
|
|
|
905
|
|
|
path: Path = EntryArgs.path, |
|
|
|
|
906
|
|
|
key: str = EntryArgs.key("chem.pubchem:computed"), |
|
|
|
|
907
|
|
|
keys: str = EntryArgs.pubchem_computed_keys, |
|
|
|
|
908
|
|
|
to: Optional[Path] = EntryArgs.to, |
|
|
|
|
909
|
|
|
check: bool = EntryArgs.test, |
|
|
|
|
910
|
|
|
log: Optional[Path] = EntryArgs.log_path, |
|
|
|
|
911
|
|
|
quiet: bool = EntryArgs.quiet, |
|
|
|
|
912
|
|
|
verbose: bool = EntryArgs.verbose, |
|
|
|
|
913
|
|
|
no_setup: bool = EntryArgs.no_setup, |
|
|
|
|
914
|
|
|
) -> Searcher: |
915
|
|
|
""" |
916
|
|
|
Computed properties from PubChem. |
917
|
|
|
|
918
|
|
|
OBJECT: Number |
919
|
|
|
|
920
|
|
|
PREDICATE: e.g. "complexity" |
921
|
|
|
""" |
922
|
|
|
# replace acronyms, etc. |
923
|
|
|
# ComputedPropertySearch standardizes punctuation and casing |
924
|
|
|
known = { |
925
|
|
|
k: v |
926
|
|
|
for k, v in { |
927
|
|
|
**EntryArgs.KNOWN_USEFUL_KEYS, |
928
|
|
|
**EntryArgs.KNOWN_USELESS_KEYS, |
929
|
|
|
}.items() |
930
|
|
|
if v is not None |
931
|
|
|
} |
932
|
|
|
keys = {known.get(s.strip(), s) for s in keys.split(",")} |
933
|
|
|
built = ComputedPropertySearch(key, Apis.Pubchem, descriptors=keys) |
934
|
|
|
return cls._run(built, path, to, check, log, quiet, verbose, no_setup) |
935
|
|
|
|
936
|
|
|
|
937
|
|
|
class EntryDrugbankAdmet(Entry[DrugbankTargetSearch]): |
|
|
|
|
938
|
|
|
@classmethod |
939
|
|
|
def run( |
|
|
|
|
940
|
|
|
cls, |
|
|
|
|
941
|
|
|
path: Path = EntryArgs.path, |
|
|
|
|
942
|
|
|
key: str = EntryArgs.key("drugbank.admet:properties"), |
|
|
|
|
943
|
|
|
to: Optional[Path] = EntryArgs.to, |
|
|
|
|
944
|
|
|
check: bool = EntryArgs.test, |
|
|
|
|
945
|
|
|
log: Optional[Path] = EntryArgs.log_path, |
|
|
|
|
946
|
|
|
quiet: bool = EntryArgs.quiet, |
|
|
|
|
947
|
|
|
verbose: bool = EntryArgs.verbose, |
|
|
|
|
948
|
|
|
no_setup: bool = EntryArgs.no_setup, |
|
|
|
|
949
|
|
|
) -> Searcher: |
950
|
|
|
""" |
951
|
|
|
Enzyme predictions from DrugBank (PENDING). |
952
|
|
|
|
953
|
|
|
OBJECT: Enzyme name |
954
|
|
|
|
955
|
|
|
PREDICATE: Action |
956
|
|
|
""" |
957
|
|
|
|
958
|
|
|
|
959
|
|
|
class EntryDrugbankMetabolites(Entry[DrugbankTargetSearch]): |
|
|
|
|
960
|
|
|
@classmethod |
961
|
|
|
def run( |
|
|
|
|
962
|
|
|
cls, |
|
|
|
|
963
|
|
|
path: Path = EntryArgs.path, |
|
|
|
|
964
|
|
|
key: str = EntryArgs.key("drugbank.admet:metabolites"), |
|
|
|
|
965
|
|
|
to: Optional[Path] = EntryArgs.to, |
|
|
|
|
966
|
|
|
check: bool = EntryArgs.test, |
|
|
|
|
967
|
|
|
log: Optional[Path] = EntryArgs.log_path, |
|
|
|
|
968
|
|
|
quiet: bool = EntryArgs.quiet, |
|
|
|
|
969
|
|
|
verbose: bool = EntryArgs.verbose, |
|
|
|
|
970
|
|
|
no_setup: bool = EntryArgs.no_setup, |
|
|
|
|
971
|
|
|
) -> Searcher: |
972
|
|
|
""" |
973
|
|
|
Metabolites from DrugBank (PENDING). |
974
|
|
|
|
975
|
|
|
OBJECT: Compound name (e.g. "norcocaine"). |
976
|
|
|
|
977
|
|
|
PREDICATE: "metabolized to" |
978
|
|
|
""" |
979
|
|
|
|
980
|
|
|
|
981
|
|
|
class EntryDrugbankDosage(Entry[DrugbankTargetSearch]): |
|
|
|
|
982
|
|
|
@classmethod |
983
|
|
|
def run( |
|
|
|
|
984
|
|
|
cls, |
|
|
|
|
985
|
|
|
path: Path = EntryArgs.path, |
|
|
|
|
986
|
|
|
key: str = EntryArgs.key("drugbank.admet:dosage"), |
|
|
|
|
987
|
|
|
to: Optional[Path] = EntryArgs.to, |
|
|
|
|
988
|
|
|
check: bool = EntryArgs.test, |
|
|
|
|
989
|
|
|
log: Optional[Path] = EntryArgs.log_path, |
|
|
|
|
990
|
|
|
quiet: bool = EntryArgs.quiet, |
|
|
|
|
991
|
|
|
verbose: bool = EntryArgs.verbose, |
|
|
|
|
992
|
|
|
no_setup: bool = EntryArgs.no_setup, |
|
|
|
|
993
|
|
|
) -> Searcher: |
994
|
|
|
""" |
995
|
|
|
Dosage from DrugBank (PENDING). |
996
|
|
|
|
997
|
|
|
OBJECT: concentration in mg/mL |
998
|
|
|
|
999
|
|
|
PREDICATE: "dosage :: <route>" |
1000
|
|
|
|
1001
|
|
|
OTHER COLUMNS: |
1002
|
|
|
|
1003
|
|
|
- form (e.g. liquid) |
1004
|
|
|
""" |
1005
|
|
|
|
1006
|
|
|
|
1007
|
|
|
class EntryMetaRandom(Entry[BioactivitySearch]): |
|
|
|
|
1008
|
|
|
@classmethod |
1009
|
|
|
def run( |
|
|
|
|
1010
|
|
|
cls, |
|
|
|
|
1011
|
|
|
path: Path = EntryArgs.path, |
|
|
|
|
1012
|
|
|
key: str = EntryArgs.key("meta:random"), |
|
|
|
|
1013
|
|
|
to: Optional[Path] = EntryArgs.to, |
|
|
|
|
1014
|
|
|
check: bool = EntryArgs.test, |
|
|
|
|
1015
|
|
|
log: Optional[Path] = EntryArgs.log_path, |
|
|
|
|
1016
|
|
|
quiet: bool = EntryArgs.quiet, |
|
|
|
|
1017
|
|
|
verbose: bool = EntryArgs.verbose, |
|
|
|
|
1018
|
|
|
no_setup: bool = EntryArgs.no_setup, |
|
|
|
|
1019
|
|
|
) -> Searcher: |
1020
|
|
|
""" |
1021
|
|
|
Random class assignment (PENDING). |
1022
|
|
|
|
1023
|
|
|
OBJECT: 1 thru n-compounds |
1024
|
|
|
|
1025
|
|
|
PREDICATE: "random" |
1026
|
|
|
""" |
1027
|
|
|
pass |
|
|
|
|
1028
|
|
|
|
1029
|
|
|
|
1030
|
|
|
Entries = [ |
1031
|
|
|
EntryChemblBinding, |
1032
|
|
|
EntryChemblMechanism, |
1033
|
|
|
EntryChemblAtc, |
1034
|
|
|
EntryChemblTrials, |
1035
|
|
|
EntryGoFunction, |
1036
|
|
|
EntryGoProcess, |
1037
|
|
|
EntryGoComponent, |
1038
|
|
|
EntryPubchemComputed, |
1039
|
|
|
EntryPubchemDisease, |
1040
|
|
|
EntryPubchemGeneCoOccurrence, |
1041
|
|
|
EntryPubchemDiseaseCoOccurrence, |
1042
|
|
|
EntryPubchemChemicalCoOccurrence, |
1043
|
|
|
EntryPubchemDgi, |
1044
|
|
|
EntryPubchemCgi, |
1045
|
|
|
EntryDrugbankTarget, |
1046
|
|
|
EntryGeneralFunction, |
1047
|
|
|
EntryDrugbankTransporter, |
1048
|
|
|
EntryTransporterGeneralFunction, |
1049
|
|
|
EntryDrugbankDdi, |
1050
|
|
|
EntryPubchemAssay, |
1051
|
|
|
EntryDeaSchedule, |
1052
|
|
|
EntryDeaClass, |
1053
|
|
|
EntryChemidPlusAcute, |
1054
|
|
|
EntryChemidPlusLd50, |
1055
|
|
|
EntryHmdbTissue, |
1056
|
|
|
EntryPubchemReact, |
1057
|
|
|
EntryMetaRandom, |
1058
|
|
|
] |
1059
|
|
|
|