Passed
Push — dependabot/pip/flake8-bugbear-... ( 16d864...b4f9fc )
by
unknown
01:45
created

DiseaseSearch.__init__()   A

Complexity

Conditions 1

Size

Total Lines 4
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nop 5
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
import abc
0 ignored issues
show
introduced by
Missing module docstring
Loading history...
Unused Code introduced by
The import abc seems to be unused.
Loading history...
2
from dataclasses import dataclass
3
from typing import Sequence
4
5
from mandos.model.pubchem_api import PubchemApi
0 ignored issues
show
Unused Code introduced by
Unused PubchemApi imported from mandos.model.pubchem_api
Loading history...
6
from mandos.search.pubchem import PubchemHit, PubchemSearch
7
8
9
@dataclass(frozen=True, order=True, repr=True)
0 ignored issues
show
introduced by
Missing class docstring
Loading history...
10
class DiseaseHit(PubchemHit):
11
    evidence_type: str
12
13
14
class DiseaseSearch(PubchemSearch[DiseaseHit]):
0 ignored issues
show
Documentation introduced by
Empty class docstring
Loading history...
15
    """"""
16
17
    @property
18
    def data_source(self) -> str:
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
19
        return "Comparative Toxicogenomics Database (CTD)"
20
21
    def find(self, inchikey: str) -> Sequence[DiseaseHit]:
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
22
        data = self.api.fetch_data(inchikey)
23
        return [
24
            DiseaseHit(
25
                record_id=dd.gid,
26
                origin_inchikey=inchikey,
27
                matched_inchikey=data.names_and_identifiers.inchikey,
28
                compound_id=str(data.cid),
29
                compound_name=data.name,
30
                predicate=f"has {dd.evidence_type} evidence for",
31
                object_id=dd.disease_id,
32
                object_name=dd.disease_name,
33
                evidence_type=dd.evidence_type,
34
                search_key=self.key,
35
                search_class=self.search_class,
36
                data_source=self.data_source,
37
            )
38
            for dd in data.associated_disorders_and_diseases.associated_disorders_and_diseases
39
        ]
40
41
42
__all__ = ["DiseaseHit", "DiseaseSearch"]
43