fix: recover VCF INFO fields around malformed tokens#156
Merged
nvictus merged 6 commits intoabdenlab:mainfrom Feb 16, 2026
Merged
fix: recover VCF INFO fields around malformed tokens#156nvictus merged 6 commits intoabdenlab:mainfrom
nvictus merged 6 commits intoabdenlab:mainfrom
Conversation
Real-world VCFs such as Ensembl variation files contain double semicolons (`;;`) in the INFO column. The previous approach called `info.get()` per field, which scans from the beginning each time and aborts at the first tokenization error, silently nullifying all fields past the error and printing noisy stderr messages. Replace per-field `info.get()` with a single `info.iter()` pass that collects all successfully parsed fields into a HashMap. The noodles iterator advances past malformed tokens, so fields on both sides of `;;` are now recovered. This also improves performance by scanning the INFO string once instead of N times per record. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
nvictus
reviewed
Feb 16, 2026
| info: &'a dyn noodles::vcf::variant::record::Info, | ||
| header: &'a noodles::vcf::Header, | ||
| ) -> HashMap<&'a str, Option<InfoFieldValue<'a>>> { | ||
| info.iter(header) |
Member
There was a problem hiding this comment.
It's unfortunate that this requires parsing all the fields, but it doesn't look like noodles provide an alternative to tokenize without parsing.
nvictus
reviewed
Feb 16, 2026
nvictus
reviewed
Feb 16, 2026
nvictus
reviewed
Feb 16, 2026
nvictus
approved these changes
Feb 16, 2026
Member
There was a problem hiding this comment.
Overall, this looks good to me. Thank you!
One issue is that we now swallow tokenization and parse errors as null values. I agree that the eprintlns were noisy, but just a mental note that it would be good to provide a way to emit something in the future, or perhaps use a sentinel value to distinguish "no value" from "failed to parse".
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
info.get()calls with a singleinfo.iter()pass that collects all successfully parsed INFO fields into a HashMap;;) are now recovered instead of being silently nullifiedeprintln!stderr messages that fired once per record per failing fieldContext
Real-world VCFs such as Ensembl variation files contain records with double semicolons (
;;) in the INFO column:The previous code called
info.get(&header, &field_name)for each defined INFO field. Under the hood, noodles'get()scans the raw INFO string from the beginning each time and aborts at the first tokenization error. This caused:;;(e.g.MA,MAF,MAC,AA) to return nullCOSMIC_101,ClinVar_*,CLIN_*) to also error, since the scan would hit;;before reaching the endError parsing INFO field: "..."for every affected (record, field) pairThe fix uses
info.iter()which advances past malformed tokens and continues parsing. All parseable fields are collected in a single pass, then looked up by name.Test plan
test_push_vcf_record_with_double_semicolons_in_info— verifies fields before and after;;are both recovered (not null)-D warnings)homo_sapiens-chr1.vcf.gz🤖 Generated with Claude Code