-
Notifications
You must be signed in to change notification settings - Fork 0
/
rm_rRNAhits.py
executable file
·52 lines (45 loc) · 1.13 KB
/
rm_rRNAhits.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
#!/usr/bin/python
import sys, os, csv
"""rm_rRNAhits.py: takes a list of files to remove hits from and a list of the
contig and coordinates that hits should be removed from"""
__author__ = "Sarah Stevens"
__email__ = "[email protected]"
def usage():
print "Usage: rm_rRNAhits.py blastfilelist toremovelist"
sys.exit(2)
if len(sys.argv) != 3:
usage()
exit()
blastfile=open(sys.argv[1], 'rU')
blastlist=blastfile.readlines()
tormfile=open(sys.argv[2], 'rU')
torm=tormfile.readlines()
torm_contigs=[]
for line in torm:
torm_contigs.append(line.split('\t')[0])
for file in blastlist:
file=file.split('\n')[0]
blast=open(file, 'rU')
blast=blast.readlines()
output=open(file+".norrna",'w')
for line in blast:
line_s=line.split('\t')
hstart=int(line_s[8])
hend=int(line_s[9])
name=line_s[1]
if name in torm_contigs:
match=""
for row in torm:
row_s=row.split('\n')[0].split('\t')
if row_s[0]==name:
rstart=int(row_s[1])
rend=int(row_s[2])
if (rstart < hstart < rend) or (rstart < hend < rend):
break
else:
output.write(line)
else:
continue
else:
output.write(line)
output.close()