Entering edit mode
8.2 years ago
kirannbishwa01
★
1.6k
I want to read the vcf file using pyvcf and output the values in a table format.
This is what I have done:
!/home/everestial007/anaconda2/bin/python
import vcf
pop1_data = vcf.Reader(open('raw01_variantsMY.vcf', 'r'))
pop2_data = vcf.Reader(open('raw01_variantsSP.vcf', 'r'))
record1 = next(pop1_data)
record2 = next(pop2_data)
alt_freqPop1 = record1.INFO['AF']
alt_freqPop2 = record1.INFO['AF']
ref_freqPop1 = 1-[alt_freqPop1]
ref_freqPop2 = 1-[alt_freqPop2]
print alt_freqPop1 **# this line prints**
print ref_freqPop1 **# this line isnot printing and receiving an error message**
Another problem:
I also want to print the values for all the lines in vcf
*print record1.CHROM, record1.POS, record1.ID, record1.REF, record1.ALT, record1.INFO['AF']*
But, this is printing only one line.