Fix for particularly small, isolated intervals: make sure the bounds of the

bin tree are dictated by the lowest bin level, whether it exists or not.


git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@5339 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
hanna 2011-02-28 22:35:53 +00:00
parent c869d1c9cf
commit e7089f9870
1 changed files with 17 additions and 10 deletions

View File

@ -38,19 +38,25 @@ import java.util.NoSuchElementException;
* BAM index.
*/
public class BinTree {
/**
* The BAM index from which this bin data is sourced.
*/
private final GATKBAMIndex index;
/**
* The bins in this tree, organized by level.
*/
private final GATKBin[] bins;
public BinTree(GATKBAMIndex index,final GATKBin[] bins) {
this.index = index;
this.bins = bins;
/**
* Starting location of the bin tree.
*/
private final int binTreeStart;
/**
* Ending location of the bin tree.
*/
private final int binTreeStop;
public BinTree(final int binTreeStart, final int binTreeStop,final GATKBin[] bins) {
this.binTreeStart = binTreeStart;
this.binTreeStop = binTreeStop;
this.bins = bins;
}
public GATKBin getLowestLevelBin() {
@ -89,7 +95,7 @@ public class BinTree {
continue;
Bin bin = new Bin(gatkBin.getReferenceSequence(),gatkBin.getBinNumber());
// Overlap occurs when the position is not disjoint with the bin boundaries.
if(!(position.getStop() < index.getFirstLocusInBin(bin) || position.getStart() > index.getLastLocusInBin(bin)))
if(!(position.getStop() < binTreeStart || position.getStart() > binTreeStop))
return true;
}
return false;
@ -189,7 +195,8 @@ class BinTreeIterator implements Iterator<BinTree> {
// Found a compelling bin tree? Break out of the loop.
for(int level = 0; level <= lowestLevel; level++) {
if(bins[level] != null) {
nextBinTree = new BinTree(index,bins);
Bin lowestLevelBin = new Bin(bins[level].getReferenceSequence(),currentBinInLowestLevel);
nextBinTree = new BinTree(index.getFirstLocusInBin(lowestLevelBin),index.getLastLocusInBin(lowestLevelBin),bins);
break;
}
}