Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parsing missing values in VCF info field doesn't work #1228

Open
davidbenjamin opened this issue Nov 21, 2018 · 1 comment
Open

parsing missing values in VCF info field doesn't work #1228

davidbenjamin opened this issue Nov 21, 2018 · 1 comment
Labels

Comments

@davidbenjamin
Copy link
Contributor

Here's the code for CommonInfo::getAttributeAsDoubleList

public List<Double> getAttributeAsDoubleList(String key, Double defaultValue) {
        return getAttributeAsList(key, x -> {
            if (x == null || x == VCFConstants.MISSING_VALUE_v4) {
                return defaultValue;
            } else if (x instanceof Number) {
                return ((Number) x).doubleValue();
            } else {
                return Double.valueOf((String)x); // throws an exception if this isn't a string
            }
        });

Note that when parsing the vcf the x in this lambda has type Object, and therefore testing x == VCFConstants.MISSING_VALUE_v4 doesn't work i.e. it returns false even when the vcf has the missing field indicator "." To return true int his case you would need ((String) x).equals(VCFConstants.MISSING_VALUE_v4).

@lbergelson This is causing a Mutect2 bug when users use their own gnomAD. I have a workaround but it adds extra vcf parsing to isActive.

@lbergelson lbergelson added the bug label Nov 21, 2018
@pshapiro4broad
Copy link
Contributor

pshapiro4broad commented Nov 26, 2018

The code uses x == VCFConstants.MISSING_VALUE_v4 in a few places; all of these should instead use x.equals(VCFConstants.MISSING_VALUE_v4). (Casting to String is a runtime error if x is another type and equals() doesn't care if you compare different types.)

There's some code duplication here and cases where it doesn't compare against MISSING_VALUE_v4, it would be nice to clean up this code while doing this. E.g. getAttributeAsDouble() and getAttributeAsDoubleList() have the same code (almost) for converting to double.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants