Repository navigation
fix: stream VCF_TO_CSV instead of retaining every record - #331
Conversation
Discover optional INFO columns in one pass, then reopen the VCF and write one CSV row at a time. Peak memory no longer grows with record count, and the CSV contract stays byte-identical. Fixes adamrtalbot/hap-rs#89
bin/vcf_to_csv.py: two streaming passes, bounded memory. Fixes adamrtalbot/hap-rs#89. Keep nf-core#88 open until executor kill reason is verified. Upstream: nf-core#331.
|
❌ nf-test failed with latest Nextflow versionNote Tests with Nextflow's latest version failed but it will not cause a CI workflow failure.
See the full run for details. |
kubranarci
left a comment
There was a problem hiding this comment.
@VictorDidier is the developer of this script. I guess the changes are good to go but I will ask for his approval.
|
Thanks @adamrtalbot for the fix! |
|
Thanks @adamrtalbot make a PR for this so fast! I think this two-pass approach is the best solution if it is important to maintain the same exact CSV output (maybe @kubranarci or @VictorDidier could give input on this). If not, have you considered a single-pass solution where all extra columns (e.g. SVTYPE) are represented in the CSV, regardless of their presence in the VCF? This would be faster and the output CSV would have the same format regardless of input. |
Honestly, I just made it match as closely as I could! My gut feeling is to merge now to fix the expanding memory, then open a fresh PR for any further improvements. |
|
I have to admit I didn't see the open issue, I found the issue myself while analysing long read VCFs. |
this module doesnt have a csv output https://github.com/nf-core/variantbenchmarking/blob/dev/modules/local/plots/svlen_dist/main.nf, it uses CSV input. As long as it produces understandable plots I am eager to test. |
I guess there were many people affected from this. My tests on big-long vcf files is limited to be honest. |
Sound good to me, just wanted to lift this as something to consider. Happy to go with this solution :) |
|
ok then lets merge this to dev, please let me know if it works fine for you as well @pontushojer |
Description
bin/vcf_to_csv.pykept every(row, info_dict)until EOF, so peak memory grew with the number of records. It now streams the VCF once to learn the header and the five optional-column flags (SUPP_VEC,SUPP,type_inferred,SVTYPE,SVLEN), reopens the same path, and writes one CSV row at a time.The CLI,
parse_info_field,extract_gt_from_sample, and the CSV dialect are unchanged. Output is byte-identical to the previous converter. No workflow, resource, or.nf-core.ymlchanges.Related: adamrtalbot/hap-rs#89
PR checklist
Local check: byte-identical against the previous converter, and
nf-test test modules/local/custom/vcf_to_csv/tests/main.nf.test --profile=+docker(2 passed, existing snapshot unchanged). No new test file; the module snapshot already covers the output contract.nf-core pipelines lint).nextflow run . -profile test,docker --outdir <OUTDIR>).nextflow run . -profile debug,test,docker --outdir <OUTDIR>).docs/usage.mdis updated.docs/output.mdis updated.CHANGELOG.mdis updated.README.mdis updated (including new tool citations and authors/contributors).Docs, changelog, and README are unchanged because the CSV contract is the same.