pysam-developers / pysam

Pysam is a Python package for reading, manipulating, and writing genomics data such as SAM/BAM/CRAM and VCF/BCF files. It's a lightweight wrapper of the HTSlib API, the same one that powers samtools, bcftools, and tabix.
https://pysam.readthedocs.io/en/latest/
MIT License
774 stars 274 forks source link

OSError: [Errno 22] b'Invalid argument' in writing the VCF #1181

Open masterzhen119 opened 1 year ago

masterzhen119 commented 1 year ago

I try to rewrite the vcf file with the following code:

import pysam main_url_saving = '/home/Data/Data/' post_vcf = 'unadjusted.vcf' out_vcf = 'justed.vcf' vcf_file_url = main_url_saving+post_vcf bcf_in = pysam.VariantFile(vcf_file_url) # auto-detect input format bcf_out = pysam.VariantFile(main_url_saving+out_vcf, 'w', header=bcf_in.header) for rec in bcf_in: bcf_out.write(rec)

But I have the titled error. Is there anything wrong? By the way, the original format of vcf is 4.1.