togows.py 730 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import logging

from bioapi.togows import TogoWSEntryAPI


logger = logging.getLogger(__name__)


class GetFunctionExternalInfo:

    def __init__(self, function_id, source):
        self.function_id = function_id
        self.source = source

    def _get_unknown_source(self):
        logger.warning("No source of information for %s from %s" % (self.function_id, self.source))
        return {}

    def _get_kegg(self):
        """
        Get detailed information from KEGG orthology through Togows.
        """
        kegg_api = TogoWSEntryAPI("kegg-orthology")
        return kegg_api.get(self.function_id)[0]

    def get_details(self):
        return getattr(self, f"_get_{self.source}", self._get_unknown_source)()