Passed
Push — main ( a07aa0...748456 )
by Douglas
01:55
created

mandos.search.pubchem.dgidb_search.CgiSearch.find()   A

Complexity

Conditions 1

Size

Total Lines 17
Code Lines 16

Duplication

Lines 17
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
eloc 16
nop 2
dl 17
loc 17
rs 9.6
c 0
b 0
f 0
1
from dataclasses import dataclass
0 ignored issues
show
introduced by
Missing module docstring
Loading history...
2
from typing import Sequence
3
4
from mandos.model.pubchem_api import PubchemApi
5
from mandos.search.pubchem import PubchemHit, PubchemSearch
6
7
8
@dataclass(frozen=True, order=True, repr=True)
0 ignored issues
show
Documentation introduced by
Empty class docstring
Loading history...
9
class DgiHit(PubchemHit):
10
    """"""
11
12
13
class DgiSearch(PubchemSearch[DgiHit]):
0 ignored issues
show
Documentation introduced by
Empty class docstring
Loading history...
14
    """"""
15
16
    def __init__(self, key: str, api: PubchemApi):
0 ignored issues
show
introduced by
Useless super delegation in method '__init__'
Loading history...
17
        super().__init__(key, api)
18
19
    @property
20
    def data_source(self) -> str:
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
21
        return "Drug Gene Interaction Database (DGIdb)"
22
23
    def find(self, inchikey: str) -> Sequence[DgiHit]:
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
24
        data = self.api.fetch_data(inchikey)
25
        return [
26
            DgiHit(
27
                record_id=None,
28
                origin_inchikey=inchikey,
29
                matched_inchikey=data.names_and_identifiers.inchikey,
30
                compound_id=str(data.cid),
31
                compound_name=data.name,
32
                predicate=f"drug/gene interaction",
0 ignored issues
show
introduced by
Using an f-string that does not have any interpolated variables
Loading history...
33
                object_id=dd.gene_claim_id,
34
                object_name=dd.gene_name,
35
                search_key=self.key,
36
                search_class=self.search_class,
37
                data_source=self.data_source,
38
            )
39
            for dd in data.biomolecular_interactions_and_pathways.drug_gene_interactions
40
        ]
41
42
43
__all__ = ["DgiHit", "DgiSearch"]
44