Skip to content

Commit

Permalink
Merge pull request #38 from hoelzer/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
MarieLataretu authored Jun 23, 2021
2 parents 96520f2 + 5b8f1a5 commit 011481d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 29 deletions.
9 changes: 5 additions & 4 deletions assets/multiqc_config.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
custom_data:
mapping:
file_format: 'tsv'
section_name: 'Mapping statistics'
anchor: 'mapping'
section_name: 'Contamination statistics'
description: "Mapped and unmapped reads (or contigs) for the mapping result against the contamination. Short and sweet: mapped = contamination."
anchor: 'contamination'
plot_type: 'bargraph'
pconfig:
id: 'Mapping'
title: 'Mapping statistics'
id: 'Contamination'
title: 'Contamination statistics'

sp:
quast:
Expand Down
40 changes: 20 additions & 20 deletions clean.nf
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ include { download_host; check_own; concat_contamination } from './modules/get_h
include { minimap2_fasta; minimap2_nano; minimap2_illumina } from './modules/minimap2'
include { bbduk } from './modules/bbmap'

include { rename_reads; restore_reads; get_number_of_reads; minimap2Stats; bbdukStats; writeLog } from './modules/utils'
include { compress_reads; get_number_of_reads; minimap2Stats; bbdukStats; writeLog } from './modules/utils'

include { fastqc; nanoplot; format_nanoplot_report; quast; multiqc } from './modules/qc'

Expand Down Expand Up @@ -272,16 +272,16 @@ workflow clean_nano {
.mix(rRNAChannel).collect()
concat_contamination( nano_input_ch.map{ it -> it[0] }, 'minimap2', contamination )
}
rename_reads(nano_input_ch, 'single')
minimap2_nano(rename_reads.out, concat_contamination.out.fa)
// rename_reads(nano_input_ch, 'single')
minimap2_nano(nano_input_ch, concat_contamination.out.fa)
writeLog(nano_input_ch.map{ it -> it[0] }, 'minimap2', nano_input_ch.map{ it -> it[1] }, contamination)
get_number_of_reads(rename_reads.out, 'single')
get_number_of_reads(nano_input_ch, 'single')
minimap2Stats(minimap2_nano.out.idxstats.join(get_number_of_reads.out))
restore_reads(minimap2_nano.out.cleaned_reads.concat(minimap2_nano.out.contaminated_reads), 'single', 'minimap2')
compress_reads(minimap2_nano.out.cleaned_reads.concat(minimap2_nano.out.contaminated_reads), 'single', 'minimap2')
emit:
stats = minimap2Stats.out.tsv
in = nano_input_ch.map{ it -> it.plus(1, 'all') }
out = restore_reads.out
out = compress_reads.out
}

workflow clean_illumina {
Expand All @@ -306,25 +306,25 @@ workflow clean_illumina {
.mix(rRNAChannel).collect()
concat_contamination( illumina_input_ch.map{ it -> it[0] }, params.bbduk ? 'bbduk' : 'minimap2', contamination )
}
rename_reads(illumina_input_ch, 'paired')
// rename_reads(illumina_input_ch, 'paired')
if (params.bbduk){
bbduk(rename_reads.out, concat_contamination.out.fa, 'paired')
bbduk(illumina_input_ch, concat_contamination.out.fa, 'paired')
writeLog(illumina_input_ch.map{ it -> it[0] }, 'bbduk', illumina_input_ch.map{ it -> it[1] }, contamination)
bbdukStats(bbduk.out.stats)
restore_reads(bbduk.out.cleaned_reads.concat(bbduk.out.contaminated_reads), 'paired', 'bbduk')
compress_reads(bbduk.out.cleaned_reads.concat(bbduk.out.contaminated_reads), 'paired', 'bbduk')
stats = bbdukStats.out.tsv
} else {
minimap2_illumina(rename_reads.out, concat_contamination.out.fa, 'paired')
minimap2_illumina(illumina_input_ch, concat_contamination.out.fa, 'paired')
writeLog(illumina_input_ch.map{ it -> it[0] }, 'minimap2', illumina_input_ch.map{ it -> it[1] }, contamination)
get_number_of_reads(rename_reads.out, 'paired')
get_number_of_reads(illumina_input_ch, 'paired')
minimap2Stats(minimap2_illumina.out.idxstats.join(get_number_of_reads.out))
restore_reads(minimap2_illumina.out.cleaned_reads.concat(minimap2_illumina.out.contaminated_reads), 'paired', 'minimap2')
compress_reads(minimap2_illumina.out.cleaned_reads.concat(minimap2_illumina.out.contaminated_reads), 'paired', 'minimap2')
stats = minimap2Stats.out.tsv
}
emit:
stats = stats
in = illumina_input_ch.map{ it -> it.plus(1, 'all') }
out = restore_reads.out
out = compress_reads.out
}

