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