-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_HG002.py
36 lines (34 loc) · 1.18 KB
/
test_HG002.py
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
from pysam import VariantFile
import sys
def main(vcf_file, out):
testtxt = open(out, 'a')
supp_dict = dict()
vcf_reader = VariantFile(vcf_file, 'r')
tot = 0
for record in vcf_reader.fetch():
supp_vec = record.info['SUPP_VEC']
tot += 1
if supp_vec in supp_dict:
supp_dict[supp_vec] = supp_dict[supp_vec] + 1
else:
supp_dict[supp_vec] = 1
#print('test HG002')
for i in ['001', '011', '101', '111', '110', '010', '100']:
#print(i + ': ' + str(supp_dict[i]))
testtxt.write('%d,'%(supp_dict[i]))
'''
print(supp_dict['001'])
print(supp_dict['011'])
print(supp_dict['101'])
print(supp_dict['111'])
print(supp_dict['110'])
print(supp_dict['010'])
print(supp_dict['100'])
'''
#print(supp_dict['011'] + supp_dict['101'] + supp_dict['110'] + supp_dict['111'])
print((supp_dict['011'] + supp_dict['101'] + supp_dict['110'] + supp_dict['111']) / (tot))
calmdown = supp_dict['011'] + supp_dict['101'] + supp_dict['110'] + supp_dict['111']
testtxt.write('%d,%f\n'%(calmdown, calmdown/tot))
testtxt.close()
if __name__ == '__main__':
main(sys.argv[1], sys.argv[2])