-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathselect-retroseq-level678.py
More file actions
58 lines (42 loc) · 1.3 KB
/
select-retroseq-level678.py
File metadata and controls
58 lines (42 loc) · 1.3 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# check levels in VCF, output 6,7,8 calls only
from optparse import OptionParser
###############################################################################
USAGE = """
select-retroseq-level678.py --in <input VCF> --out <output VCF>
Counts calls in each filter levle in RetroSeq VCF and output new VCF
consiting only of calls in level 6,7,8.
"""
parser = OptionParser(USAGE)
parser.add_option('--in',dest='vcfIn', help = 'vcf infput file')
parser.add_option('--out',dest='vcfOut', help = 'vcf out file')
(options, args) = parser.parse_args()
if options.vcfIn is None:
parser.error('vcf input not given')
if options.vcfOut is None:
parser.error('vcf output not given')
###############################################################################
#setup count bins for each level
counts = []
for i in range(0,9):
counts.append(0)
inFile = open(options.vcfIn,'r')
outFile = open(options.vcfOut,'w')
for line in inFile:
if line[0] == '#':
continue
ol = line
line = line.rstrip()
line = line.split()
g = line[-1]
fl = g.split(':')[2]
fl = int(fl)
counts[fl] += 1
if fl >= 6:
outFile.write(ol)
inFile.close()
sum = 0
for i in range(1,9):
sum += counts[i]
print 'flag %i\t%i' % (i,counts[i])
print 'Total\t%i' % sum
outFile.close()