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

Add bcftools validation tests for error conditions #137

Closed
tomwhite opened this issue Feb 10, 2025 · 0 comments · Fixed by #140
Closed

Add bcftools validation tests for error conditions #137

tomwhite opened this issue Feb 10, 2025 · 0 comments · Fixed by #140

Comments

@tomwhite
Copy link
Contributor

Ideally we would match the error text - we could at least do an approximate match, or look for key phrases.

$ bcftools view -i 'INFO/DP > 10' -e 'INFO/DP < 50' ./tests/data/vcf/sample.vcf.gz
Error: only one -i or -e expression can be given, and they cannot be combined

vs

vcztools view -i 'INFO/DP > 10' -e 'INFO/DP < 50' ./vcz_test_cache/sample.vcf.vcz
##fileformat=VCFv4.0
##FILTER=<ID=PASS,Description="All filters passed">
##fileDate=20090805
##source=myImputationProgramV3.1
##reference=1000GenomesPilot-NCBI36
##phasing=partial
##INFO=<ID=NS,Number=1,Type=Integer,Description="Number of Samples With Data">
##INFO=<ID=AN,Number=1,Type=Integer,Description="Total number of alleles in called genotypes">
##INFO=<ID=AC,Number=.,Type=Integer,Description="Allele count in genotypes, for each ALT allele, in the same order as listed">
##INFO=<ID=DP,Number=1,Type=Integer,Description="Total Depth">
##INFO=<ID=AF,Number=.,Type=Float,Description="Allele Frequency">
##INFO=<ID=AA,Number=1,Type=String,Description="Ancestral Allele">
##INFO=<ID=DB,Number=0,Type=Flag,Description="dbSNP membership, build 129">
##INFO=<ID=H2,Number=0,Type=Flag,Description="HapMap2 membership">
##FILTER=<ID=s50,Description="Less than 50% of samples have data">
##FILTER=<ID=q10,Description="Quality below 10">
##FORMAT=<ID=GT,Number=1,Type=String,Description="Genotype">
##FORMAT=<ID=GQ,Number=1,Type=Integer,Description="Genotype Quality">
##FORMAT=<ID=DP,Number=1,Type=Integer,Description="Read Depth">
##FORMAT=<ID=HQ,Number=2,Type=Integer,Description="Haplotype Quality">
##ALT=<ID=DEL:ME:ALU,Description="Deletion of ALU element">
##ALT=<ID=CNV,Description="Copy number variable region">
##contig=<ID=19>
##contig=<ID=20>
##contig=<ID=X>
##vcztools_viewCommand=view -i INFO/DP > 10 -e INFO/DP < 50 ./vcz_test_cache/sample.vcf.vcz; Date=2025-02-10 17:33:36.255776
#CHROM	POS	ID	REF	ALT	QUAL	FILTER	INFO	FORMAT	NA00001	NA00002	NA00003
Traceback (most recent call last):
  File "/Users/tom/miniforge3/envs/vcztools-3.11-m1/bin/vcztools", line 8, in <module>
    sys.exit(vcztools_main())
             ^^^^^^^^^^^^^^^
  File "/Users/tom/miniforge3/envs/vcztools-3.11-m1/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tom/miniforge3/envs/vcztools-3.11-m1/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/Users/tom/miniforge3/envs/vcztools-3.11-m1/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tom/miniforge3/envs/vcztools-3.11-m1/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tom/miniforge3/envs/vcztools-3.11-m1/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tom/workspace/vcztools/vcztools/cli.py", line 219, in view
    vcf_writer.write_vcf(
  File "/Users/tom/workspace/vcztools/vcztools/vcf_writer.py", line 178, in write_vcf
    raise ValueError(
ValueError: Cannot handle both an include expression and an exclude expression.

There are a couple of things wrong with the vcztools output here: there shouldn't be a VCF header, and we should just print an error, not a stacktrace.

#117 is related

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 a pull request may close this issue.

1 participant