Skip to content

Commit 4a3f9c9

Browse files
committed
Addressing review comments.
1 parent 8c98bb4 commit 4a3f9c9

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

src/main/java/org/broadinstitute/hellbender/engine/FeatureDataSource.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ private static <T extends Feature> FeatureReader<T> getFeatureReader(final Featu
334334
// Set the name if we have to:
335335
if ( codec instanceof NameAwareCodec ) {
336336
final NameAwareCodec namedCodec = (NameAwareCodec) codec;
337-
namedCodec.setName( featureInput.getFeaturePath() );
337+
namedCodec.setName( featureInput.getName() );
338338
}
339339

340340
return codec;

src/test/java/org/broadinstitute/hellbender/engine/FeatureDataSourceUnitTest.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import htsjdk.variant.variantcontext.VariantContext;
66
import htsjdk.variant.vcf.VCFFileReader;
77
import htsjdk.variant.vcf.VCFHeader;
8+
import org.apache.commons.io.FilenameUtils;
89
import org.apache.commons.lang3.tuple.Pair;
910
import org.broadinstitute.hellbender.exceptions.UserException;
1011
import org.broadinstitute.hellbender.utils.SimpleInterval;
@@ -174,7 +175,7 @@ private void checkTraversalResults( final Iterator<VariantContext> traversalResu
174175
public Object[][] getIndependentFeatureQueryTestData() {
175176
// Query Interval + Expected Variant ID(s)
176177
return new Object[][] {
177-
{ new SimpleInterval("1", 1, 99), Collections.<String>emptyList() },
178+
{ new SimpleInterval("1", 1, 99), Collections.emptyList() },
178179
{ new SimpleInterval("1", 100, 100), Arrays.asList("a") },
179180
{ new SimpleInterval("1", 100, 200), Arrays.asList("a", "b", "c") },
180181
{ new SimpleInterval("1", 200, 202), Arrays.asList("b", "c") },
@@ -414,12 +415,25 @@ public void testQueryGVCF( final SimpleInterval queryInterval, final List<String
414415

415416
@Test(dataProvider = "IndependentFeatureQueryTestData")
416417
public void testForNamedCodec (final SimpleInterval queryInterval, final List<String> UNUSED) {
418+
419+
// Test with default name:
417420
try (final FeatureDataSource<VariantContext> featureSource = new FeatureDataSource<>(QUERY_TEST_VCF)) {
418421
final Iterator<VariantContext> featureIterator = featureSource.query(queryInterval);
419-
while (featureIterator.hasNext()) {
422+
while ( featureIterator.hasNext() ) {
420423
Assert.assertEquals( featureIterator.next().getSource(), QUERY_TEST_VCF.getAbsolutePath() );
421424
}
422425
}
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+
}
423437
}
424438

425439
/**************************************************

src/testUtils/java/org/broadinstitute/hellbender/testutils/VariantContextTestUtils.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,7 @@ public static void assertEqualVariants(final List<VariantContext> v1, final List
400400
int numFailed = 0;
401401

402402
for (int i = 0; i < v1.size(); i++) {
403+
// assertVariantContextsAreEqual( v1.get(i), v2.get(i), Collections.emptyList() );
403404
if (! v1.get(i).toStringDecodeGenotypes().equals(v2.get(i).toStringDecodeGenotypes())){
404405
logger.error("Variant Comparison Error: different element (compared by toStringDecodeGenotypes) " + i + ":\n" + v1.get(i) + "\n" + v2.get(i));
405406
passed = false;

0 commit comments

Comments
 (0)