Standardized and improved the API to create new columns, updated the doc

This commit is contained in:
Celine Mercier
2017-07-18 17:34:32 +02:00
parent c88df2e12c
commit 59dd0a8a8c
4 changed files with 47 additions and 39 deletions

View File

@ -1619,7 +1619,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, NULL, NULL, -1, NULL, false);
view->line_selection = obi_create_column(view->dms, LINES_COLUMN_NAME, OBI_IDX, 0, 1, NULL, false, NULL, NULL, -1, NULL);
if ((view->line_selection) == NULL)
{
obidebug(1, "\nError creating a column corresponding to a line selection");
@ -1838,19 +1838,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, NUC_SEQUENCE_COLUMN, OBI_SEQ, 0, 1, NULL, "", NULL, -1, "Nucleotide sequences", true) < 0)
if (obi_view_add_column(view, NUC_SEQUENCE_COLUMN, -1, NULL, OBI_SEQ, 0, 1, NULL, NULL, NULL, -1, "Nucleotide sequences", true) < 0)
{
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, ID_COLUMN, OBI_STR, 0, 1, NULL, "", NULL, -1, "Sequence identifiers", true) < 0)
if (obi_view_add_column(view, ID_COLUMN, -1, NULL, OBI_STR, 0, 1, NULL, 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, DEFINITION_COLUMN, OBI_STR, 0, 1, NULL, "", NULL, -1, "Definitions", true) < 0)
if (obi_view_add_column(view, DEFINITION_COLUMN, -1, NULL, OBI_STR, 0, 1, NULL, NULL, NULL, -1, "Definitions", true) < 0)
{
obidebug(1, "Error adding an obligatory column in a nucleotide sequences view");
return NULL;
@ -1859,7 +1859,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, QUALITY_COLUMN, OBI_QUAL, 0, 1, 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, 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;
@ -2265,7 +2265,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, indexer_name, associated_column_name, associated_column_version, comments, false);
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);
if (column == NULL)
{
obidebug(1, "\nError creating a column to add to a view");
@ -2304,8 +2304,8 @@ int obi_view_add_column(Obiview_p view,
return -1;
}
// If an alias is not defined, it's the original name of the column. // TODO discuss
if (alias == NULL)
// If an alias is not defined, it's the original name of the column.
if ((alias == NULL) || (*alias == '\0'))
alias = column_name;
// Save column alias
@ -2411,6 +2411,12 @@ OBIDMS_column_p obi_view_get_column(Obiview_p view, const char* column_name)
}
OBIDMS_column_p* obi_view_get_pointer_on_column_in_view(Obiview_p view, const char* column_name)
{
return (OBIDMS_column_p*)(ht_get(view->column_dict, column_name));
}
bool obi_view_column_exists(Obiview_p view, const char* column_name)
{
if (obi_view_get_column(view, column_name) == NULL)
@ -2420,12 +2426,6 @@ bool obi_view_column_exists(Obiview_p view, const char* column_name)
}
OBIDMS_column_p* obi_view_get_pointer_on_column_in_view(Obiview_p view, const char* column_name)
{
return (OBIDMS_column_p*)(ht_get(view->column_dict, column_name));
}
int obi_view_create_column_alias(Obiview_p view, const char* current_name, const char* alias)
{
int i;