Pushing the RR bug fix that I puished into unstable into stable, as requested by Tim

This commit is contained in:
Eric Banks 2012-12-19 11:47:16 -05:00
parent 3ad45223be
commit 4a7e0427a3
2 changed files with 29 additions and 3 deletions

View File

@ -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<Integer>());
}
/**
* 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<Integer>());
}
/**
* 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
*

View File

@ -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;
}