Better *Seq* classes but still need work
This commit is contained in:
@ -3,9 +3,15 @@
|
||||
from obitools3.utils cimport bytes2str, str2bytes
|
||||
|
||||
from .capi.obiview cimport NUC_SEQUENCE_COLUMN, \
|
||||
ID_COLUMN, \
|
||||
DEFINITION_COLUMN, \
|
||||
QUALITY_COLUMN
|
||||
ID_COLUMN, \
|
||||
DEFINITION_COLUMN, \
|
||||
QUALITY_COLUMN
|
||||
|
||||
|
||||
NUC_SEQUENCE_COLUMN_str = bytes2str(NUC_SEQUENCE_COLUMN)
|
||||
ID_COLUMN_str = bytes2str(ID_COLUMN)
|
||||
DEFINITION_COLUMN_str = bytes2str(DEFINITION_COLUMN)
|
||||
QUALITY_COLUMN_str = bytes2str(QUALITY_COLUMN)
|
||||
|
||||
|
||||
cdef class Seq(dict) :
|
||||
@ -23,7 +29,7 @@ cdef class Seq(dict) :
|
||||
@id.setter
|
||||
def id(self, str new_id): # @ReservedAssignment @DuplicatedSignature
|
||||
self._id = new_id
|
||||
self[bytes2str(ID_COLUMN)] = new_id
|
||||
self[ID_COLUMN] = new_id
|
||||
|
||||
# sequence property getter and setter
|
||||
@property
|
||||
@ -43,7 +49,7 @@ cdef class Seq(dict) :
|
||||
@definition.setter
|
||||
def definition(self, object new_definition): # @DuplicatedSignature
|
||||
self._definition = new_definition
|
||||
self[bytes2str(DEFINITION_COLUMN)] = new_definition
|
||||
self[DEFINITION_COLUMN_str] = new_definition
|
||||
|
||||
|
||||
cdef class Nuc_Seq(Seq) :
|
||||
@ -56,7 +62,7 @@ cdef class Nuc_Seq(Seq) :
|
||||
@seq.setter
|
||||
def seq(self, object new_seq): # @DuplicatedSignature
|
||||
self._seq = new_seq
|
||||
self[bytes2str(NUC_SEQUENCE_COLUMN)] = new_seq
|
||||
self[NUC_SEQUENCE_COLUMN_str] = new_seq
|
||||
|
||||
# sequence quality property getter and setter
|
||||
@property
|
||||
@ -66,57 +72,55 @@ cdef class Nuc_Seq(Seq) :
|
||||
@quality.setter
|
||||
def quality(self, object new_quality): # @DuplicatedSignature
|
||||
self._quality = new_quality
|
||||
self[bytes2str(QUALITY_COLUMN)] = new_quality
|
||||
self[QUALITY_COLUMN_str] = new_quality
|
||||
|
||||
# cpdef str reverse_complement(self) : TODO in C ?
|
||||
# pass
|
||||
|
||||
|
||||
cdef class Nuc_Seq_Stored(Line) :
|
||||
|
||||
# TODO store the str version of column name macros?
|
||||
|
||||
# sequence id property getter and setter
|
||||
@property
|
||||
def id(self): # @ReservedAssignment @DuplicatedSignature
|
||||
return self[bytes2str(ID_COLUMN)]
|
||||
return self[ID_COLUMN_str]
|
||||
|
||||
@id.setter
|
||||
def id(self, str new_id): # @ReservedAssignment @DuplicatedSignature
|
||||
self[bytes2str(ID_COLUMN)] = new_id
|
||||
self[ID_COLUMN_str] = new_id
|
||||
|
||||
# sequence definition property getter and setter
|
||||
@property
|
||||
def definition(self):
|
||||
return self[bytes2str(DEFINITION_COLUMN)]
|
||||
return self[DEFINITION_COLUMN_str]
|
||||
|
||||
@definition.setter
|
||||
def definition(self, str new_def): # @DuplicatedSignature
|
||||
self[bytes2str(DEFINITION_COLUMN)] = new_def
|
||||
self[DEFINITION_COLUMN_str] = new_def
|
||||
|
||||
# nuc_seq property getter and setter
|
||||
@property
|
||||
def nuc_seq(self):
|
||||
return self[bytes2str(NUC_SEQUENCE_COLUMN)]
|
||||
return self[NUC_SEQUENCE_COLUMN_str]
|
||||
|
||||
@nuc_seq.setter
|
||||
def nuc_seq(self, object new_seq): # @DuplicatedSignature
|
||||
self[bytes2str(NUC_SEQUENCE_COLUMN)] = new_seq
|
||||
self[NUC_SEQUENCE_COLUMN_str] = new_seq
|
||||
|
||||
# quality property getter and setter
|
||||
@property
|
||||
def quality(self):
|
||||
return self[bytes2str(QUALITY_COLUMN)]
|
||||
return self[QUALITY_COLUMN_str]
|
||||
|
||||
@quality.setter
|
||||
def quality(self, object new_qual): # @DuplicatedSignature
|
||||
if (type(new_qual) == list) or (new_qual is None) : # TODO check that quality column exists
|
||||
self[bytes2str(QUALITY_COLUMN)] = new_qual
|
||||
self[QUALITY_COLUMN_str] = new_qual
|
||||
else : # Quality is in str form
|
||||
(((self._view).columns)[bytes2str(QUALITY_COLUMN)]).set_str_line(self._index, new_qual)
|
||||
self._view.get_column(QUALITY_COLUMN_str).set_str_line(self._index, new_qual)
|
||||
|
||||
cpdef object get_str_quality(self) : # TODO not ideal. Make quality_int and quality_str properties
|
||||
return ((self._view).columns)[bytes2str(QUALITY_COLUMN)].get_str_line(self._index)
|
||||
return self._view.get_column(QUALITY_COLUMN_str).get_str_line(self._index)
|
||||
|
||||
# cpdef str reverse_complement(self) : TODO in C ?
|
||||
# pass
|
||||
|
Reference in New Issue
Block a user