fixing a bug where reads in overlapping interval based locus traversals could get assigned to only one of two the regions
git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@1407 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
parent
bb1d31914c
commit
fc1c76f1d2
|
|
@ -40,8 +40,12 @@ public class IntervalShard implements Shard {
|
||||||
|
|
||||||
/** a collection of genomic locations to interate over */
|
/** a collection of genomic locations to interate over */
|
||||||
private GenomeLoc mSet;
|
private GenomeLoc mSet;
|
||||||
|
private Shard.ShardType mType = Shard.ShardType.LOCUS_INTERVAL;
|
||||||
|
|
||||||
IntervalShard(GenomeLoc myLocation) {
|
IntervalShard(GenomeLoc myLocation, Shard.ShardType intervalType) {
|
||||||
|
if (intervalType != Shard.ShardType.LOCUS_INTERVAL && intervalType != Shard.ShardType.READ_INTERVAL)
|
||||||
|
throw new IllegalArgumentException("The specified interval type must be either LOCUS_INTERVAL or READ_INTERVAL");
|
||||||
|
mType = intervalType;
|
||||||
mSet = myLocation.clone();
|
mSet = myLocation.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -56,6 +60,6 @@ public class IntervalShard implements Shard {
|
||||||
* @return READ, indicating the shard type
|
* @return READ, indicating the shard type
|
||||||
*/
|
*/
|
||||||
public Shard.ShardType getShardType() {
|
public Shard.ShardType getShardType() {
|
||||||
return ShardType.INTERVAL;
|
return mType;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ public class IntervalShardStrategy implements ShardStrategy {
|
||||||
|
|
||||||
/** their prefered size of the shard, we can modify this based on what we see in the shards */
|
/** their prefered size of the shard, we can modify this based on what we see in the shards */
|
||||||
private long size;
|
private long size;
|
||||||
|
private Shard.ShardType type;
|
||||||
/**
|
/**
|
||||||
* change the recommended shard size for the next shard we generate. The code will do it's
|
* change the recommended shard size for the next shard we generate. The code will do it's
|
||||||
* best to respect this value, but there are no guarantees.
|
* best to respect this value, but there are no guarantees.
|
||||||
|
|
@ -66,10 +66,11 @@ public class IntervalShardStrategy implements ShardStrategy {
|
||||||
* @param size
|
* @param size
|
||||||
* @param locations
|
* @param locations
|
||||||
*/
|
*/
|
||||||
IntervalShardStrategy( long size, GenomeLocSortedSet locations ) {
|
IntervalShardStrategy( long size, GenomeLocSortedSet locations, Shard.ShardType shardType ) {
|
||||||
if (locations == null || locations.isEmpty()) {
|
if (locations == null || locations.isEmpty()) {
|
||||||
throw new StingException("IntervalShardStrategy: genomic regions list is empty.");
|
throw new StingException("IntervalShardStrategy: genomic regions list is empty.");
|
||||||
}
|
}
|
||||||
|
type = shardType;
|
||||||
this.regions = locations.clone();
|
this.regions = locations.clone();
|
||||||
this.size = size;
|
this.size = size;
|
||||||
}
|
}
|
||||||
|
|
@ -110,7 +111,7 @@ public class IntervalShardStrategy implements ShardStrategy {
|
||||||
GenomeLoc loc = regions.iterator().next();
|
GenomeLoc loc = regions.iterator().next();
|
||||||
|
|
||||||
regions.removeRegion(loc);
|
regions.removeRegion(loc);
|
||||||
return new IntervalShard(loc);
|
return new IntervalShard(loc,type);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -173,11 +173,11 @@ public abstract class LocusShardStrategy implements ShardStrategy {
|
||||||
|
|
||||||
if (loc.getStop() - loc.getStart() <= proposedSize) {
|
if (loc.getStop() - loc.getStart() <= proposedSize) {
|
||||||
intervals.removeRegion(loc);
|
intervals.removeRegion(loc);
|
||||||
return new IntervalShard(loc);
|
return new IntervalShard(loc,Shard.ShardType.LOCUS_INTERVAL);
|
||||||
} else {
|
} else {
|
||||||
GenomeLoc subLoc = GenomeLocParser.createGenomeLoc(loc.getContigIndex(), loc.getStart(), loc.getStart() + proposedSize - 1);
|
GenomeLoc subLoc = GenomeLocParser.createGenomeLoc(loc.getContigIndex(), loc.getStart(), loc.getStart() + proposedSize - 1);
|
||||||
intervals.removeRegion(subLoc);
|
intervals.removeRegion(subLoc);
|
||||||
return new IntervalShard(subLoc);
|
return new IntervalShard(subLoc,Shard.ShardType.LOCUS_INTERVAL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ import java.io.Serializable;
|
||||||
*/
|
*/
|
||||||
public interface Shard extends Serializable {
|
public interface Shard extends Serializable {
|
||||||
enum ShardType {
|
enum ShardType {
|
||||||
READ, LOCUS, INTERVAL
|
READ, LOCUS, READ_INTERVAL, LOCUS_INTERVAL
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return the genome location represented by this shard */
|
/** @return the genome location represented by this shard */
|
||||||
|
|
|
||||||
|
|
@ -106,8 +106,9 @@ public class ShardStrategyFactory {
|
||||||
case EXPONENTIAL:
|
case EXPONENTIAL:
|
||||||
return new ExpGrowthLocusShardStrategy(dic, startingSize, lst, limitDataCount);
|
return new ExpGrowthLocusShardStrategy(dic, startingSize, lst, limitDataCount);
|
||||||
case INTERVAL:
|
case INTERVAL:
|
||||||
|
return new IntervalShardStrategy(startingSize, lst, Shard.ShardType.LOCUS_INTERVAL);
|
||||||
case READS:
|
case READS:
|
||||||
return new IntervalShardStrategy(startingSize, lst);
|
return new IntervalShardStrategy(startingSize, lst, Shard.ShardType.READ_INTERVAL);
|
||||||
default:
|
default:
|
||||||
throw new StingException("Strategy: " + strat + " isn't implemented");
|
throw new StingException("Strategy: " + strat + " isn't implemented");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -162,7 +162,8 @@ public class SAMDataSource implements SimpleDataSource {
|
||||||
reads.getDownsamplingFraction(),
|
reads.getDownsamplingFraction(),
|
||||||
reads.getSafetyChecking(),
|
reads.getSafetyChecking(),
|
||||||
reads.getSupplementalFilters());
|
reads.getSupplementalFilters());
|
||||||
} else if (shard.getShardType() == Shard.ShardType.INTERVAL) {
|
} else if ((shard.getShardType() == Shard.ShardType.LOCUS_INTERVAL) ||
|
||||||
|
(shard.getShardType() == Shard.ShardType.READ_INTERVAL)) {
|
||||||
iterator = seekLocus(shard.getGenomeLoc());
|
iterator = seekLocus(shard.getGenomeLoc());
|
||||||
iterator = applyDecoratingIterators(false,
|
iterator = applyDecoratingIterators(false,
|
||||||
iterator,
|
iterator,
|
||||||
|
|
@ -170,8 +171,8 @@ public class SAMDataSource implements SimpleDataSource {
|
||||||
reads.getSafetyChecking(),
|
reads.getSafetyChecking(),
|
||||||
reads.getSupplementalFilters());
|
reads.getSupplementalFilters());
|
||||||
|
|
||||||
// add the new overlapping detection iterator, if we have a last interval
|
// add the new overlapping detection iterator, if we have a last interval and we're a read based shard
|
||||||
if (mLastInterval != null && queryOverlapping) iterator = new IntervalOverlapIterator(iterator,mLastInterval,false);
|
if (mLastInterval != null && shard.getShardType() == Shard.ShardType.READ_INTERVAL ) iterator = new IntervalOverlapIterator(iterator,mLastInterval,false);
|
||||||
mLastInterval = shard.getGenomeLoc();
|
mLastInterval = shard.getGenomeLoc();
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue