Goes with c2af955b
: forgotten files for NUC_SEQS views
This commit is contained in:
0
python/obitools3/dms/view/typed_view/__init__.py
Normal file
0
python/obitools3/dms/view/typed_view/__init__.py
Normal file
8
python/obitools3/dms/view/typed_view/view_NUC_SEQS.pxd
Normal file
8
python/obitools3/dms/view/typed_view/view_NUC_SEQS.pxd
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#cython: language_level=3
|
||||||
|
|
||||||
|
|
||||||
|
from ..view cimport View
|
||||||
|
|
||||||
|
|
||||||
|
cdef class View_NUC_SEQS(View):
|
||||||
|
pass
|
76
python/obitools3/dms/view/typed_view/view_NUC_SEQS.pyx
Normal file
76
python/obitools3/dms/view/typed_view/view_NUC_SEQS.pyx
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
#cython: language_level=3
|
||||||
|
|
||||||
|
from obitools3.dms.capi.obiview cimport obi_new_view_nuc_seqs, \
|
||||||
|
obi_new_view_nuc_seqs_cloned_from_name, \
|
||||||
|
VIEW_TYPE_NUC_SEQS
|
||||||
|
|
||||||
|
from ..view cimport register_view_class
|
||||||
|
|
||||||
|
from obitools3.dms.obiseq cimport Nuc_Seq, Nuc_Seq_Stored
|
||||||
|
|
||||||
|
from obitools3.dms.dms cimport DMS
|
||||||
|
|
||||||
|
from obitools3.dms.capi.obitypes cimport index_t
|
||||||
|
|
||||||
|
from obitools3.utils cimport tobytes, bytes2str
|
||||||
|
|
||||||
|
from obitools3.dms.capi.obidms cimport OBIDMS_p
|
||||||
|
|
||||||
|
from obitools3.dms.object cimport OBIWrapper
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
cdef class View_NUC_SEQS(View):
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def new(DMS dms,
|
||||||
|
object view_name,
|
||||||
|
object comments=None,
|
||||||
|
bint quality=False):
|
||||||
|
|
||||||
|
cdef bytes view_name_b = tobytes(view_name)
|
||||||
|
cdef bytes comments_b
|
||||||
|
cdef str message
|
||||||
|
cdef void* pointer
|
||||||
|
|
||||||
|
cdef View_NUC_SEQS view
|
||||||
|
|
||||||
|
if comments is not None:
|
||||||
|
comments_b = tobytes(comments)
|
||||||
|
else:
|
||||||
|
comments_b = b''
|
||||||
|
|
||||||
|
pointer = <void*>obi_new_view_nuc_seqs(<OBIDMS_p>dms._pointer,
|
||||||
|
view_name_b,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
comments_b,
|
||||||
|
quality)
|
||||||
|
|
||||||
|
if pointer == NULL :
|
||||||
|
message = "Error : Cannot create view %s" % bytes2str(view_name_b)
|
||||||
|
raise RuntimeError(message)
|
||||||
|
|
||||||
|
view = OBIWrapper.new(View_NUC_SEQS, pointer)
|
||||||
|
view._dms = dms
|
||||||
|
dms.register(view)
|
||||||
|
|
||||||
|
return view
|
||||||
|
|
||||||
|
|
||||||
|
def __getitem__(self, object item) :
|
||||||
|
if type(item) == str :
|
||||||
|
return self.get_column(item) # TODO hyper lent dans la pratique
|
||||||
|
elif type(item) == int :
|
||||||
|
return Nuc_Seq_Stored(self, item)
|
||||||
|
|
||||||
|
|
||||||
|
def __setitem__(self, index_t line_idx, Nuc_Seq sequence_obj) :
|
||||||
|
for key in sequence_obj :
|
||||||
|
self[line_idx][key] = sequence_obj[key]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def register_class() :
|
||||||
|
register_view_class(VIEW_TYPE_NUC_SEQS, View_NUC_SEQS)
|
||||||
|
|
Reference in New Issue
Block a user