Added tuple columns containing immutable indexed data arrays of any type

This commit is contained in:
Celine Mercier
2017-11-15 13:48:59 +01:00
parent 1684f96b79
commit 9a50803c00
32 changed files with 1097 additions and 284 deletions

View File

@ -28,6 +28,7 @@
#include "obidmscolumn_qual.h"
#include "obidmscolumn_seq.h"
#include "obidmscolumn_str.h"
#include "obidmscolumn_array.h"
#include "obierrno.h"
#include "obidebug.h"
#include "obilittlebigman.h"
@ -1643,7 +1644,7 @@ Obiview_p obi_new_view(OBIDMS_p dms, const char* view_name, Obiview_p view_to_cl
// If there is a new line selection, build it by combining it with the one from the view to clone if there is one
else if (line_selection != NULL)
{
view->line_selection = obi_create_column(view->dms, LINES_COLUMN_NAME, OBI_IDX, 0, 1, NULL, false, NULL, NULL, -1, NULL);
view->line_selection = obi_create_column(view->dms, LINES_COLUMN_NAME, OBI_IDX, 0, 1, NULL, false, false, NULL, NULL, -1, NULL);
if ((view->line_selection) == NULL)
{
obidebug(1, "\nError creating a column corresponding to a line selection");
@ -1795,6 +1796,7 @@ Obiview_p obi_new_view(OBIDMS_p dms, const char* view_name, Obiview_p view_to_cl
0,
0,
NULL,
false,
NULL,
NULL,
-1,
@ -1862,19 +1864,19 @@ Obiview_p obi_new_view_nuc_seqs(OBIDMS_p dms, const char* view_name, Obiview_p v
if (view_to_clone == NULL)
{
// Adding sequence column
if (obi_view_add_column(view, NUC_SEQUENCE_COLUMN, -1, NULL, OBI_SEQ, 0, 1, NULL, NULL, NULL, -1, "Nucleotide sequences", true) < 0) // discuss using same indexer "NUC_SEQ_INDEXER"
if (obi_view_add_column(view, NUC_SEQUENCE_COLUMN, -1, NULL, OBI_SEQ, 0, 1, NULL, false, NULL, NULL, -1, "Nucleotide sequences", true) < 0) // discuss using same indexer "NUC_SEQ_INDEXER"
{
obidebug(1, "Error adding an obligatory column in a nucleotide sequences view");
return NULL;
}
// Adding id column
if (obi_view_add_column(view, ID_COLUMN, -1, NULL, OBI_STR, 0, 1, NULL, NULL, NULL, -1, "Sequence identifiers", true) < 0)
if (obi_view_add_column(view, ID_COLUMN, -1, NULL, OBI_STR, 0, 1, NULL, false, NULL, NULL, -1, "Sequence identifiers", true) < 0)
{
obidebug(1, "Error adding an obligatory column in a nucleotide sequences view");
return NULL;
}
// Adding definition column
if (obi_view_add_column(view, DEFINITION_COLUMN, -1, NULL, OBI_STR, 0, 1, NULL, NULL, NULL, -1, "Definitions", true) < 0)
if (obi_view_add_column(view, DEFINITION_COLUMN, -1, NULL, OBI_STR, 0, 1, NULL, false, NULL, NULL, -1, "Definitions", true) < 0)
{
obidebug(1, "Error adding an obligatory column in a nucleotide sequences view");
return NULL;
@ -1883,7 +1885,7 @@ Obiview_p obi_new_view_nuc_seqs(OBIDMS_p dms, const char* view_name, Obiview_p v
if (quality_column)
{
associated_nuc_column = obi_view_get_column(view, NUC_SEQUENCE_COLUMN);
if (obi_view_add_column(view, QUALITY_COLUMN, -1, NULL, OBI_QUAL, 0, 1, NULL, NULL, (associated_nuc_column->header)->name, (associated_nuc_column->header)->version, "Sequence qualities", true) < 0) // TODO discuss automatic association
if (obi_view_add_column(view, QUALITY_COLUMN, -1, NULL, OBI_QUAL, 0, 1, NULL, false, NULL, (associated_nuc_column->header)->name, (associated_nuc_column->header)->version, "Sequence qualities", true) < 0) // TODO discuss automatic association
{
obidebug(1, "Error adding an obligatory column in a nucleotide sequences view");
return NULL;
@ -2211,6 +2213,7 @@ int obi_view_add_column(Obiview_p view,
index_t nb_lines,
index_t nb_elements_per_line,
char* elements_names,
bool tuples,
const char* indexer_name,
const char* associated_column_name,
obiversion_t associated_column_version,
@ -2289,7 +2292,7 @@ int obi_view_add_column(Obiview_p view,
// Open or create the column
if (create)
{ // Create column
column = obi_create_column(view->dms, column_name, data_type, nb_lines, nb_elements_per_line, elements_names, false, indexer_name, associated_column_name, associated_column_version, comments);
column = obi_create_column(view->dms, column_name, data_type, nb_lines, nb_elements_per_line, elements_names, false, tuples, indexer_name, associated_column_name, associated_column_version, comments);
if (column == NULL)
{
obidebug(1, "\nError creating a column to add to a view");
@ -2796,7 +2799,7 @@ int obi_create_auto_count_column(Obiview_p view)
return -1;
}
if (obi_view_add_column(view, COUNT_COLUMN, -1, NULL, OBI_INT, 0, 1, NULL, NULL, NULL, -1, "Sequence counts", true) < 0)
if (obi_view_add_column(view, COUNT_COLUMN, -1, NULL, OBI_INT, 0, 1, NULL, false, NULL, NULL, -1, "Sequence counts", true) < 0)
{
obidebug(1, "Error adding an automatic count column in a view");
return -1;
@ -2848,7 +2851,7 @@ int obi_create_auto_id_column(Obiview_p view, const char* prefix)
}
// Create the new ID column
if (obi_view_add_column(view, ID_COLUMN, -1, NULL, OBI_STR, 0, 1, NULL, NULL, NULL, -1, "Sequence identifiers", true) < 0)
if (obi_view_add_column(view, ID_COLUMN, -1, NULL, OBI_STR, 0, 1, NULL, false, NULL, NULL, -1, "Sequence identifiers", true) < 0)
{
obidebug(1, "Error adding an automatic ID column in a view");
return -1;
@ -3623,3 +3626,42 @@ index_t obi_get_index_with_elt_name_and_col_name_in_view(Obiview_p view, const c
/****************************************/
/*********** FOR ARRAY COLUMNS ***********/
int obi_set_array_with_col_p_in_view(Obiview_p view, OBIDMS_column_p column, index_t line_nb, const void* value, uint8_t elt_size, int32_t value_length)
{
if (prepare_to_set_value_in_column(view, &column, &line_nb) < 0)
return -1;
return obi_column_set_array(column, line_nb, value, elt_size, value_length);
}
const void* obi_get_array_with_col_p_in_view(Obiview_p view, OBIDMS_column_p column, index_t line_nb, int32_t* value_length_p)
{
if (prepare_to_get_value_from_column(view, &line_nb) < 0)
return OBITuple_NA;
return obi_column_get_array(column, line_nb, value_length_p);
}
int obi_set_array_with_col_name_in_view(Obiview_p view, const char* column_name, index_t line_nb, const void* value, uint8_t elt_size, int32_t value_length)
{
OBIDMS_column_p column_p;
column_p = obi_view_get_column(view, column_name);
if (column_p == NULL)
return -1;
return obi_set_array_with_col_p_in_view(view, column_p, line_nb, value, elt_size, value_length);
}
const void* obi_get_array_with_col_name_in_view(Obiview_p view, const char* column_name, index_t line_nb, int32_t* value_length_p)
{
OBIDMS_column_p column_p;
column_p = obi_view_get_column(view, column_name);
if (column_p == NULL)
return OBITuple_NA;
return obi_get_array_with_col_p_in_view(view, column_p, line_nb, value_length_p);
}
/****************************************/