From 9c9aec255677c6f336895cb5f21db73a595034eb Mon Sep 17 00:00:00 2001 From: Celine Mercier Date: Wed, 8 Aug 2018 19:49:56 +0200 Subject: [PATCH] Cython API: the associated sequence column for a quality column can now be specified at the Python level --- python/obitools3/dms/column/column.pyx | 22 +++++++++---------- .../dms/column/typed_column/qual.pyx | 4 ++++ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/python/obitools3/dms/column/column.pyx b/python/obitools3/dms/column/column.pyx index 8ffc562..2e15201 100644 --- a/python/obitools3/dms/column/column.pyx +++ b/python/obitools3/dms/column/column.pyx @@ -80,6 +80,8 @@ cdef class Column(OBIWrapper) : list elements_names=None, bint tuples=False, bint to_eval=False, + object associated_column_name=b"", + int associated_column_version=-1, object comments=b"", object alias=b""): # TODO indexer_name? @@ -87,8 +89,7 @@ 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 bytes associated_column_name_b = tobytes(associated_column_name) cdef list elements_names_s cdef bytes elements_names_b cdef char* elements_names_p @@ -113,16 +114,13 @@ 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 associated_column_name_b == b"": + 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_b = NUC_SEQUENCE_COLUMN + associated_column_version = view[NUC_SEQUENCE_COLUMN].version if (obi_view_add_column(view = view.pointer(), column_name = column_name_b, @@ -136,7 +134,7 @@ cdef class Column(OBIWrapper) : tuples = tuples, to_eval = to_eval, indexer_name = NULL, - associated_column_name = associated_column_name, + associated_column_name = associated_column_name_b, associated_column_version = associated_column_version, comments = comments_b, create = True)<0): diff --git a/python/obitools3/dms/column/typed_column/qual.pyx b/python/obitools3/dms/column/typed_column/qual.pyx index 3ecfc46..9018cc9 100644 --- a/python/obitools3/dms/column/typed_column/qual.pyx +++ b/python/obitools3/dms/column/typed_column/qual.pyx @@ -38,12 +38,16 @@ cdef class Column_qual(Column_idx): object column_name, index_t nb_elements_per_line=1, object elements_names=None, + object associated_column_name=b"", + int associated_column_version=-1, object comments=b""): return Column.new_column(view, column_name, OBI_QUAL, nb_elements_per_line=nb_elements_per_line, elements_names=elements_names, tuples=False, + associated_column_name=associated_column_name, + associated_column_version=associated_column_name, comments=comments)