diff --git a/src/main/java/htsjdk/variant/variantcontext/Genotype.java b/src/main/java/htsjdk/variant/variantcontext/Genotype.java
index a104b0eb1..8d781a0ad 100644
--- a/src/main/java/htsjdk/variant/variantcontext/Genotype.java
+++ b/src/main/java/htsjdk/variant/variantcontext/Genotype.java
@@ -528,7 +528,7 @@ public double getAttributeAsDouble(String key, double defaultValue) {
}
/**
- * A totally generic getter, that allows you to specific keys that correspond
+ * A totally generic getter, that allows you to get specific keys that correspond
* to even inline values (GQ, for example). Can be very expensive. Additionally,
* all int[] are converted inline into List<Integer> for convenience.
*
@@ -556,6 +556,8 @@ public Object getAnyAttribute(final String key) {
return Collections.EMPTY_LIST;
} else if (key.equals(VCFConstants.DEPTH_KEY)) {
return getDP();
+ } else if (key.equals(VCFConstants.GENOTYPE_FILTER_KEY)) {
+ return getFilters();
} else {
return getExtendedAttribute(key);
}
@@ -572,6 +574,8 @@ public boolean hasAnyAttribute(final String key) {
return hasPL();
} else if (key.equals(VCFConstants.DEPTH_KEY)) {
return hasDP();
+ } else if (key.equals(VCFConstants.GENOTYPE_FILTER_KEY)) {
+ return true; //always available
} else {
return hasExtendedAttribute(key);
}
diff --git a/src/test/java/htsjdk/variant/variantcontext/GenotypeUnitTest.java b/src/test/java/htsjdk/variant/variantcontext/GenotypeUnitTest.java
index a698407b8..a447a0bea 100644
--- a/src/test/java/htsjdk/variant/variantcontext/GenotypeUnitTest.java
+++ b/src/test/java/htsjdk/variant/variantcontext/GenotypeUnitTest.java
@@ -30,6 +30,7 @@
import htsjdk.variant.VariantBaseTest;
+import htsjdk.variant.vcf.VCFConstants;
import org.testng.Assert;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;
@@ -63,6 +64,9 @@ public void testFilters() {
Assert.assertEquals(makeGB().filters("x", "y", "z").make().getFilters(), "x;y;z", "Multiple filter field values should be joined with ;");
Assert.assertTrue(makeGB().filters("x", "y", "z").make().isFiltered(), "Multiple filter values should be filtered");
Assert.assertEquals(makeGB().filter("x;y;z").make().getFilters(), "x;y;z", "Multiple filter field values should be joined with ;");
+ Assert.assertEquals(makeGB().filter("x;y;z").make().getAnyAttribute(VCFConstants.GENOTYPE_FILTER_KEY), "x;y;z", "getAnyAttribute(GENOTYPE_FILTER_KEY) should return the filter");
+ Assert.assertTrue(makeGB().filter("x;y;z").make().hasAnyAttribute(VCFConstants.GENOTYPE_FILTER_KEY), "hasAnyAttribute(GENOTYPE_FILTER_KEY) should return true");
+ Assert.assertTrue(makeGB().make().hasAnyAttribute(VCFConstants.GENOTYPE_FILTER_KEY), "hasAnyAttribute(GENOTYPE_FILTER_KEY) should return true");
Assert.assertFalse(makeGB().filter("").make().isFiltered(), "empty filters should count as unfiltered");
Assert.assertEquals(makeGB().filter("").make().getFilters(), null, "empty filter string should result in null filters");
}