Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Followup work to #34.
I tried to tackle the task of INFO field description scraping requested in #33. Found rust-htslib pretty ill-equipped for the task, but I'm way too much of a rust/c novice to delve deeply into the core of htslib. This could perhaps be done better using
bcf_hdr_get_hrec
.In the end I made a short function to filter down the
HeaderRecord vector
using anID
value. Since there should only ever be one INFO header record with a particular ID, I return the description from the first of the remaining records. If it's not there I pass along the default value. On the way out I make sure to trim the"
since theupdate_header
function expects the descriptions to be unquoted.In the
encoder_main
function I only call this function when thefield
description
is not the default. I figure we'd want to give user priority in field naming.As for how the check against the default is done, I couldn't really figure out how to get a default value for a field the way things were so I went ahead and made the
fields::default_description_string()
function public. I'm not sure if that's a good way of doing that so I'm open to suggestions.Let me know if this is fine. Feel free to discard the PR if you want to go about this a different way.