mandos.search.chembl.indication_search   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 76
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 36
dl 0
loc 76
rs 10
c 0
b 0
f 0
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A IndicationHit.predicate() 0 3 1
A IndicationSearch.find() 0 19 3
A IndicationSearch.process() 0 22 1
1
from __future__ import annotations
0 ignored issues
show
introduced by
Missing module docstring
Loading history...
2
3
import logging
4
from dataclasses import dataclass
5
from typing import Sequence
6
7
from pocketutils.core.dot_dict import NestedDotDict
0 ignored issues
show
introduced by
Unable to import 'pocketutils.core.dot_dict'
Loading history...
8
9
from mandos.model import AbstractHit, ChemblCompound, Search
10
11
logger = logging.getLogger("mandos")
12
13
14
@dataclass(frozen=True, order=True, repr=True)
15
class IndicationHit(AbstractHit):
16
    """
17
    An indication with a MESH term.
18
    """
19
20
    max_phase: int
21
22
    @property
23
    def predicate(self) -> str:
24
        return f"phase-{self.max_phase} indication"
25
26
27
class IndicationSearch(Search[IndicationHit]):
0 ignored issues
show
Documentation introduced by
Empty class docstring
Loading history...
introduced by
Value 'Search' is unsubscriptable
Loading history...
28
    """"""
29
30
    def find(self, lookup: str) -> Sequence[IndicationHit]:
31
        """
32
33
        Args:
34
            lookup:
35
36
        Returns:
37
38
        """
39
        # 'atc_classifications': ['S01HA01', 'N01BC01', 'R02AD03', 'S02DA02']
40
        # 'indication_class': 'Anesthetic (topical)'
41
        ch = self.get_compound_dot_dict(lookup)
0 ignored issues
show
Coding Style Naming introduced by
Variable name "ch" 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...
42
        compound = self.compound_dot_dict_to_obj(ch)
43
        inds = self.api.drug_indication.filter(parent_molecule_chembl_id=compound.chid)
44
        hits = []
45
        for ind in inds:
46
            if ind.req_as("max_phase_for_ind", int) >= self.config.min_phase:
47
                hits.append(self.process(lookup, compound, ind))
48
        return hits
49
50
    def process(
0 ignored issues
show
Coding Style introduced by
This method could be written as a function/class method.

If a method does not access any attributes of the class, it could also be implemented as a function or static method. This can help improve readability. For example

class Foo:
    def some_method(self, x, y):
        return x + y;

could be written as

class Foo:
    @classmethod
    def some_method(cls, x, y):
        return x + y;
Loading history...
51
        self, lookup: str, compound: ChemblCompound, indication: NestedDotDict
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
52
    ) -> IndicationHit:
53
        """
54
55
        Args:
56
            lookup:
57
            compound:
58
            indication:
59
60
        Returns:
61
62
        """
63
        return IndicationHit(
64
            indication.req_as("drugind_id", str),
65
            compound.chid,
66
            compound.inchikey,
67
            lookup,
68
            compound.name,
69
            object_id=indication.req_as("mesh_id", str),
70
            object_name=indication.req_as("mesh_heading", str).strip("\n"),
71
            max_phase=indication.req_as("max_phase_for_ind", int),
72
        )
73
74
75
__all__ = ["IndicationHit", "IndicationSearch"]
76