|
1
|
|
|
from dataclasses import dataclass |
|
|
|
|
|
|
2
|
|
|
from typing import Sequence |
|
3
|
|
|
|
|
4
|
|
|
from mandos.model.apis.g2p_data import G2pData, G2pInteraction |
|
5
|
|
|
|
|
6
|
|
|
from mandos.search.g2p import G2pSearch, G2pHit |
|
7
|
|
|
|
|
8
|
|
|
|
|
9
|
|
|
@dataclass(frozen=True, order=True, repr=True) |
|
|
|
|
|
|
10
|
|
|
class G2pInteractionHit(G2pHit): |
|
11
|
|
|
""" """ |
|
12
|
|
|
|
|
13
|
|
|
action: str |
|
14
|
|
|
selective: str |
|
15
|
|
|
primary: str |
|
16
|
|
|
endogenous: str |
|
17
|
|
|
species: str |
|
18
|
|
|
affinity: float |
|
19
|
|
|
measurement: str |
|
20
|
|
|
|
|
21
|
|
|
|
|
22
|
|
|
class G2pInteractionSearch(G2pSearch[G2pInteractionHit]): |
|
|
|
|
|
|
23
|
|
|
""" """ |
|
24
|
|
|
|
|
25
|
|
|
@property |
|
26
|
|
|
def data_source(self) -> str: |
|
|
|
|
|
|
27
|
|
|
return "G2P :: interactions" |
|
28
|
|
|
|
|
29
|
|
|
def find(self, inchikey: str) -> Sequence[G2pInteractionHit]: |
|
|
|
|
|
|
30
|
|
|
ligand = self.api.fetch(inchikey) |
|
31
|
|
|
results = [] |
|
32
|
|
|
for inter in ligand.interactions: |
|
33
|
|
|
results.append(self.process(inchikey, ligand, inter)) |
|
34
|
|
|
return results |
|
35
|
|
|
|
|
36
|
|
|
def process(self, inchikey: str, ligand: G2pData, inter: G2pInteraction) -> G2pInteractionHit: |
|
|
|
|
|
|
37
|
|
|
return self._create_hit( |
|
38
|
|
|
c_origin=inchikey, |
|
39
|
|
|
c_matched=ligand.inchikey, |
|
40
|
|
|
c_id=str(ligand.g2pid), |
|
41
|
|
|
c_name=ligand.name, |
|
42
|
|
|
predicate=f"interaction:{inter.action}", |
|
43
|
|
|
statement=f"{inter.action} at", |
|
44
|
|
|
object_id=inter.target_id, |
|
45
|
|
|
object_name=inter.target, |
|
46
|
|
|
action=inter.action, |
|
47
|
|
|
affinity=inter.affinity_median, |
|
48
|
|
|
measurement=inter.affinity_units, |
|
49
|
|
|
species=inter.target_species, |
|
50
|
|
|
primary=str(inter.primary_target), |
|
51
|
|
|
selective=str(inter.selectivity), |
|
52
|
|
|
endogenous=str(inter.endogenous), |
|
53
|
|
|
) |
|
54
|
|
|
|
|
55
|
|
|
|
|
56
|
|
|
__all__ = ["G2pInteractionHit", "G2pInteractionSearch"] |
|
57
|
|
|
|