From e7089f9870f205fd1f5bd6249e2e451eda94c4e2 Mon Sep 17 00:00:00 2001 From: hanna Date: Mon, 28 Feb 2011 22:35:53 +0000 Subject: [PATCH] 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 --- .../sting/gatk/datasources/reads/BinTree.java | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/java/src/org/broadinstitute/sting/gatk/datasources/reads/BinTree.java b/java/src/org/broadinstitute/sting/gatk/datasources/reads/BinTree.java index 94cebe9e7..a379ac761 100644 --- a/java/src/org/broadinstitute/sting/gatk/datasources/reads/BinTree.java +++ b/java/src/org/broadinstitute/sting/gatk/datasources/reads/BinTree.java @@ -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 { // 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; } }