Passed
Push — main ( d08a4e...a07aa0 )
by Douglas
01:59
created

mandos.model.pubchem_api   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 17
dl 0
loc 34
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A PubchemApi.fetch_data_from_cid() 0 4 1
A PubchemApi.fetch_data() 0 2 1
A PubchemApi.find_similar_compounds() 0 2 1
1
"""
2
PubChem querying API.
3
"""
4
from __future__ import annotations
5
6
import abc
7
import logging
8
from typing import Optional, Union, FrozenSet
9
10
from mandos.model import CompoundNotFoundError
11
from mandos.model.pubchem_support.pubchem_data import PubchemData
12
13
logger = logging.getLogger("mandos")
14
15
16
class PubchemCompoundLookupError(CompoundNotFoundError):
0 ignored issues
show
Documentation introduced by
Empty class docstring
Loading history...
17
    """"""
18
19
20
class PubchemApi(metaclass=abc.ABCMeta):
0 ignored issues
show
introduced by
Missing class docstring
Loading history...
21
    def fetch_data_from_cid(self, cid: int) -> Optional[PubchemData]:
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
22
        # separated from fetch_data to make it completely clear what an int value means
23
        # noinspection PyTypeChecker
24
        return self.fetch_data(cid)
25
26
    def fetch_data(self, inchikey: str) -> Optional[PubchemData]:
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
27
        raise NotImplementedError()
28
29
    def find_similar_compounds(self, inchi: Union[int, str], min_tc: float) -> FrozenSet[int]:
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
30
        raise NotImplementedError()
31
32
33
__all__ = ["PubchemApi", "PubchemCompoundLookupError"]
34