@@ -13,7 +13,6 @@ def chunk(fastq, platform_unit, lines_per_chunk, num_pieces):
13
13
output_prefix = "-" .join (exploded )
14
14
while lines_per_chunk % 4 != 0 :
15
15
lines_per_chunk += 1
16
- fh = io .BufferedReader (gzip .open (fastq , "rb" ))
17
16
output_file_count = 0
18
17
output_file_lines = 0
19
18
#these aren't relaly gz but trimgalore doesnt like files not named gz...great work trimgalore
@@ -24,17 +23,19 @@ def chunk(fastq, platform_unit, lines_per_chunk, num_pieces):
24
23
for line in os .popen ("zcat < " + fastq ):
25
24
lines .append (line )
26
25
output_file_lines += 1
27
- if output_file_lines == lines_per_chunk :
26
+ if output_file_lines == lines_per_chunk and int ( num_pieces ) > 1 :
28
27
if (output_file_count < int (num_pieces )- 1 ):
29
28
output_file_lines = 0
30
- ofh .write ("" .join (lines ))
29
+ for l in lines :
30
+ ofh .write (l )
31
31
ofh .close ()
32
32
lines = list ()
33
33
output_file_count += 1
34
34
filename = output_prefix + "chunk{:0>3d}" .format (output_file_count ) + ".fastq.gz"
35
35
logger .info ("Opening %s and writing reads..." % (filename ))
36
36
ofh = gzip .open (filename , "wb" , 1 )
37
- ofh .write ("" .join (lines ))
37
+ for l in lines :
38
+ ofh .write (l )
38
39
ofh .close ()
39
40
return True
40
41
@@ -52,7 +53,7 @@ if __name__ =='__main__':
52
53
fastqs .append (args .fastq2 )
53
54
filesize = os .path .getsize (fastqs [0 ])
54
55
logger .info ("Fastq1 Filesize: %sGB" % ("{:.2f}" .format (float (filesize )/ 1000000000 )))
55
- num_pieces = math .ceil (float (filesize )/ 350000000 )
56
+ num_pieces = math .ceil (float (filesize )/ 2800000000 )
56
57
logger .info ("Splitting into %s pieces" % "{:.0f}" .format (num_pieces ))
57
58
num_lines = sum (1 for line in os .popen ("zcat " + fastqs [0 ]))
58
59
lines_per_chunk = math .ceil (float (num_lines ) / int (num_pieces ))
@@ -62,16 +63,3 @@ if __name__ =='__main__':
62
63
result = pool .apply_async (chunk , args = (fastq , args .platform_unit , lines_per_chunk , num_pieces , ))
63
64
pool .close ()
64
65
pool .join ()
65
-
66
-
67
-
68
-
69
-
70
-
71
-
72
-
73
-
74
-
75
-
76
-
77
-
0 commit comments