cnvkit icon indicating copy to clipboard operation
cnvkit copied to clipboard

IO test fails on nosample.vcf file

Open jbedo opened this issue 3 years ago • 2 comments

I'm encountering an issue running the IO tests bundled with cnvkit 0.9.9. The VCF IO test seems to partially succeed but ultimately fail on the nosample.vcf file. Log below:

Read the UCSC 'refFlat' format. ... ok
test_read_seg (__main__.IOTests)
Read the SEG format. ... ok
test_read_text (__main__.IOTests)
Read the text region format. ... ok
test_read_vcf (__main__.IOTests)
Read the VCF format. ... [E::bcf_hdr_parse_sample_line] Could not parse the "#CHROM.." line, either FORMAT is missing or spaces are present instead of tabs:
        #CHROM  POS     ID      REF     ALT     QUAL    FILTER  INFO    FORMAT

ERROR

======================================================================
ERROR: test_read_vcf (__main__.IOTests)
Read the VCF format.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "pysam/libcbcf.pyx", line 4292, in pysam.libcbcf.VariantFile.open
  File "pysam/libcbcf.pyx", line 2193, in pysam.libcbcf.makeVariantHeader
ValueError: cannot create VariantHeader

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/nix/store/7ah3c6j14m8q86b5p2y40fpjh5xqqb1r-python3.9-CNVkit-0.9.9/lib/python3.9/site-packages/skgenome/tabio/vcfio.py", line 28, in read_vcf
    vcf_reader = pysam.VariantFile(infile)
  File "pysam/libcbcf.pyx", line 4054, in pysam.libcbcf.VariantFile.__init__
  File "pysam/libcbcf.pyx", line 4294, in pysam.libcbcf.VariantFile.open
ValueError: file `b'formats/nosample.vcf'` does not have valid header (mode=`b'r'`) - is it VCF/BCF format?

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/build/source/test/test_io.py", line 115, in test_read_vcf
    v4 = tabio.read('formats/nosample.vcf', 'vcf')
  File "/nix/store/7ah3c6j14m8q86b5p2y40fpjh5xqqb1r-python3.9-CNVkit-0.9.9/lib/python3.9/site-packages/skgenome/tabio/__init__.py", line 74, in read
    dframe = reader(infile, **kwargs)
  File "/nix/store/7ah3c6j14m8q86b5p2y40fpjh5xqqb1r-python3.9-CNVkit-0.9.9/lib/python3.9/site-packages/skgenome/tabio/vcfio.py", line 30, in read_vcf
    raise ValueError("Must give a VCF filename, not open file handle: %s"
ValueError: Must give a VCF filename, not open file handle: file `b'formats/nosample.vcf'` does not have valid header (mode=`b'r'`) - is it VCF/BCF format?

----------------------------------------------------------------------
Ran 10 tests in 11.981s

FAILED (errors=1)

jbedo avatar Jan 01 '22 04:01 jbedo

We started seeing this in the cnvkit NixOS package when we moved from pysam 0.17.0 to 0.18.0. Full build log including failure: https://hydra.nixos.org/log/4xh8l9vv6gm4lgjglb033aaa414bn8sb-python3.10-CNVkit-0.9.7.drv

Same error if we try with 0.9.9

risicle avatar May 29 '22 19:05 risicle

This error was only added in 0.18.0 https://github.com/pysam-developers/pysam/commit/6a170cfaa0ab562e2ae597a383f5c5134818d23e#diff-93a78e45fea134d909b59bf25d4e6394bfdbbc27f95bd28a381a856ceb03195f

risicle avatar May 29 '22 20:05 risicle