Passed
Push — main ( 2b775d...83a9fb )
by Douglas
04:59 queued 02:43
created

ource()   A

Complexity

Conditions 1

Size

Total Lines 3
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
from typing import Sequence
0 ignored issues
show
introduced by
Missing module docstring
Loading history...
2
3
from mandos.model.apis.pubchem_api import PubchemApi
4
from mandos.model.apis.pubchem_support.pubchem_data import PubchemData
5
from mandos.model.apis.pubchem_support.pubchem_models import Bioactivity
6
from mandos.search.pubchem import PubchemSearch
7
from mandos.model.concrete_hits import BioactivityHit
8
9
10
class BioactivitySearch(PubchemSearch[BioactivityHit]):
0 ignored issues
show
Documentation introduced by
Empty class docstring
Loading history...
11
    """ """
12
13
    def __init__(
14
        self,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
15
        key: str,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
16
        api: PubchemApi,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
17
        compound_name_must_match: bool,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
18
    ):
19
        super().__init__(key, api)
20
        self.compound_name_must_match = compound_name_must_match
21
22
    def find(self, inchikey: str) -> Sequence[BioactivityHit]:
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
23
        data = self.api.fetch_data(inchikey)
24
        results = []
25
        for dd in data.biological_test_results.bioactivity:
0 ignored issues
show
Coding Style Naming introduced by
Variable name "dd" 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...
26
            if not self.compound_name_must_match or dd.compound_name.lower() == data.name.lower():
27
                results.append(self.process(inchikey, data, dd))
28
        return results
29
30
    def process(self, inchikey: str, data: PubchemData, dd: Bioactivity) -> BioactivityHit:
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
Coding Style Naming introduced by
Argument name "dd" 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...
31
        target_name, target_abbrev, species = dd.target_name_abbrev_species
32
        action = dd.activity.name.lower()
33
        source = self._format_source(
34
            assay_type=dd.assay_type,
35
            species=species,
36
        )
37
        predicate = self._format_predicate(
38
            action=action,
39
            assay_type=dd.assay_type,
40
            species=species,
41
        )
42
        return self._create_hit(
43
            inchikey=inchikey,
44
            c_id=str(data.cid),
45
            c_origin=inchikey,
46
            c_matched=data.names_and_identifiers.inchikey,
47
            c_name=data.name,
48
            data_source=source,
49
            predicate=predicate,
50
            object_id=dd.gene_id,
51
            object_name=target_name,
52
            target_abbrev=target_abbrev,
53
            activity=action,
54
            assay_type=dd.assay_type,
55
            micromolar=dd.activity_value,
56
            relation=dd.activity_name,
57
            species=species,
58
            compound_name_in_assay=dd.compound_name,
59
            referrer=dd.assay_ref,
60
        )
61
62
63
__all__ = ["BioactivitySearch"]
64