Entering edit mode
8.3 years ago
larafrommer
•
0
Hi all I am supposed to use a Python script to identify possible SNPs at specified positions from a csv file in vcf files. Sadly I always get followig Error :
Traceback (most recent call last):
File "getSNPs.py", line 20, in <module>
oo = line[2] + "_" + line[3]
IndexError: list index out of range from the following script :
# !/bin/python
# usage: python getSNPs.py your.vcf PhenoSNPs.csv
# uses a lot of RAM
import sys
import gzip
SNPs = {}
for I in gzip.open(sys.argv[1], "r"):
if '#' not in i:
line = i.split("\t")
oo = line[0] + "_" + line[1]
SNPs[oo] = i
pp = sys.argv[1] + ".captureSNPs"
out = open(pp, "w")
for I in open(sys.argv[2], "r"):
line = i.split(";")
oo = line[2] + "_" + line[3]
try:
out.write(SNPs[oo])
except KeyError:
ow = line[2] + "\t" + line[3] + "\t" + "not covered" + "\n"
out.write(ow)