Go Back   SEQanswers > Bioinformatics > Bioinformatics

Similar Threads
Thread Thread Starter Forum Replies Last Post
Bowtie2-build error writing to reference index file cz0013 Bioinformatics 8 08-17-2015 09:31 AM
PyVCF question dktldkrh13 Bioinformatics 0 11-20-2014 10:35 AM
multiple vcf files to one multisampled vcf file Jetse Bioinformatics 2 06-27-2013 05:34 AM
vcflib, a C++ library for reading and writing VCF files ekg Bioinformatics 0 09-29-2010 01:12 PM

Thread Tools
Old 06-24-2017, 11:51 PM   #1
Junior Member
Location: India

Join Date: Jun 2017
Posts: 2
Default Writing VCF File using PyVCF [HELP]

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:

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
    count = count + 1
    if count > 100:

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
ravaan is offline   Reply With Quote
Old 06-25-2017, 03:07 PM   #2
Senior Member
Location: East Coast USA

Join Date: Feb 2008
Posts: 6,961

Looks like the output is specified as (/dev/null = nothing). Change that to a real path/file name e.g. /home/ubuntu/GSoC-Strain_Diffrential/test_modified.vcf.gz
GenoMax is offline   Reply With Quote
Old 06-25-2017, 11:44 PM   #3
Junior Member
Location: India

Join Date: Jun 2017
Posts: 2

I tried that earlier but got some error, tried again worked like charm! Thanks for the help!
ravaan is offline   Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

All times are GMT -8. The time now is 11:13 AM.

Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Single Sign On provided by vBSSO