From 4a7e0427a39fd6a561b321313e1c392040dd0e42 Mon Sep 17 00:00:00 2001 From: Eric Banks Date: Wed, 19 Dec 2012 11:47:16 -0500 Subject: [PATCH] Pushing the RR bug fix that I puished into unstable into stable, as requested by Tim --- .../reducereads/HeaderElement.java | 21 ++++++++++++++++++- .../reducereads/SlidingWindow.java | 11 ++++++++-- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/protected/java/src/org/broadinstitute/sting/gatk/walkers/compression/reducereads/HeaderElement.java b/protected/java/src/org/broadinstitute/sting/gatk/walkers/compression/reducereads/HeaderElement.java index 3097c2ee9..bebc27221 100644 --- a/protected/java/src/org/broadinstitute/sting/gatk/walkers/compression/reducereads/HeaderElement.java +++ b/protected/java/src/org/broadinstitute/sting/gatk/walkers/compression/reducereads/HeaderElement.java @@ -39,16 +39,27 @@ public class HeaderElement { * * @param location the reference location for the new element */ - public HeaderElement(int location) { + public HeaderElement(final int location) { this(new BaseAndQualsCounts(), new BaseAndQualsCounts(), 0, 0, location, new LinkedList()); } + /** + * Creates a new HeaderElement with the following default values: - empty consensusBaseCounts - empty + * filteredBaseCounts - empty mappingQuality list + * + * @param location the reference location for the new element + */ + public HeaderElement(final int location, final int insertionsToTheRight) { + this(new BaseAndQualsCounts(), new BaseAndQualsCounts(), insertionsToTheRight, 0, location, new LinkedList()); + } + /** * Creates a new HeaderElement with all given parameters * * @param consensusBaseCounts the BaseCounts object for the running consensus synthetic read * @param filteredBaseCounts the BaseCounts object for the filtered data synthetic read * @param insertionsToTheRight number of insertions to the right of this HeaderElement + * @param nSoftClippedBases number of softclipped bases of this HeaderElement * @param location the reference location of this reference element * @param mappingQuality the list of mapping quality values of all reads that contributed to this * HeaderElement @@ -151,6 +162,14 @@ public class HeaderElement { throw new ReviewedStingException("Removed too many insertions, header is now negative!"); } + public boolean hasInsertionToTheRight() { + return insertionsToTheRight > 0; + } + + public int numInsertionsToTheRight() { + return insertionsToTheRight; + } + /** * Whether or not the HeaderElement is variant due to excess insertions * diff --git a/protected/java/src/org/broadinstitute/sting/gatk/walkers/compression/reducereads/SlidingWindow.java b/protected/java/src/org/broadinstitute/sting/gatk/walkers/compression/reducereads/SlidingWindow.java index fff1c20a5..9af54b4a8 100644 --- a/protected/java/src/org/broadinstitute/sting/gatk/walkers/compression/reducereads/SlidingWindow.java +++ b/protected/java/src/org/broadinstitute/sting/gatk/walkers/compression/reducereads/SlidingWindow.java @@ -645,8 +645,15 @@ public class SlidingWindow { } } - for (int i = 0; i <= lastStop; i++) // clean up the window header elements up until the end of the variant region. (we keep the last element in case the following element had a read that started with insertion) - windowHeader.remove(); + // clean up the window header elements up until the end of the variant region. + // note that we keep the last element of the region in the event that the following element has a read that starts with insertion. + if ( lastStop >= 0 ) { + for (int i = 0; i < lastStop; i++) + windowHeader.remove(); + final HeaderElement lastOfRegion = windowHeader.remove(); + if ( lastOfRegion.hasInsertionToTheRight() ) + windowHeader.addFirst(new HeaderElement(lastOfRegion.getLocation(), lastOfRegion.numInsertionsToTheRight())); + } } return allReads; }