-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSameExon.py
67 lines (54 loc) · 1.83 KB
/
SameExon.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/python
import os
import re
import argparse
"""
Louis Chauviere
05/09/2016
Inserm UMR-S 1155
"""
def main():
inputfile, outputfile = commandLine()
fich = open(inputfile, 'r')
out = open(outputfile, 'w')
line_prec = ""
exon_prec = ""
gene_prec = ""
geno_prec = ""
pos_prec = 0
for lines in fich:
matchHeader = re.search(r'Func.refGene', lines)
if matchHeader:
out.write(lines)
else:
line = lines.split("\t")
exon_name = line[9].split(":")[2]
#print exon_name
#print exon_prec
if exon_prec != "":
if exon_name == exon_prec or int(exon_name.split("exon")[1]) == int(exon_prec.split("n")[1]) + 1 or int(exon_name.split("exon")[1]) == int(exon_prec.split("n")[1]) - 1:
if line[6] == gene_prec:
#and line[65].split(":")[0] != geno_prec:
print exon_name
dif = int(line[1]) - pos_prec
if dif <= 100:
out.write(line_prec)
out.write(lines)
line_prec = lines
exon_prec = exon_name
gene_prec = line[6]
geno_prec = line[65].split(":")[0]
pos_prec = int(line[1])
#Use argparse for the command line
def commandLine():
parser = argparse.ArgumentParser()
parser.add_argument('inputfile', action='store', help='Store the input file pathway : Annovar annotated file with in order Father, Mother, Child')
parser.add_argument('outputfile', action='store', help='Store path for the outputfile : same annotated file, but after filtering')
parser.add_argument("-d", "--description", help="Script description", action="store_true")
results = parser.parse_args()
if results.description:
print "Script that will filter an Annotated Annovar file that describe genotypes from a trio (Father, Mother, Child)."
print "It will return variants that can be considered as Compound Heterozygous"
return results.inputfile, results.outputfile
if __name__ == '__main__':
main()