From 31053591b53c3af4887d6066ef2f3c78aaa415d8 Mon Sep 17 00:00:00 2001 From: Celine Mercier Date: Mon, 19 Nov 2018 11:05:53 +0100 Subject: [PATCH] Fixed 2 bugs when checking qualities matching sequences predicate: now closing and reopening indexers so that they are mapped properly, and fixed memory leak when reading sequences --- src/obiview.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/obiview.c b/src/obiview.c index d50b360..9fea12e 100755 --- a/src/obiview.c +++ b/src/obiview.c @@ -1418,6 +1418,30 @@ static char* view_check_qual_match_seqs(Obiview_p view) return NULL; } + // Close and reopen indexers to remap them properly, because in writable mode they are mostly unmapped + if (obi_close_indexer(qual_column->indexer) < 0) + { + obidebug(1, "\nError closing the quality indexer when checking the predicate for view %s: The sequences and sequence quality arrays match.", (view->infos)->name); + return NULL; + } + qual_column->indexer = obi_open_avl_group(view->dms, (qual_column->header)->indexer_name); + if (qual_column->indexer == NULL) + { + obidebug(1, "\nError reopening the quality indexer when checking the predicate for view %s: The sequences and sequence quality arrays match.", (view->infos)->name); + return NULL; + } + if (obi_close_indexer(seq_column->indexer) < 0) + { + obidebug(1, "\nError closing the sequence indexer when checking the predicate for view %s: The sequences and sequence quality arrays match.", (view->infos)->name); + return NULL; + } + seq_column->indexer = obi_open_avl_group(view->dms, (seq_column->header)->indexer_name); + if (seq_column->indexer == NULL) + { + obidebug(1, "\nError reopening the sequence indexer when checking the predicate for view %s: The sequences and sequence quality arrays match.", (view->infos)->name); + return NULL; + } + 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 if (nb_elements_per_line != (seq_column->header)->nb_elements_per_line) @@ -1432,7 +1456,6 @@ static char* view_check_qual_match_seqs(Obiview_p view) 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); - 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)) { @@ -1449,6 +1472,7 @@ static char* view_check_qual_match_seqs(Obiview_p view) obidebug(1, "\nError checking the predicate for view %s: The sequences and sequence quality arrays match.", (view->infos)->name); return NULL; } + free(seq); } }