5 # @I321_1_FC30BBUAAXX:2:1:4:1436/1
10 for i
in xrange(65,91):
12 for i
in xrange(97,123):
15 for (key
, value
) in code
.iteritems():
22 for i
in xrange(63,-1,-1):
23 bin
+= str((integer
>>i
)&1)
25 #regexpNew = re.compile("@FC(\w{1,5})AAXX:(\d):(\d+):(-?\d+):(-?\d+)#[01]/?([12]?)")
26 regexpOld
= re
.compile("@(\w+)_FC(\w{1,5})AAXX:(\d):(\d+):(-?\d+):(-?\d+)/?([12]?)")
27 #regexpNew = re.compile("@FC(\w{1,5})AAXX:(\d):(\d+):(-?\d+):(-?\d+)#[01]/?([12]?)")
28 regexpNew
= re
.compile("@FC(\w{1,5})AAXX:(\d):(\d+):(-?\d+):(-?\d+)#\w+/?([12]?)")
32 if re
.match(regexpNew
, line
).groups():
33 data
=re
.match(regexpNew
, line
).groups()
34 elif re
.match(regexpOld
, line
).groups():
35 data
=re
.match(regexpOld
, line
).groups()
36 except AttributeError:
40 if re
.match(regexpNew
, line
).groups():
41 if type(data
) == None:
42 print >>sys
.stderr
, "The FASTQ header cannot be recognized\n",line
45 ( fc
, lane
, tile
, x
, y
) = data
47 ( fc
, lane
, tile
, x
, y
, pe
) = data
49 print >>sys
.stderr
, "The FASTQ header cannot be recognized\n",line
51 elif re
.match(regexpOld
, line
).groups():
52 if type(data
) == None:
53 print >>sys
.stderr
, "The FASTQ header cannot be recognized\n",line
56 (machine
, fc
, lane
, tile
, x
, y
) = data
58 (machine
, fc
, lane
, tile
, x
, y
, pe
) = data
60 print >>sys
.stderr
, "The FASTQ header cannot be recognized\n",line
64 fc_num
= (fc_num
<<6)|code
[char
]
65 #print fc_num,int2bin(fc_num)
66 (lane
, tile
, x
, y
) = map(int, (lane
, tile
, x
, y
))
71 #print "FC"+fc+"AAXX",lane,tile,x,y,pe
72 lane
-=1; tile
-=1;#pe-=1
73 assert lane
<8 and tile
<512 and x
< 4096 and y
< 4096 #and pe<2
74 info
= (lane
<<34)|
(tile
<<25)|
(x
<<13)|
(y
<<1)|
1
75 #print info,int2bin(info)
76 part1
= (fc_num
<<34)|
(info
>>3&(~
(~
0<<34)))
77 #print part1,int2bin(part1)
78 part2
= (ver
<<3)|
(info
&7)
79 #print part2,int2bin(part2)
82 code_string
+= rev_code
[part2
% 62]
84 #print part2,code_string
87 code_string
+= rev_code
[part1
% 62]
89 #print part1,code_string
90 code_string
+= ("/"+pe
)
93 def decode(code_string
):
96 for char
in code_string
[::-1]:
100 part1
= part1
*62+code
[char
]
102 part2
= part2
*62+code
[char
]
104 fc_num
= (part1
>>34)&(~
(~
0<<30))
106 lane
= ((part1
>>31)&7)+1
107 tile
= ((part1
>>22)&511)+1
109 y
= (part1
&1023)<<2|
((part2
>>1)&3)
113 fc
= rev_code
[fc_num
&63] + fc
115 #print "FC"+fc+"AAXX",lane,tile,x,y,pe
118 fastq
= open(sys
.argv
[1])
119 output
= open(sys
.argv
[2],"w")
121 print >>sys
.stderr
, "python",sys
.argv
[0],"FASTQ OUTPUT"
124 print >>sys
.stderr
, "No such file or directory:",sys
.argv
[1]
130 if line_count
% 4 == 1:
134 elif line_count
% 4 == 3:
137 print >>output
, line
.rstrip()