Skip to content

Commit

Permalink
Added catch to TaxDict constructor to fix problem with empty terminal…
Browse files Browse the repository at this point in the history
… ranks
  • Loading branch information
Jon Sanders committed Feb 3, 2016
1 parent 6b76851 commit e14cec0
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions taxon_names_resolver/manip_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,19 @@ def __init__(self, idents, ranks, lineages, taxonomy=default_taxonomy,
# extract lineage according to given taxonomy
lineage = [lineages[i][ranks[i].index(e)] if e in ranks[i] else ''
for e in self.taxonomy]
# find lowest tax rank present that is also in either the passed
# taxonomy or the default taxonomy
for j in range(len(ranks[i])):
low_rank = ranks[i][-(j+1)]
if low_rank in taxonomy or low_rank in default_taxonomy:
break
# create taxref
taxref = TaxRef(ident=idents[i], rank=ranks[i][-1],
taxref = TaxRef(ident=idents[i], rank=low_rank,
taxonomy=self.taxonomy)
# create key for ident and insert a dictionary of:
# lineage, taxref, cident, ident and rank
self[idents[i]] = {'lineage': lineage, 'taxref': taxref,
'cident': None, 'rank': ranks[i][-1],
'cident': None, 'rank': low_rank,
'ident': lineage[taxref.level]}
# add addtional optional slots from **kwargs
self._additional(idents, kwargs)
Expand Down

0 comments on commit e14cec0

Please sign in to comment.