Skip to content

Commit

Permalink
Fix crash circularizing teeny-tiny tigs.
Browse files Browse the repository at this point in the history
  • Loading branch information
brianwalenz committed Nov 6, 2020
1 parent 61ade1a commit 4dd74b5
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions src/utgcns/unitigConsensus.C
Original file line number Diff line number Diff line change
Expand Up @@ -1415,20 +1415,19 @@ unitigConsensus::trimCircular(void) {
// Align trimmed-off start to end of tig. EDLIB_MODE_HW allows free gaps
// at the start/end of the second sequence.
{
EdlibAlignResult result;

uint32 aBgn = 0;
uint32 aEnd = keepBgn;
uint32 aLen = aEnd - aBgn;
int32 aBgn = 0;
int32 aEnd = keepBgn;
int32 aLen = aEnd - aBgn;

uint32 bBgn = tailBgn - 222;
uint32 bEnd = tailEnd;
uint32 bLen = bEnd - bBgn;
int32 bBgn = (tailBgn >= 222) ? (tailBgn - 222) : (0);
int32 bEnd = tailEnd;
int32 bLen = bEnd - bBgn;

if (showAlgorithm())
fprintf(stderr, " Test trimmed head %6d-%6d against kept tail %6d-%6d\n",
aBgn, aEnd, bBgn, bEnd);

EdlibAlignResult result;
result = edlibAlign(bases + aBgn, aLen, // Piece of the start we trim off
bases + bBgn, bLen, // Should align into the tail we keep
edlibNewAlignConfig(0.5 * aLen, EDLIB_MODE_HW, EDLIB_TASK_PATH));
Expand All @@ -1445,20 +1444,19 @@ unitigConsensus::trimCircular(void) {

// Align trimmed-off end to start of tig.
{
EdlibAlignResult result;

uint32 aBgn = keepEnd;
uint32 aEnd = length;
uint32 aLen = aEnd - aBgn;
int32 aBgn = keepEnd;
int32 aEnd = length;
int32 aLen = aEnd - aBgn;

uint32 bBgn = headBgn;
uint32 bEnd = headEnd + 222;
uint32 bLen = bEnd - bBgn;
int32 bBgn = headBgn;
int32 bEnd = (headEnd + 222 <= length) ? (headEnd + 222) : (length);
int32 bLen = bEnd - bBgn;

if (showAlgorithm())
fprintf(stderr, " Test trimmed tail %6d-%6d against kept head %6d-%6d\n",
aBgn, aEnd, bBgn, bEnd);

EdlibAlignResult result;
result = edlibAlign(bases + aBgn, aLen, // Piece of the end we trim off
bases + bBgn, bLen, // Should align into the head we keep
edlibNewAlignConfig(0.5 * aLen, EDLIB_MODE_HW, EDLIB_TASK_PATH));
Expand Down

0 comments on commit 4dd74b5

Please sign in to comment.