I am trying to extract positions and SNPs from a VCF file. I have written the following so far. But how can I change the name of the dictionary so that I end up with one dictionary for each input file?
i.e.: python vcf_compare.py file1.vcf file2.vcf file3.vcf
import sys
import vcf
for variants in sys.argv[1:]:
file1 = {}
vcf_reader = vcf.Reader(open(variants))
for record in vcf_reader:
pos = record.POS
alt = record.ALT
ref= record.REF
snps[pos]=ref,alt
so for argv[1] a dictionary called file1 is created. How can I make the dictionary change name to e.g. file two for the second iteration of the loop?