fixed dropping single base intervals from deleteRegion, moving onto performance fixes.

(stop - start is length-1 on closed intervals, so we need to check greater than OR equals to zero)

git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@2990 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
aaron 2010-03-12 19:14:21 +00:00
parent 7aa7a5f9b8
commit 1eb5f97255
2 changed files with 26 additions and 2 deletions

View File

@ -174,10 +174,10 @@ public class GenomeLocSortedSet extends AbstractSet<GenomeLoc> {
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) {
if (after.getStop() - after.getStart() >= 0) {
mArray.add(index, after);
}
if (before.getStop() - before.getStart() > 0) {
if (before.getStop() - before.getStart() >= 0) {
mArray.add(index, before);
}
mArray.remove(mArray.indexOf(g));

View File

@ -142,6 +142,30 @@ public class GenomeLocSortedSetTest extends BaseTest {
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);