Merge branch 'master' of github.com:broadinstitute/gsa-unstable

This commit is contained in:
Chris Hartl 2013-01-02 15:11:30 -05:00
commit 03294ae1c8
3 changed files with 21 additions and 1 deletions

View File

@ -287,6 +287,11 @@ public final class GenomeLocParser {
return new GenomeLoc(contig, index, start, stop);
}
public GenomeLoc createGenomeLocOnContig(final String contig, final int start, final int stop) {
GenomeLoc contigLoc = createOverEntireContig(contig);
return new GenomeLoc(contig, getContigIndex(contig), start, stop).intersect(contigLoc);
}
/**
* validate a position or interval on the genome as valid
*

View File

@ -31,7 +31,7 @@ public class ActiveRegion implements HasGenomeLocation {
this.isActive = isActive;
this.genomeLocParser = genomeLocParser;
this.extension = extension;
extendedLoc = genomeLocParser.createGenomeLoc(activeRegionLoc.getContig(), activeRegionLoc.getStart() - extension, activeRegionLoc.getStop() + extension);
extendedLoc = genomeLocParser.createGenomeLocOnContig(activeRegionLoc.getContig(), activeRegionLoc.getStart() - extension, activeRegionLoc.getStop() + extension);
fullExtentReferenceLoc = extendedLoc;
}

View File

@ -241,6 +241,21 @@ public class TraverseActiveRegionsUnitTest extends BaseTest {
Assert.assertEquals(intervalStops.size(), 0, "Interval stop location does not match an active region stop location");
}
@Test
public void testActiveRegionExtensionOnContig() {
DummyActiveRegionWalker walker = new DummyActiveRegionWalker();
Collection<ActiveRegion> activeRegions = getActiveRegions(walker, intervals).values();
for (ActiveRegion activeRegion : activeRegions) {
GenomeLoc loc = activeRegion.getExtendedLoc();
// Contract: active region extensions must stay on the contig
Assert.assertTrue(loc.getStart() > 0, "Active region extension begins at location " + loc.getStart() + ", past the left end of the contig");
int refLen = dictionary.getSequence(loc.getContigIndex()).getSequenceLength();
Assert.assertTrue(loc.getStop() <= refLen, "Active region extension ends at location " + loc.getStop() + ", past the right end of the contig");
}
}
@Test
public void testPrimaryReadMapping() {
DummyActiveRegionWalker walker = new DummyActiveRegionWalker();