-
Notifications
You must be signed in to change notification settings - Fork 2
/
polarise_wga_ref_indels.py
executable file
·53 lines (37 loc) · 1.09 KB
/
polarise_wga_ref_indels.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env python
from __future__ import print_function
import sys
from wga_bed_indels import unique_to_ref
import argparse
def indel_type(wga_line):
"""
takes a wga bed line and returns indel type
:param wga_line: str
:return: bool
"""
# get sequence column
seqs = wga_line.split()[7].split(',')
# catch non indel lines
if len(seqs[0]) == 1:
return 'non_indel'
# process indel lines
elif not unique_to_ref(seqs):
return 'ambig_indel'
# process ref specific indels
else:
ref_seq = seqs[0]
if '-' in ref_seq:
return 'deletion'
else:
return 'insertion'
def main():
parser = argparse.ArgumentParser()
parser.add_argument('-indel_type', help='type of indel to output',
choices=['non_indel', 'ambig_indel', 'deletion', 'insertion'],
required=True)
args = parser.parse_args()
for line in sys.stdin:
if indel_type(line) == args.indel_type:
print(line.rstrip())
if __name__ == '__main__':
main()