I am using PyVCF to read a VCF file, modify the data, and write this modified data either to the old file or to a new file. As given in their documentation I am using the vcf.Writer function to create a wrtieStream and write the file, code here:
The code is running without any errors, but no changes are written to the file (The original file remains unchanged and no new file is created).
Any help is highly appreciated.
The complete code is provided here
Code:
vcf_reader = vcf.Reader(open('/home/ubuntu/GSoC-Strain_Diffrential/test.vcf.gz')) # code to modify the data vcf_writer = vcf.Writer(open('/dev/null', 'w'), vcf_reader) count = 1 record = next(vcf_reader) REF_list = [record.CHROM] for record in vcf_reader: print record.REF, record.POS record.REF = 'C' print record.REF REF_list.extend([record.POS]) vcf_writer.write_record(record) vcf_writer.flush() count = count + 1 if count > 100: break
The code is running without any errors, but no changes are written to the file (The original file remains unchanged and no new file is created).
Any help is highly appreciated.
The complete code is provided here
Comment