More comprehensive tracking of position when bin trees are sparse.

git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@5344 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
hanna 2011-03-01 15:53:43 +00:00
parent bb969cd3a2
commit d6145de970
3 changed files with 29 additions and 13 deletions

View File

@ -59,15 +59,6 @@ public class BinTree {
this.bins = bins;
}
public GATKBin getLowestLevelBin() {
for(int i = bins.length-1; i >= 0; i--) {
if(bins[i] != null)
return bins[i];
}
return null;
}
/**
* Retrieve the bins from the bin tree.
* @return list of bins.
@ -84,6 +75,31 @@ public class BinTree {
return bins.length;
}
/**
* Returns the start of the region covered by this bin tree.
* @return Start of the region covered by this bin tree.
*/
public int getStart() {
return binTreeStart;
}
/**
* Returns the end of the region covered by this bin tree.
* @return End of the region covered by this bin tree.
*/
public int getStop() {
return binTreeStop;
}
/**
* Returns true if the location of this bin tree is before the given position.
* @param locus Locus to test.
* @return True if this bin sits completely before the given locus; false otherwise.
*/
public boolean isBefore(final GenomeLoc locus) {
return binTreeStop < locus.getStart();
}
/**
* Checks overlap between this bin tree and other bin trees.
* @param position the position over which to detect overlap.

View File

@ -95,8 +95,8 @@ public class LowMemoryIntervalSharder implements Iterator<FilePointer> {
GATKBAMIndex index = (GATKBAMIndex)dataSource.getIndex(reader);
BinTree binTree = getNextOverlappingBinTree((GATKBAMIndex)dataSource.getIndex(reader),currentLocus);
if(binTree != null) {
coveredRegionStart = Math.max(coveredRegionStart,index.getFirstLocusInBin(binTree.getLowestLevelBin().toBin()));
coveredRegionStop = Math.min(coveredRegionStop,index.getLastLocusInBin(binTree.getLowestLevelBin().toBin()));
coveredRegionStart = Math.max(coveredRegionStart,binTree.getStart());
coveredRegionStop = Math.min(coveredRegionStop,binTree.getStop());
coveredRegion = loci.getGenomeLocParser().createGenomeLoc(currentLocus.getContig(),coveredRegionStart,coveredRegionStop);
GATKBAMFileSpan fileSpan = generateFileSpan(index,binTree,currentLocus);
@ -164,7 +164,7 @@ public class LowMemoryIntervalSharder implements Iterator<FilePointer> {
return null;
BinTree binTree = binTreeIterator.peek();
while(index.getLastLocusInBin(binTree.getLowestLevelBin().toBin()) < locus.getStart()) {
while(binTree.isBefore(locus)) {
binTreeIterator.next(); // Before the point of interest. Consume this one.
binTree = binTreeIterator.peek();
}

View File

@ -96,7 +96,7 @@ public class ReadShardStrategy implements ShardStrategy {
this.locations = locations;
if(locations != null)
filePointerIterator = IntervalSharder.shardIntervals(this.dataSource,locations);
filePointerIterator = SAMDataSource.TRY_LOW_MEMORY_SHARDING ? new LowMemoryIntervalSharder(this.dataSource,locations) : IntervalSharder.shardIntervals(this.dataSource,locations);
else
filePointerIterator = filePointers.iterator();