| Total Complexity | 3 |
| Total Lines | 31 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | """ |
||
| 2 | PubChem querying API. |
||
| 3 | """ |
||
| 4 | from __future__ import annotations |
||
| 5 | |||
| 6 | import abc |
||
| 7 | from typing import FrozenSet, Optional, Union |
||
| 8 | |||
| 9 | from mandos.model import Api, CompoundNotFoundError |
||
| 10 | from mandos.model.apis.pubchem_support.pubchem_data import PubchemData |
||
| 11 | |||
| 12 | |||
| 13 | class PubchemCompoundLookupError(CompoundNotFoundError): |
||
|
|
|||
| 14 | """ """ |
||
| 15 | |||
| 16 | |||
| 17 | class PubchemApi(Api, metaclass=abc.ABCMeta): |
||
| 18 | def fetch_data_from_cid(self, cid: int) -> Optional[PubchemData]: |
||
| 19 | # separated from fetch_data to make it completely clear what an int value means |
||
| 20 | # noinspection PyTypeChecker |
||
| 21 | return self.fetch_data(cid) |
||
| 22 | |||
| 23 | def fetch_data(self, inchikey: str) -> Optional[PubchemData]: |
||
| 24 | raise NotImplementedError() |
||
| 25 | |||
| 26 | def find_similar_compounds(self, inchi: Union[int, str], min_tc: float) -> FrozenSet[int]: |
||
| 27 | raise NotImplementedError() |
||
| 28 | |||
| 29 | |||
| 30 | __all__ = ["PubchemApi", "PubchemCompoundLookupError"] |
||
| 31 |