From a290e7b08e704a0497b1079197a62ed0ce485505 Mon Sep 17 00:00:00 2001 From: Marcel Martin Date: Thu, 28 Sep 2023 00:07:13 +0200 Subject: [PATCH] Fix: Avoid nam id collisions that reduce accuracy This fixes a regression introduced by commit 91f2223 and brings accuracy to the expected levels (higher than v0.11.0 due to tuned parameters). See #345 --- src/nam.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/nam.cpp b/src/nam.cpp index 790ee610..38623992 100644 --- a/src/nam.cpp +++ b/src/nam.cpp @@ -35,7 +35,6 @@ void merge_hits_into_nams( bool is_revcomp, std::vector& nams // inout ) { - int nam_id_cnt = 0; for (auto &[ref_id, hits] : hits_per_ref) { if (sort) { std::sort(hits.begin(), hits.end(), [](const Hit& a, const Hit& b) -> bool { @@ -81,8 +80,6 @@ void merge_hits_into_nams( // Add the hit to open matches if (!is_added){ Nam n; - n.nam_id = nam_id_cnt; - nam_id_cnt ++; n.query_start = h.query_start; n.query_end = h.query_end; n.ref_start = h.ref_start; @@ -110,6 +107,7 @@ void merge_hits_into_nams( n_score = ( 2*n_min_span - n_max_span) > 0 ? (float) (n.n_hits * ( 2*n_min_span - n_max_span) ) : 1; // this is really just n_hits * ( min_span - (offset_in_span) ) ); // n_score = n.n_hits * n.query_span(); n.score = n_score; + n.nam_id = nams.size(); nams.push_back(n); } } @@ -130,6 +128,7 @@ void merge_hits_into_nams( n_score = ( 2*n_min_span - n_max_span) > 0 ? (float) (n.n_hits * ( 2*n_min_span - n_max_span) ) : 1; // this is really just n_hits * ( min_span - (offset_in_span) ) ); // n_score = n.n_hits * n.query_span(); n.score = n_score; + n.nam_id = nams.size(); nams.push_back(n); } }