Skip to content

Commit b3a76d7

Browse files
committed
Fix bug for single-end reads that sometimes put junk in output file after a duplicate.
1 parent 3be2293 commit b3a76d7

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Determine the samblaster build number
2-
BUILDNUM = 17
2+
BUILDNUM = 18
33
# INTERNAL = TRUE
44

55
OBJS = samblaster.o sbhash.o

samblaster.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ void unsplitSplitLine(splitLine_t * line)
247247
line->fields[i][-1] = '\t';
248248
}
249249
// Now put the newline back in.
250-
line->buffer[line->bufLen-1] = '\n';
250+
line->buffer[line->bufLen-1] = '\n';
251251
// Mark as no longer split.
252252
line->split = false;
253253
}
@@ -274,8 +274,9 @@ void changeFieldSplitLine(splitLine_t * line, int fnum, char * newValue)
274274
{
275275
fatalError("samblaster: New buffer length exceeds maximum while changing field value.\n");
276276
}
277-
// Make the right sized hole for the copy.
278-
int distance = 1 + line->bufLen - (fp - line->buffer) - move;
277+
// Calculate the size of the tail that is still needed.
278+
int distance = 1 + line->bufLen - (fp - line->buffer) - oldLen;
279+
// Do the copy.
279280
memmove(fp+newLen, fp+oldLen, distance);
280281
// Correct the total length of the buffer.
281282
line->bufLen += move;

0 commit comments

Comments
 (0)