|
5 | 5 | import htsjdk.variant.variantcontext.VariantContext; |
6 | 6 | import htsjdk.variant.vcf.VCFFileReader; |
7 | 7 | import htsjdk.variant.vcf.VCFHeader; |
| 8 | +import org.apache.commons.io.FilenameUtils; |
8 | 9 | import org.apache.commons.lang3.tuple.Pair; |
9 | 10 | import org.broadinstitute.hellbender.exceptions.UserException; |
10 | 11 | import org.broadinstitute.hellbender.utils.SimpleInterval; |
@@ -174,7 +175,7 @@ private void checkTraversalResults( final Iterator<VariantContext> traversalResu |
174 | 175 | public Object[][] getIndependentFeatureQueryTestData() { |
175 | 176 | // Query Interval + Expected Variant ID(s) |
176 | 177 | return new Object[][] { |
177 | | - { new SimpleInterval("1", 1, 99), Collections.<String>emptyList() }, |
| 178 | + { new SimpleInterval("1", 1, 99), Collections.emptyList() }, |
178 | 179 | { new SimpleInterval("1", 100, 100), Arrays.asList("a") }, |
179 | 180 | { new SimpleInterval("1", 100, 200), Arrays.asList("a", "b", "c") }, |
180 | 181 | { new SimpleInterval("1", 200, 202), Arrays.asList("b", "c") }, |
@@ -414,12 +415,25 @@ public void testQueryGVCF( final SimpleInterval queryInterval, final List<String |
414 | 415 |
|
415 | 416 | @Test(dataProvider = "IndependentFeatureQueryTestData") |
416 | 417 | public void testForNamedCodec (final SimpleInterval queryInterval, final List<String> UNUSED) { |
| 418 | + |
| 419 | + // Test with default name: |
417 | 420 | try (final FeatureDataSource<VariantContext> featureSource = new FeatureDataSource<>(QUERY_TEST_VCF)) { |
418 | 421 | final Iterator<VariantContext> featureIterator = featureSource.query(queryInterval); |
419 | | - while (featureIterator.hasNext()) { |
| 422 | + while ( featureIterator.hasNext() ) { |
420 | 423 | Assert.assertEquals( featureIterator.next().getSource(), QUERY_TEST_VCF.getAbsolutePath() ); |
421 | 424 | } |
422 | 425 | } |
| 426 | + |
| 427 | + // Test with logical name: |
| 428 | + final String logicalDataSourceName = FilenameUtils.getBaseName(QUERY_TEST_VCF.getAbsolutePath()) |
| 429 | + + '_' + queryInterval.getContig() + ":" + queryInterval.getStart() + '-' + queryInterval.getEnd(); |
| 430 | + |
| 431 | + try (final FeatureDataSource<VariantContext> featureSource = new FeatureDataSource<>(QUERY_TEST_VCF, logicalDataSourceName)) { |
| 432 | + final Iterator<VariantContext> featureIterator = featureSource.query(queryInterval); |
| 433 | + while ( featureIterator.hasNext() ) { |
| 434 | + Assert.assertEquals( featureIterator.next().getSource(), logicalDataSourceName ); |
| 435 | + } |
| 436 | + } |
423 | 437 | } |
424 | 438 |
|
425 | 439 | /************************************************** |
|
0 commit comments