Fixed major bug: when setting all the columns of a view to the same
number of lines, columns are now cloned before being enlarged if needed + predicate functions now print error messages if the predicates are not respected
This commit is contained in:
@ -444,7 +444,7 @@ size_t get_platform_view_file_size()
|
|||||||
|
|
||||||
int enlarge_view_file(Obiview_p view, size_t new_size)
|
int enlarge_view_file(Obiview_p view, size_t new_size)
|
||||||
{
|
{
|
||||||
int obiview_file_descriptor;
|
int obiview_file_descriptor;
|
||||||
double multiple;
|
double multiple;
|
||||||
size_t rounded_new_size;
|
size_t rounded_new_size;
|
||||||
|
|
||||||
@ -655,14 +655,31 @@ int update_column_refs_and_dict(Obiview_p view)
|
|||||||
|
|
||||||
int update_lines(Obiview_p view, index_t line_count)
|
int update_lines(Obiview_p view, index_t line_count)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
// Check that the view is not read-only
|
||||||
|
if (view->read_only)
|
||||||
|
{
|
||||||
|
obi_set_errno(OBIVIEW_ERROR);
|
||||||
|
obidebug(1, "\nError trying to update the line count of all columns in a read-only view");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
for (i=0; i<((view->infos)->column_count); i++)
|
for (i=0; i<((view->infos)->column_count); i++)
|
||||||
{
|
{
|
||||||
while (line_count > (((view->columns)[i])->header)->line_count)
|
while (line_count > (((view->columns)[i])->header)->line_count)
|
||||||
{
|
{ // The column needs to be enlarged
|
||||||
|
// Clone it first if needed
|
||||||
|
if (!(((view->columns)[i])->writable))
|
||||||
|
{
|
||||||
|
if (clone_column_in_view(view, (((view->infos)->column_references)[i]).alias) < 0)
|
||||||
|
{
|
||||||
|
obidebug(1, "\nError cloning a column in a view when updating its line count");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
// Enlarge the column
|
// Enlarge the column
|
||||||
if (obi_enlarge_column((view->columns)[i]) < 0)
|
if (obi_enlarge_column(((view->columns)[i])) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
(((view->columns)[i])->header)->lines_used = line_count;
|
(((view->columns)[i])->header)->lines_used = line_count;
|
||||||
}
|
}
|
||||||
@ -758,6 +775,15 @@ int prepare_to_set_value_in_column(Obiview_p view, OBIDMS_column_p* column_pp, i
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* // If there is a new line selection being created, columns can't be modified // TODO investigate this
|
||||||
|
if (view->new_line_selection != NULL)
|
||||||
|
{
|
||||||
|
obi_set_errno(OBIVIEW_ERROR);
|
||||||
|
obidebug(1, "\nError trying to set a value in a column in a view with a new line selection being created");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
// If there is a line selection associated with the view or if the column
|
// If there is a line selection associated with the view or if the column
|
||||||
// is read-only, all columns or this column respectively must be cloned
|
// is read-only, all columns or this column respectively must be cloned
|
||||||
if ((view->line_selection != NULL) || (!((*column_pp)->writable)))
|
if ((view->line_selection != NULL) || (!((*column_pp)->writable)))
|
||||||
@ -833,7 +859,10 @@ char* view_has_nuc_sequence_column(Obiview_p view)
|
|||||||
if (obi_view_get_column(view, NUC_SEQUENCE_COLUMN) != NULL)
|
if (obi_view_get_column(view, NUC_SEQUENCE_COLUMN) != NULL)
|
||||||
return predicate;
|
return predicate;
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
obidebug(1, "\nError checking the predicate: %s", predicate);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -854,7 +883,10 @@ char* view_has_quality_column(Obiview_p view)
|
|||||||
if (obi_view_get_column(view, QUALITY_COLUMN) != NULL)
|
if (obi_view_get_column(view, QUALITY_COLUMN) != NULL)
|
||||||
return predicate;
|
return predicate;
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
obidebug(1, "\nError checking the predicate: %s", predicate);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -875,10 +907,12 @@ char* view_has_id_column(Obiview_p view)
|
|||||||
if (obi_view_get_column(view, ID_COLUMN) != NULL)
|
if (obi_view_get_column(view, ID_COLUMN) != NULL)
|
||||||
return predicate;
|
return predicate;
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
obidebug(1, "\nError checking the predicate: %s", predicate);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char* view_has_definition_column(Obiview_p view)
|
char* view_has_definition_column(Obiview_p view)
|
||||||
{
|
{
|
||||||
char* predicate;
|
char* predicate;
|
||||||
@ -896,7 +930,10 @@ char* view_has_definition_column(Obiview_p view)
|
|||||||
if (obi_view_get_column(view, DEFINITION_COLUMN) != NULL)
|
if (obi_view_get_column(view, DEFINITION_COLUMN) != NULL)
|
||||||
return predicate;
|
return predicate;
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
obidebug(1, "\nError checking the predicate: %s", predicate);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -923,7 +960,10 @@ char* view_check_quality_matches_seq_column(Obiview_p view) // TODO Print error
|
|||||||
|
|
||||||
qual_column = obi_view_get_column(view, QUALITY_COLUMN);
|
qual_column = obi_view_get_column(view, QUALITY_COLUMN);
|
||||||
if (qual_column == NULL)
|
if (qual_column == NULL)
|
||||||
|
{
|
||||||
|
obidebug(1, "\nError checking the predicate: %s", predicate);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
seq_column = obi_view_get_column(view, ((qual_column->header)->associated_column).column_name);
|
seq_column = obi_view_get_column(view, ((qual_column->header)->associated_column).column_name);
|
||||||
//seq_column = obi_open_column(view->dms, ((qual_column->header)->associated_column).column_name, ((qual_column->header)->associated_column).version);
|
//seq_column = obi_open_column(view->dms, ((qual_column->header)->associated_column).column_name, ((qual_column->header)->associated_column).version);
|
||||||
@ -931,12 +971,18 @@ char* view_check_quality_matches_seq_column(Obiview_p view) // TODO Print error
|
|||||||
// TODO if outside of view, make function that opens a column from a column reference structure?
|
// TODO if outside of view, make function that opens a column from a column reference structure?
|
||||||
|
|
||||||
if (seq_column == NULL)
|
if (seq_column == NULL)
|
||||||
|
{
|
||||||
|
obidebug(1, "\nError checking the predicate: %s", predicate);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
nb_elements_per_line = (qual_column->header)->nb_elements_per_line;
|
nb_elements_per_line = (qual_column->header)->nb_elements_per_line;
|
||||||
// Check that the quality and the sequence columns have the same number of elements per line
|
// Check that the quality and the sequence columns have the same number of elements per line
|
||||||
if (nb_elements_per_line != (seq_column->header)->nb_elements_per_line)
|
if (nb_elements_per_line != (seq_column->header)->nb_elements_per_line)
|
||||||
|
{
|
||||||
|
obidebug(1, "\nError checking the predicate: %s", predicate);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
for (i=0; i < (view->infos)->line_count; i++)
|
for (i=0; i < (view->infos)->line_count; i++)
|
||||||
{
|
{
|
||||||
@ -948,11 +994,17 @@ char* view_check_quality_matches_seq_column(Obiview_p view) // TODO Print error
|
|||||||
{
|
{
|
||||||
// Test that the lengths of the quality and the sequence are equal
|
// Test that the lengths of the quality and the sequence are equal
|
||||||
if (qual_len != (int)strlen(seq))
|
if (qual_len != (int)strlen(seq))
|
||||||
|
{
|
||||||
|
obidebug(1, "\nError checking the predicate: %s", predicate);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Test if one value is NA and not the other
|
// Test if one value is NA and not the other
|
||||||
else if (((qual == OBIQual_int_NA) && (seq != OBISeq_NA)) || ((qual != OBIQual_int_NA) && (seq == OBISeq_NA)))
|
else if (((qual == OBIQual_int_NA) && (seq != OBISeq_NA)) || ((qual != OBIQual_int_NA) && (seq == OBISeq_NA)))
|
||||||
|
{
|
||||||
|
obidebug(1, "\nError checking the predicate: %s", predicate);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1947,7 +1999,10 @@ int obi_save_and_close_view(Obiview_p view)
|
|||||||
{
|
{
|
||||||
predicates = view_check_all_predicates(view);
|
predicates = view_check_all_predicates(view);
|
||||||
if (predicates == NULL)
|
if (predicates == NULL)
|
||||||
|
{
|
||||||
|
obidebug(1, "\nView predicates not respected");
|
||||||
return -1; // TODO reverse view (delete files)
|
return -1; // TODO reverse view (delete files)
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
write_comments_to_view_file(view, predicates);
|
write_comments_to_view_file(view, predicates);
|
||||||
|
Reference in New Issue
Block a user