-
Notifications
You must be signed in to change notification settings - Fork 0
/
mapper.py
executable file
·47 lines (42 loc) · 964 Bytes
/
mapper.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
#!/usr/bin/python
import sys
import re
import hashlib
def read_input(files):
for line in files:
yield line.strip()
sep = sys.argv[1]
if sep == 'space':
sep=' '
elif sep == 'none':
sep=None
mate = sys.argv[2]
#print 'the sep is', sep
def main(sep):
list =[]
# read FASTQ file using python iterators
lines = read_input(sys.stdin)
nLines=0; tmp=100
while True:
line = next(lines)
nLines+=1
if (line[0] == '@'): tmp = nLines
elif (line[0] == '+'):
if nLines - tmp == 2: break
next(lines)
while True:
try:
line = next(lines)
line = ''.join(line.split('.'))
if sep:
list.append('@'+ hashlib.sha1(''.join(line.split(sep)[0])).hexdigest()+mate)
else:
list.append('@'+hashlib.sha1(line).hexdigest() +mate)
list.append(next(lines))
_=next(lines)
list.append(next(lines))
except StopIteration: break
print "%s\t%s\t%s" % (list[0], list[1], list[2])
list = []
if __name__ == "__main__":
main(sep)