Added an iterator to the OBI_Taxonomy cython class
This commit is contained in:
@ -6,7 +6,8 @@ from .capi.obitaxonomy cimport obi_read_taxonomy, \
|
||||
obi_read_taxdump, \
|
||||
obi_write_taxonomy, \
|
||||
obi_close_taxonomy, \
|
||||
obi_taxo_get_taxon_with_taxid
|
||||
obi_taxo_get_taxon_with_taxid, \
|
||||
ecotx_t
|
||||
|
||||
|
||||
from ._obidms cimport OBIDMS
|
||||
@ -43,19 +44,20 @@ cdef class OBI_Taxonomy :
|
||||
raise Exception("Not implemented")
|
||||
|
||||
|
||||
# def __iter__(self):
|
||||
#
|
||||
# cdef ecotx_t* taxa
|
||||
# cdef ecotx_t* taxon_p
|
||||
# cdef object taxon_capsule
|
||||
#
|
||||
# taxa = self._pointer.taxa.taxon
|
||||
#
|
||||
# # Yield each taxid
|
||||
# for t in range(self._pointer.taxa.count):
|
||||
# taxon_p = taxa+t # TODO not compiling for mysterious cython reasons
|
||||
# taxon_capsule = PyCapsule_New(taxon_p, NULL, NULL)
|
||||
# yield OBI_Taxon(taxon_capsule)
|
||||
def __iter__(self):
|
||||
|
||||
cdef ecotx_t* taxa
|
||||
cdef ecotx_t* taxon_p
|
||||
cdef object taxon_capsule
|
||||
cdef int t
|
||||
|
||||
taxa = self._pointer.taxa.taxon
|
||||
|
||||
# Yield each taxid
|
||||
for t in range(self._pointer.taxa.count):
|
||||
taxon_p = <ecotx_t*> (taxa+t) # TODO not compiling for mysterious cython reasons
|
||||
taxon_capsule = PyCapsule_New(taxon_p, NULL, NULL)
|
||||
yield OBI_Taxon(taxon_capsule)
|
||||
|
||||
|
||||
cpdef write(self, str prefix) :
|
||||
|
Reference in New Issue
Block a user