From 1c563e3cc1db2377f9e8bf5ab8450985d466ad07 Mon Sep 17 00:00:00 2001 From: Glenn Hickey Date: Mon, 7 Sep 2020 19:57:43 -0400 Subject: [PATCH] fix bug where column iterator could visit genomes outside target set --- hal2vg.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hal2vg.cpp b/hal2vg.cpp index 66cf212..bb4e987 100644 --- a/hal2vg.cpp +++ b/hal2vg.cpp @@ -432,7 +432,12 @@ void pinch_genome(const Genome* genome, targets.insert(*gi); } } - ColumnIteratorPtr colIt = genome->getColumnIterator(&targets); + ColumnIteratorPtr colIt; + if (!targets.empty()) { + // if there are no targets, then this is probably the last genome + // so all snps were pinched by a previous genome + colIt = genome->getColumnIterator(&targets); + } // avoid thread set lookups const Sequence* topSeq = nullptr; @@ -486,7 +491,7 @@ void pinch_genome(const Genome* genome, first_match = i; } last_match = i; - } else { + } else if (colIt.get() != NULL) { pinch_snp(genome, threads, nameToID, fullNames, topIt, i, colIt, std::toupper(topString[i]), topThread); }