Passed
Push — main ( 2e1b6b...3a0c28 )
by Douglas
02:06
created

mandos.model.apis.pubchem_support.pubchem_models   A

Complexity

Total Complexity 41

Size/Duplication

Total Lines 511
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 366
dl 0
loc 511
rs 9.1199
c 0
b 0
f 0
wmc 41

25 Methods

Rating   Name   Duplication   Size   Complexity  
A ComputedProperty.req_is() 0 4 2
A Code.type_name() 0 3 1
A ComputedProperty.as_str() 0 3 1
A CoOccurrence.strip_pubs() 0 10 1
A ClinicalTrialsGovUtils.known_phases() 0 3 1
A GhsCode.find() 0 11 1
A Codes.value() 0 3 1
A ClinicalTrialsGovUtils.resolve_statuses() 0 14 5
A Code.of_nullable() 0 5 2
A Codes.category() 0 3 1
A ClinicalTrialsGovUtils.known_statuses() 0 3 1
A Bioactivity.target_name_abbrev_species() 0 22 3
A ClinicalTrial.mapped_phase() 0 3 1
A ClinicalTrialsGovUtils.phase_map() 0 10 1
A Codes.subcategory() 0 3 1
A Code.of() 0 4 1
A AtcCode.parts() 0 4 1
A ClinicalTrial.mapped_status() 0 3 1
A CoOccurrenceType.id_name() 0 9 4
A AtcCode.level() 0 3 1
A ClinicalTrialsGovUtils.status_map() 0 16 1
A GhsCode.level() 0 3 1
A Codes.is_human() 0 3 1
A AcuteEffectEntry.mg_per_kg() 0 8 2
A CoOccurrenceType.x_name() 0 9 4

How to fix   Complexity   

Complexity

Complex classes like mandos.model.apis.pubchem_support.pubchem_models often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

1
from __future__ import annotations
0 ignored issues
show
introduced by
Missing module docstring
Loading history...
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
0 ignored issues
show
introduced by
Unable to import 'orjson'
Loading history...
10
from pocketutils.core.dot_dict import NestedDotDict
0 ignored issues
show
introduced by
Unable to import 'pocketutils.core.dot_dict'
Loading history...
11
from pocketutils.core.enums import CleverEnum
0 ignored issues
show
introduced by
Unable to import 'pocketutils.core.enums'
Loading history...
12
from pocketutils.core.exceptions import XTypeError, XValueError
0 ignored issues
show
introduced by
Unable to import 'pocketutils.core.exceptions'
Loading history...
13
from pocketutils.tools.string_tools import StringTools
0 ignored issues
show
introduced by
Unable to import 'pocketutils.tools.string_tools'
Loading history...
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)
0 ignored issues
show
introduced by
Missing class docstring
Loading history...
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]:
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
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:
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
38
        return f"{self.value} {self.unit}"
39
40
41
class Code(str):
0 ignored issues
show
introduced by
Missing class docstring
Loading history...
42
    @property
43
    def type_name(self) -> str:
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
44
        return self.__class__.__name__.lower()
45
46
    @classmethod
47
    def of(cls, value: Union[str, int, float]) -> __qualname__:
0 ignored issues
show
Comprehensibility Best Practice introduced by
Undefined variable '__qualname__'
Loading history...
introduced by
Missing function or method docstring
Loading history...
Coding Style Naming introduced by
Method name "of" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
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__]:
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
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:
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
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:
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
81
            return self[: self.index(":")].strip()
82
83
        @property
84
        def subcategory(self) -> str:
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
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):
0 ignored issues
show
Documentation introduced by
Empty class docstring
Loading history...
109
        """ """
110
111
    class UniprotId(GeneId):
0 ignored issues
show
Documentation introduced by
Empty class docstring
Loading history...
112
        """ """
113
114
    class PubchemCompoundId(Code):
115
        """
116
        e.g. 2352
117
        """
118
119
        @property
120
        def value(self) -> int:
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
121
            return int(self)
122
123
    class AtcCode(Code):
0 ignored issues
show
Documentation introduced by
Empty class docstring
Loading history...
124
        """ """
125
126
    class PubmedId(Code):
0 ignored issues
show
Documentation introduced by
Empty class docstring
Loading history...
127
        """ """
128
129
    class Doi(Code):
0 ignored issues
show
Documentation introduced by
Empty class docstring
Loading history...
130
        """ """
131
132
    class MeshCode(Code):
0 ignored issues
show
Documentation introduced by
Empty class docstring
Loading history...
133
        """ """
134
135
    class PdbId(Code):
0 ignored issues
show
Documentation introduced by
Empty class docstring
Loading history...
136
        """ """
137
138
    class MeshHeading(Code):
0 ignored issues
show
Documentation introduced by
Empty class docstring
Loading history...
139
        """ """
140
141
    class MeshSubheading(Code):
0 ignored issues
show
Documentation introduced by
Empty class docstring
Loading history...
142
        """ """
