Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
GENUS = 5
FAMILY = 4
ORDER = 3
CLASS = 2
PHYLUM = 1
KINGDOM = 0
str2rank = {
'species': Rank.SPECIES,
'genus': Rank.GENUS,
'family': Rank.FAMILY,
'order': Rank.ORDER,
'class': Rank.CLASS,
'phylum': Rank.PHYLUM,
'kingdom': Rank.KINGDOM,
'no rank': Rank.NO_RANK
}
def build_complete_tree(tree, log):
"""Build the taxonomic tree including internal nodes (for rank dependent evaluation)
Args:
tree (fileobject): file name of the reference tree, without internal nodes
log (fileobject): log file
"""
ncbi = NCBITaxa()
original_tree = Tree(tree, format=1)
taxa = [n.taxid for n in original_tree.traverse('postorder')]
built = False
while not built: