From 2b70735e256a35e7f697d96dc80e1f40bcf50ae4 Mon Sep 17 00:00:00 2001 From: "Brian P. Walenz" Date: Mon, 28 Jun 2021 14:08:58 -0400 Subject: [PATCH] Fix _rare_ crash when placing reads in abnormally short tigs. --- src/bogart/AS_BAT_PlaceReadUsingOverlaps.C | 2 +- src/bogart/AS_BAT_Unitig.C | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/bogart/AS_BAT_PlaceReadUsingOverlaps.C b/src/bogart/AS_BAT_PlaceReadUsingOverlaps.C index d29f703c3..1ed53783e 100644 --- a/src/bogart/AS_BAT_PlaceReadUsingOverlaps.C +++ b/src/bogart/AS_BAT_PlaceReadUsingOverlaps.C @@ -124,7 +124,7 @@ placeRead_fromOverlaps(TigVector &tigs, if (ovl[oo].b_hang > 0) bposlen -= ovl[oo].b_hang; - if (bposlen < 0) { + if (bposlen <= 0) { writeLog("WARNING: read %u overlap to read %u in tig %u at %d-%d - hangs %d %d to large for placement, ignoring overlap\n", ovl[oo].a_iid, ovl[oo].b_iid, diff --git a/src/bogart/AS_BAT_Unitig.C b/src/bogart/AS_BAT_Unitig.C index 1f22c0b7a..fe4401667 100644 --- a/src/bogart/AS_BAT_Unitig.C +++ b/src/bogart/AS_BAT_Unitig.C @@ -390,9 +390,10 @@ Unitig::overlapConsistentWithTig(double deviations, int32 nBelow = 0; int32 nAbove = 0; - assert(bgn < end); - assert(bgn < getLength()); - assert(end <= getLength()); + if ((bgn >= end) || // If the read placement is garbage, + (bgn >= getLength()) || // the placement is not consistent! + (end > getLength())) // (used to just assert on these, + return(1.0); // and they almost never occur) // If this is a singleton tig - we should only be here when finding graph edges to repeats - // we've got nothing to go on, so default to 'consistent'.