1
|
|
|
from __future__ import annotations |
|
|
|
|
2
|
|
|
import abc |
3
|
|
|
import enum |
4
|
|
|
from dataclasses import dataclass |
5
|
|
|
from typing import Optional, Union |
6
|
|
|
|
7
|
|
|
from mandos.model import ReflectionUtils |
8
|
|
|
from mandos.model.hits import AbstractHit |
9
|
|
|
|
10
|
|
|
|
11
|
|
|
@dataclass(frozen=True, order=True, repr=True) |
|
|
|
|
12
|
|
|
class ChemblHit(AbstractHit, metaclass=abc.ABCMeta): |
13
|
|
|
""" """ |
14
|
|
|
|
15
|
|
|
|
16
|
|
|
@dataclass(frozen=True, order=True, repr=True) |
17
|
|
|
class ProteinHit(ChemblHit, metaclass=abc.ABCMeta): |
18
|
|
|
""" |
19
|
|
|
A protein target entry for a compound. |
20
|
|
|
""" |
21
|
|
|
|
22
|
|
|
exact_target_id: str |
23
|
|
|
|
24
|
|
|
|
25
|
|
|
@dataclass(frozen=True, order=True, repr=True) |
26
|
|
|
class _ActivityHit(ProteinHit): |
27
|
|
|
taxon_id: int |
28
|
|
|
taxon_name: str |
29
|
|
|
src_id: str |
30
|
|
|
|
31
|
|
|
|
32
|
|
|
@dataclass(frozen=True, order=True, repr=True) |
33
|
|
|
class AtcHit(ChemblHit): |
34
|
|
|
""" |
35
|
|
|
An ATC code found for a compound. |
36
|
|
|
""" |
37
|
|
|
|
38
|
|
|
level: int |
39
|
|
|
|
40
|
|
|
|
41
|
|
|
@dataclass(frozen=True, order=True, repr=True) |
42
|
|
|
class BindingHit(_ActivityHit): |
43
|
|
|
""" |
44
|
|
|
An "activity" hit for a compound. |
45
|
|
|
""" |
46
|
|
|
|
47
|
|
|
pchembl: float |
48
|
|
|
std_type: str |
49
|
|
|
standard_relation: str |
50
|
|
|
|
51
|
|
|
|
52
|
|
|
@dataclass(frozen=True, order=True, repr=True) |
53
|
|
|
class FunctionalHit(_ActivityHit): |
54
|
|
|
""" |
55
|
|
|
An "activity" hit of type "F" for a compound. |
56
|
|
|
""" |
57
|
|
|
|
58
|
|
|
tissue: Optional[str] |
59
|
|
|
cell_type: Optional[str] |
60
|
|
|
subcellular_region: Optional[str] |
61
|
|
|
|
62
|
|
|
|
63
|
|
|
class GoType(enum.Enum): |
|
|
|
|
64
|
|
|
component = enum.auto() |
65
|
|
|
function = enum.auto() |
66
|
|
|
process = enum.auto() |
67
|
|
|
|
68
|
|
|
@classmethod |
69
|
|
|
def of(cls, s: Union[str, GoType]) -> GoType: |
|
|
|
|
70
|
|
|
if isinstance(s, GoType): |
71
|
|
|
return s |
72
|
|
|
return GoType[s.lower()] |
73
|
|
|
|
74
|
|
|
|
75
|
|
|
@dataclass(frozen=True, order=True, repr=True) |
76
|
|
|
class GoHit(ChemblHit, metaclass=abc.ABCMeta): |
77
|
|
|
""" |
78
|
|
|
A mechanism entry for a compound. |
79
|
|
|
""" |
80
|
|
|
|
81
|
|
|
go_type: str |
82
|
|
|
binding: BindingHit |
83
|
|
|
|
84
|
|
|
|
85
|
|
|
@dataclass(frozen=True, order=True, repr=True) |
86
|
|
|
class IndicationHit(ChemblHit): |
87
|
|
|
""" |
88
|
|
|
An indication with a MESH term. |
89
|
|
|
""" |
90
|
|
|
|
91
|
|
|
max_phase: int |
92
|
|
|
|
93
|
|
|
|
94
|
|
|
@dataclass(frozen=True, order=True, repr=True) |
95
|
|
|
class MechanismHit(ProteinHit): |
96
|
|
|
""" |
97
|
|
|
A mechanism entry for a compound. |
98
|
|
|
""" |
99
|
|
|
|
100
|
|
|
action_type: str |
101
|
|
|
|
102
|
|
|
|
103
|
|
|
@dataclass(frozen=True, order=True, repr=True) |
|
|
|
|
104
|
|
|
class G2pHit(AbstractHit, metaclass=abc.ABCMeta): |
105
|
|
|
""" """ |
106
|
|
|
|
107
|
|
|
|
108
|
|
|
@dataclass(frozen=True, order=True, repr=True) |
|
|
|
|
109
|
|
|
class G2pInteractionHit(G2pHit): |
110
|
|
|
""" """ |
111
|
|
|
|
112
|
|
|
action: str |
113
|
|
|
selective: str |
114
|
|
|
primary: str |
115
|
|
|
endogenous: str |
116
|
|
|
species: str |
117
|
|
|
affinity: float |
118
|
|
|
measurement: str |
119
|
|
|
|
120
|
|
|
|
121
|
|
|
@dataclass(frozen=True, order=True, repr=True) |
|
|
|
|
122
|
|
|
class PubchemHit(AbstractHit, metaclass=abc.ABCMeta): |
123
|
|
|
""" """ |
124
|
|
|
|
125
|
|
|
|
126
|
|
|
@dataclass(frozen=True, order=True, repr=True) |
|
|
|
|
127
|
|
|
class AcuteEffectHit(PubchemHit): |
128
|
|
|
""" """ |
129
|
|
|
|
130
|
|
|
organism: str |
131
|
|
|
human: bool |
132
|
|
|
test_type: str |
133
|
|
|
route: str |
134
|
|
|
effect: str |
135
|
|
|
mg_per_kg: float |
136
|
|
|
|
137
|
|
|
|
138
|
|
|
@dataclass(frozen=True, order=True, repr=True) |
|
|
|
|
139
|
|
|
class Ld50Hit(PubchemHit): |
140
|
|
|
""" """ |
141
|
|
|
|
142
|
|
|
organism: str |
143
|
|
|
human: bool |
144
|
|
|
|
145
|
|
|
|
146
|
|
|
@dataclass(frozen=True, order=True, repr=True) |
|
|
|
|
147
|
|
|
class BioactivityHit(PubchemHit): |
148
|
|
|
""" """ |
149
|
|
|
|
150
|
|
|
target_abbrev: Optional[str] |
151
|
|
|
activity: str |
152
|
|
|
assay_type: str |
153
|
|
|
micromolar: float |
154
|
|
|
relation: str |
155
|
|
|
species: Optional[str] |
156
|
|
|
compound_name_in_assay: str |
157
|
|
|
referrer: str |
158
|
|
|
|
159
|
|
|
|
160
|
|
|
@dataclass(frozen=True, order=True, repr=True) |
|
|
|
|
161
|
|
|
class ComputedPropertyHit(PubchemHit): |
162
|
|
|
pass |
163
|
|
|
|
164
|
|
|
|
165
|
|
|
@dataclass(frozen=True, order=True, repr=True) |
|
|
|
|
166
|
|
|
class CoOccurrenceHit(PubchemHit, metaclass=abc.ABCMeta): |
167
|
|
|
score: int |
168
|
|
|
intersect_count: int |
169
|
|
|
query_count: int |
170
|
|
|
neighbor_count: int |
171
|
|
|
|
172
|
|
|
|
173
|
|
|
@dataclass(frozen=True, order=True, repr=True) |
|
|
|
|
174
|
|
|
class DiseaseCoOccurrenceHit(CoOccurrenceHit): |
175
|
|
|
""" """ |
176
|
|
|
|
177
|
|
|
|
178
|
|
|
@dataclass(frozen=True, order=True, repr=True) |
|
|
|
|
179
|
|
|
class GeneCoOccurrenceHit(CoOccurrenceHit): |
180
|
|
|
""" """ |
181
|
|
|
|
182
|
|
|
|
183
|
|
|
@dataclass(frozen=True, order=True, repr=True) |
|
|
|
|
184
|
|
|
class ChemicalCoOccurrenceHit(CoOccurrenceHit): |
185
|
|
|
""" """ |
186
|
|
|
|
187
|
|
|
|
188
|
|
|
@dataclass(frozen=True, order=True, repr=True) |
|
|
|
|
189
|
|
|
class CtdGeneHit(PubchemHit): |
190
|
|
|
""" """ |
191
|
|
|
|
192
|
|
|
taxon_id: Optional[int] |
193
|
|
|
taxon_name: Optional[str] |
194
|
|
|
|
195
|
|
|
|
196
|
|
|
@dataclass(frozen=True, order=True, repr=True) |
|
|
|
|
197
|
|
|
class DgiHit(PubchemHit): |
198
|
|
|
""" """ |
199
|
|
|
|
200
|
|
|
|
201
|
|
|
@dataclass(frozen=True, order=True, repr=True) |
|
|
|
|
202
|
|
|
class DiseaseHit(PubchemHit): |
203
|
|
|
evidence_type: str |
204
|
|
|
|
205
|
|
|
|
206
|
|
|
@dataclass(frozen=True, order=True, repr=True) |
|
|
|
|
207
|
|
|
class DrugbankDdiHit(PubchemHit): |
208
|
|
|
""" """ |
209
|
|
|
|
210
|
|
|
type: str |
211
|
|
|
effect_target: Optional[str] |
212
|
|
|
change: Optional[str] |
213
|
|
|
description: str |
214
|
|
|
|
215
|
|
|
|
216
|
|
|
@dataclass(frozen=True, order=True, repr=True) |
217
|
|
|
class _DrugbankInteractionHit(PubchemHit): |
218
|
|
|
""" """ |
219
|
|
|
|
220
|
|
|
gene_symbol: str |
221
|
|
|
protein_id: str |
222
|
|
|
target_type: str |
223
|
|
|
target_name: str |
224
|
|
|
general_function: str |
225
|
|
|
|
226
|
|
|
|
227
|
|
|
@dataclass(frozen=True, order=True, repr=True) |
|
|
|
|
228
|
|
|
class DrugbankTargetHit(_DrugbankInteractionHit): |
229
|
|
|
""" """ |
230
|
|
|
|
231
|
|
|
|
232
|
|
|
@dataclass(frozen=True, order=True, repr=True) |
|
|
|
|
233
|
|
|
class DrugbankGeneralFunctionHit(_DrugbankInteractionHit): |
234
|
|
|
""" """ |
235
|
|
|
|
236
|
|
|
|
237
|
|
|
@dataclass(frozen=True, order=True, repr=True) |
|
|
|
|
238
|
|
|
class TrialHit(PubchemHit): |
239
|
|
|
phase: float |
240
|
|
|
status: str |
241
|
|
|
interventions: str |
242
|
|
|
|
243
|
|
|
|
244
|
|
|
HIT_CLASSES = ReflectionUtils.subclass_dict(AbstractHit, concrete=True) |
245
|
|
|
|