1
|
|
|
from dataclasses import dataclass |
|
|
|
|
2
|
|
|
from typing import Sequence |
3
|
|
|
|
4
|
|
|
from mandos.model.pubchem_api import PubchemApi |
5
|
|
|
from mandos.search.pubchem import PubchemHit, PubchemSearch |
6
|
|
|
|
7
|
|
|
|
8
|
|
|
@dataclass(frozen=True, order=True, repr=True) |
|
|
|
|
9
|
|
|
class DgiHit(PubchemHit): |
10
|
|
|
"""""" |
11
|
|
|
|
12
|
|
|
|
13
|
|
|
@dataclass(frozen=True, order=True, repr=True) |
|
|
|
|
14
|
|
|
class CgiHit(PubchemHit): |
15
|
|
|
"""""" |
16
|
|
|
|
17
|
|
|
|
18
|
|
View Code Duplication |
class DgiSearch(PubchemSearch[DgiHit]): |
|
|
|
|
19
|
|
|
"""""" |
20
|
|
|
|
21
|
|
|
def __init__(self, key: str, api: PubchemApi): |
|
|
|
|
22
|
|
|
super().__init__(key, api) |
23
|
|
|
|
24
|
|
|
@property |
25
|
|
|
def data_source(self) -> str: |
|
|
|
|
26
|
|
|
return "The Drug Gene Interaction Database (DGIdb)" |
27
|
|
|
|
28
|
|
|
def find(self, inchikey: str) -> Sequence[DgiHit]: |
|
|
|
|
29
|
|
|
data = self.api.fetch_data(inchikey) |
30
|
|
|
return [ |
31
|
|
|
DgiHit( |
32
|
|
|
record_id=None, |
33
|
|
|
origin_inchikey=inchikey, |
34
|
|
|
matched_inchikey=data.names_and_identifiers.inchikey, |
35
|
|
|
compound_id=str(data.cid), |
36
|
|
|
compound_name=data.name, |
37
|
|
|
predicate=f"interacts with gene (drug)", |
|
|
|
|
38
|
|
|
object_id=dd.gene_claim_id, |
39
|
|
|
object_name=dd.gene_name, |
40
|
|
|
search_key=self.key, |
41
|
|
|
search_class=self.search_class, |
42
|
|
|
data_source=self.data_source, |
43
|
|
|
) |
44
|
|
|
for dd in data.biomolecular_interactions_and_pathways.drug_gene_interactions |
45
|
|
|
] |
46
|
|
|
|
47
|
|
|
|
48
|
|
View Code Duplication |
class CgiSearch(PubchemSearch[CgiHit]): |
|
|
|
|
49
|
|
|
"""""" |
50
|
|
|
|
51
|
|
|
def __init__(self, key: str, api: PubchemApi): |
|
|
|
|
52
|
|
|
super().__init__(key, api) |
53
|
|
|
|
54
|
|
|
@property |
55
|
|
|
def data_source(self) -> str: |
|
|
|
|
56
|
|
|
return "The Drug Gene Interaction Database (DGIdb)" |
57
|
|
|
|
58
|
|
|
def find(self, inchikey: str) -> Sequence[DgiHit]: |
|
|
|
|
59
|
|
|
data = self.api.fetch_data(inchikey) |
60
|
|
|
return [ |
61
|
|
|
DgiHit( |
62
|
|
|
record_id=None, |
63
|
|
|
origin_inchikey=inchikey, |
64
|
|
|
matched_inchikey=data.names_and_identifiers.inchikey, |
65
|
|
|
compound_id=str(data.cid), |
66
|
|
|
compound_name=data.name, |
67
|
|
|
predicate=f"interacts with gene (compound)", |
|
|
|
|
68
|
|
|
object_id=dd.gene_name, |
69
|
|
|
object_name=dd.gene_name, |
70
|
|
|
search_key=self.key, |
71
|
|
|
search_class=self.search_class, |
72
|
|
|
data_source=self.data_source, |
73
|
|
|
) |
74
|
|
|
for dd in data.biomolecular_interactions_and_pathways.compound_gene_interactions |
75
|
|
|
] |
76
|
|
|
|
77
|
|
|
|
78
|
|
|
__all__ = ["DgiHit", "DgiSearch", "CgiHit", "CgiSearch"] |
79
|
|
|
|