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