Total Complexity | 46 |
Total Lines | 1174 |
Duplicated Lines | 44.04 % |
Changes | 0 |
Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like mandos.entry.entry_commands often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
1 | """ |
||
|
|||
2 | Run searches and write files. |
||
3 | """ |
||
4 | |||
5 | from __future__ import annotations |
||
6 | |||
7 | import abc |
||
8 | import inspect |
||
9 | from pathlib import Path |
||
10 | from typing import Optional, TypeVar |
||
11 | |||
12 | from pocketutils.core.exceptions import InjectionError |
||
13 | from pocketutils.tools.reflection_tools import ReflectionTools |
||
14 | |||
15 | from mandos.entry import entry |
||
16 | from mandos.entry.abstract_entries import Entry |
||
17 | from mandos.entry.api_singletons import Apis |
||
18 | from mandos.entry.tools.searchers import Searcher |
||
19 | from mandos.entry.utils._arg_utils import ArgUtils |
||
20 | from mandos.entry.utils._common_args import CommonArgs |
||
21 | from mandos.entry.utils._entry_args import EntryArgs |
||
22 | from mandos.model.apis.chembl_api import ChemblApi |
||
23 | from mandos.model.apis.pubchem_support.pubchem_models import ( |
||
24 | ClinicalTrialsGovUtils, |
||
25 | CoOccurrenceType, |
||
26 | DrugbankTargetType, |
||
27 | ) |
||
28 | from mandos.model.concrete_hits import GoType |
||
29 | from mandos.model.utils.setup import logger |
||
30 | from mandos.search.chembl.atc_search import AtcSearch |
||
31 | from mandos.search.chembl.binding_search import BindingSearch |
||
32 | from mandos.search.chembl.go_search import GoSearch |
||
33 | from mandos.search.chembl.indication_search import IndicationSearch |
||
34 | from mandos.search.chembl.mechanism_search import MechanismSearch |
||
35 | from mandos.search.chembl.target_prediction_search import TargetPredictionSearch |
||
36 | from mandos.search.g2p.g2p_interaction_search import G2pInteractionSearch |
||
37 | from mandos.search.hmdb.tissue_concentration_search import TissueConcentrationSearch |
||
38 | from mandos.search.meta.random_search import RandomSearch |
||
39 | from mandos.search.pubchem.acute_effects_search import AcuteEffectSearch, Ld50Search |
||
40 | from mandos.search.pubchem.bioactivity_search import BioactivitySearch |
||
41 | from mandos.search.pubchem.computed_property_search import ComputedPropertySearch |
||
42 | from mandos.search.pubchem.cooccurrence_search import ( |
||
43 | ChemicalCoOccurrenceSearch, |
||
44 | CoOccurrenceSearch, |
||
45 | DiseaseCoOccurrenceSearch, |
||
46 | GeneCoOccurrenceSearch, |
||
47 | ) |
||
48 | from mandos.search.pubchem.ctd_gene_search import CtdGeneSearch |
||
49 | from mandos.search.pubchem.dgidb_search import DgiSearch |
||
50 | from mandos.search.pubchem.disease_search import DiseaseSearch |
||
51 | from mandos.search.pubchem.drugbank_ddi_search import DrugbankDdiSearch |
||
52 | from mandos.search.pubchem.drugbank_interaction_search import ( |
||
53 | DrugbankGeneralFunctionSearch, |
||
54 | DrugbankTargetSearch, |
||
55 | ) |
||
56 | from mandos.search.pubchem.trials_search import TrialSearch |
||
57 | |||
58 | U = TypeVar("U", covariant=True, bound=CoOccurrenceSearch) |
||
59 | |||
60 | |||
61 | class EntryChemblBinding(Entry[BindingSearch]): |
||
62 | @classmethod |
||
63 | def run( |
||
64 | cls, |
||
65 | path: Path = CommonArgs.in_compound_table, |
||
66 | key: str = EntryArgs.key("chembl:binding"), |
||
67 | to: Optional[Path] = CommonArgs.out_annotations_file, |
||
68 | taxa: str = CommonArgs.taxa, |
||
69 | traversal: str = EntryArgs.traversal, |
||
70 | target_types: str = EntryArgs.target_types, |
||
71 | confidence: int = EntryArgs.min_confidence, |
||
72 | binding: float = EntryArgs.binds_cutoff, |
||
73 | pchembl: float = EntryArgs.min_pchembl, |
||
74 | as_of: Optional[str] = CommonArgs.as_of, |
||
75 | replace: bool = CommonArgs.replace, |
||
76 | proceed: bool = CommonArgs.proceed, |
||
77 | check: bool = EntryArgs.check, |
||
78 | log: Optional[Path] = CommonArgs.log, |
||
79 | stderr: str = CommonArgs.stderr, |
||
80 | ) -> Searcher: |
||
81 | """ |
||
82 | Binding data from ChEMBL. |
||
83 | |||
84 | These are 'activity' annotations of the type 'B' that have a pCHEMBL value. |
||
85 | https://mandos-chem.readthedocs.io/en/latest/binding.html |
||
86 | |||
87 | OBJECT: The target name |
||
88 | |||
89 | WEIGHT: The PCHEMBL value |
||
90 | """ |
||
91 | tax = ArgUtils.get_taxonomy(taxa) |
||
92 | built = BindingSearch( |
||
93 | key=key, |
||
94 | api=Apis.Chembl, |
||
95 | taxa=tax, |
||
96 | traversal=traversal, |
||
97 | target_types=ArgUtils.get_target_types(target_types), |
||
98 | min_conf_score=confidence, |
||
99 | relations={"<", "<=", "="}, # there are no others with pchembl |
||
100 | min_pchembl=pchembl, |
||
101 | binds_cutoff=binding, |
||
102 | ) |
||
103 | return cls._run(built, path, to, replace, proceed, check, log, stderr) |
||
104 | |||
105 | |||
106 | class EntryChemblMechanism(Entry[MechanismSearch]): |
||
107 | View Code Duplication | @classmethod |
|
108 | @entry() |
||
109 | def run( |
||
110 | cls, |
||
111 | path: Path = CommonArgs.in_compound_table, |
||
112 | key: str = EntryArgs.key("chembl:mechanism"), |
||
113 | to: Optional[Path] = CommonArgs.out_annotations_file, |
||
114 | taxa: str = CommonArgs.taxa, |
||
115 | traversal: str = EntryArgs.traversal, |
||
116 | target_types: str = EntryArgs.target_types, |
||
117 | min_confidence: Optional[int] = EntryArgs.min_confidence, |
||
118 | as_of: Optional[str] = CommonArgs.as_of, |
||
119 | replace: bool = CommonArgs.replace, |
||
120 | proceed: bool = CommonArgs.proceed, |
||
121 | check: bool = EntryArgs.check, |
||
122 | log: Optional[Path] = CommonArgs.log, |
||
123 | stderr: str = CommonArgs.stderr, |
||
124 | ) -> Searcher: |
||
125 | """ |
||
126 | Mechanism of action (MOA) data from ChEMBL. |
||
127 | |||
128 | OBJECT: The target name |
||
129 | |||
130 | PREDICATE: The target action (e.g. "agonist") |
||
131 | """ |
||
132 | tax = ArgUtils.get_taxonomy(taxa) |
||
133 | built = MechanismSearch( |
||
134 | key=key, |
||
135 | api=Apis.Chembl, |
||
136 | taxa=tax, |
||
137 | traversal=traversal, |
||
138 | allowed_target_types=ArgUtils.get_target_types(target_types), |
||
139 | min_confidence_score=min_confidence, |
||
140 | ) |
||
141 | return cls._run(built, path, to, replace, proceed, check, log, stderr) |
||
142 | |||
143 | |||
144 | class ChemblQsarPredictions(Entry[TargetPredictionSearch]): |
||
145 | View Code Duplication | @classmethod |
|
146 | @entry() |
||
147 | def run( |
||
148 | cls, |
||
149 | path: Path = CommonArgs.in_compound_table, |
||
150 | key: str = EntryArgs.key("chembl:predictions"), |
||
151 | to: Optional[Path] = CommonArgs.out_annotations_file, |
||
152 | taxa: str = CommonArgs.taxa, |
||
153 | traversal: str = EntryArgs.traversal, |
||
154 | target_types: str = EntryArgs.target_types, |
||
155 | min_threshold: float = EntryArgs.min_threshold, |
||
156 | as_of: Optional[str] = CommonArgs.as_of, |
||
157 | replace: bool = CommonArgs.replace, |
||
158 | proceed: bool = CommonArgs.proceed, |
||
159 | check: bool = EntryArgs.check, |
||
160 | log: Optional[Path] = CommonArgs.log, |
||
161 | stderr: str = CommonArgs.stderr, |
||
162 | ) -> Searcher: |
||
163 | """ |
||
164 | Predicted target binding from ChEMBL. |
||
165 | |||
166 | https://mandos-chem.readthedocs.io/en/latest/binding.html |
||
167 | These are from a QSAR model by ChEMBL. |
||
168 | |||
169 | OBJECT: The target name |
||
170 | |||
171 | WEIGHT: The square root of the PCHEMBL threshold |
||
172 | multiplied by a prediction odds-ratio, normalized |
||
173 | """ |
||
174 | tax = ArgUtils.get_taxonomy(taxa) |
||
175 | built = TargetPredictionSearch( |
||
176 | key=key, |
||
177 | api=Apis.Chembl, |
||
178 | scrape=Apis.ChemblScrape, |
||
179 | taxa=tax, |
||
180 | traversal=traversal, |
||
181 | target_types=ArgUtils.get_target_types(target_types), |
||
182 | min_threshold=min_threshold, |
||
183 | ) |
||
184 | return cls._run(built, path, to, replace, proceed, check, log, stderr) |
||
185 | |||
186 | |||
187 | class EntryChemblTrials(Entry[IndicationSearch]): |
||
188 | @classmethod |
||
189 | @entry() |
||
190 | def run( |
||
191 | cls, |
||
192 | path: Path = CommonArgs.in_compound_table, |
||
193 | key: str = EntryArgs.key("chembl:trial"), |
||
194 | to: Optional[Path] = CommonArgs.out_annotations_file, |
||
195 | min_phase: Optional[int] = EntryArgs.chembl_trial, |
||
196 | as_of: Optional[str] = CommonArgs.as_of, |
||
197 | replace: bool = CommonArgs.replace, |
||
198 | proceed: bool = CommonArgs.proceed, |
||
199 | check: bool = EntryArgs.check, |
||
200 | log: Optional[Path] = CommonArgs.log, |
||
201 | stderr: str = CommonArgs.stderr, |
||
202 | ) -> Searcher: |
||
203 | """ |
||
204 | Diseases from clinical trials listed in ChEMBL. |
||
205 | |||
206 | OBJECT: The name of the disease (in MeSH) |
||
207 | """ |
||
208 | built = IndicationSearch(key=key, api=Apis.Chembl, min_phase=min_phase) |
||
209 | return cls._run(built, path, to, replace, proceed, check, log, stderr) |
||
210 | |||
211 | |||
212 | class EntryChemblAtc(Entry[AtcSearch]): |
||
213 | @classmethod |
||
214 | @entry() |
||
215 | def run( |
||
216 | cls, |
||
217 | path: Path = CommonArgs.in_compound_table, |
||
218 | key: str = EntryArgs.key("chembl:atc"), |
||
219 | to: Optional[Path] = CommonArgs.out_annotations_file, |
||
220 | levels: str = EntryArgs.atc_level, |
||
221 | as_of: Optional[str] = CommonArgs.as_of, |
||
222 | replace: bool = CommonArgs.replace, |
||
223 | proceed: bool = CommonArgs.proceed, |
||
224 | check: bool = EntryArgs.check, |
||
225 | log: Optional[Path] = CommonArgs.log, |
||
226 | stderr: str = CommonArgs.stderr, |
||
227 | ) -> Searcher: |
||
228 | """ |
||
229 | ATC codes from ChEMBL. |
||
230 | |||
231 | OBJECT: The ATC code name |
||
232 | """ |
||
233 | built = AtcSearch( |
||
234 | key=key, api=Apis.Chembl, levels={int(x.strip()) for x in levels.split(",")} |
||
235 | ) |
||
236 | return cls._run(built, path, to, replace, proceed, check, log, stderr) |
||
237 | |||
238 | |||
239 | class _EntryChemblGo(Entry[GoSearch], metaclass=abc.ABCMeta): |
||
240 | @classmethod |
||
241 | def go_type(cls) -> GoType: |
||
242 | raise NotImplementedError() |
||
243 | |||
244 | @classmethod |
||
245 | def cmd(cls) -> str: |
||
246 | me = str(cls.go_type().name) |
||
247 | return f"chembl:go.{me.lower()}" |
||
248 | |||
249 | @classmethod |
||
250 | @entry() |
||
251 | def run( |
||
252 | cls, |
||
253 | path: Path = CommonArgs.in_compound_table, |
||
254 | key: str = EntryArgs.key("<see above>"), |
||
255 | to: Optional[Path] = CommonArgs.out_annotations_file, |
||
256 | taxa: str = CommonArgs.taxa, |
||
257 | traversal: str = EntryArgs.traversal, |
||
258 | target_types: str = EntryArgs.target_types, |
||
259 | confidence: Optional[int] = EntryArgs.min_confidence, |
||
260 | pchembl: float = EntryArgs.min_pchembl, |
||
261 | binding_search: Optional[str] = EntryArgs.binding_search_name, |
||
262 | as_of: Optional[str] = CommonArgs.as_of, |
||
263 | replace: bool = CommonArgs.replace, |
||
264 | proceed: bool = CommonArgs.proceed, |
||
265 | check: bool = EntryArgs.check, |
||
266 | log: Optional[Path] = CommonArgs.log, |
||
267 | stderr: str = CommonArgs.stderr, |
||
268 | ) -> Searcher: |
||
269 | """ |
||
270 | See the docs for the specific entries. |
||
271 | """ |
||
272 | if key is None or key == "<see above>": |
||
273 | key = cls.cmd() |
||
274 | api = ChemblApi.wrap(Apis.Chembl) |
||
275 | if binding_search is None: |
||
276 | binding_clazz = BindingSearch |
||
277 | else: |
||
278 | binding_clazz = ReflectionTools.injection(binding_search, BindingSearch) |
||
279 | logger.info(f"Passing parameters to {binding_clazz.__qualname__}") |
||
280 | try: |
||
281 | tax = ArgUtils.get_taxonomy(taxa) |
||
282 | binding_search = binding_clazz( |
||
283 | key=key, |
||
284 | api=Apis.Chembl, |
||
285 | taxa=tax, |
||
286 | traversal=traversal, |
||
287 | target_types=ArgUtils.get_target_types(target_types), |
||
288 | min_conf_score=confidence, |
||
289 | relations={"<", "<=", "="}, |
||
290 | min_pchembl=pchembl, |
||
291 | ) |
||
292 | except (TypeError, ValueError): |
||
293 | raise InjectionError(f"Failed to build {binding_clazz.__qualname__}") |
||
294 | built = GoSearch(key, api, cls.go_type(), binding_search) |
||
295 | return cls._run(built, path, to, replace, proceed, check, log, stderr) |
||
296 | |||
297 | |||
298 | View Code Duplication | class EntryGoFunction(_EntryChemblGo): |
|
299 | @classmethod |
||
300 | def go_type(cls) -> GoType: |
||
301 | return GoType.function |
||
302 | |||
303 | @classmethod |
||
304 | @entry() |
||
305 | def run( |
||
306 | cls, |
||
307 | path: Path = CommonArgs.in_compound_table, |
||
308 | key: str = EntryArgs.key("chembl:go.function"), |
||
309 | to: Optional[Path] = CommonArgs.out_annotations_file, |
||
310 | taxa: str = CommonArgs.taxa, |
||
311 | traversal: str = EntryArgs.traversal, |
||
312 | target_types: str = EntryArgs.target_types, |
||
313 | confidence: Optional[int] = EntryArgs.min_confidence, |
||
314 | pchembl: float = EntryArgs.min_pchembl, |
||
315 | binding_search: Optional[str] = EntryArgs.binding_search_name, |
||
316 | as_of: Optional[str] = CommonArgs.as_of, |
||
317 | replace: bool = CommonArgs.replace, |
||
318 | proceed: bool = CommonArgs.proceed, |
||
319 | check: bool = EntryArgs.check, |
||
320 | log: Optional[Path] = CommonArgs.log, |
||
321 | stderr: str = CommonArgs.stderr, |
||
322 | ) -> Searcher: |
||
323 | """ |
||
324 | GO Function terms associated with ChEMBL binding targets. |
||
325 | |||
326 | OBJECT: The GO Function term name |
||
327 | |||
328 | WEIGHT: The sum of the PCHEMBL values |
||
329 | """ |
||
330 | args, _, _, locs = inspect.getargvalues(inspect.currentframe()) |
||
331 | return super().run(**{a: locs[a] for a in args if a != "cls"}) |
||
332 | |||
333 | |||
334 | View Code Duplication | class EntryGoProcess(_EntryChemblGo): |
|
335 | @classmethod |
||
336 | def go_type(cls) -> GoType: |
||
337 | return GoType.process |
||
338 | |||
339 | @classmethod |
||
340 | @entry() |
||
341 | def run( |
||
342 | cls, |
||
343 | path: Path = CommonArgs.in_compound_table, |
||
344 | key: str = EntryArgs.key("chembl:go.process"), |
||
345 | to: Optional[Path] = CommonArgs.out_annotations_file, |
||
346 | taxa: str = CommonArgs.taxa, |
||
347 | traversal: str = EntryArgs.traversal, |
||
348 | target_types: str = EntryArgs.target_types, |
||
349 | confidence: Optional[int] = EntryArgs.min_confidence, |
||
350 | pchembl: float = EntryArgs.min_pchembl, |
||
351 | binding_search: Optional[str] = EntryArgs.binding_search_name, |
||
352 | as_of: Optional[str] = CommonArgs.as_of, |
||
353 | replace: bool = CommonArgs.replace, |
||
354 | proceed: bool = CommonArgs.proceed, |
||
355 | check: bool = EntryArgs.check, |
||
356 | log: Optional[Path] = CommonArgs.log, |
||
357 | stderr: str = CommonArgs.stderr, |
||
358 | ) -> Searcher: |
||
359 | """ |
||
360 | GO Process terms associated with ChEMBL binding targets. |
||
361 | |||
362 | OBJECT: The GO Process term name |
||
363 | |||
364 | WEIGHT: The sum of the PCHEMBL values |
||
365 | """ |
||
366 | args, _, _, locs = inspect.getargvalues(inspect.currentframe()) |
||
367 | return super().run(**{a: locs[a] for a in args if a != "cls"}) |
||
368 | |||
369 | |||
370 | View Code Duplication | class EntryGoComponent(_EntryChemblGo): |
|
371 | @classmethod |
||
372 | def go_type(cls) -> GoType: |
||
373 | return GoType.component |
||
374 | |||
375 | @classmethod |
||
376 | @entry() |
||
377 | def run( |
||
378 | cls, |
||
379 | path: Path = CommonArgs.in_compound_table, |
||
380 | key: str = EntryArgs.key("chembl:go.component"), |
||
381 | to: Optional[Path] = CommonArgs.out_annotations_file, |
||
382 | taxa: str = CommonArgs.taxa, |
||
383 | traversal: str = EntryArgs.traversal, |
||
384 | target_types: str = EntryArgs.target_types, |
||
385 | confidence: Optional[int] = EntryArgs.min_confidence, |
||
386 | pchembl: float = EntryArgs.min_pchembl, |
||
387 | binding_search: Optional[str] = EntryArgs.binding_search_name, |
||
388 | as_of: Optional[str] = CommonArgs.as_of, |
||
389 | replace: bool = CommonArgs.replace, |
||
390 | proceed: bool = CommonArgs.proceed, |
||
391 | check: bool = EntryArgs.check, |
||
392 | log: Optional[Path] = CommonArgs.log, |
||
393 | stderr: str = CommonArgs.stderr, |
||
394 | ) -> Searcher: |
||
395 | """ |
||
396 | GO Component terms associated with ChEMBL binding targets. |
||
397 | |||
398 | OBJECT: The GO Component term name |
||
399 | |||
400 | WEIGHT: The sum of the PCHEMBL values |
||
401 | """ |
||
402 | args, _, _, locs = inspect.getargvalues(inspect.currentframe()) |
||
403 | return super().run(**{a: locs[a] for a in args if a != "cls"}) |
||
404 | |||
405 | |||
406 | class EntryPubchemTrials(Entry[TrialSearch]): |
||
407 | @classmethod |
||
408 | @entry() |
||
409 | def run( |
||
410 | cls, |
||
411 | path: Path = CommonArgs.in_compound_table, |
||
412 | key: str = EntryArgs.key("pubchem:trial"), |
||
413 | to: Optional[Path] = CommonArgs.out_annotations_file, |
||
414 | min_phase: Optional[int] = EntryArgs.pubchem_trial_phase, |
||
415 | statuses: str = EntryArgs.pubchem_trial_statuses, |
||
416 | req_explicit: bool = EntryArgs.req_explicit, |
||
417 | as_of: Optional[str] = CommonArgs.as_of, |
||
418 | replace: bool = CommonArgs.replace, |
||
419 | proceed: bool = CommonArgs.proceed, |
||
420 | check: bool = EntryArgs.check, |
||
421 | log: Optional[Path] = CommonArgs.log, |
||
422 | stderr: str = CommonArgs.stderr, |
||
423 | ) -> Searcher: |
||
424 | """ |
||
425 | Diseases from clinical trials listed in clinicaltrials.gov. |
||
426 | |||
427 | OBJECT: The name of the disease (in MeSH) |
||
428 | """ |
||
429 | statuses = ClinicalTrialsGovUtils.resolve_statuses(statuses) |
||
430 | built = TrialSearch( |
||
431 | key=key, api=Apis.Pubchem, min_phase=min_phase, statuses=statuses, explicit=req_explicit |
||
432 | ) |
||
433 | return cls._run(built, path, to, replace, proceed, check, log, stderr) |
||
434 | |||
435 | |||
436 | class EntryPubchemDisease(Entry[DiseaseSearch]): |
||
437 | View Code Duplication | @classmethod |
|
438 | @entry() |
||
439 | def run( |
||
440 | cls, |
||
441 | path: Path = CommonArgs.in_compound_table, |
||
442 | key: str = EntryArgs.key("disease.ctd:mesh"), |
||
443 | to: Optional[Path] = CommonArgs.out_annotations_file, |
||
444 | as_of: Optional[str] = CommonArgs.as_of, |
||
445 | replace: bool = CommonArgs.replace, |
||
446 | proceed: bool = CommonArgs.proceed, |
||
447 | check: bool = EntryArgs.check, |
||
448 | log: Optional[Path] = CommonArgs.log, |
||
449 | stderr: str = CommonArgs.stderr, |
||
450 | ) -> Searcher: |
||
451 | """ |
||
452 | Diseases in the CTD. |
||
453 | |||
454 | (Comparative Toxicogenomics Database.) |
||
455 | |||
456 | OBJECT: The MeSH code of the disease |
||
457 | |||
458 | """ |
||
459 | built = DiseaseSearch(key, Apis.Pubchem) |
||
460 | return cls._run(built, path, to, replace, proceed, check, log, stderr) |
||
461 | |||
462 | |||
463 | class _EntryPubchemCoOccurrence(Entry[U], metaclass=abc.ABCMeta): |
||
464 | @classmethod |
||
465 | def cmd(cls) -> str: |
||
466 | me = str(cls.get_cooccurrence_type().name) |
||
467 | return f"lit.pubchem:{me.lower()}" |
||
468 | |||
469 | @classmethod |
||
470 | def get_cooccurrence_type(cls) -> CoOccurrenceType: |
||
471 | s: CoOccurrenceSearch = cls.get_search_type() |
||
472 | return s.cooccurrence_type() |
||
473 | |||
474 | @classmethod |
||
475 | @entry() |
||
476 | def run( |
||
477 | cls, |
||
478 | path: Path = CommonArgs.in_compound_table, |
||
479 | key: str = EntryArgs.key("<see above>"), |
||
480 | to: Optional[Path] = CommonArgs.out_annotations_file, |
||
481 | min_score: float = EntryArgs.min_cooccurrence_score, |
||
482 | min_articles: int = EntryArgs.min_cooccurring_articles, |
||
483 | as_of: Optional[str] = CommonArgs.as_of, |
||
484 | replace: bool = CommonArgs.replace, |
||
485 | proceed: bool = CommonArgs.proceed, |
||
486 | check: bool = EntryArgs.check, |
||
487 | log: Optional[Path] = CommonArgs.log, |
||
488 | stderr: str = CommonArgs.stderr, |
||
489 | ) -> Searcher: |
||
490 | """See the docstrings for the individual entries.""" |
||
491 | clazz = cls.get_search_type() |
||
492 | built = clazz(key, Apis.Pubchem, min_score=min_score, min_articles=min_articles) |
||
493 | return cls._run(built, path, to, replace, proceed, check, log, stderr) |
||
494 | |||
495 | |||
496 | View Code Duplication | class EntryPubchemGeneCoOccurrence(_EntryPubchemCoOccurrence[GeneCoOccurrenceSearch]): |
|
497 | @classmethod |
||
498 | @entry() |
||
499 | def run( |
||
500 | cls, |
||
501 | path: Path = CommonArgs.in_compound_table, |
||
502 | key: str = EntryArgs.key(f"lit.pubchem:{CoOccurrenceType.gene.name.lower()}"), |
||
503 | to: Optional[Path] = CommonArgs.out_annotations_file, |
||
504 | min_score: float = EntryArgs.min_cooccurrence_score, |
||
505 | min_articles: int = EntryArgs.min_cooccurring_articles, |
||
506 | as_of: Optional[str] = CommonArgs.as_of, |
||
507 | replace: bool = CommonArgs.replace, |
||
508 | proceed: bool = CommonArgs.proceed, |
||
509 | check: bool = EntryArgs.check, |
||
510 | log: Optional[Path] = CommonArgs.log, |
||
511 | stderr: str = CommonArgs.stderr, |
||
512 | ) -> Searcher: |
||
513 | """ |
||
514 | Co-occurrences of genes from PubMed articles. |
||
515 | |||
516 | https://mandos-chem.readthedocs.io/en/latest/co-occurrences.html |
||
517 | |||
518 | OBJECT: The name of the gene |
||
519 | |||
520 | WEIGHT: The co-occurrence score (refer to the docs) |
||
521 | """ |
||
522 | args, _, _, locs = inspect.getargvalues(inspect.currentframe()) |
||
523 | return super().run(**{a: locs[a] for a in args if a != "cls"}) |
||
524 | |||
525 | |||
526 | View Code Duplication | class EntryPubchemDiseaseCoOccurrence(_EntryPubchemCoOccurrence[DiseaseCoOccurrenceSearch]): |
|
527 | @classmethod |
||
528 | @entry() |
||
529 | def run( |
||
530 | cls, |
||
531 | path: Path = CommonArgs.in_compound_table, |
||
532 | key: str = EntryArgs.key(f"lit.pubchem:{CoOccurrenceType.disease.name.lower()}"), |
||
533 | to: Optional[Path] = CommonArgs.out_annotations_file, |
||
534 | min_score: float = EntryArgs.min_cooccurrence_score, |
||
535 | min_articles: int = EntryArgs.min_cooccurring_articles, |
||
536 | as_of: Optional[str] = CommonArgs.as_of, |
||
537 | replace: bool = CommonArgs.replace, |
||
538 | proceed: bool = CommonArgs.proceed, |
||
539 | check: bool = EntryArgs.check, |
||
540 | log: Optional[Path] = CommonArgs.log, |
||
541 | stderr: str = CommonArgs.stderr, |
||
542 | ) -> Searcher: |
||
543 | """ |
||
544 | Co-occurrences of diseases from PubMed articles. |
||
545 | |||
546 | https://mandos-chem.readthedocs.io/en/latest/co-occurrences.html |
||
547 | |||
548 | OBJECT: The name of the disease |
||
549 | |||
550 | WEIGHT: The co-occurrence score (refer to the docs) |
||
551 | """ |
||
552 | args, _, _, locs = inspect.getargvalues(inspect.currentframe()) |
||
553 | return super().run(**{a: locs[a] for a in args if a != "cls"}) |
||
554 | |||
555 | |||
556 | View Code Duplication | class EntryPubchemChemicalCoOccurrence(_EntryPubchemCoOccurrence[ChemicalCoOccurrenceSearch]): |
|
557 | @classmethod |
||
558 | @entry() |
||
559 | def run( |
||
560 | cls, |
||
561 | path: Path = CommonArgs.in_compound_table, |
||
562 | key: str = EntryArgs.key(f"lit.pubchem:{CoOccurrenceType.chemical.name.lower()}"), |
||
563 | to: Optional[Path] = CommonArgs.out_annotations_file, |
||
564 | min_score: float = EntryArgs.min_cooccurrence_score, |
||
565 | min_articles: int = EntryArgs.min_cooccurring_articles, |
||
566 | as_of: Optional[str] = CommonArgs.as_of, |
||
567 | replace: bool = CommonArgs.replace, |
||
568 | proceed: bool = CommonArgs.proceed, |
||
569 | check: bool = EntryArgs.check, |
||
570 | log: Optional[Path] = CommonArgs.log, |
||
571 | stderr: str = CommonArgs.stderr, |
||
572 | ) -> Searcher: |
||
573 | """ |
||
574 | Co-occurrences of chemicals from PubMed articles. |
||
575 | |||
576 | https://mandos-chem.readthedocs.io/en/latest/co-occurrences.html |
||
577 | |||
578 | OBJECT: The name of the chemical (e.g. "cocaine") |
||
579 | |||
580 | WEIGHT: The co-occurrence score (refer to the docs) |
||
581 | """ |
||
582 | args, _, _, locs = inspect.getargvalues(inspect.currentframe()) |
||
583 | return super().run(**{a: locs[a] for a in args if a != "cls"}) |
||
584 | |||
585 | |||
586 | class EntryPubchemDgi(Entry[DgiSearch]): |
||
587 | View Code Duplication | @classmethod |
|
588 | @entry() |
||
589 | def run( |
||
590 | cls, |
||
591 | path: Path = CommonArgs.in_compound_table, |
||
592 | key: str = EntryArgs.key("inter.dgidb:gene"), |
||
593 | to: Optional[Path] = CommonArgs.out_annotations_file, |
||
594 | as_of: Optional[str] = CommonArgs.as_of, |
||
595 | replace: bool = CommonArgs.replace, |
||
596 | proceed: bool = CommonArgs.proceed, |
||
597 | check: bool = EntryArgs.check, |
||
598 | log: Optional[Path] = CommonArgs.log, |
||
599 | stderr: str = CommonArgs.stderr, |
||
600 | ) -> Searcher: |
||
601 | """ |
||
602 | Drug/gene interactions in the DGIDB. |
||
603 | |||
604 | Drug Gene Interaction Database. |
||
605 | Also see disease.dgidb:int. |
||
606 | |||
607 | OBJECT: The name of the gene |
||
608 | |||
609 | PREDICATE: "interaction:generic" or "interaction:<type>" |
||
610 | """ |
||
611 | built = DgiSearch(key, Apis.Pubchem) |
||
612 | return cls._run(built, path, to, replace, proceed, check, log, stderr) |
||
613 | |||
614 | |||
615 | class EntryPubchemCgi(Entry[CtdGeneSearch]): |
||
616 | View Code Duplication | @classmethod |
|
617 | @entry() |
||
618 | def run( |
||
619 | cls, |
||
620 | path: Path = CommonArgs.in_compound_table, |
||
621 | key: str = EntryArgs.key("inter.ctd:gene"), |
||
622 | as_of: Optional[str] = CommonArgs.as_of, |
||
623 | replace: bool = CommonArgs.replace, |
||
624 | proceed: bool = CommonArgs.proceed, |
||
625 | to: Optional[Path] = CommonArgs.out_annotations_file, |
||
626 | check: bool = EntryArgs.check, |
||
627 | log: Optional[Path] = CommonArgs.log, |
||
628 | stderr: str = CommonArgs.stderr, |
||
629 | ) -> Searcher: |
||
630 | """ |
||
631 | Compound/gene interactions in the DGIDB. |
||
632 | |||
633 | Drug Gene Interaction Database. |
||
634 | Also see ``interact.dgidb:int``. |
||
635 | |||
636 | OBJECT: The name of the gene |
||
637 | |||
638 | PREDICATE: derived from the interaction type (e.g. "downregulation") |
||
639 | """ |
||
640 | built = CtdGeneSearch(key, Apis.Pubchem) |
||
641 | return cls._run(built, path, to, replace, proceed, check, log, stderr) |
||
642 | |||
643 | |||
644 | View Code Duplication | class EntryDrugbankTarget(Entry[DrugbankTargetSearch]): |
|
645 | @classmethod |
||
646 | @entry() |
||
647 | def run( |
||
648 | cls, |
||
649 | path: Path = CommonArgs.in_compound_table, |
||
650 | key: str = EntryArgs.key("inter.drugbank:targ"), |
||
651 | as_of: Optional[str] = CommonArgs.as_of, |
||
652 | replace: bool = CommonArgs.replace, |
||
653 | proceed: bool = CommonArgs.proceed, |
||
654 | to: Optional[Path] = CommonArgs.out_annotations_file, |
||
655 | check: bool = EntryArgs.check, |
||
656 | log: Optional[Path] = CommonArgs.log, |
||
657 | stderr: str = CommonArgs.stderr, |
||
658 | ) -> Searcher: |
||
659 | """ |
||
660 | Protein targets from DrugBank. |
||
661 | |||
662 | OBJECT: The target name (e.g. "Solute carrier family 22 member 11") |
||
663 | |||
664 | PREDICATE: "<target_type>:<action>" |
||
665 | """ |
||
666 | built = DrugbankTargetSearch(key, Apis.Pubchem, {DrugbankTargetType.target}) |
||
667 | return cls._run(built, path, to, replace, proceed, check, log, stderr) |
||
668 | |||
669 | |||
670 | View Code Duplication | class EntryGeneralFunction(Entry[DrugbankGeneralFunctionSearch]): |
|
671 | @classmethod |
||
672 | @entry() |
||
673 | def run( |
||
674 | cls, |
||
675 | path: Path = CommonArgs.in_compound_table, |
||
676 | key: str = EntryArgs.key("inter.drugbank:targ-fn"), |
||
677 | as_of: Optional[str] = CommonArgs.as_of, |
||
678 | replace: bool = CommonArgs.replace, |
||
679 | proceed: bool = CommonArgs.proceed, |
||
680 | to: Optional[Path] = CommonArgs.out_annotations_file, |
||
681 | check: bool = EntryArgs.check, |
||
682 | log: Optional[Path] = CommonArgs.log, |
||
683 | stderr: str = CommonArgs.stderr, |
||
684 | ) -> Searcher: |
||
685 | """ |
||
686 | General functions from DrugBank targets. |
||
687 | |||
688 | OBJECT: The name of the "general function" (e.g. "Toxic substance binding") |
||
689 | |||
690 | PREDICATE: "<target_type>:<action>" |
||
691 | """ |
||
692 | built = DrugbankGeneralFunctionSearch(key, Apis.Pubchem, {DrugbankTargetType.target}) |
||
693 | return cls._run(built, path, to, replace, proceed, check, log, stderr) |
||
694 | |||
695 | |||
696 | View Code Duplication | class EntryDrugbankTransporter(Entry[DrugbankTargetSearch]): |
|
697 | @classmethod |
||
698 | @entry() |
||
699 | def run( |
||
700 | cls, |
||
701 | path: Path = CommonArgs.in_compound_table, |
||
702 | key: str = EntryArgs.key("inter.drugbank:pk"), |
||
703 | as_of: Optional[str] = CommonArgs.as_of, |
||
704 | replace: bool = CommonArgs.replace, |
||
705 | proceed: bool = CommonArgs.proceed, |
||
706 | to: Optional[Path] = CommonArgs.out_annotations_file, |
||
707 | check: bool = EntryArgs.check, |
||
708 | log: Optional[Path] = CommonArgs.log, |
||
709 | stderr: str = CommonArgs.stderr, |
||
710 | ) -> Searcher: |
||
711 | """ |
||
712 | PK-related proteins from DrugBank. |
||
713 | |||
714 | OBJECT: The transporter name (e.g. "Solute carrier family 22 member 11") |
||
715 | |||
716 | PREDICATE: "<target_type>:<action>" (e.g. metabolized, transported, etc.) |
||
717 | """ |
||
718 | target_types = { |
||
719 | DrugbankTargetType.transporter, |
||
720 | DrugbankTargetType.carrier, |
||
721 | DrugbankTargetType.enzyme, |
||
722 | } |
||
723 | built = DrugbankTargetSearch(key, Apis.Pubchem, target_types) |
||
724 | return cls._run(built, path, to, replace, proceed, check, log, stderr) |
||
725 | |||
726 | |||
727 | View Code Duplication | class EntryTransporterGeneralFunction(Entry[DrugbankGeneralFunctionSearch]): |
|
728 | @classmethod |
||
729 | @entry() |
||
730 | def run( |
||
731 | cls, |
||
732 | path: Path = CommonArgs.in_compound_table, |
||
733 | key: str = EntryArgs.key("inter.drugbank:pk-fn"), |
||
734 | as_of: Optional[str] = CommonArgs.as_of, |
||
735 | replace: bool = CommonArgs.replace, |
||
736 | proceed: bool = CommonArgs.proceed, |
||
737 | to: Optional[Path] = CommonArgs.out_annotations_file, |
||
738 | check: bool = EntryArgs.check, |
||
739 | log: Optional[Path] = CommonArgs.log, |
||
740 | stderr: str = CommonArgs.stderr, |
||
741 | ) -> Searcher: |
||
742 | """ |
||
743 | DrugBank PK-related protein functions. |
||
744 | |||
745 | OBJECT: The name of the general function (e.g. "Toxic substance binding") |
||
746 | |||
747 | PREDICATE: "<target_type>:<action>" (e.g. metabolized, transported, etc.) |
||
748 | """ |
||
749 | target_types = { |
||
750 | DrugbankTargetType.transporter, |
||
751 | DrugbankTargetType.carrier, |
||
752 | DrugbankTargetType.enzyme, |
||
753 | } |
||
754 | built = DrugbankGeneralFunctionSearch(key, Apis.Pubchem, target_types) |
||
755 | return cls._run(built, path, to, replace, proceed, check, log, stderr) |
||
756 | |||
757 | |||
758 | class EntryDrugbankDdi(Entry[DrugbankDdiSearch]): |
||
759 | View Code Duplication | @classmethod |
|
760 | @entry() |
||
761 | def run( |
||
762 | cls, |
||
763 | path: Path = CommonArgs.in_compound_table, |
||
764 | key: str = EntryArgs.key("inter.drugbank:ddi"), |
||
765 | to: Optional[Path] = CommonArgs.out_annotations_file, |
||
766 | as_of: Optional[str] = CommonArgs.as_of, |
||
767 | replace: bool = CommonArgs.replace, |
||
768 | proceed: bool = CommonArgs.proceed, |
||
769 | check: bool = EntryArgs.check, |
||
770 | log: Optional[Path] = CommonArgs.log, |
||
771 | stderr: str = CommonArgs.stderr, |
||
772 | ) -> Searcher: |
||
773 | """ |
||
774 | Drug/drug interactions listed by DrugBank. |
||
775 | |||
776 | The "description" column includes useful information about the interaction, |
||
777 | such as diseases and whether a risk is increased or decreased. |
||
778 | |||
779 | OBJECT: The name of the drug (e.g. "ibuprofen") |
||
780 | |||
781 | PREDICATE: typically increase/decrease/change followed by risk/activity/etc. |
||
782 | """ |
||
783 | built = DrugbankDdiSearch(key, Apis.Pubchem) |
||
784 | return cls._run(built, path, to, replace, proceed, check, log, stderr) |
||
785 | |||
786 | |||
787 | class EntryPubchemAssay(Entry[BioactivitySearch]): |
||
788 | @classmethod |
||
789 | @entry() |
||
790 | def run( |
||
791 | cls, |
||
792 | path: Path = CommonArgs.in_compound_table, |
||
793 | key: str = EntryArgs.key("assay.pubchem:act"), |
||
794 | to: Optional[Path] = CommonArgs.out_annotations_file, |
||
795 | match_name: bool = EntryArgs.match_name, |
||
796 | ban_sources: Optional[str] = EntryArgs.banned_sources, |
||
797 | as_of: Optional[str] = CommonArgs.as_of, |
||
798 | replace: bool = CommonArgs.replace, |
||
799 | proceed: bool = CommonArgs.proceed, |
||
800 | check: bool = EntryArgs.check, |
||
801 | log: Optional[Path] = CommonArgs.log, |
||
802 | stderr: str = CommonArgs.stderr, |
||
803 | ) -> Searcher: |
||
804 | """ |
||
805 | PubChem bioactivity results. |
||
806 | |||
807 | Note: The species name, if present, is taken from the target name. |
||
808 | The taxon ID is what was curated in PubChem. |
||
809 | |||
810 | OBJECT: The name of the target without species suffix |
||
811 | (e.g. "Slc6a3 - solute carrier family 6 member 3") |
||
812 | |||
813 | PREDICATE: "active", "inactive", "inconclusive", or "undetermined" |
||
814 | |||
815 | WEIGHT: 2 for confirmatory; 1 otherwise |
||
816 | """ |
||
817 | built = BioactivitySearch(key, Apis.Pubchem, compound_name_must_match=match_name) |
||
818 | return cls._run(built, path, to, replace, proceed, check, log, stderr) |
||
819 | |||
820 | |||
821 | class EntryDeaSchedule(Entry[BioactivitySearch]): |
||
822 | @classmethod |
||
823 | @entry() |
||
824 | def run( |
||
825 | cls, |
||
826 | path: Path = CommonArgs.in_compound_table, |
||
827 | key: str = EntryArgs.key("drug.dea:schedule"), |
||
828 | to: Optional[Path] = CommonArgs.out_annotations_file, |
||
829 | as_of: Optional[str] = CommonArgs.as_of, |
||
830 | replace: bool = CommonArgs.replace, |
||
831 | proceed: bool = CommonArgs.proceed, |
||
832 | check: bool = EntryArgs.check, |
||
833 | log: Optional[Path] = CommonArgs.log, |
||
834 | stderr: str = CommonArgs.stderr, |
||
835 | ) -> Searcher: |
||
836 | """ |
||
837 | DEA schedules (PENDING). |
||
838 | |||
839 | OBJECT: The DEA schedule (1 to 4, or "unscheduled") |
||
840 | """ |
||
841 | pass |
||
842 | |||
843 | |||
844 | class EntryDeaClass(Entry[BioactivitySearch]): |
||
845 | @classmethod |
||
846 | @entry() |
||
847 | def run( |
||
848 | cls, |
||
849 | path: Path = CommonArgs.in_compound_table, |
||
850 | key: str = EntryArgs.key("drug.dea:class"), |
||
851 | to: Optional[Path] = CommonArgs.out_annotations_file, |
||
852 | as_of: Optional[str] = CommonArgs.as_of, |
||
853 | replace: bool = CommonArgs.replace, |
||
854 | proceed: bool = CommonArgs.proceed, |
||
855 | check: bool = EntryArgs.check, |
||
856 | log: Optional[Path] = CommonArgs.log, |
||
857 | stderr: str = CommonArgs.stderr, |
||
858 | ) -> Searcher: |
||
859 | """ |
||
860 | DEA classes (PENDING). |
||
861 | |||
862 | OBJECT: The DEA class name (e.g. "hallucinogen") |
||
863 | """ |
||
864 | pass |
||
865 | |||
866 | |||
867 | class EntryChemidPlusAcute(Entry[AcuteEffectSearch]): |
||
868 | @classmethod |
||
869 | @entry() |
||
870 | def run( |
||
871 | cls, |
||
872 | path: Path = CommonArgs.in_compound_table, |
||
873 | key: str = EntryArgs.key("tox.chemidplus:acute"), |
||
874 | to: Optional[Path] = CommonArgs.out_annotations_file, |
||
875 | level: int = EntryArgs.acute_effect_level, |
||
876 | as_of: Optional[str] = CommonArgs.as_of, |
||
877 | replace: bool = CommonArgs.replace, |
||
878 | proceed: bool = CommonArgs.proceed, |
||
879 | check: bool = EntryArgs.check, |
||
880 | log: Optional[Path] = CommonArgs.log, |
||
881 | stderr: str = CommonArgs.stderr, |
||
882 | ) -> Searcher: |
||
883 | """ |
||
884 | Acute effect codes from ChemIDPlus. |
||
885 | |||
886 | OBJECT: The code name (e.g. "behavioral: excitement") |
||
887 | """ |
||
888 | built = AcuteEffectSearch( |
||
889 | key, |
||
890 | Apis.Pubchem, |
||
891 | top_level=level == 1, |
||
892 | ) |
||
893 | return cls._run(built, path, to, replace, proceed, check, log, stderr) |
||
894 | |||
895 | |||
896 | class EntryChemidPlusLd50(Entry[Ld50Search]): |
||
897 | View Code Duplication | @classmethod |
|
898 | @entry() |
||
899 | def run( |
||
900 | cls, |
||
901 | path: Path = CommonArgs.in_compound_table, |
||
902 | key: str = EntryArgs.key("tox.chemidplus:ld50"), |
||
903 | to: Optional[Path] = CommonArgs.out_annotations_file, |
||
904 | as_of: Optional[str] = CommonArgs.as_of, |
||
905 | replace: bool = CommonArgs.replace, |
||
906 | proceed: bool = CommonArgs.proceed, |
||
907 | check: bool = EntryArgs.check, |
||
908 | log: Optional[Path] = CommonArgs.log, |
||
909 | stderr: str = CommonArgs.stderr, |
||
910 | ) -> Searcher: |
||
911 | """ |
||
912 | LD50 acute effects from ChemIDPlus. |
||
913 | |||
914 | OBJECT: The negative of the dose in mg/kg |
||
915 | |||
916 | PREDICATE: "LD50:<route>" (e.g. "LD50:intravenous") |
||
917 | """ |
||
918 | built = Ld50Search(key, Apis.Pubchem) |
||
919 | return cls._run(built, path, to, replace, proceed, check, log, stderr) |
||
920 | |||
921 | |||
922 | class EntryPubchemComputed(Entry[ComputedPropertySearch]): |
||
923 | @classmethod |
||
924 | @entry() |
||
925 | def run( |
||
926 | cls, |
||
927 | path: Path = CommonArgs.in_compound_table, |
||
928 | key: str = EntryArgs.key("chem.pubchem:computed"), |
||
929 | keys: str = EntryArgs.pubchem_computed_keys, |
||
930 | to: Optional[Path] = CommonArgs.out_annotations_file, |
||
931 | as_of: Optional[str] = CommonArgs.as_of, |
||
932 | replace: bool = CommonArgs.replace, |
||
933 | proceed: bool = CommonArgs.proceed, |
||
934 | check: bool = EntryArgs.check, |
||
935 | log: Optional[Path] = CommonArgs.log, |
||
936 | stderr: str = CommonArgs.stderr, |
||
937 | ) -> Searcher: |
||
938 | """ |
||
939 | Computed properties from PubChem. |
||
940 | |||
941 | OBJECT: Number |
||
942 | |||
943 | PREDICATE: e.g. "complexity" |
||
944 | """ |
||
945 | # replace acronyms, etc. |
||
946 | # ComputedPropertySearch standardizes punctuation and casing |
||
947 | known = { |
||
948 | k: v |
||
949 | for k, v in { |
||
950 | **EntryArgs.KNOWN_USEFUL_KEYS, |
||
951 | **EntryArgs.KNOWN_USELESS_KEYS, |
||
952 | }.items() |
||
953 | if v is not None |
||
954 | } |
||
955 | keys = {known.get(s.strip(), s) for s in keys.split(",")} |
||
956 | built = ComputedPropertySearch(key, Apis.Pubchem, descriptors=keys) |
||
957 | return cls._run(built, path, to, replace, proceed, check, log, stderr) |
||
958 | |||
959 | |||
960 | class EntryG2pInteractions(Entry[G2pInteractionSearch]): |
||
961 | View Code Duplication | @classmethod |
|
962 | @entry() |
||
963 | def run( |
||
964 | cls, |
||
965 | path: Path = CommonArgs.in_compound_table, |
||
966 | key: str = EntryArgs.key("g2p:interactions"), |
||
967 | to: Optional[Path] = CommonArgs.out_annotations_file, |
||
968 | as_of: Optional[str] = CommonArgs.as_of, |
||
969 | replace: bool = CommonArgs.replace, |
||
970 | proceed: bool = CommonArgs.proceed, |
||
971 | check: bool = EntryArgs.check, |
||
972 | log: Optional[Path] = CommonArgs.log, |
||
973 | stderr: str = CommonArgs.stderr, |
||
974 | ) -> Searcher: |
||
975 | """ |
||
976 | Target interactions with affinities from Guide to Pharmacology. |
||
977 | |||
978 | OBJECT: A molecular target |
||
979 | |||
980 | PREDICATE: "interaction:agonism", etc. |
||
981 | |||
982 | WEIGHT: 1.0 |
||
983 | """ |
||
984 | built = G2pInteractionSearch(key, Apis.G2p) |
||
985 | return cls._run(built, path, to, replace, proceed, check, log, stderr) |
||
986 | |||
987 | |||
988 | class EntryHmdbTissue(Entry[TissueConcentrationSearch]): |
||
989 | @classmethod |
||
990 | @entry() |
||
991 | def run( |
||
992 | cls, |
||
993 | path: Path = CommonArgs.in_compound_table, |
||
994 | key: str = EntryArgs.key("hmdb:tissue"), |
||
995 | to: Optional[Path] = CommonArgs.out_annotations_file, |
||
996 | min_nm: Optional[float] = EntryArgs.min_nanomolar, |
||
997 | as_of: Optional[str] = CommonArgs.as_of, |
||
998 | replace: bool = CommonArgs.replace, |
||
999 | proceed: bool = CommonArgs.proceed, |
||
1000 | check: bool = EntryArgs.check, |
||
1001 | log: Optional[Path] = CommonArgs.log, |
||
1002 | stderr: str = CommonArgs.stderr, |
||
1003 | ) -> Searcher: |
||
1004 | """ |
||
1005 | Tissue concentrations from HMDB. |
||
1006 | |||
1007 | OBJECT: |
||
1008 | |||
1009 | PREDICATE: "tissue:..." |
||
1010 | """ |
||
1011 | built = TissueConcentrationSearch(key, Apis.Hmdb) |
||
1012 | return cls._run(built, path, to, replace, proceed, check, log, stderr) |
||
1013 | |||
1014 | |||
1015 | class EntryHmdbComputed(Entry[BioactivitySearch]): |
||
1016 | @classmethod |
||
1017 | @entry() |
||
1018 | def run( |
||
1019 | cls, |
||
1020 | path: Path = CommonArgs.in_compound_table, |
||
1021 | key: str = EntryArgs.key("hmdb:computed"), |
||
1022 | to: Optional[Path] = CommonArgs.out_annotations_file, |
||
1023 | min_nm: Optional[float] = None, |
||
1024 | as_of: Optional[str] = CommonArgs.as_of, |
||
1025 | replace: bool = CommonArgs.replace, |
||
1026 | proceed: bool = CommonArgs.proceed, |
||
1027 | check: bool = EntryArgs.check, |
||
1028 | log: Optional[Path] = CommonArgs.log, |
||
1029 | stderr: str = CommonArgs.stderr, |
||
1030 | ) -> Searcher: |
||
1031 | """ |
||
1032 | Computed properties from HMDB (PENDING). |
||
1033 | |||
1034 | Keys include pKa, logP, logS, etc. |
||
1035 | |||
1036 | OBJECT: A number; booleans are converted to 0/1 |
||
1037 | |||
1038 | PREDICATE: The name of the property |
||
1039 | """ |
||
1040 | pass |
||
1041 | |||
1042 | |||
1043 | class EntryDrugbankAdmet(Entry[DrugbankTargetSearch]): |
||
1044 | @classmethod |
||
1045 | @entry() |
||
1046 | def run( |
||
1047 | cls, |
||
1048 | path: Path = CommonArgs.in_compound_table, |
||
1049 | key: str = EntryArgs.key("drugbank.admet:properties"), |
||
1050 | to: Optional[Path] = CommonArgs.out_annotations_file, |
||
1051 | as_of: Optional[str] = CommonArgs.as_of, |
||
1052 | replace: bool = CommonArgs.replace, |
||
1053 | proceed: bool = CommonArgs.proceed, |
||
1054 | check: bool = EntryArgs.check, |
||
1055 | log: Optional[Path] = CommonArgs.log, |
||
1056 | stderr: str = CommonArgs.stderr, |
||
1057 | ) -> Searcher: |
||
1058 | """ |
||
1059 | Enzyme predictions from DrugBank (PENDING). |
||
1060 | |||
1061 | OBJECT: Enzyme name |
||
1062 | |||
1063 | PREDICATE: Action |
||
1064 | """ |
||
1065 | |||
1066 | |||
1067 | class EntryDrugbankMetabolites(Entry[DrugbankTargetSearch]): |
||
1068 | @classmethod |
||
1069 | @entry() |
||
1070 | def run( |
||
1071 | cls, |
||
1072 | path: Path = CommonArgs.in_compound_table, |
||
1073 | key: str = EntryArgs.key("drugbank.admet:metabolites"), |
||
1074 | to: Optional[Path] = CommonArgs.out_annotations_file, |
||
1075 | as_of: Optional[str] = CommonArgs.as_of, |
||
1076 | replace: bool = CommonArgs.replace, |
||
1077 | proceed: bool = CommonArgs.proceed, |
||
1078 | check: bool = EntryArgs.check, |
||
1079 | log: Optional[Path] = CommonArgs.log, |
||
1080 | stderr: str = CommonArgs.stderr, |
||
1081 | ) -> Searcher: |
||
1082 | """ |
||
1083 | Metabolites from DrugBank (PENDING). |
||
1084 | |||
1085 | OBJECT: Compound name (e.g. "norcocaine"). |
||
1086 | |||
1087 | PREDICATE: "metabolized to" |
||
1088 | """ |
||
1089 | |||
1090 | |||
1091 | class EntryDrugbankDosage(Entry[DrugbankTargetSearch]): |
||
1092 | @classmethod |
||
1093 | @entry() |
||
1094 | def run( |
||
1095 | cls, |
||
1096 | path: Path = CommonArgs.in_compound_table, |
||
1097 | key: str = EntryArgs.key("drugbank.admet:dosage"), |
||
1098 | to: Optional[Path] = CommonArgs.out_annotations_file, |
||
1099 | as_of: Optional[str] = CommonArgs.as_of, |
||
1100 | replace: bool = CommonArgs.replace, |
||
1101 | proceed: bool = CommonArgs.proceed, |
||
1102 | check: bool = EntryArgs.check, |
||
1103 | log: Optional[Path] = CommonArgs.log, |
||
1104 | stderr: str = CommonArgs.stderr, |
||
1105 | ) -> Searcher: |
||
1106 | """ |
||
1107 | Dosage from DrugBank (PENDING). |
||
1108 | |||
1109 | OBJECT: concentration in mg/mL |
||
1110 | |||
1111 | PREDICATE: "dosage :: <route>" |
||
1112 | |||
1113 | OTHER COLUMNS: |
||
1114 | |||
1115 | - form (e.g. liquid) |
||
1116 | """ |
||
1117 | |||
1118 | |||
1119 | class EntryMetaRandom(Entry[RandomSearch]): |
||
1120 | @classmethod |
||
1121 | @entry() |
||
1122 | def run( |
||
1123 | cls, |
||
1124 | path: Path = CommonArgs.in_compound_table, |
||
1125 | key: str = EntryArgs.key("meta:random"), |
||
1126 | to: Optional[Path] = CommonArgs.out_annotations_file, |
||
1127 | n: int = EntryArgs.random_n, |
||
1128 | seed: int = CommonArgs.seed, |
||
1129 | as_of: Optional[str] = CommonArgs.as_of, |
||
1130 | replace: bool = CommonArgs.replace, |
||
1131 | proceed: bool = CommonArgs.proceed, |
||
1132 | check: bool = EntryArgs.check, |
||
1133 | log: Optional[Path] = CommonArgs.log, |
||
1134 | stderr: str = CommonArgs.stderr, |
||
1135 | ) -> Searcher: |
||
1136 | r""" |
||
1137 | Random class assignment. |
||
1138 | |||
1139 | OBJECT: 0 thru n (inclusive-exclusive). |
||
1140 | |||
1141 | PREDICATE: "random" |
||
1142 | """ |
||
1143 | built = RandomSearch(key, seed, n) |
||
1144 | return cls._run(built, path, to, replace, proceed, check, log, stderr) |
||
1145 | |||
1146 | |||
1147 | Entries = [ |
||
1148 | EntryChemblBinding, |
||
1149 | EntryChemblMechanism, |
||
1150 | EntryChemblAtc, |
||
1151 | EntryChemblTrials, |
||
1152 | EntryGoFunction, |
||
1153 | EntryGoProcess, |
||
1154 | EntryGoComponent, |
||
1155 | EntryPubchemComputed, |
||
1156 | EntryPubchemDisease, |
||
1157 | EntryPubchemGeneCoOccurrence, |
||
1158 | EntryPubchemDiseaseCoOccurrence, |
||
1159 | EntryPubchemChemicalCoOccurrence, |
||
1160 | EntryPubchemDgi, |
||
1161 | EntryPubchemCgi, |
||
1162 | EntryDrugbankTarget, |
||
1163 | EntryGeneralFunction, |
||
1164 | EntryDrugbankTransporter, |
||
1165 | EntryTransporterGeneralFunction, |
||
1166 | EntryDrugbankDdi, |
||
1167 | EntryPubchemAssay, |
||
1168 | EntryDeaSchedule, |
||
1169 | EntryDeaClass, |
||
1170 | EntryChemidPlusAcute, |
||
1171 | EntryChemidPlusLd50, |
||
1172 | EntryHmdbTissue, |
||
1173 | EntryMetaRandom, |
||
1174 | ] |
||
1175 |