| Total Complexity | 3 |
| Total Lines | 34 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 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): |
||
|
|
|||
| 17 | """""" |
||
| 18 | |||
| 19 | |||
| 20 | class PubchemApi(metaclass=abc.ABCMeta): |
||
| 21 | def fetch_data_from_cid(self, cid: int) -> Optional[PubchemData]: |
||
| 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]: |
||
| 27 | raise NotImplementedError() |
||
| 28 | |||
| 29 | def find_similar_compounds(self, inchi: Union[int, str], min_tc: float) -> FrozenSet[int]: |
||
| 30 | raise NotImplementedError() |
||
| 31 | |||
| 32 | |||
| 33 | __all__ = ["PubchemApi", "PubchemCompoundLookupError"] |
||
| 34 |