Total Complexity | 2 |
Total Lines | 45 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | from dataclasses import dataclass |
||
|
|||
2 | from typing import Sequence, Optional |
||
3 | |||
4 | from mandos.search.pubchem import PubchemHit, PubchemSearch |
||
5 | |||
6 | |||
7 | @dataclass(frozen=True, order=True, repr=True) |
||
8 | class CtdGeneHit(PubchemHit): |
||
9 | """""" |
||
10 | |||
11 | taxon_id: Optional[int] |
||
12 | taxon_name: Optional[str] |
||
13 | |||
14 | |||
15 | class CtdGeneSearch(PubchemSearch[CtdGeneHit]): |
||
16 | """""" |
||
17 | |||
18 | @property |
||
19 | def data_source(self) -> str: |
||
20 | return "Comparative Toxicogenomics Database (CTD)" |
||
21 | |||
22 | def find(self, inchikey: str) -> Sequence[CtdGeneHit]: |
||
23 | data = self.api.fetch_data(inchikey) |
||
24 | return [ |
||
25 | CtdGeneHit( |
||
26 | record_id=None, |
||
27 | origin_inchikey=inchikey, |
||
28 | matched_inchikey=data.names_and_identifiers.inchikey, |
||
29 | compound_id=str(data.cid), |
||
30 | compound_name=data.name, |
||
31 | predicate="gene interaction", |
||
32 | object_id=dd.gene_name, |
||
33 | object_name=dd.gene_name, |
||
34 | search_key=self.key, |
||
35 | search_class=self.search_class, |
||
36 | data_source=self.data_source, |
||
37 | taxon_id=dd.tax_id, |
||
38 | taxon_name=dd.tax_name, |
||
39 | ) |
||
40 | for dd in data.biomolecular_interactions_and_pathways.compound_gene_interactions |
||
41 | ] |
||
42 | |||
43 | |||
44 | __all__ = ["CtdGeneHit", "CtdGeneSearch"] |
||
45 |