workflow clean_illumina_single {
Expand All @@ -349,25 +349,25 @@ workflow clean_illumina_single {
.mix(rRNAChannel).collect()
concat_contamination( illumina_single_end_input_ch.map{ it -> it[0] }, params.bbduk ? 'bbduk' : 'minimap2', contamination )
}
rename_reads(illumina_single_end_input_ch, 'single')
// rename_reads(illumina_single_end_input_ch, 'single')
if (params.bbduk){
bbduk(rename_reads.out, concat_contamination.out.fa, 'single')
bbduk(illumina_single_end_input_ch, concat_contamination.out.fa, 'single')
writeLog(illumina_single_end_input_ch.map{ it -> it[0] }, 'bbduk', illumina_single_end_input_ch.map{ it -> it[1] }, contamination)
bbdukStats(bbduk.out.stats)
stats = bbdukStats.out.tsv
restore_reads(bbduk.out.cleaned_reads.concat(bbduk.out.contaminated_reads), 'single', 'bbduk')
compress_reads(bbduk.out.cleaned_reads.concat(bbduk.out.contaminated_reads), 'single', 'bbduk')
} else {
minimap2_illumina(rename_reads.out, concat_contamination.out.fa, 'single')
minimap2_illumina(illumina_single_end_input_ch, concat_contamination.out.fa, 'single')
writeLog(illumina_single_end_input_ch.map{ it -> it[0] }, 'minimap2', illumina_single_end_input_ch.map{ it -> it[1] }, contamination)
get_number_of_reads(rename_reads.out, 'single')
get_number_of_reads(illumina_single_end_input_ch, 'single')
minimap2Stats(minimap2_illumina.out.idxstats.join(get_number_of_reads.out))
stats = minimap2Stats.out.tsv
restore_reads(minimap2_illumina.out.cleaned_reads.concat(minimap2_illumina.out.contaminated_reads), 'single', 'minimap2')
compress_reads(minimap2_illumina.out.cleaned_reads.concat(minimap2_illumina.out.contaminated_reads), 'single', 'minimap2')
}
emit:
stats = stats
in = illumina_single_end_input_ch.map{ it -> it.plus(1, 'all') }
out = restore_reads.out
out = compress_reads.out
}

workflow qc_fasta {
Expand Down
9 changes: 4 additions & 5 deletions modules/utils.nf
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ process rename_reads {
}
}

process restore_reads {
process compress_reads {
label 'basics'

publishDir "${params.output}/${name}/${tool}", mode: 'copy', pattern: "*.gz"
Expand All @@ -63,13 +63,12 @@ process restore_reads {
script:
if ( mode == 'paired' ) {
"""
# restore the original read IDs
sed 's/DECONTAMINATE/ /g' ${reads}[0] | awk 'BEGIN{LINE=0};{if(LINE % 4 == 0 || LINE == 0){print \$0"/1"}else{print \$0};LINE++;}' | pigz -p ${task.cpus} > ${name}_1.${type}.fastq.gz
sed 's/DECONTAMINATE/ /g' ${reads}[1] | awk 'BEGIN{LINE=0};{if(LINE % 4 == 0 || LINE == 0){print \$0"/2"}else{print \$0};LINE++;}' | pigz -p ${task.cpus} > ${name}_2.${type}.fastq.gz
pigz -fc -p ${task.cpus} ${reads[0]} > ${name}_1.${type}.fastq.gz
pigz -fc -p ${task.cpus} ${reads[1]} > ${name}_2.${type}.fastq.gz
"""
} else {
"""
sed 's/DECONTAMINATE/ /g' ${reads} | pigz -p ${task.cpus} > ${name}.${type}.fastq.gz
pigz -fc -p ${task.cpus} ${reads} > ${name}.${type}.fastq.gz
"""
}
}
Expand Down

0 comments on commit 011481d

Please sign in to comment.