79 lines
2.0 KiB
Cython
79 lines
2.0 KiB
Cython
#cython: language_level=3
|
|
|
|
from obitools3.utils cimport bytes2str, str2bytes
|
|
|
|
from .capi.obiview cimport NUC_SEQUENCE_COLUMN, \
|
|
ID_COLUMN, \
|
|
DESCRIPTION_COLUMN
|
|
|
|
cdef class OBI_Seq(dict) :
|
|
|
|
def __init__(self, str id, str seq, str description=None) :
|
|
self.set_id(id)
|
|
self.set_sequence(seq)
|
|
if description is not None :
|
|
self.set_description(description)
|
|
|
|
cpdef set_id(self, str id) :
|
|
self.id = id
|
|
self[bytes2str(ID_COLUMN)] = id
|
|
|
|
cpdef get_id(self) :
|
|
return self.id
|
|
|
|
cpdef set_description(self, str description) :
|
|
self.description = description
|
|
self[bytes2str(DESCRIPTION_COLUMN)] = description
|
|
|
|
cpdef get_description(self) :
|
|
return self.description
|
|
|
|
cpdef get_sequence(self) :
|
|
return self.sequence
|
|
|
|
def __str__(self) :
|
|
return self.sequence # or not
|
|
|
|
|
|
cdef class OBI_Nuc_Seq(OBI_Seq) :
|
|
|
|
cpdef set_sequence(self, str sequence) :
|
|
self.sequence = sequence
|
|
self[bytes2str(NUC_SEQUENCE_COLUMN)] = sequence
|
|
|
|
# cpdef str reverse_complement(self) : TODO in C ?
|
|
# pass
|
|
|
|
|
|
cdef class OBI_Nuc_Seq_Stored(OBIView_line) :
|
|
|
|
cpdef set_id(self, str id) :
|
|
self.id = id
|
|
self[bytes2str(ID_COLUMN)] = id
|
|
|
|
cpdef get_id(self) :
|
|
return self.id
|
|
|
|
cpdef set_description(self, str description) :
|
|
self.description = description
|
|
self[bytes2str(DESCRIPTION_COLUMN)] = description
|
|
|
|
cpdef get_description(self) :
|
|
return self.description
|
|
|
|
cpdef set_sequence(self, str sequence) :
|
|
self.sequence = sequence
|
|
self[bytes2str(NUC_SEQUENCE_COLUMN)] = sequence
|
|
|
|
cpdef get_sequence(self) :
|
|
return self.sequence
|
|
|
|
def __str__(self) :
|
|
return self.sequence # or not
|
|
|
|
# cpdef str reverse_complement(self) : TODO in C ?
|
|
# pass
|
|
|
|
# TODO static method to import?
|
|
|