From 07c462e36f361ff3049280f6588693c5d45ac887 Mon Sep 17 00:00:00 2001 From: Sam Horsfield <57448593+samhorsfield96@users.noreply.github.com> Date: Tue, 16 Jul 2024 11:09:25 +0100 Subject: [PATCH 1/2] Update indexing.cpp Corrects potential out of range error --- src/indexing.cpp | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/indexing.cpp b/src/indexing.cpp index b903eb4..17291fa 100644 --- a/src/indexing.cpp +++ b/src/indexing.cpp @@ -458,16 +458,18 @@ void calculate_genome_paths(const std::vector& head_kmer_arr, } } - // map to last entry and assign end-contig - auto um_pair = get_um_data(ccdbg, head_kmer_arr, prev_head); - auto& um_data = um_pair.second; - - um_data->set_end_contig(colour_ID, nb_colours); - - // add delimiter between contigs - genome_path += contig_path; - genome_path += ";"; - contig_ID++; + if (prev_head != 0) { + // map to last entry and assign end-contig + auto um_pair = get_um_data(ccdbg, head_kmer_arr, prev_head); + auto& um_data = um_pair.second; + + um_data->set_end_contig(colour_ID, nb_colours); + + // add delimiter between contigs + genome_path += contig_path; + genome_path += ";"; + contig_ID++; + } } } } @@ -585,4 +587,4 @@ NodeColourVector index_graph(std::vector& head_kmer_arr, // return node_colour vector return node_colour_vector; -} \ No newline at end of file +} From 0f0acd39d574ce722f8ee7bb03dcbab84bc7cd30 Mon Sep 17 00:00:00 2001 From: Sam Horsfield <57448593+samhorsfield96@users.noreply.github.com> Date: Wed, 17 Jul 2024 09:19:37 +0100 Subject: [PATCH 2/2] Adds comment for changes --- src/indexing.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/indexing.cpp b/src/indexing.cpp index 17291fa..7aa3ceb 100644 --- a/src/indexing.cpp +++ b/src/indexing.cpp @@ -458,6 +458,8 @@ void calculate_genome_paths(const std::vector& head_kmer_arr, } } + // in case where whole contig removed, do not add to FM index + // otherwise causes out of range error with head_kmer_arr as k-mer not present if (prev_head != 0) { // map to last entry and assign end-contig auto um_pair = get_um_data(ccdbg, head_kmer_arr, prev_head);