diff --git a/python/obitools3/commands/test.pyx b/python/obitools3/commands/test.pyx index aa49991..66b36c1 100644 --- a/python/obitools3/commands/test.pyx +++ b/python/obitools3/commands/test.pyx @@ -5,7 +5,7 @@ from obitools3.dms.view.view import View, Line_selection from obitools3.dms.view.typed_view.view_NUC_SEQS import View_NUC_SEQS from obitools3.dms.dms import DMS from obitools3.dms.column import Column -from obitools3.dms.taxo.taxo import OBI_Taxonomy +from obitools3.dms.taxo.taxo import Taxonomy from obitools3.utils cimport str2bytes from obitools3.dms.capi.obitypes cimport OBI_INT, \ OBI_FLOAT, \ @@ -42,9 +42,9 @@ default_config = { def test_taxo(config, infos): - tax1 = OBI_Taxonomy.open(infos['dms'], config['obi']['taxo'], taxdump=True) + tax1 = Taxonomy.open(infos['dms'], config['obi']['taxo'], taxdump=True) tax1.write(TAXTEST) - tax2 = OBI_Taxonomy.open(infos['dms'], TAXTEST, taxdump=False) + tax2 = Taxonomy.open(infos['dms'], TAXTEST, taxdump=False) assert len(tax1) == len(tax2), "Length of written taxonomy != length of read taxdump : "+str(len(tax2))+" != "+str(len(tax1)) i = 0 diff --git a/python/obitools3/dms/taxo/taxo.pxd b/python/obitools3/dms/taxo/taxo.pxd index edbb06a..c7c2a67 100644 --- a/python/obitools3/dms/taxo/taxo.pxd +++ b/python/obitools3/dms/taxo/taxo.pxd @@ -7,7 +7,7 @@ from ..dms cimport DMS from ..object cimport OBIWrapper -cdef class OBI_Taxonomy(OBIWrapper) : +cdef class Taxonomy(OBIWrapper) : cdef str _name # TODO keep as bytes? cdef DMS _dms @@ -18,6 +18,6 @@ cdef class OBI_Taxonomy(OBIWrapper) : cpdef int add_taxon(self, str name, str rank_name, int parent_taxid, int min_taxid=*) cpdef close(self) -cdef class OBI_Taxon : +cdef class Taxon : cdef ecotx_t* _pointer - cdef OBI_Taxonomy _tax \ No newline at end of file + cdef Taxonomy _tax \ No newline at end of file diff --git a/python/obitools3/dms/taxo/taxo.pyx b/python/obitools3/dms/taxo/taxo.pyx index bb8a93c..30f643e 100644 --- a/python/obitools3/dms/taxo/taxo.pyx +++ b/python/obitools3/dms/taxo/taxo.pyx @@ -14,7 +14,7 @@ from ..capi.obitaxonomy cimport obi_read_taxonomy, \ from cpython.pycapsule cimport PyCapsule_New, PyCapsule_GetPointer -cdef class OBI_Taxonomy(OBIWrapper) : +cdef class Taxonomy(OBIWrapper) : # TODO function to import taxonomy? cdef inline OBIDMS_taxonomy_p pointer(self) : @@ -24,8 +24,8 @@ cdef class OBI_Taxonomy(OBIWrapper) : @staticmethod def open(DMS dms, str name, bint taxdump=False) : - cdef void* pointer - cdef OBI_Taxonomy taxo + cdef void* pointer + cdef Taxonomy taxo if taxdump : pointer = obi_read_taxdump(tobytes(name)) @@ -37,7 +37,7 @@ cdef class OBI_Taxonomy(OBIWrapper) : raise RuntimeError("Error : Cannot read taxonomy %s" % name) - taxo = OBIWrapper.new(OBI_Taxonomy, pointer) + taxo = OBIWrapper.new_wrapper(Taxonomy, pointer) dms.register(taxo) @@ -57,7 +57,7 @@ cdef class OBI_Taxonomy(OBIWrapper) : if taxon_p == NULL : raise Exception("Taxon not found") taxon_capsule = PyCapsule_New(taxon_p, NULL, NULL) - return OBI_Taxon(taxon_capsule, self) + return Taxon(taxon_capsule, self) else : raise Exception("Not implemented") @@ -71,7 +71,7 @@ cdef class OBI_Taxonomy(OBIWrapper) : taxa = self.pointer().taxa.taxon taxon_p = (taxa+idx) taxon_capsule = PyCapsule_New(taxon_p, NULL, NULL) - return OBI_Taxon(taxon_capsule, self) + return Taxon(taxon_capsule, self) def __len__(self): @@ -91,7 +91,7 @@ cdef class OBI_Taxonomy(OBIWrapper) : for t in range(self.pointer().taxa.count): taxon_p = (taxa+t) taxon_capsule = PyCapsule_New(taxon_p, NULL, NULL) - yield OBI_Taxon(taxon_capsule, self) + yield Taxon(taxon_capsule, self) cpdef write(self, str prefix) : @@ -126,9 +126,9 @@ cdef class OBI_Taxonomy(OBIWrapper) : return self._name -cdef class OBI_Taxon : # TODO dict subclass? +cdef class Taxon : # TODO dict subclass? - def __init__(self, object taxon_capsule, OBI_Taxonomy tax) : + def __init__(self, object taxon_capsule, Taxonomy tax) : self._pointer = PyCapsule_GetPointer(taxon_capsule, NULL) if self._pointer == NULL : raise Exception("Error reading a taxon (NULL pointer)") @@ -136,7 +136,7 @@ cdef class OBI_Taxon : # TODO dict subclass? # To test equality - def __richcmp__(self, OBI_Taxon taxon2, int op): + def __richcmp__(self, Taxon taxon2, int op): return (self.name == taxon2.name) and \ (self.taxid == taxon2.taxid) and \ (self.rank == taxon2.rank) and \ @@ -170,7 +170,7 @@ cdef class OBI_Taxon : # TODO dict subclass? def parent(self): cdef object parent_capsule parent_capsule = PyCapsule_New(self._pointer.parent, NULL, NULL) - return OBI_Taxon(parent_capsule, self._tax) + return Taxon(parent_capsule, self._tax) # preferred name property getter and setter @property