-
Notifications
You must be signed in to change notification settings - Fork 1
/
annotation_stat_snpEff.py
32 lines (26 loc) · 893 Bytes
/
annotation_stat_snpEff.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
#!/usr/bin/python3
import argparse
parser = argparse.ArgumentParser(description="arranges the text output file of SnPeff to include only the gene with canonical transcript. Assumes one gene per file")
parser.add_argument("--inputFile", help="SnpEff text output file")
parser.add_argument("--tag", help="tag")
def parseSnpEff(input_file, tag=""):
with open(input_file, 'r') as snpeff:
lines = snpeff.read().splitlines()
#if tag != "":
mylines=[]
for index,line in enumerate(lines):
if index in [1,2] :
mylines.append( line.split())
if tag != "":
print(tag)
mylines[0].append("Tag")
mylines[1].append(tag)
for line in mylines:
line=[str(element) for element in line]
print(','.join( line ))
if __name__ == "__main__":
args = parser.parse_args()
try:
parseSnpEff(input_file=args.inputFile, tag=args.tag)
except:
parseSnpEff(input_file=args.inputFile)