fix: writeVcf preserves fileDate and suppresses bare contig lines (#78)#101
Open
jmg421 wants to merge 1 commit into
Open
fix: writeVcf preserves fileDate and suppresses bare contig lines (#78)#101jmg421 wants to merge 1 commit into
jmg421 wants to merge 1 commit into
Conversation
…oconductor#78) Two changes to improve writeVcf + readVcf round-trip fidelity: 1. Preserve existing fileDate: writeVcf no longer unconditionally replaces the fileDate header with the current date. If a fileDate exists in the VCF metadata, it is written as-is. A new fileDate is only added when none exists. 2. Suppress uninformative contig lines: when seqinfo has all-NA seqlengths and all-NA genomes (e.g., structural variants with unknown assembly), writeVcf no longer emits bare ##contig=<ID=X> lines that carry no useful information and break round-trip equality. Together these fixes allow: all.equal(readVcf(writeVcf(x, out)), x) == TRUE for all package example VCFs (structural.vcf, ex2.vcf). Closes Bioconductor#78
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
Fixes #78.
Achieves faithful
writeVcf()+readVcf()round-trips by addressing both sources of metadata discrepancy reported in the issue.Changes
1. Preserve existing fileDate
writeVcf()previously unconditionally replaced thefileDateheader withSys.time(). Now it preserves any existing fileDate value, only adding a new one when none exists. This retains provenance information (e.g., the original VCF creation date).2. Suppress uninformative contig lines
When
seqinfo()contains only NA seqlengths and NA genomes (common for structural variant VCFs),writeVcf()no longer emits bare##contig=<ID=X>lines. These lines carry no useful information and were the primary cause of round-trip mismatches — on re-read, they altered the header structure (added a contig slot that didn't exist in the original).Result
Testing
test_writeVcf_roundtrip_issue78verifying perfect round-trips for bothstructural.vcf(all-NA seqinfo) andex2.vcf(real seqinfo with contig lines).Agentic tooling disclosure
This PR was produced with the assistance of Kiro CLI (Amazon's AI coding agent). All changes were reviewed and verified by the author.