From 1a5b499b5c9fbe1b05ad1aa2dea48dfcabb808d5 Mon Sep 17 00:00:00 2001 From: Celine Mercier Date: Tue, 19 Dec 2017 11:06:24 +0100 Subject: [PATCH] Cython API to add an OBI_QUAL column after creating a view --- python/obitools3/dms/column/column.pyx | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/python/obitools3/dms/column/column.pyx b/python/obitools3/dms/column/column.pyx index d867f41..8ffc562 100644 --- a/python/obitools3/dms/column/column.pyx +++ b/python/obitools3/dms/column/column.pyx @@ -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),