Passed
Push — dependabot/pip/flake8-bugbear-... ( 82a4d5...16d864 )
by
unknown
02:18
created

mandos.search.pubchem.ctd_gene_search   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 31
dl 0
loc 45
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A CtdGeneSearch.data_source() 0 3 1
A CtdGeneSearch.find() 0 19 1
1
from dataclasses import dataclass
0 ignored issues
show
introduced by
Missing module docstring
Loading history...
2
from typing import Sequence, Optional
3
4
from mandos.search.pubchem import PubchemHit, PubchemSearch
5
6
7
@dataclass(frozen=True, order=True, repr=True)
0 ignored issues
show
Documentation introduced by
Empty class docstring
Loading history...
8
class CtdGeneHit(PubchemHit):
9
    """"""
10
11
    taxon_id: Optional[int]
12
    taxon_name: Optional[str]
13
14
15
class CtdGeneSearch(PubchemSearch[CtdGeneHit]):
0 ignored issues
show
Documentation introduced by
Empty class docstring
Loading history...
16
    """"""
17
18
    @property
19
    def data_source(self) -> str:
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
20
        return "Comparative Toxicogenomics Database (CTD)"
21
22
    def find(self, inchikey: str) -> Sequence[CtdGeneHit]:
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
23
        data = self.api.fetch_data(inchikey)
24
        return [
25
            CtdGeneHit(
26
                record_id=None,
27
                origin_inchikey=inchikey,
28
                matched_inchikey=data.names_and_identifiers.inchikey,
29
                compound_id=str(data.cid),
30
                compound_name=data.name,
31
                predicate="gene interaction",
32
                object_id=dd.gene_name,
33
                object_name=dd.gene_name,
34
                search_key=self.key,
35
                search_class=self.search_class,
36
                data_source=self.data_source,
37
                taxon_id=dd.tax_id,
38
                taxon_name=dd.tax_name,
39
            )
40
            for dd in data.biomolecular_interactions_and_pathways.compound_gene_interactions
41
        ]
42
43
44
__all__ = ["CtdGeneHit", "CtdGeneSearch"]
45