Cython API: the associated sequence column for a quality column can now

be specified at the Python level
This commit is contained in:
Celine Mercier
2018-08-08 19:49:56 +02:00
parent 303648bd47
commit 9c9aec2556
2 changed files with 14 additions and 12 deletions

View File

@ -80,6 +80,8 @@ cdef class Column(OBIWrapper) :
list elements_names=None, list elements_names=None,
bint tuples=False, bint tuples=False,
bint to_eval=False, bint to_eval=False,
object associated_column_name=b"",
int associated_column_version=-1,
object comments=b"", object comments=b"",
object alias=b""): object alias=b""):
# TODO indexer_name? # TODO indexer_name?
@ -87,8 +89,7 @@ cdef class Column(OBIWrapper) :
cdef bytes column_name_b = tobytes(column_name) cdef bytes column_name_b = tobytes(column_name)
cdef bytes alias_b = tobytes(alias) cdef bytes alias_b = tobytes(alias)
cdef bytes comments_b = tobytes(comments) cdef bytes comments_b = tobytes(comments)
cdef char* associated_column_name cdef bytes associated_column_name_b = tobytes(associated_column_name)
cdef int associated_column_version
cdef list elements_names_s cdef list elements_names_s
cdef bytes elements_names_b cdef bytes elements_names_b
cdef char* elements_names_p cdef char* elements_names_p
@ -113,16 +114,13 @@ cdef class Column(OBIWrapper) :
else: else:
elements_names_p = NULL elements_names_p = NULL
# TODO discuss
if data_type == OBI_QUAL: if data_type == OBI_QUAL:
if NUC_SEQUENCE_COLUMN not in view: if associated_column_name_b == b"":
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), if NUC_SEQUENCE_COLUMN not in view:
bytes2str(view.name))) 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),
associated_column_name = NUC_SEQUENCE_COLUMN bytes2str(view.name)))
associated_column_version = view[NUC_SEQUENCE_COLUMN].version associated_column_name_b = NUC_SEQUENCE_COLUMN
else: associated_column_version = view[NUC_SEQUENCE_COLUMN].version
associated_column_name = NULL
associated_column_version = -1
if (obi_view_add_column(view = view.pointer(), if (obi_view_add_column(view = view.pointer(),
column_name = column_name_b, column_name = column_name_b,
@ -136,7 +134,7 @@ cdef class Column(OBIWrapper) :
tuples = tuples, tuples = tuples,
to_eval = to_eval, to_eval = to_eval,
indexer_name = NULL, indexer_name = NULL,
associated_column_name = associated_column_name, associated_column_name = associated_column_name_b,
associated_column_version = associated_column_version, associated_column_version = associated_column_version,
comments = comments_b, comments = comments_b,
create = True)<0): create = True)<0):

View File

@ -38,12 +38,16 @@ cdef class Column_qual(Column_idx):
object column_name, object column_name,
index_t nb_elements_per_line=1, index_t nb_elements_per_line=1,
object elements_names=None, object elements_names=None,
object associated_column_name=b"",
int associated_column_version=-1,
object comments=b""): object comments=b""):
return Column.new_column(view, column_name, OBI_QUAL, return Column.new_column(view, column_name, OBI_QUAL,
nb_elements_per_line=nb_elements_per_line, nb_elements_per_line=nb_elements_per_line,
elements_names=elements_names, elements_names=elements_names,
tuples=False, tuples=False,
associated_column_name=associated_column_name,
associated_column_version=associated_column_name,
comments=comments) comments=comments)