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