Taxonomy Cython API: added is_ancestor() function
This commit is contained in:
@ -113,7 +113,7 @@ cdef class Taxonomy(OBIWrapper) :
|
||||
raise Exception("Not implemented")
|
||||
|
||||
|
||||
cpdef Taxon get_taxon_by_taxid(self, int taxid):
|
||||
cpdef Taxon get_taxon_by_taxid(self, int taxid): # TODO check deleted taxon behavior (403122)
|
||||
cdef ecotx_t* taxon_p
|
||||
cdef object taxon_capsule
|
||||
taxon_p = obi_taxo_get_taxon_with_taxid(self.pointer(), taxid)
|
||||
@ -254,7 +254,10 @@ cdef class Taxonomy(OBIWrapper) :
|
||||
first ancestor to the root.
|
||||
"""
|
||||
cdef Taxon taxon
|
||||
taxon = self.get_taxon_by_taxid(taxid)
|
||||
try:
|
||||
taxon = self.get_taxon_by_taxid(taxid)
|
||||
except: # TODO error handling (related to deleted taxon thing)
|
||||
raise StopIteration
|
||||
if taxon is not None:
|
||||
while taxon.parent.taxid != 1: # TODO was 0 before?
|
||||
yield taxon
|
||||
@ -264,6 +267,10 @@ cdef class Taxonomy(OBIWrapper) :
|
||||
raise StopIteration
|
||||
|
||||
|
||||
def is_ancestor(self, int ancestor_taxid, int taxid):
|
||||
return ancestor_taxid in [x.taxid for x in self.parental_tree_iterator(taxid)]
|
||||
|
||||
|
||||
def last_common_taxon(self, *taxids):
|
||||
|
||||
cdef list t1
|
||||
|
Reference in New Issue
Block a user