Finally found the bug that everyone is reporting on GS. Iterators on PriorityQueues aren't guaranteed to return elements in sorted order (a pretty stupid contract) - so we were passing items to the constrained writer out of order. Just do a Collections.sort instead (1 line of code). Happy father's day!

git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@5476 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
ebanks 2011-03-18 21:28:19 +00:00
parent 9568c84af9
commit 1c95208e26
3 changed files with 6 additions and 22 deletions

View File

@ -402,9 +402,10 @@ public class IndelRealigner extends ReadWalker<Integer, Integer> {
}
private void emitReadLists() {
// pre-merge lists with priority queue for constrained SAMFileWriter
// pre-merge lists to sort them in preparation for constrained SAMFileWriter
readsNotToClean.addAll(readsToClean.getReads());
for ( SAMRecord read : ReadUtils.coordinateSortReads(readsNotToClean) )
ReadUtils.coordinateSortReads(readsNotToClean);
for ( SAMRecord read : readsNotToClean )
emit(read);
readsToClean.clear();
readsNotToClean.clear();

View File

@ -216,17 +216,9 @@ public class ReadUtils {
* @param reads
* @return
*/
public final static List<SAMRecord> coordinateSortReads(Collection<SAMRecord> reads) {
final int n = reads.size();
if ( n > 0 ) {
final SAMRecordComparator comparer = new SAMRecordCoordinateComparator();
final Queue<SAMRecord> sorted = new PriorityQueue<SAMRecord>(reads.size(), comparer);
sorted.addAll(reads);
return new ArrayList<SAMRecord>(sorted);
} else {
return Collections.emptyList();
}
public final static void coordinateSortReads(List<SAMRecord> reads) {
final SAMRecordComparator comparer = new SAMRecordCoordinateComparator();
Collections.sort(reads, comparer);
}
public final static int getFirstInsertionOffset(SAMRecord read) {

View File

@ -117,13 +117,4 @@ public class IndelRealignerIntegrationTest extends WalkerTest {
executeTest(String.format("realigner [%s]", entry.getKey()), spec);
}
}
@Test(expectedExceptions = { RuntimeException.class }, dependsOnMethods = { "testMaxReadsInMemory" })
public void testFailure() {
WalkerTest.WalkerTestSpec spec = new WalkerTest.WalkerTestSpec(
baseCommand + "--maxReadsInMemory 1000",
1,
Arrays.asList(""));
executeTest("realigner failure", spec);
}
}