Taxonomy: fixed an issue related to StopIteration behaviour in new

versions of python
This commit is contained in:
Celine Mercier
2024-01-10 15:53:15 +13:00
parent aeed42456a
commit 837ff1a1ba

View File

@ -325,8 +325,9 @@ cdef class Taxonomy(OBIWrapper) :
cdef Taxon taxon
try:
taxon = self.get_taxon_by_taxid(taxid)
except:
raise StopIteration
except Exception as e:
print('\n'+e, file=sys.stderr)
return
if taxon is not None:
while taxon.taxid != 1:
yield taxon
@ -334,7 +335,7 @@ cdef class Taxonomy(OBIWrapper) :
taxon = taxon.parent
yield taxon
else:
raise StopIteration
return
def is_ancestor(self, int ancestor_taxid, int taxid):