From d8a7bd42bdd92a9772c3f7c65e0794f37700aa49 Mon Sep 17 00:00:00 2001 From: Celine Mercier Date: Tue, 26 Mar 2019 14:08:54 +0100 Subject: [PATCH] Cython API, taxonomy: fixed parental tree iterator (skipped second to last taxon, in OBI1 too) --- python/obitools3/dms/taxo/taxo.pyx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/python/obitools3/dms/taxo/taxo.pyx b/python/obitools3/dms/taxo/taxo.pyx index 758b7ac..ec1cf21 100755 --- a/python/obitools3/dms/taxo/taxo.pyx +++ b/python/obitools3/dms/taxo/taxo.pyx @@ -113,7 +113,7 @@ cdef class Taxonomy(OBIWrapper) : raise NotImplementedError() - cpdef Taxon get_taxon_by_taxid(self, int taxid): # TODO check deleted taxon behavior (403122) + cpdef Taxon get_taxon_by_taxid(self, int taxid): cdef ecotx_t* taxon_p cdef object taxon_capsule taxon_p = obi_taxo_get_taxon_with_taxid(self.pointer(), taxid) @@ -256,13 +256,13 @@ cdef class Taxonomy(OBIWrapper) : cdef Taxon taxon try: taxon = self.get_taxon_by_taxid(taxid) - except: # TODO error handling (related to deleted taxon thing) + except: raise StopIteration if taxon is not None: - while taxon.parent.taxid != 1: # TODO was 0 before? + while taxon.taxid != 1: yield taxon taxon = taxon.parent - yield self[1] + yield taxon else: raise StopIteration