# Path: pytaxize/itis/itis.py
# def hierarchy_full(tsn, as_dataframe=False, **kwargs):
#     """
#     Get full hierarchy from ts
# 
#     :param tsn: (int) TSN for a taxonomic group
#     :param as_dataframe: (bool) specify return type, if pandas is available
#     :param \*\*kwargs: Curl options passed on to `requests.get`
# 
#     Usage::
#         
#         from pytaxize import itis
#         itis.hierarchy_full(tsn = 37906)
#         itis.hierarchy_full(tsn = 100800)
#         # as data_frame
#         itis.hierarchy_full(tsn = 100800, as_dataframe=True)
#     """
#     tt = Refactor(
#         itis_base + "getFullHierarchyFromTSN", payload={"tsn": tsn}, request="get"
#     ).json(**kwargs)
#     hier = tt["hierarchyList"]
#     [z.pop("class") for z in hier if z is not None]
#     return _df(hier, as_dataframe)
# 
# Path: pytaxize/ncbi/ncbi.py
# def hierarchy(ids):
#     """
#     Get a full taxonomic hierarchy from NCBI
# 
#     :param ids: one or more NCBI taxonomy ids
# 
#     :note: Remember to set your Entrez API key as `ENTREZ_KEY`
# 
#     :return: dict, named with ids given to `ids`, 
#         where each value in the dict is a list of taxa, each
#         a dict with the fields ``ScientificName``, ``Rank``, and ``TaxId``
# 
#     Usage::
# 
#         from pytaxize import ncbi
#         ncbi.hierarchy(ids=9606)
#         ncbi.hierarchy(ids=[9606,55062,4231])
#     """
#     toget = ["ScientificName", "Rank", "TaxId"]
#     key = os.environ.get("ENTREZ_KEY")
#     if key is None:
#         raise Exception("ENTREZ_KEY is not defined")
#     if not isinstance(ids, list):
#         ids = [ids]
#     idz = ",".join([str(x) for x in ids])
#     args = {"db": "taxonomy", "ID": idz, "api_key": key}
#     res = _entrez("efetch", args)
#     taxa = res.xpath("//TaxaSet/Taxon")
#     out = []
#     for x in range(len(taxa)):
#         nodes = taxa[x].xpath(".//LineageEx/Taxon")
#         tmp = [
#             dict(zip(toget, [node.xpath(w)[0].text for w in toget])) for node in nodes
#         ]
#         tmp.append(dict(zip(toget, [taxa[x].xpath(w)[0].text for w in toget])))
#         out.append(tmp)
#     return dict(zip(ids, out))


import warnings
import sys
from pytaxize.itis import hierarchy_full
from pytaxize.ncbi import hierarchy
        ## many ids - with one invalid id
        x = Classification([99208, 129313, 9999999])
        x
        x.ids
        res = x.itis()
        res[99208]
        res[129313]
        res[9999999]

        # NCBI
        x = Classification(9606)
        x
        x.ids
        x.ncbi()
    """

    def __init__(self, ids):
        if isinstance(ids, int):
            ids = [ids]
        self.ids = ids

    def __repr__(self):
        x = """<%s>\n""" % type(self).__name__
        y = """  ids: %s""" % ",".join([str(w) for w in self.ids[:10]])
        return x + y

    def itis(self):
        out = []
        for i in range(len(self.ids)):
            id = self.ids[i]

# Path: pytaxize/itis/itis.py
# def hierarchy_full(tsn, as_dataframe=False, **kwargs):
#     """
#     Get full hierarchy from ts
# 
#     :param tsn: (int) TSN for a taxonomic group
#     :param as_dataframe: (bool) specify return type, if pandas is available
#     :param \*\*kwargs: Curl options passed on to `requests.get`
# 
#     Usage::
#         
#         from pytaxize import itis
#         itis.hierarchy_full(tsn = 37906)
#         itis.hierarchy_full(tsn = 100800)
#         # as data_frame
#         itis.hierarchy_full(tsn = 100800, as_dataframe=True)
#     """
#     tt = Refactor(
#         itis_base + "getFullHierarchyFromTSN", payload={"tsn": tsn}, request="get"
#     ).json(**kwargs)
#     hier = tt["hierarchyList"]
#     [z.pop("class") for z in hier if z is not None]
#     return _df(hier, as_dataframe)
# 
# Path: pytaxize/ncbi/ncbi.py
# def hierarchy(ids):
#     """
#     Get a full taxonomic hierarchy from NCBI
# 
#     :param ids: one or more NCBI taxonomy ids
# 
#     :note: Remember to set your Entrez API key as `ENTREZ_KEY`
# 
#     :return: dict, named with ids given to `ids`, 
#         where each value in the dict is a list of taxa, each
#         a dict with the fields ``ScientificName``, ``Rank``, and ``TaxId``
# 
#     Usage::
# 
#         from pytaxize import ncbi
#         ncbi.hierarchy(ids=9606)
#         ncbi.hierarchy(ids=[9606,55062,4231])
#     """
#     toget = ["ScientificName", "Rank", "TaxId"]
#     key = os.environ.get("ENTREZ_KEY")
#     if key is None:
#         raise Exception("ENTREZ_KEY is not defined")
#     if not isinstance(ids, list):
#         ids = [ids]
#     idz = ",".join([str(x) for x in ids])
#     args = {"db": "taxonomy", "ID": idz, "api_key": key}
#     res = _entrez("efetch", args)
#     taxa = res.xpath("//TaxaSet/Taxon")
#     out = []
#     for x in range(len(taxa)):
#         nodes = taxa[x].xpath(".//LineageEx/Taxon")
#         tmp = [
#             dict(zip(toget, [node.xpath(w)[0].text for w in toget])) for node in nodes
#         ]
#         tmp.append(dict(zip(toget, [taxa[x].xpath(w)[0].text for w in toget])))
#         out.append(tmp)
#     return dict(zip(ids, out))


# Path: pytaxize/classification/classification.py
import warnings
import sys
from pytaxize.itis import hierarchy_full
from pytaxize.ncbi import hierarchy

        ## many ids - with one invalid id
        x = Classification([99208, 129313, 9999999])
        x
        x.ids
        res = x.itis()
        res[99208]
        res[129313]
        res[9999999]

        # NCBI
        x = Classification(9606)
        x
        x.ids
        x.ncbi()
    """

    def __init__(self, ids):
        if isinstance(ids, int):
            ids = [ids]
        self.ids = ids

    def __repr__(self):
        x = """<%s>\n""" % type(self).__name__
        y = """  ids: %s""" % ",".join([str(w) for w in self.ids[:10]])
        return x + y

    def itis(self):
        out = []
        for i in range(len(self.ids)):
            id = self.ids[i]

            res = hierarchy_full(id)