143
144
    class DrugbankCompoundId(Code):
0 ignored issues
show
Documentation introduced by
Empty class docstring
Loading history...
145
        """ """
146
147
    class DeaSchedule(Code):
0 ignored issues
show
Documentation introduced by
Empty class docstring
Loading history...
148
        """ """
149
150
        @property
151
        def value(self) -> int:
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
152
            return Mapx.roman_to_arabic(1, 5)(self)
153
154
    class GhsCode(Code):
0 ignored issues
show
Documentation introduced by
Empty class docstring
Loading history...
155
        """ """
156
157
158
class CoOccurrenceType(CleverEnum):
0 ignored issues
show
introduced by
Missing class docstring
Loading history...
159
    chemical = enum.auto()
160
    gene = enum.auto()
161
    disease = enum.auto()
162
163
    @property
164
    def x_name(self) -> str:
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
165
        if self is CoOccurrenceType.chemical:
0 ignored issues
show
unused-code introduced by
Unnecessary "elif" after "return"
Loading history...
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:
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
175
        if self is CoOccurrenceType.chemical:
0 ignored issues
show
unused-code introduced by
Unnecessary "elif" after "return"
Loading history...
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:
0 ignored issues
show
introduced by
Missing class docstring
Loading history...
185
    @classmethod
186
    def phase_map(cls) -> Mapping[str, float]:
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
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]:
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
199
        return set(cls.phase_map().values())
200
201
    @classmethod
202
    def resolve_statuses(cls, st: str) -> Set[str]:
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
Coding Style Naming introduced by
Argument name "st" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
203
        found = set()
204
        for s in st.lower().split(","):
0 ignored issues
show
Coding Style Naming introduced by
Variable name "s" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
205
            s = s.strip()
0 ignored issues
show
Coding Style Naming introduced by
Variable name "s" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
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:
0 ignored issues
show
Coding Style Naming introduced by
Variable name "m" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
213
                found.add(m)
214
        return found
215
216
    @classmethod
217
    def known_statuses(cls) -> Set[str]:
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
218
        return set(cls.status_map().values())
219
220
    @classmethod
221
    def status_map(cls) -> Mapping[str, str]:
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
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)
0 ignored issues
show
best-practice introduced by
Too many instance attributes (9/7)
Loading history...
introduced by
Missing class docstring
Loading history...
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:
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
253
        return ClinicalTrialsGovUtils.phase_map().get(self.phase, 0)
254
255
    @property
256
    def mapped_status(self) -> str:
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
257
        return ClinicalTrialsGovUtils.status_map().get(self.status, "unknown")
258
259
260
@dataclass(frozen=True, repr=True, eq=True)
0 ignored issues
show
introduced by
Missing class docstring
Loading history...
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:
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
271
        h = hazards[code]
0 ignored issues
show
Coding Style Naming introduced by
Variable name "h" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
272
        cats = h["category"]  # TODO
0 ignored issues
show
Coding Style introduced by
TODO and FIXME comments should generally be avoided.
Loading history...
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:
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
284
        return int(self.code[1])
285
286
287
@dataclass(frozen=True, repr=True, eq=True)
0 ignored issues
show
introduced by
Missing class docstring
Loading history...
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:
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
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)
0 ignored issues
show
introduced by
Missing class docstring
Loading history...
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)
0 ignored issues
show
introduced by
Missing class docstring
Loading history...
316
class AtcCode:
317
    code: str
318
    name: str
319
320
    @property
321
    def level(self) -> int:
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
322
        return len(self.parts)
323
324
    @property
325
    def parts(self) -> Sequence[str]:
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
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):
0 ignored issues
show
introduced by
Missing class docstring
Loading history...
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)
0 ignored issues
show
introduced by
Missing class docstring
Loading history...
best-practice introduced by
Too many instance attributes (10/7)
Loading history...
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)
0 ignored issues
show
introduced by
Missing class docstring
Loading history...
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):
0 ignored issues
show
introduced by
Missing class docstring
Loading history...
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)
0 ignored issues
show
introduced by
Missing class docstring
Loading history...
best-practice introduced by
Too many instance attributes (13/7)
Loading history...
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]]:
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
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)
0 ignored issues
show
best-practice introduced by
Too many instance attributes (9/7)
Loading history...
introduced by
Missing class docstring
Loading history...
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)
0 ignored issues
show
best-practice introduced by
Too many instance attributes (11/7)
Loading history...
introduced by
Missing class docstring
Loading history...
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)
0 ignored issues
show
introduced by
Missing class docstring
Loading history...
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)
0 ignored issues
show
best-practice introduced by
Too many instance attributes (8/7)
Loading history...
introduced by
Missing class docstring
Loading history...
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:
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
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)
0 ignored issues
show
Documentation introduced by
Empty class docstring
Loading history...
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)
0 ignored issues
show
introduced by
Missing class docstring
Loading history...
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