More explicit predicate error when checking that sequences and qualities

match
This commit is contained in:
Celine Mercier
2018-08-08 19:51:05 +02:00
parent 080a97cccf
commit 3fcf29a76f

View File

@ -15,6 +15,8 @@
#include <stdbool.h> #include <stdbool.h>
#include <fcntl.h> #include <fcntl.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <inttypes.h>
#include "obiview.h" #include "obiview.h"
#include "obidms.h" #include "obidms.h"
@ -1381,7 +1383,7 @@ static char* view_check_qual_match_seqs(Obiview_p view)
if (column == NULL) if (column == NULL)
{ {
obi_set_errno(OBIVIEW_ERROR); obi_set_errno(OBIVIEW_ERROR);
obidebug(1, "\nError getting a column to clone from the linked list of column pointers of a view"); obidebug(1, "\nError getting a column to clone from the linked list of column pointers of view %s", (view->infos)->name);
return NULL; return NULL;
} }
@ -1394,7 +1396,7 @@ static char* view_check_qual_match_seqs(Obiview_p view)
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);
if (seq_column == NULL) if (seq_column == NULL)
{ {
obidebug(1, "\nError checking the predicate: The sequences and sequence quality arrays match."); obidebug(1, "\nError checking the predicate for view %s: The sequences and sequence quality arrays match.", (view->infos)->name);
return NULL; return NULL;
} }
@ -1402,7 +1404,7 @@ static char* view_check_qual_match_seqs(Obiview_p view)
// 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: The sequences and sequence quality arrays match."); obidebug(1, "\nError checking the predicate for view %s: The sequences and sequence quality arrays match.", (view->infos)->name);
return NULL; return NULL;
} }
@ -1412,20 +1414,21 @@ static char* view_check_qual_match_seqs(Obiview_p view)
for (k=0; k < nb_elements_per_line; k++) for (k=0; k < nb_elements_per_line; k++)
{ {
qual = obi_get_qual_int_with_elt_idx_and_col_p_in_view(view, qual_column, j, k, &qual_len); qual = obi_get_qual_int_with_elt_idx_and_col_p_in_view(view, qual_column, j, k, &qual_len);
seq = obi_get_seq_with_elt_idx_and_col_p_in_view(view, seq_column, j, k); seq = obi_get_seq_with_elt_idx_and_col_p_in_view(view, seq_column, j, k);
if ((qual != OBIQual_int_NA) && (seq != OBISeq_NA)) if ((qual != OBIQual_int_NA) && (seq != OBISeq_NA))
{ {
// 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: The sequences and sequence quality arrays match."); obidebug(1, "\nError checking the predicate for view %s: The sequences and sequence quality arrays match. \n%d, %s, %d", (view->infos)->name, j, seq, qual_len);
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: The sequences and sequence quality arrays match."); obidebug(1, "\nError checking the predicate for view %s: The sequences and sequence quality arrays match.", (view->infos)->name);
return NULL; return NULL;
} }
} }