-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathgetBLASThitsbyquery.py
More file actions
64 lines (55 loc) · 1.62 KB
/
Copy pathgetBLASThitsbyquery.py
File metadata and controls
64 lines (55 loc) · 1.62 KB
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
import sys
infile = open(sys.argv[1], 'r')
outfile = open(sys.argv[2], 'w')
previousQuery = ''
hitdict = {}
for line in infile:
line = line.split("\t")
query = line[0]
hit = line[1]
if query in hitdict.keys():
if hit not in hitdict[query]:
hitdict[query].append(hit)
else:
if len(hitdict) > 0:
for hit in hitdict:
outfile.write("%s\t%s\n" % (hit, ', '.join(hitdict[hit])))
hitdict = {}
hitdict[query] = [hit]
#get the last one
for hit in hitdict:
outfile.write("%s\t%s\n" % (hit, ', '.join(hitdict[hit])))
# while(query == previousQuery):
# if query in hitdict.keys():
# if hit not in hitdict[query]:
# hitdict[query].append(hit)
# else:
# hitdict[query] = [hit]
# try:
# line = infile.readline()
# line = line.split("\t")
# previousQuery = query
# query = line[0]
# hit = line[1]
# except StopIteration:
# break
# for line in infile:
# line = line.split("\t")
# query = line[0]
# hit = line[1]
# previousQuery = query
#
# while(query == previousQuery):
# if query in hitdict.keys():
# if hit not in hitdict[query]:
# hitdict[query].append(hit)
# else:
# hitdict[query] = [hit]
# try:
# line = infile.next()
# line = line.split("\t")
# previousQuery = query
# query = line[0]
# hit = line[1]
# except StopIteration:
# break