removed the dependence on removeRegion() in GenomeLocSortedSet
git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@2993 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
parent
196bca6819
commit
88a48821ea
|
|
@ -94,7 +94,7 @@ public class IntervalShardStrategy implements ShardStrategy {
|
||||||
// get the first region in the list
|
// get the first region in the list
|
||||||
GenomeLoc loc = regions.iterator().next();
|
GenomeLoc loc = regions.iterator().next();
|
||||||
|
|
||||||
regions.removeRegion(loc);
|
regions.remove(loc);
|
||||||
return new IntervalShard(loc,type);
|
return new IntervalShard(loc,type);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ public abstract class LocusShardStrategy implements ShardStrategy {
|
||||||
*
|
*
|
||||||
* @param dic the seq dictionary
|
* @param dic the seq dictionary
|
||||||
*/
|
*/
|
||||||
LocusShardStrategy( SAMSequenceDictionary dic ) {
|
LocusShardStrategy(SAMSequenceDictionary dic) {
|
||||||
this.dic = dic;
|
this.dic = dic;
|
||||||
limitingFactor = -1;
|
limitingFactor = -1;
|
||||||
mLoc = GenomeLocParser.createGenomeLoc(0, 0, 0);
|
mLoc = GenomeLocParser.createGenomeLoc(0, 0, 0);
|
||||||
|
|
@ -76,7 +76,7 @@ public abstract class LocusShardStrategy implements ShardStrategy {
|
||||||
*
|
*
|
||||||
* @param old the old strategy
|
* @param old the old strategy
|
||||||
*/
|
*/
|
||||||
LocusShardStrategy( LocusShardStrategy old ) {
|
LocusShardStrategy(LocusShardStrategy old) {
|
||||||
this.dic = old.dic;
|
this.dic = old.dic;
|
||||||
this.mLoc = old.mLoc;
|
this.mLoc = old.mLoc;
|
||||||
this.seqLoc = old.seqLoc;
|
this.seqLoc = old.seqLoc;
|
||||||
|
|
@ -92,7 +92,7 @@ public abstract class LocusShardStrategy implements ShardStrategy {
|
||||||
* @param dic the seq dictionary
|
* @param dic the seq dictionary
|
||||||
* @param intervals file
|
* @param intervals file
|
||||||
*/
|
*/
|
||||||
LocusShardStrategy( SAMSequenceDictionary dic, GenomeLocSortedSet intervals ) {
|
LocusShardStrategy(SAMSequenceDictionary dic, GenomeLocSortedSet intervals) {
|
||||||
this.dic = dic;
|
this.dic = dic;
|
||||||
this.intervals = intervals.clone();
|
this.intervals = intervals.clone();
|
||||||
// set the starting point to the beginning interval
|
// set the starting point to the beginning interval
|
||||||
|
|
@ -152,7 +152,7 @@ public abstract class LocusShardStrategy implements ShardStrategy {
|
||||||
if (this.intervals == null) {
|
if (this.intervals == null) {
|
||||||
return nonIntervaledNext(length, proposedSize, nextStart);
|
return nonIntervaledNext(length, proposedSize, nextStart);
|
||||||
} else {
|
} else {
|
||||||
return intervaledNext(proposedSize);
|
return intervaledNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -160,26 +160,20 @@ public abstract class LocusShardStrategy implements ShardStrategy {
|
||||||
/**
|
/**
|
||||||
* Interval based next processing
|
* Interval based next processing
|
||||||
*
|
*
|
||||||
* @param proposedSize the proposed size
|
|
||||||
*
|
*
|
||||||
* @return the shard that represents this data
|
* @return the shard that represents this data
|
||||||
*/
|
*/
|
||||||
private Shard intervaledNext( long proposedSize ) {
|
private Shard intervaledNext() {
|
||||||
if (( this.intervals == null ) || ( intervals.isEmpty() )) {
|
if ((this.intervals == null) || (intervals.isEmpty())) {
|
||||||
throw new StingException("LocusShardStrategy: genomic regions list is empty in next() function.");
|
throw new StingException("LocusShardStrategy: genomic regions list is empty in next() function.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the first region in the list
|
// get the first region in the list
|
||||||
GenomeLoc loc = intervals.iterator().next();
|
GenomeLoc loc = intervals.iterator().next();
|
||||||
|
|
||||||
if (loc.getStop() - loc.getStart() <= proposedSize) {
|
intervals.remove(loc);
|
||||||
intervals.removeRegion(loc);
|
return new IntervalShard(loc, Shard.ShardType.LOCUS_INTERVAL);
|
||||||
return new IntervalShard(loc,Shard.ShardType.LOCUS_INTERVAL);
|
|
||||||
} else {
|
|
||||||
GenomeLoc subLoc = GenomeLocParser.createGenomeLoc(loc.getContigIndex(), loc.getStart(), loc.getStart() + proposedSize - 1);
|
|
||||||
intervals.removeRegion(subLoc);
|
|
||||||
return new IntervalShard(subLoc,Shard.ShardType.LOCUS_INTERVAL);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -191,7 +185,7 @@ public abstract class LocusShardStrategy implements ShardStrategy {
|
||||||
*
|
*
|
||||||
* @return the shard to return to the user
|
* @return the shard to return to the user
|
||||||
*/
|
*/
|
||||||
private Shard nonIntervaledNext( long length, long proposedSize, long nextStart ) {
|
private Shard nonIntervaledNext(long length, long proposedSize, long nextStart) {
|
||||||
// can we fit it into the current seq size?
|
// can we fit it into the current seq size?
|
||||||
if (nextStart + proposedSize - 1 < length) {
|
if (nextStart + proposedSize - 1 < length) {
|
||||||
lastGenomeLocSize = proposedSize;
|
lastGenomeLocSize = proposedSize;
|
||||||
|
|
@ -223,7 +217,7 @@ public abstract class LocusShardStrategy implements ShardStrategy {
|
||||||
private void jumpContig() {
|
private void jumpContig() {
|
||||||
++seqLoc;
|
++seqLoc;
|
||||||
|
|
||||||
if (!( seqLoc < dic.getSequences().size() )) {
|
if (!(seqLoc < dic.getSequences().size())) {
|
||||||
nextContig = false;
|
nextContig = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -246,7 +240,7 @@ public abstract class LocusShardStrategy implements ShardStrategy {
|
||||||
if (this.intervals == null) {
|
if (this.intervals == null) {
|
||||||
return nextContig;
|
return nextContig;
|
||||||
} else {
|
} else {
|
||||||
return ( this.intervals.size() > 0 );
|
return (this.intervals.size() > 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -223,6 +223,15 @@ public class GenomeLocSortedSet extends AbstractSet<GenomeLoc> {
|
||||||
return returnValue;
|
return returnValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* a simple removal of an interval contained in this list. The interval must be identical to one in the list (no partial locations or overlapping)
|
||||||
|
* @param location the GenomeLoc to remove
|
||||||
|
*/
|
||||||
|
public void remove(GenomeLoc location) {
|
||||||
|
if (!mArray.contains(location)) throw new IllegalArgumentException("Unable to remove location: " + location + ", not in the list");
|
||||||
|
mArray.remove(location);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* create a list of genomic locations, given a reference sequence
|
* create a list of genomic locations, given a reference sequence
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -113,7 +113,7 @@ public class LinearLocusShardStrategyTest extends BaseTest {
|
||||||
Shard d = strat.next();
|
Shard d = strat.next();
|
||||||
assertTrue(d instanceof LocusShard);
|
assertTrue(d instanceof LocusShard);
|
||||||
assertEquals("Sharding strategy must emit single locus shards",1,d.getGenomeLocs().size());
|
assertEquals("Sharding strategy must emit single locus shards",1,d.getGenomeLocs().size());
|
||||||
assertTrue((d.getGenomeLocs().get(0).getStop() - d.getGenomeLocs().get(0).getStart()) == 199);
|
assertEquals(199,(d.getGenomeLocs().get(0).getStop() - d.getGenomeLocs().get(0).getStart()));
|
||||||
++counter;
|
++counter;
|
||||||
}
|
}
|
||||||
assertTrue(counter == 1);
|
assertTrue(counter == 1);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue