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,
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 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 = NUC_SEQUENCE_COLUMN
associated_column_name_b = 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,
@ -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):

View File

@ -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)