-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathgetSNPcountByPos.py
More file actions
39 lines (35 loc) · 1.03 KB
/
getSNPcountByPos.py
File metadata and controls
39 lines (35 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import sys
from collections import defaultdict
#infile = open(sys.argv[1], 'r')
outfile = open("testsnpdepth.txt", 'w')
genedict = defaultdict(lambda: defaultdict(int))
for n in sys.argv[1:]:
infile = open(n, 'r')
for line in infile:
if line.startswith("#"):
continue
line = line.split("\t")
gene = line[0].strip()
pos = int(line[1].strip())
info = line[7]
info = info.split(";")
depth = info[0].split("=")
depth = int(depth[1])
#ref = line[2]
#alt = line[3]
# try:
# alt = alt.split(",")
# for snp in alt:
# genedict[gene].append(snp)
# except:
# genedict[gene][pos] += 1
if depth < 5:
continue
else:
genedict[gene][pos] += 1
infile.close()
for gene in genedict:
outfile.write("%s\t" % gene)
for position in genedict[gene]:
outfile.write("%s\t%s\t" %(position,genedict[gene][position]) )
outfile.write("\n")