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

Return missing values mask for Integer INFO/FORMAT fields #195

Open
tomwhite opened this issue Mar 9, 2021 · 2 comments
Open

Return missing values mask for Integer INFO/FORMAT fields #195

tomwhite opened this issue Mar 9, 2021 · 2 comments

Comments

@tomwhite
Copy link
Collaborator

tomwhite commented Mar 9, 2021

Missing values for Integer INFO/FORMAT fields are represented by the minimum int32 value (-2147483648, or np.iinfo(np.int32).min). It would be nice if a mask array could be retrieved that didn't rely on checking for this value, but that looked for missing values in the original VCF field.

This would be useful for Flag (boolean) fields too.

@timothymillar
Copy link
Contributor

The value -2147483648 comes from interpreting the bytes of the reserved 'missing' value b'\x80\x00\x00\x00' as an integer.
Within cyvcf2.pyx it should be able to do this using the bcf_int32_missing constant, this is similar to using bcf_int32_vector_end in #169.

@tomwhite
Copy link
Collaborator Author

Thanks @timothymillar. Reading the spec more closely I see that it says

For the Integer type, the values from −2^31 to −2^31 + 7 cannot be stored in the binary version and therefore are disallowed in both VCF and BCF, see 6.3.3.

So there is no danger of confusing missing values with the literal value -2147483648 in the field (since the latter is not allowed). (When I opened this issue I thought there was such a danger.)

It still might be useful to provide a mask in cyvcf2, since getting the logic right is slightly tricky (because of the range of values).

Also, for Flag fields, I don't think there's a problem, since Flag only applies to INFO fields, and they return tuples, not NumPy arrays.

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

No branches or pull requests

2 participants