|
1
|
|
|
from __future__ import annotations |
|
|
|
|
|
|
2
|
|
|
|
|
3
|
|
|
import enum |
|
4
|
|
|
import typing |
|
5
|
|
|
from dataclasses import dataclass |
|
6
|
|
|
from datetime import date |
|
7
|
|
|
from typing import FrozenSet, Mapping, Optional, Sequence, Set, Union |
|
8
|
|
|
|
|
9
|
|
|
import orjson |
|
|
|
|
|
|
10
|
|
|
from pocketutils.core.dot_dict import NestedDotDict |
|
|
|
|
|
|
11
|
|
|
from pocketutils.core.enums import CleverEnum |
|
|
|
|
|
|
12
|
|
|
from pocketutils.core.exceptions import XTypeError, XValueError |
|
|
|
|
|
|
13
|
|
|
from pocketutils.tools.string_tools import StringTools |
|
|
|
|
|
|
14
|
|
|
|
|
15
|
|
|
from mandos.model.apis.pubchem_support._nav_fns import Mapx |
|
16
|
|
|
from mandos.model.apis.pubchem_support._patterns import Patterns |
|
17
|
|
|
from mandos.model.utils.setup import MandosResources |
|
18
|
|
|
|
|
19
|
|
|
hazards = MandosResources.file("hazards.json").read_text(encoding="utf8") |
|
20
|
|
|
hazards = NestedDotDict(orjson.loads(hazards)) |
|
21
|
|
|
hazards = {d["code"]: d for d in hazards["signals"]} |
|
22
|
|
|
|
|
23
|
|
|
|
|
24
|
|
|
@dataclass(frozen=True, repr=True, eq=True, order=True) |
|
|
|
|
|
|
25
|
|
|
class ComputedProperty: |
|
26
|
|
|
key: str |
|
27
|
|
|
value: Union[int, str, float, bool] |
|
28
|
|
|
unit: Optional[str] |
|
29
|
|
|
ref: str |
|
30
|
|
|
|
|
31
|
|
|
def req_is(self, type_) -> Union[int, str, float, bool]: |
|
|
|
|
|
|
32
|
|
|
if not isinstance(self.value, type_): |
|
33
|
|
|
raise XTypeError(f"{self.key}->{self.value} has {type(self.value)}, not {type_}") |
|
34
|
|
|
return self.value |
|
35
|
|
|
|
|
36
|
|
|
@property |
|
37
|
|
|
def as_str(self) -> str: |
|
|
|
|
|
|
38
|
|
|
return f"{self.value} {self.unit}" |
|
39
|
|
|
|
|
40
|
|
|
|
|
41
|
|
|
class Code(str): |
|
|
|
|
|
|
42
|
|
|
@property |
|
43
|
|
|
def type_name(self) -> str: |
|
|
|
|
|
|
44
|
|
|
return self.__class__.__name__.lower() |
|
45
|
|
|
|
|
46
|
|
|
@classmethod |
|
47
|
|
|
def of(cls, value: Union[str, int, float]) -> __qualname__: |
|
|
|
|
|
|
48
|
|
|
value = StringTools.strip_off_end(str(value).strip(), ".0").strip() |
|
49
|
|
|
return cls(value) |
|
50
|
|
|
|
|
51
|
|
|
@classmethod |
|
52
|
|
|
def of_nullable(cls, value: Union[None, str, int, float]) -> Optional[__qualname__]: |
|
|
|
|
|
|
53
|
|
|
if value is None: |
|
54
|
|
|
return None |
|
55
|
|
|
return cls.of(value) |
|
56
|
|
|
|
|
57
|
|
|
|
|
58
|
|
|
class Codes: |
|
59
|
|
|
""" |
|
60
|
|
|
These turn out to be extremely useful for documenting return types. |
|
61
|
|
|
For example, ``DrugbankInteraction`` might have a ``gene`` field, |
|
62
|
|
|
which can be described as a ``GenecardSymbol`` if known. |
|
63
|
|
|
""" |
|
64
|
|
|
|
|
65
|
|
|
class ChemIdPlusOrganism(Code): |
|
66
|
|
|
""" |
|
67
|
|
|
E.g. 'women', 'frog', 'infant', or 'domestic animals - goat/sheep' |
|
68
|
|
|
""" |
|
69
|
|
|
|
|
70
|
|
|
@property |
|
71
|
|
|
def is_human(self) -> bool: |
|
|
|
|
|
|
72
|
|
|
return str(self) in {"women", "woman", "men", "man", "infant", "infants", "human"} |
|
73
|
|
|
|
|
74
|
|
|
class ChemIdPlusEffect(Code): |
|
75
|
|
|
""" |
|
76
|
|
|
E.g. 'BEHAVIORAL: MUSCLE WEAKNESS' |
|
77
|
|
|
""" |
|
78
|
|
|
|
|
79
|
|
|
@property |
|
80
|
|
|
def category(self) -> str: |
|
|
|
|
|
|
81
|
|
|
return self[: self.index(":")].strip() |
|
82
|
|
|
|
|
83
|
|
|
@property |
|
84
|
|
|
def subcategory(self) -> str: |
|
|
|
|
|
|
85
|
|
|
return self[self.index(":") + 1 :].strip() |
|
86
|
|
|
|
|
87
|
|
|
class EcNumber(Code): |
|
88
|
|
|
""" |
|
89
|
|
|
e.g. 'EC:4.6.1.1' |
|
90
|
|
|
""" |
|
91
|
|
|
|
|
92
|
|
|
class GeneId(Code): |
|
93
|
|
|
""" |
|
94
|
|
|
GeneCard, UniProt gene name, etc. |
|
95
|
|
|
e.g. 'slc1a2' |
|
96
|
|
|
""" |
|
97
|
|
|
|
|
98
|
|
|
class ClinicaltrialId(Code): |
|
99
|
|
|
""" |
|
100
|
|
|
From clinicaltrials.gov |
|
101
|
|
|
""" |
|
102
|
|
|
|
|
103
|
|
|
class GenericDiseaseCode(Code): |
|
104
|
|
|
""" |
|
105
|
|
|
From clinicaltrials.gov; pure int |
|
106
|
|
|
""" |
|
107
|
|
|
|
|
108
|
|
|
class GenecardSymbol(GeneId): |
|
|
|
|
|
|
109
|
|
|
""" """ |
|
110
|
|
|
|
|
111
|
|
|
class UniprotId(GeneId): |
|
|
|
|
|
|
112
|
|
|
""" """ |
|
113
|
|
|
|
|
114
|
|
|
class PubchemCompoundId(Code): |
|
115
|
|
|
""" |
|
116
|
|
|
e.g. 2352 |
|
117
|
|
|
""" |
|
118
|
|
|
|
|
119
|
|
|
@property |
|
120
|
|
|
def value(self) -> int: |
|
|
|
|
|
|
121
|
|
|
return int(self) |
|
122
|
|
|
|
|
123
|
|
|
class AtcCode(Code): |
|
|
|
|
|
|
124
|
|
|
""" """ |
|
125
|
|
|
|
|
126
|
|
|
class PubmedId(Code): |
|
|
|
|
|
|
127
|
|
|
""" """ |
|
128
|
|
|
|
|
129
|
|
|
class Doi(Code): |
|
|
|
|
|
|
130
|
|
|
""" """ |
|
131
|
|
|
|
|
132
|
|
|
class MeshCode(Code): |
|
|
|
|
|
|
133
|
|
|
""" """ |
|
134
|
|
|
|
|
135
|
|
|
class PdbId(Code): |
|
|
|
|
|
|
136
|
|
|
""" """ |
|
137
|
|
|
|
|
138
|
|
|
class MeshHeading(Code): |
|
|
|
|
|
|
139
|
|
|
""" """ |
|
140
|
|
|
|
|
141
|
|
|
class MeshSubheading(Code): |
|
|
|
|
|
|
142
|
|
|
""" """ |
|
143
|
|
|
|
|
144
|
|
|
class DrugbankCompoundId(Code): |
|
|
|
|
|
|
145
|
|
|
""" """ |
|
146
|
|
|
|
|
147
|
|
|
class DeaSchedule(Code): |
|
|
|
|
|
|
148
|
|
|
""" """ |
|
149
|
|
|
|
|
150
|
|
|
@property |
|
151
|
|
|
def value(self) -> int: |
|
|
|
|
|
|
152
|
|
|
return Mapx.roman_to_arabic(1, 5)(self) |
|
153
|
|
|
|
|
154
|
|
|
class GhsCode(Code): |
|
|
|
|
|
|
155
|
|
|
""" """ |
|
156
|
|
|
|
|
157
|
|
|
|
|
158
|
|
|
class CoOccurrenceType(CleverEnum): |
|
|
|
|
|
|
159
|
|
|
chemical = enum.auto() |
|
160
|
|
|
gene = enum.auto() |
|
161
|
|
|
disease = enum.auto() |
|
162
|
|
|
|
|
163
|
|
|
@property |
|
164
|
|
|
def x_name(self) -> str: |
|
|
|
|
|
|
165
|
|
|
if self is CoOccurrenceType.chemical: |
|
|
|
|
|
|
166
|
|
|
return "ChemicalNeighbor" |
|
167
|
|
|
elif self is CoOccurrenceType.gene: |
|
168
|
|
|
return "ChemicalGeneSymbolNeighbor" |
|
169
|
|
|
elif self is CoOccurrenceType.disease: |
|
170
|
|
|
return "ChemicalDiseaseNeighbor" |
|
171
|
|
|
raise AssertionError(f"{self} not found!!") |
|
172
|
|
|
|
|
173
|
|
|
@property |
|
174
|
|
|
def id_name(self) -> str: |
|
|
|
|
|
|
175
|
|
|
if self is CoOccurrenceType.chemical: |
|
|
|
|
|
|
176
|
|
|
return "CID" |
|
177
|
|
|
elif self is CoOccurrenceType.gene: |
|
178
|
|
|
return "GeneSymbol" |
|
179
|
|
|
elif self is CoOccurrenceType.disease: |
|
180
|
|
|
return "MeSH" |
|
181
|
|
|
raise AssertionError(f"{self} not found!!") |
|
182
|
|
|
|
|
183
|
|
|
|
|
184
|
|
|
class ClinicalTrialsGovUtils: |
|
|
|
|
|
|
185
|
|
|
@classmethod |
|
186
|
|
|
def phase_map(cls) -> Mapping[str, float]: |
|
|
|
|
|
|
187
|
|
|
return { |
|
188
|
|
|
"Phase 4": 4, |
|
189
|
|
|
"Phase 3": 3, |
|
190
|
|
|
"Phase 2": 2, |
|
191
|
|
|
"Phase 1": 1, |
|
192
|
|
|
"Early Phase 1": 1.5, |
|
193
|
|
|
"Phase 2/Phase 3": 2.5, |
|
194
|
|
|
"N/A": 0.5, |
|
195
|
|
|
} |
|
196
|
|
|
|
|
197
|
|
|
@classmethod |
|
198
|
|
|
def known_phases(cls) -> Set[float]: |
|
|
|
|
|
|
199
|
|
|
return set(cls.phase_map().values()) |
|
200
|
|
|
|
|
201
|
|
|
@classmethod |
|
202
|
|
|
def resolve_statuses(cls, st: str) -> Set[str]: |
|
|
|
|
|
|
203
|
|
|
found = set() |
|
204
|
|
|
for s in st.lower().split(","): |
|
|
|
|
|
|
205
|
|
|
s = s.strip() |
|
|
|
|
|
|
206
|
|
|
if s == "@all": |
|
207
|
|
|
match = cls.known_statuses() |
|
208
|
|
|
elif s in cls.known_statuses(): |
|
209
|
|
|
match = {s} |
|
210
|
|
|
else: |
|
211
|
|
|
raise XValueError(f"Invalid status {s}") |
|
212
|
|
|
for m in match: |
|
|
|
|
|
|
213
|
|
|
found.add(m) |
|
214
|
|
|
return found |
|
215
|
|
|
|
|
216
|
|
|
@classmethod |
|
217
|
|
|
def known_statuses(cls) -> Set[str]: |
|
|
|
|
|
|
218
|
|
|
return set(cls.status_map().values()) |
|
219
|
|
|
|
|
220
|
|
|
@classmethod |
|
221
|
|
|
def status_map(cls) -> Mapping[str, str]: |
|
|
|
|
|
|
222
|
|
|
return { |
|
223
|
|
|
"Unknown status": "unknown", |
|
224
|
|
|
"Completed": "completed", |
|
225
|
|
|
"Terminated": "stopped", |
|
226
|
|
|
"Suspended": "stopped", |
|
227
|
|
|
"Withdrawn": "stopped", |
|
228
|
|
|
"Not yet recruiting": "ongoing", |
|
229
|
|
|
"Recruiting": "ongoing", |
|
230
|
|
|
"Enrolling by invitation": "ongoing", |
|
231
|
|
|
"Active, not recruiting": "ongoing", |
|
232
|
|
|
"Available": "completed", |
|
233
|
|
|
"No longer available": "completed", |
|
234
|
|
|
"Temporarily not available": "completed", |
|
235
|
|
|
"Approved for marketing": "completed", |
|
236
|
|
|
} |
|
237
|
|
|
|
|
238
|
|
|
|
|
239
|
|
|
@dataclass(frozen=True, repr=True, eq=True) |
|
|
|
|
|
|
240
|
|
|
class ClinicalTrial: |
|
241
|
|
|
ctid: Codes.ClinicaltrialId |
|
242
|
|
|
title: str |
|
243
|
|
|
conditions: FrozenSet[str] |
|
244
|
|
|
disease_ids: FrozenSet[Codes.ClinicaltrialId] |
|
245
|
|
|
phase: str |
|
246
|
|
|
status: str |
|
247
|
|
|
interventions: FrozenSet[str] |
|
248
|
|
|
cids: FrozenSet[Codes.PubchemCompoundId] |
|
249
|
|
|
source: str |
|
250
|
|
|
|
|
251
|
|
|
@property |
|
252
|
|
|
def mapped_phase(self) -> float: |
|
|
|
|
|
|
253
|
|
|
return ClinicalTrialsGovUtils.phase_map().get(self.phase, 0) |
|
254
|
|
|
|
|
255
|
|
|
@property |
|
256
|
|
|
def mapped_status(self) -> str: |
|
|
|
|
|
|
257
|
|
|
return ClinicalTrialsGovUtils.status_map().get(self.status, "unknown") |
|
258
|
|
|
|
|
259
|
|
|
|
|
260
|
|
|
@dataclass(frozen=True, repr=True, eq=True) |
|
|
|
|
|
|
261
|
|
|
class GhsCode: |
|
262
|
|
|
code: Codes.GhsCode |
|
263
|
|
|
statement: str |
|
264
|
|
|
clazz: str |
|
265
|
|
|
categories: FrozenSet[str] |
|
266
|
|
|
signal_word: str |
|
267
|
|
|
type: str |
|
268
|
|
|
|
|
269
|
|
|
@classmethod |
|
270
|
|
|
def find(cls, code: str) -> GhsCode: |
|
|
|
|
|
|
271
|
|
|
h = hazards[code] |
|
|
|
|
|
|
272
|
|
|
cats = h["category"] # TODO |
|
|
|
|
|
|
273
|
|
|
return GhsCode( |
|
274
|
|
|
code=Codes.GhsCode(code), |
|
275
|
|
|
statement=h["statement"], |
|
276
|
|
|
clazz=h["class"], |
|
277
|
|
|
categories=cats, |
|
278
|
|
|
signal_word=h["signal_word"], |
|
279
|
|
|
type=h["type"], |
|
280
|
|
|
) |
|
281
|
|
|
|
|
282
|
|
|
@property |
|
283
|
|
|
def level(self) -> int: |
|
|
|
|
|
|
284
|
|
|
return int(self.code[1]) |
|
285
|
|
|
|
|
286
|
|
|
|
|
287
|
|
|
@dataclass(frozen=True, repr=True, eq=True) |
|
|
|
|
|
|
288
|
|
|
class AcuteEffectEntry: |
|
289
|
|
|
gid: int |
|
290
|
|
|
effects: FrozenSet[Codes.ChemIdPlusEffect] |
|
291
|
|
|
organism: Codes.ChemIdPlusOrganism |
|
292
|
|
|
test_type: str |
|
293
|
|
|
route: str |
|
294
|
|
|
dose: str |
|
295
|
|
|
|
|
296
|
|
|
@property |
|
297
|
|
|
def mg_per_kg(self) -> float: |
|
|
|
|
|
|
298
|
|
|
match = Patterns.mg_per_kg_pattern.search(self.dose) |
|
299
|
|
|
if match is None: |
|
300
|
|
|
# e.g. mg/m3/2H (mass per liter per time) |
|
301
|
|
|
raise XValueError(f"Dose {self.dose} (acute effect {self.gid}) could not be parsed") |
|
302
|
|
|
scale = dict(g=1e3, gm=1e3, mg=1, ug=10e-3, ng=10e-6, pg=10e-9)[match.group(2)] |
|
303
|
|
|
return float(match.group(1)) * scale |
|
304
|
|
|
|
|
305
|
|
|
|
|
306
|
|
|
@dataclass(frozen=True, repr=True, eq=True) |
|
|
|
|
|
|
307
|
|
|
class AssociatedDisorder: |
|
308
|
|
|
gid: str |
|
309
|
|
|
disease_id: Codes.MeshCode |
|
310
|
|
|
disease_name: str |
|
311
|
|
|
evidence_type: str |
|
312
|
|
|
n_refs: int |
|
313
|
|
|
|
|
314
|
|
|
|
|
315
|
|
|
@dataclass(frozen=True, repr=True, eq=True) |
|
|
|
|
|
|
316
|
|
|
class AtcCode: |
|
317
|
|
|
code: str |
|
318
|
|
|
name: str |
|
319
|
|
|
|
|
320
|
|
|
@property |
|
321
|
|
|
def level(self) -> int: |
|
|
|
|
|
|
322
|
|
|
return len(self.parts) |
|
323
|
|
|
|
|
324
|
|
|
@property |
|
325
|
|
|
def parts(self) -> Sequence[str]: |
|
|
|
|
|
|
326
|
|
|
match = Patterns.atc_parts_pattern.fullmatch(self.code) |
|
327
|
|
|
return [g for g in match.groups() if g is not None] |
|
328
|
|
|
|
|
329
|
|
|
|
|
330
|
|
|
class DrugbankTargetType(CleverEnum): |
|
|
|
|
|
|
331
|
|
|
target = enum.auto() |
|
332
|
|
|
carrier = enum.auto() |
|
333
|
|
|
transporter = enum.auto() |
|
334
|
|
|
enzyme = enum.auto() |
|
335
|
|
|
|
|
336
|
|
|
|
|
337
|
|
|
@dataclass(frozen=True, repr=True, eq=True) |
|
|
|
|
|
|
338
|
|
|
class DrugbankInteraction: |
|
339
|
|
|
record_id: Optional[str] |
|
340
|
|
|
gene_symbol: Codes.GeneId |
|
341
|
|
|
action: Optional[str] |
|
342
|
|
|
protein_id: str |
|
343
|
|
|
target_type: DrugbankTargetType |
|
344
|
|
|
target_name: str |
|
345
|
|
|
general_function: Optional[str] |
|
346
|
|
|
specific_function: str |
|
347
|
|
|
pmids: FrozenSet[Codes.PubmedId] |
|
348
|
|
|
dois: FrozenSet[Codes.Doi] |
|
349
|
|
|
|
|
350
|
|
|
|
|
351
|
|
|
@dataclass(frozen=True, repr=True, eq=True) |
|
|
|
|
|
|
352
|
|
|
class DrugbankDdi: |
|
353
|
|
|
drug_drugbank_id: Codes.DrugbankCompoundId |
|
354
|
|
|
drug_pubchem_id: Codes.PubchemCompoundId |
|
355
|
|
|
drug_drugbank_name: str |
|
356
|
|
|
description: str |
|
357
|
|
|
|
|
358
|
|
|
|
|
359
|
|
|
class Activity(CleverEnum): |
|
|
|
|
|
|
360
|
|
|
active = enum.auto() |
|
361
|
|
|
inactive = enum.auto() |
|
362
|
|
|
inconclusive = enum.auto() |
|
363
|
|
|
unspecified = enum.auto() |
|
364
|
|
|
|
|
365
|
|
|
|
|
366
|
|
|
@dataclass(frozen=True, repr=True, eq=True) |
|
|
|
|
|
|
367
|
|
|
class Bioactivity: |
|
368
|
|
|
assay_id: int |
|
369
|
|
|
assay_type: str |
|
370
|
|
|
assay_ref: str |
|
371
|
|
|
assay_name: str |
|
372
|
|
|
assay_made_date: date |
|
373
|
|
|
gene_id: Optional[Codes.GeneId] |
|
374
|
|
|
tax_id: Optional[int] |
|
375
|
|
|
pmid: Optional[Codes.PubmedId] |
|
376
|
|
|
activity: Optional[Activity] |
|
377
|
|
|
activity_name: Optional[str] |
|
378
|
|
|
activity_value: Optional[float] |
|
379
|
|
|
target_name: Optional[str] |
|
380
|
|
|
compound_name: str |
|
381
|
|
|
|
|
382
|
|
|
@property |
|
383
|
|
|
def target_name_abbrev_species(self) -> typing.Tuple[Optional[str], str, Optional[str]]: |
|
|
|
|
|
|
384
|
|
|
# first, look for a species name in parentheses |
|
385
|
|
|
# We use \)+ at the end instead of \) |
|
386
|
|
|
# this is to catch cases where we have parentheses inside of the species name |
|
387
|
|
|
# this happens with some virus strains, for e.g. |
|
388
|
|
|
match = Patterns.target_name_abbrev_species_pattern_1.fullmatch(self.target_name) |
|
389
|
|
|
if match is None: |
|
390
|
|
|
species = None |
|
391
|
|
|
target = self.target_name |
|
392
|
|
|
else: |
|
393
|
|
|
species = match.group(2) |
|
394
|
|
|
target = match.group(1) |
|
395
|
|
|
# now try to get an abbreviation |
|
396
|
|
|
match = Patterns.target_name_abbrev_species_pattern_2.fullmatch(target) |
|
397
|
|
|
if match is None: |
|
398
|
|
|
abbrev = None |
|
399
|
|
|
name = target |
|
400
|
|
|
else: |
|
401
|
|
|
abbrev = match.group(1) |
|
402
|
|
|
name = match.group(2) |
|
403
|
|
|
return name, abbrev, species |
|
404
|
|
|
|
|
405
|
|
|
|
|
406
|
|
|
@dataclass(frozen=True, repr=True, eq=True) |
|
|
|
|
|
|
407
|
|
|
class PdbEntry: |
|
408
|
|
|
pdbid: Codes.PdbId |
|
409
|
|
|
title: str |
|
410
|
|
|
exp_method: str |
|
411
|
|
|
resolution: float |
|
412
|
|
|
lig_names: FrozenSet[str] |
|
413
|
|
|
cids: FrozenSet[Codes.PubchemCompoundId] |
|
414
|
|
|
uniprot_ids: FrozenSet[Codes.UniprotId] |
|
415
|
|
|
pmids: FrozenSet[Codes.PubmedId] |
|
416
|
|
|
dois: FrozenSet[Codes.Doi] |
|
417
|
|
|
|
|
418
|
|
|
|
|
419
|
|
|
@dataclass(frozen=True, repr=True, eq=True) |
|
|
|
|
|
|
420
|
|
|
class PubmedEntry: |
|
421
|
|
|
pmid: Codes.PubmedId |
|
422
|
|
|
article_type: str |
|
423
|
|
|
pmidsrcs: FrozenSet[str] |
|
424
|
|
|
mesh_headings: FrozenSet[Codes.MeshHeading] |
|
425
|
|
|
mesh_subheadings: FrozenSet[Codes.MeshSubheading] |
|
426
|
|
|
mesh_codes: FrozenSet[Codes.MeshCode] |
|
427
|
|
|
cids: FrozenSet[Codes.PubchemCompoundId] |
|
428
|
|
|
article_title: str |
|
429
|
|
|
article_abstract: str |
|
430
|
|
|
journal_name: str |
|
431
|
|
|
pub_date: date |
|
432
|
|
|
|
|
433
|
|
|
|
|
434
|
|
|
@dataclass(frozen=True, repr=True, eq=True) |
|
|
|
|
|
|
435
|
|
|
class Publication: |
|
436
|
|
|
pmid: Codes.PubmedId |
|
437
|
|
|
pub_date: date |
|
438
|
|
|
is_review: bool |
|
439
|
|
|
title: str |
|
440
|
|
|
journal: str |
|
441
|
|
|
relevance_score: int |
|
442
|
|
|
|
|
443
|
|
|
|
|
444
|
|
|
@dataclass(frozen=True, repr=True, eq=True) |
|
|
|
|
|
|
445
|
|
|
class CoOccurrence: |
|
446
|
|
|
neighbor_id: str |
|
447
|
|
|
neighbor_name: str |
|
448
|
|
|
kind: CoOccurrenceType |
|
449
|
|
|
# https://pubchemdocs.ncbi.nlm.nih.gov/knowledge-panels |
|
450
|
|
|
article_count: int |
|
451
|
|
|
query_article_count: int |
|
452
|
|
|
neighbor_article_count: int |
|
453
|
|
|
score: int |
|
454
|
|
|
publications: FrozenSet[Publication] |
|
455
|
|
|
|
|
456
|
|
|
def strip_pubs(self) -> CoOccurrence: |
|
|
|
|
|
|
457
|
|
|
return CoOccurrence( |
|
458
|
|
|
self.neighbor_id, |
|
459
|
|
|
self.neighbor_name, |
|
460
|
|
|
self.kind, |
|
461
|
|
|
self.article_count, |
|
462
|
|
|
self.query_article_count, |
|
463
|
|
|
self.neighbor_article_count, |
|
464
|
|
|
self.score, |
|
465
|
|
|
frozenset({}), |
|
466
|
|
|
) |
|
467
|
|
|
|
|
468
|
|
|
|
|
469
|
|
|
@dataclass(frozen=True, repr=True, eq=True) |
|
|
|
|
|
|
470
|
|
|
class DrugGeneInteraction: |
|
471
|
|
|
""" """ |
|
472
|
|
|
|
|
473
|
|
|
gene_name: Optional[str] |
|
474
|
|
|
gene_claim_id: Optional[str] |
|
475
|
|
|
source: str |
|
476
|
|
|
interactions: FrozenSet[str] |
|
477
|
|
|
pmids: FrozenSet[Codes.PubmedId] |
|
478
|
|
|
dois: FrozenSet[Codes.Doi] |
|
479
|
|
|
|
|
480
|
|
|
|
|
481
|
|
|
@dataclass(frozen=True, repr=True, eq=True) |
|
|
|
|
|
|
482
|
|
|
class ChemicalGeneInteraction: |
|
483
|
|
|
gene_name: Optional[Codes.GeneId] |
|
484
|
|
|
interactions: FrozenSet[str] |
|
485
|
|
|
tax_id: Optional[int] |
|
486
|
|
|
tax_name: Optional[str] |
|
487
|
|
|
pmids: FrozenSet[Codes.PubmedId] |
|
488
|
|
|
|
|
489
|
|
|
|
|
490
|
|
|
__all__ = [ |
|
491
|
|
|
"ClinicalTrial", |
|
492
|
|
|
"AssociatedDisorder", |
|
493
|
|
|
"AtcCode", |
|
494
|
|
|
"DrugbankInteraction", |
|
495
|
|
|
"DrugbankDdi", |
|
496
|
|
|
"Bioactivity", |
|
497
|
|
|
"Activity", |
|
498
|
|
|
"DrugGeneInteraction", |
|
499
|
|
|
"ChemicalGeneInteraction", |
|
500
|
|
|
"GhsCode", |
|
501
|
|
|
"PubmedEntry", |
|
502
|
|
|
"Code", |
|
503
|
|
|
"Codes", |
|
504
|
|
|
"CoOccurrenceType", |
|
505
|
|
|
"CoOccurrence", |
|
506
|
|
|
"Publication", |
|
507
|
|
|
"ComputedProperty", |
|
508
|
|
|
"ClinicalTrialsGovUtils", |
|
509
|
|
|
"AcuteEffectEntry", |
|
510
|
|
|
"DrugbankTargetType", |
|
511
|
|
|
] |
|
512
|
|
|
|