From ee1dc6092f5540f0337b9e6f0758ee9a3e92521c Mon Sep 17 00:00:00 2001 From: asivache Date: Mon, 22 Mar 2010 17:37:52 +0000 Subject: [PATCH] Test updated. Now we do not throw an exception when locus interval is out of bounds, we just return silently a reference context trimmed to the current shard boundaries. New test checks for trimming. git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@3058 348d0f76-0448-11de-a6fe-93d51630548a --- .../providers/LocusReferenceViewTest.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/java/test/org/broadinstitute/sting/gatk/datasources/providers/LocusReferenceViewTest.java b/java/test/org/broadinstitute/sting/gatk/datasources/providers/LocusReferenceViewTest.java index 9aef9e56a..e5cc7956b 100755 --- a/java/test/org/broadinstitute/sting/gatk/datasources/providers/LocusReferenceViewTest.java +++ b/java/test/org/broadinstitute/sting/gatk/datasources/providers/LocusReferenceViewTest.java @@ -8,6 +8,7 @@ import org.broadinstitute.sting.utils.sam.ArtificialSAMUtils; import org.broadinstitute.sting.gatk.datasources.shards.Shard; import org.broadinstitute.sting.gatk.datasources.shards.LocusShard; import org.broadinstitute.sting.gatk.iterators.GenomeLocusIterator; +import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import net.sf.picard.reference.ReferenceSequence; import net.sf.samtools.util.StringUtil; @@ -57,7 +58,6 @@ public class LocusReferenceViewTest extends ReferenceViewTemplate { @Test public void testOverlappingReferenceBases() { Shard shard = new LocusShard(Collections.singletonList(GenomeLocParser.createGenomeLoc(0, sequenceFile.getSequence("chrM").length() - 10, sequenceFile.getSequence("chrM").length()))); - LocusShardDataProvider dataProvider = new LocusShardDataProvider(shard, null, shard.getGenomeLocs().get(0), null, sequenceFile, null); LocusReferenceView view = new LocusReferenceView(dataProvider); @@ -70,15 +70,20 @@ public class LocusReferenceViewTest extends ReferenceViewTemplate { } - /** Queries outside the bounds of the shard should generate an error. */ - @Test(expected = InvalidPositionException.class) + /** Queries outside the bounds of the shard should result in reference context window trimmed at the shard boundary. */ + @Test public void testBoundsFailure() { Shard shard = new LocusShard(Collections.singletonList(GenomeLocParser.createGenomeLoc(0, 1, 50))); LocusShardDataProvider dataProvider = new LocusShardDataProvider(shard, null, shard.getGenomeLocs().get(0), null, sequenceFile, null); LocusReferenceView view = new LocusReferenceView(dataProvider); - view.getReferenceContext(GenomeLocParser.createGenomeLoc(0, 51)).getBase(); + GenomeLoc locus = GenomeLocParser.createGenomeLoc(0, 50, 51); + + ReferenceContext rc = view.getReferenceContext(locus); + Assert.assertTrue(rc.getLocus().equals(locus)); + Assert.assertTrue(rc.getWindow().equals(GenomeLocParser.createGenomeLoc(0,50))); + Assert.assertTrue(rc.getBases().length == 1); }