From ab6a8151845dfd01321bd3d9866f33483c5a2141 Mon Sep 17 00:00:00 2001 From: ebanks Date: Mon, 21 Mar 2011 20:30:24 +0000 Subject: [PATCH] As per the comments in the commit itself: when reads get mapped to the junction of two chromosomes (e.g. MT since it is actually circular DNA), their unmapped bit is set, but they are given legitimate coordinates. The Picard code will come in and move the read all the way back to its mate - which can be arbitrarily far away and cause records to be written out of order. Very evil. git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@5484 348d0f76-0448-11de-a6fe-93d51630548a --- .../walkers/indels/ConstrainedMateFixingManager.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/indels/ConstrainedMateFixingManager.java b/java/src/org/broadinstitute/sting/gatk/walkers/indels/ConstrainedMateFixingManager.java index 0c43a063f..da3a5b185 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/indels/ConstrainedMateFixingManager.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/indels/ConstrainedMateFixingManager.java @@ -197,13 +197,19 @@ public class ConstrainedMateFixingManager { if ( newRead.getReadPairedFlag() ) { SAMRecord mate = forMateMatching.get(newRead.getReadName()); if ( mate != null ) { - // Frustratingly, Picard's setMateInfo() method unaligns (by setting the reference contig + // 1. Frustratingly, Picard's setMateInfo() method unaligns (by setting the reference contig // to '*') read pairs when both of their flags have the unmapped bit set. This is problematic // when trying to emit reads in coordinate order because all of a sudden we have reads in the // middle of the bam file that now belong at the end - and any mapped reads that get emitted // after them trigger an exception in the writer. For our purposes, because we shouldn't be // moving read pairs when they are both unmapped anyways, we'll just not run fix mates on them. - boolean doNotFixMates = newRead.getReadUnmappedFlag() && mate.getReadUnmappedFlag(); + // 2. Furthermore, when reads get mapped to the junction of two chromosomes (e.g. MT since it + // is actually circular DNA), their unmapped bit is set, but they are given legitimate coordinates. + // The Picard code will come in and move the read all the way back to its mate (which can be + // arbitrarily far away). However, we do still want to move legitimately unmapped reads whose + // mates are mapped, so the compromise will be that if the mate is still in the queue then we'll + // move the read and otherwise we won't. + boolean doNotFixMates = newRead.getReadUnmappedFlag() && (mate.getReadUnmappedFlag() || !waitingReads.contains(mate)); if ( !doNotFixMates ) { boolean reQueueMate = mate.getReadUnmappedFlag() && ! newRead.getReadUnmappedFlag();