@@ -252,14 +252,16 @@ process get_fastq_files_single {
252
252
val samplename from sample_list_dirse. flatMap{ it. readLines() }
253
253
output :
254
254
set val(samplename), file(" ${ samplename} .fastq.gz" ) optional true into ch_fastqs_dirse
255
+ file(' numreads.txt' ) optional true into ch_numreads_fastq_se
255
256
script :
256
257
"""
257
258
name=${ params.fastqdir} /${ samplename} .fastq.gz
258
259
if [[ ! -e \$ name ]]; then
259
- echo "Count file \$ name not found"
260
+ echo "Fastq file \$ name not found"
260
261
false
261
262
else
262
263
ln -s \$ name .
264
+ echo \$ (( \$ (zcat \$ fname | wc -l) / 4)) > numreads.txt
263
265
fi
264
266
"""
265
267
}
@@ -275,14 +277,19 @@ process get_fastq_files {
275
277
val samplename from sample_list_dirpe. flatMap{ it. readLines() }
276
278
output :
277
279
set val(samplename), file(" ${ samplename} _?.fastq.gz" ) optional true into ch_fastqs_dirpe
280
+ file(' numreads.txt' ) optional true into ch_numreads_fastq
278
281
script :
279
282
"""
280
283
list=( \$ (ls ${ params.fastqdir} /${ samplename} _{1,2}.fastq.gz) )
281
284
if [[ 2 == \$ {#list[@]} ]]; then
282
- ln -s \$ {list[0]} .
283
- ln -s \$ {list[1]} .
285
+ f1=\$ {list[0]}
286
+ f2=\$ {list[1]}
287
+ ln -s \$ f1 .
288
+ ln -s \$ f2 .
289
+ echo \$ (( \$ (zcat \$ f1 | wc -l) / 2)) > numreads.txt
290
+ # TODO: we could do the same for f2 and introduce check. #shouldWe?
284
291
else
285
- echo "Count mismatch sample ${ samplename} found (\$ {list[@]})"
292
+ echo "File count error sample ${ samplename} found (\$ {list[@]})"
286
293
false
287
294
fi
288
295
"""
@@ -301,7 +308,7 @@ process crams_to_fastq {
301
308
output :
302
309
set val(samplename), file(" ${ samplename} _?.fastq.gz" ) optional true into ch_fastqs_irods
303
310
file(' *.lostcause.txt' ) optional true into ch_lostcause_cram
304
- file(' numreads.txt' ) optional true into ch_numreads
311
+ file(' numreads.txt' ) optional true into ch_numreads_crams
305
312
script :
306
313
307
314
// 0.7 factor below: see https://github.com/samtools/samtools/issues/494
929
936
"""
930
937
}
931
938
932
- ch_numreads
939
+ ch_numreads_crams
940
+ .mix(ch_numreads_fastq, ch_numreads_fastq_se)
933
941
.map { it. text. trim(). toBigInteger() }
934
942
.sum()
935
943
.subscribe{ n_numreads = it }
0 commit comments