removed old tests and old code
git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@2995 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
parent
e7eae9b61d
commit
ecb59f5d0d
|
|
@ -242,39 +242,6 @@ public class GenomeLocSortedSet extends AbstractSet<GenomeLoc> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* remove an element from the set. Given a specific genome location, this function will
|
|
||||||
* remove all regions in the element set that overlap the specified region.
|
|
||||||
*
|
|
||||||
* @param e the genomic range to remove
|
|
||||||
*
|
|
||||||
* @return true if a removal action was performed, false if the collection was unchanged.
|
|
||||||
*/
|
|
||||||
public boolean removeRegion(GenomeLoc e) {
|
|
||||||
// todo -- delete me
|
|
||||||
if (e == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// sometimes we can't return right away, this holds the value for those cases
|
|
||||||
boolean returnValue = false;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* check if the specified element overlaps any current locations, subtract the removed
|
|
||||||
* region and reinsert what is left.
|
|
||||||
*/
|
|
||||||
for (GenomeLoc g : mArray) {
|
|
||||||
if (g.overlapsP(e)) {
|
|
||||||
returnValue = true;
|
|
||||||
|
|
||||||
boolean finishEarly = removeOverlappingRegion(g, e);
|
|
||||||
if ( finishEarly )
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return returnValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// public boolean removeRegions(GenomeLocSortedSet toRemove) {
|
// public boolean removeRegions(GenomeLocSortedSet toRemove) {
|
||||||
// int i = 0, j = 0;
|
// int i = 0, j = 0;
|
||||||
|
|
@ -309,70 +276,6 @@ public class GenomeLocSortedSet extends AbstractSet<GenomeLoc> {
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
|
|
||||||
// todo -- delete me
|
|
||||||
private boolean removeOverlappingRegion(GenomeLoc g, GenomeLoc e) {
|
|
||||||
if (g.equals(e)) {
|
|
||||||
mArray.remove(mArray.indexOf(g));
|
|
||||||
return true;
|
|
||||||
} else if (g.containsP(e)) {
|
|
||||||
/**
|
|
||||||
* we have to create two new region, one for the before part, one for the after
|
|
||||||
* The old region:
|
|
||||||
* |----------------- old region (g) -------------|
|
|
||||||
* |----- to delete (e) ------|
|
|
||||||
*
|
|
||||||
* product (two new regions):
|
|
||||||
* |------| + |--------|
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
GenomeLoc before = GenomeLocParser.createGenomeLoc(g.getContigIndex(), g.getStart(), e.getStart() - 1);
|
|
||||||
GenomeLoc after = GenomeLocParser.createGenomeLoc(g.getContigIndex(), e.getStop() + 1, g.getStop());
|
|
||||||
int index = mArray.indexOf(g);
|
|
||||||
if (after.getStop() - after.getStart() >= 0) {
|
|
||||||
mArray.add(index, after);
|
|
||||||
}
|
|
||||||
if (before.getStop() - before.getStart() >= 0) {
|
|
||||||
mArray.add(index, before);
|
|
||||||
}
|
|
||||||
mArray.remove(mArray.indexOf(g));
|
|
||||||
return true;
|
|
||||||
} else if (e.containsP(g)) {
|
|
||||||
/**
|
|
||||||
* e completely contains g, delete g, but keep looking, there may be more regions
|
|
||||||
* i.e.:
|
|
||||||
* |--------------------- e --------------------|
|
|
||||||
* |--- g ---| |---- others ----|
|
|
||||||
*/
|
|
||||||
mArray.remove(mArray.indexOf(g));
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
/**
|
|
||||||
* otherwise e overlaps some part of g
|
|
||||||
*/
|
|
||||||
GenomeLoc l;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* figure out which region occurs first on the genome. I.e., is it:
|
|
||||||
* |------------- g ----------|
|
|
||||||
* |------------- e ----------|
|
|
||||||
*
|
|
||||||
* or:
|
|
||||||
* |------------- g ----------|
|
|
||||||
* |------------ e -----------|
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (e.getStart() < g.getStart()) {
|
|
||||||
l = GenomeLocParser.createGenomeLoc(g.getContigIndex(), e.getStop() + 1, g.getStop());
|
|
||||||
} else {
|
|
||||||
l = GenomeLocParser.createGenomeLoc(g.getContigIndex(), g.getStart(), e.getStart() - 1);
|
|
||||||
}
|
|
||||||
// replace g with the new region
|
|
||||||
mArray.set(mArray.indexOf(g), l);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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)
|
* 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
|
* @param location the GenomeLoc to remove
|
||||||
|
|
|
||||||
|
|
@ -120,99 +120,10 @@ public class GenomeLocSortedSetTest extends BaseTest {
|
||||||
assertTrue(loc.getContigIndex() == 1);
|
assertTrue(loc.getContigIndex() == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void deleteSubRegion() {
|
|
||||||
GenomeLoc e = GenomeLocParser.createGenomeLoc(1, 0, 50);
|
|
||||||
GenomeLoc g = GenomeLocParser.createGenomeLoc(1, 49, 100);
|
|
||||||
mSortedSet.add(g);
|
|
||||||
mSortedSet.addRegion(e);
|
|
||||||
|
|
||||||
// now delete a region
|
|
||||||
GenomeLoc d = GenomeLocParser.createGenomeLoc(1, 25, 75);
|
|
||||||
mSortedSet.removeRegion(d);
|
|
||||||
Iterator<GenomeLoc> iter = mSortedSet.iterator();
|
|
||||||
GenomeLoc loc = iter.next();
|
|
||||||
assertTrue(loc.getStart() == 0);
|
|
||||||
assertTrue(loc.getStop() == 24);
|
|
||||||
assertTrue(loc.getContigIndex() == 1);
|
|
||||||
|
|
||||||
loc = iter.next();
|
|
||||||
assertTrue(loc.getStart() == 76);
|
|
||||||
assertTrue(loc.getStop() == 100);
|
|
||||||
assertTrue(loc.getContigIndex() == 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void deleteAllButTwoEndBases() {
|
|
||||||
GenomeLoc e = GenomeLocParser.createGenomeLoc(1, 1, 50);
|
|
||||||
mSortedSet.add(e);
|
|
||||||
|
|
||||||
// now delete the region
|
|
||||||
GenomeLoc d = GenomeLocParser.createGenomeLoc(1, 2, 49);
|
|
||||||
mSortedSet.removeRegion(d);
|
|
||||||
Iterator<GenomeLoc> iter = mSortedSet.iterator();
|
|
||||||
|
|
||||||
// we expect to find the two end bases only, this was added because we were
|
|
||||||
// dropping intervals that were of size one.
|
|
||||||
GenomeLoc loc = iter.next();
|
|
||||||
assertTrue(loc.getStart() == 1);
|
|
||||||
assertTrue(loc.getStop() == 1);
|
|
||||||
assertTrue(loc.getContigIndex() == 1);
|
|
||||||
|
|
||||||
loc = iter.next();
|
|
||||||
assertTrue(loc.getStart() == 50);
|
|
||||||
assertTrue(loc.getStop() == 50);
|
|
||||||
assertTrue(loc.getContigIndex() == 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void deleteAllByRegion() {
|
|
||||||
GenomeLoc e = GenomeLocParser.createGenomeLoc(1, 1, 100);
|
|
||||||
mSortedSet.add(e);
|
|
||||||
for (int x = 1; x < 101; x++) {
|
|
||||||
GenomeLoc del = GenomeLocParser.createGenomeLoc(1,x,x);
|
|
||||||
mSortedSet.removeRegion(del);
|
|
||||||
}
|
|
||||||
assertTrue(mSortedSet.isEmpty());
|
|
||||||
}
|
|
||||||
@Test
|
|
||||||
public void deleteSomeByRegion() {
|
|
||||||
GenomeLoc e = GenomeLocParser.createGenomeLoc(1, 1, 100);
|
|
||||||
mSortedSet.add(e);
|
|
||||||
for (int x = 1; x < 50; x++) {
|
|
||||||
GenomeLoc del = GenomeLocParser.createGenomeLoc(1,x,x);
|
|
||||||
mSortedSet.removeRegion(del);
|
|
||||||
}
|
|
||||||
assertTrue(!mSortedSet.isEmpty());
|
|
||||||
assertTrue(mSortedSet.size() == 1);
|
|
||||||
GenomeLoc loc = mSortedSet.iterator().next();
|
|
||||||
assertTrue(loc.getStop() == 100);
|
|
||||||
assertTrue(loc.getStart() == 50);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void deleteSuperRegion() {
|
|
||||||
GenomeLoc e = GenomeLocParser.createGenomeLoc(1, 10, 20);
|
|
||||||
GenomeLoc g = GenomeLocParser.createGenomeLoc(1, 70, 100);
|
|
||||||
mSortedSet.add(g);
|
|
||||||
mSortedSet.addRegion(e);
|
|
||||||
assertTrue(mSortedSet.size() == 2);
|
|
||||||
// now delete a region
|
|
||||||
GenomeLoc d = GenomeLocParser.createGenomeLoc(1, 15, 75);
|
|
||||||
mSortedSet.removeRegion(d);
|
|
||||||
Iterator<GenomeLoc> iter = mSortedSet.iterator();
|
|
||||||
GenomeLoc loc = iter.next();
|
|
||||||
assertTrue(loc.getStart() == 10);
|
|
||||||
assertTrue(loc.getStop() == 14);
|
|
||||||
assertTrue(loc.getContigIndex() == 1);
|
|
||||||
|
|
||||||
loc = iter.next();
|
|
||||||
assertTrue(loc.getStart() == 76);
|
|
||||||
assertTrue(loc.getStop() == 100);
|
|
||||||
assertTrue(loc.getContigIndex() == 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void fromSequenceDictionary() {
|
public void fromSequenceDictionary() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue