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

Fix writing of Number=A and G INFO/FORMAT fields #53

Merged
merged 4 commits into from Jun 25, 2012

Conversation

lennax
Copy link

@lennax lennax commented Jun 20, 2012

Currently, the Reader stores field Numbers of A and G as negative integers, and the Writer doesn't convert them back to letters.

To make it easier to reverse the cast to integer, I changed the conversion method. Instead of converting using hard-coded if/elif, I've made a module-level dictionary for both conversion and reversal lookup. I'm using if/else because I've read that it's faster than try/except if the check is expected to fail over half the time, and I put if not first because it's more likely.

For writing the header fields, I switched to use str.format() (instead of C-style) and added a method that uses the conversion dictionary to switch the integers back to the correct letters.

In the third commit I removed the '.' if None str() _mapped to each line. The dictionary handles None to '.' for the Number field. As far as I can tell from the spec, only Number is allowed to have a value of '.' -- if this is incorrect this commit can be skipped.

@lennax
Copy link
Author

lennax commented Jun 21, 2012

Added another commit to write a None alt as '.'

Current logic is str(x) or '.' but str(None) evaluates to 'None' which is True.

jamescasbon pushed a commit that referenced this pull request Jun 25, 2012
Fix writing of Number=A and G INFO/FORMAT fields
@jamescasbon jamescasbon merged commit 880ce55 into jamescasbon:master Jun 25, 2012
gotgenes pushed a commit to gotgenes/PyVCF that referenced this pull request May 13, 2014
Fix writing of Number=A and G INFO/FORMAT fields
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

Successfully merging this pull request may close these issues.

None yet

2 participants