Skip to content
This repository has been archived by the owner on Apr 27, 2018. It is now read-only.

Commit

Permalink
1.0beta.20: fix infinite loop in alignment adjustment code
Browse files Browse the repository at this point in the history
  • Loading branch information
bolosky committed Sep 21, 2015
1 parent bf4a24b commit 3b222a2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion SNAPLib/CommandProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Pulled from the main program and expanded to handle daemon mode
#include "Error.h"
#include "Compat.h"

const char *SNAP_VERSION = "1.0beta.19";
const char *SNAP_VERSION = "1.0beta.20";

static void usage()
{
Expand Down
9 changes: 7 additions & 2 deletions SNAPLib/ReadWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,13 @@ SimpleReadWriter::writeReads(
int cumulativeAddFrontClipping = 0;
finalLocations[whichResult] = results[whichResult].location;

unsigned nAdjustments = 0;

while (!format->writeRead(context, &lvc, buffer + used, size - used, &usedBuffer[whichResult], read->getIdLength(), read, results[whichResult].status,
results[whichResult].mapq, finalLocations[whichResult], results[whichResult].direction, (whichResult > 0) || !firstIsPrimary, &addFrontClipping)) {

nAdjustments++;

if (0 == addFrontClipping) {
blewBuffer = true;
break;
Expand All @@ -186,9 +190,10 @@ SimpleReadWriter::writeReads(
: genome->getContigAtLocation(results[whichResult].location);
const Genome::Contig *newContig = results[whichResult].status == NotFound ? NULL
: genome->getContigAtLocation(results[whichResult].location + addFrontClipping);
if (newContig == NULL || newContig != originalContig || finalLocations[whichResult] + addFrontClipping > originalContig->beginningLocation + originalContig->length - genome->getChromosomePadding()) {
if (newContig == NULL || newContig != originalContig || finalLocations[whichResult] + addFrontClipping > originalContig->beginningLocation + originalContig->length - genome->getChromosomePadding() ||
nAdjustments > read->getDataLength()) {
//
// Altering this would push us over a contig boundary. Just give up on the read.
// Altering this would push us over a contig boundary, or we're stuck in a loop. Just give up on the read.
//
results[whichResult].status = NotFound;
results[whichResult].location = InvalidGenomeLocation;
Expand Down

0 comments on commit 3b222a2

Please sign in to comment.