From eae1b739458dd0ff91a79cd6ef0e28440efcc5b6 Mon Sep 17 00:00:00 2001 From: asivache Date: Fri, 15 Jan 2010 17:41:23 +0000 Subject: [PATCH] Fixed a bug in left-adjusting the indels introduced in previous commit :-/ git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@2591 348d0f76-0448-11de-a6fe-93d51630548a --- .../walkers/indels/IntervalCleanerWalker.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/indels/IntervalCleanerWalker.java b/java/src/org/broadinstitute/sting/gatk/walkers/indels/IntervalCleanerWalker.java index 9d36f3683..96159f9b6 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/indels/IntervalCleanerWalker.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/indels/IntervalCleanerWalker.java @@ -243,8 +243,9 @@ public class IntervalCleanerWalker extends LocusWindowWalker int numBlocks = AlignmentUtils.getNumAlignmentBlocks(read); if ( numBlocks == 2 ) { Cigar newCigar = indelRealignment(read.getCigar(), reference, read.getReadString(), read.getAlignmentStart()-(int)leftmostIndex, 0); - if ( aRead.setCigar(newCigar) ) + if ( aRead.setCigar(newCigar) ) { leftMovedIndels.add(aRead); + } } int mismatchScore = mismatchQualitySumIgnoreCigar(aRead, reference, read.getAlignmentStart()-(int)leftmostIndex); @@ -258,7 +259,9 @@ public class IntervalCleanerWalker extends LocusWindowWalker aRead.setMismatchScoreToReference(mismatchScore); // if it has an indel, let's see if that's the best consensus if ( numBlocks == 2 ) { - altConsenses.add(createAlternateConsensus(aRead.getAlignmentStart() - (int)leftmostIndex, aRead.getCigar(), reference, aRead.getRead().getReadBases())); + Consensus c = createAlternateConsensus(aRead.getAlignmentStart() - (int)leftmostIndex, aRead.getCigar(), reference, aRead.getRead().getReadBases()); + if ( c==null) {} //System.out.println("ERROR: Failed to create alt consensus for read "+aRead.getRead().getReadName()); + else altConsenses.add(c); } else { // if ( debugOn ) System.out.println("Going to test..."); @@ -785,13 +788,15 @@ public class IntervalCleanerWalker extends LocusWindowWalker // The following if() statement: this should've never happened, unless the alignment is really screwed up. // A real life example: // - // ref: TTTTTTTTTTTTTTTTTT***TTTTTACTTATAGAAGAAAT... - // read: GTCTTTTTTTTTTTTTTTTTTTTTTTACTTATAGAAGAAAT... + // ref: TTTTTTTTTTTTTTTTTT******TTTTTACTTATAGAAGAAAT... + // read: GTCTTTTTTTTTTTTTTTTTTTTTTTACTTATAGAAGAAAT... // - // i.e. the alignment claims 6 T's to be inserted. The alignment is clearly incorrect since we could + // i.e. the alignment claims 6 T's to be inserted. The alignment is clearly malformed/non-conforming since we could // have just 3 T's inserted (so that the beginning of the read maps right onto the beginning of the // reference fragment shown): that would leave us with same 2 mismatches at the beginning of the read - // (G and C) but lower gap penalty. While it is unclear how the alignment shown above could be generated + // (G and C) but lower gap penalty. Note that this has nothing to do with the alignment being "right" or "wrong" + // with respect to where on the DNA the read actually came from. It is the assumptions of *how* the alignments are + // built and represented that are broken here. While it is unclear how the alignment shown above could be generated // in the first place, we are not in the business of fixing incorrect alignments in this method; all we are // trying to do is to left-adjust correct ones. So if something like that happens, we refuse to change the cigar // and bail out. @@ -825,8 +830,6 @@ public class IntervalCleanerWalker extends LocusWindowWalker } } - newCigar.add(new CigarElement(cigar.getCigarElement(2).getLength()+difference, CigarOperator.M)); - //logger.debug("Realigning indel: " + AlignmentUtils.cigarToString(cigar) + " to " + AlignmentUtils.cigarToString(newCigar)); cigar = newCigar;