Cython API to add an OBI_QUAL column after creating a view
This commit is contained in:
@ -6,8 +6,9 @@ __OBIDMS_COLUMN_CLASS__ = {}
|
||||
|
||||
from ..capi.obitypes cimport name_data_type, \
|
||||
obitype_t, \
|
||||
obiversion_t
|
||||
|
||||
obiversion_t, \
|
||||
OBI_QUAL
|
||||
|
||||
from ..capi.obidms cimport obi_import_column
|
||||
|
||||
from ..capi.obidmscolumn cimport OBIDMS_column_header_p, \
|
||||
@ -18,7 +19,8 @@ from ..capi.obiutils cimport obi_format_date
|
||||
|
||||
from ..capi.obiview cimport obi_view_add_column, \
|
||||
obi_view_get_pointer_on_column_in_view, \
|
||||
Obiview_p
|
||||
Obiview_p, \
|
||||
NUC_SEQUENCE_COLUMN
|
||||
|
||||
from ..object cimport OBIDeactivatedInstanceError
|
||||
|
||||
@ -85,6 +87,8 @@ cdef class Column(OBIWrapper) :
|
||||
cdef bytes column_name_b = tobytes(column_name)
|
||||
cdef bytes alias_b = tobytes(alias)
|
||||
cdef bytes comments_b = tobytes(comments)
|
||||
cdef char* associated_column_name
|
||||
cdef int associated_column_version
|
||||
cdef list elements_names_s
|
||||
cdef bytes elements_names_b
|
||||
cdef char* elements_names_p
|
||||
@ -109,6 +113,17 @@ cdef class Column(OBIWrapper) :
|
||||
else:
|
||||
elements_names_p = NULL
|
||||
|
||||
# TODO discuss
|
||||
if data_type == OBI_QUAL:
|
||||
if NUC_SEQUENCE_COLUMN not in view:
|
||||
raise RuntimeError("Cannot create column %s in view %s: trying to create quality column but no NUC_SEQ column to associate it with in the view" % (bytes2str(column_name_b),
|
||||
bytes2str(view.name)))
|
||||
associated_column_name = NUC_SEQUENCE_COLUMN
|
||||
associated_column_version = view[NUC_SEQUENCE_COLUMN].version
|
||||
else:
|
||||
associated_column_name = NULL
|
||||
associated_column_version = -1
|
||||
|
||||
if (obi_view_add_column(view = view.pointer(),
|
||||
column_name = column_name_b,
|
||||
version_number = -1,
|
||||
@ -121,8 +136,8 @@ cdef class Column(OBIWrapper) :
|
||||
tuples = tuples,
|
||||
to_eval = to_eval,
|
||||
indexer_name = NULL,
|
||||
associated_column_name = NULL,
|
||||
associated_column_version = -1,
|
||||
associated_column_name = associated_column_name,
|
||||
associated_column_version = associated_column_version,
|
||||
comments = comments_b,
|
||||
create = True)<0):
|
||||
raise RuntimeError("Cannot create column %s in view %s" % (bytes2str(column_name_b),
|
||||
|
Reference in New Issue
Block a user