-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmozGoldenPathDmel.py
53 lines (43 loc) · 1.5 KB
/
mozGoldenPathDmel.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/python
#mozGoldenPathDmel.py
#Author: Rachel Wiltshire, U. Notre Dame, June 2021
#Creates multiple alignments (.maf) containing selected mosquito seqs. aligned to Drosophila melanogaster dm6.chr assemblies
#Usage: Give 1 <argument> in addition to the script.py in this format:
#python mozGoldenPathDmel.py <chr.maf>
import sys
if len(sys.argv) !=2:
print ("Error! Give 1 argument.\nUsage: python mozGoldenPathDmel.py <chr.maf>")
sys.exit(0)
maf = open(sys.argv[1], 'r')
mname = sys.argv[1]
mline = maf.readline()
moz_of_interest = ["aegypti", "quinquefasciatus", "epiroticus", "farauti", "farauti_No4", "gambiae", "koliensis",
"punctulatus"]
outfilename = "moz" + mname
outfile = open(outfilename, 'w')
if mline[0] == "#":
outfile.write(mline)
mline = maf.readline()
written = 0
while mline != "":
info_to_write = ""
if mline[0] == 'a':
info_to_write += mline
info_to_write += maf.readline()
mline = maf.readline()
moz_to_write = ""
while mline.strip() != "":
for moz in moz_of_interest:
if moz in mline:
moz_to_write += mline
break
mline = maf.readline()
if moz_to_write != "":
outfile.write(info_to_write + moz_to_write + "\n")
written += 1
if written % 1000 == 0:
print("Written " + str(written) + " scored regions")
mline = maf.readline()
outfile.close()
maf.close()
#END