diff --git a/src/nf_modules/bowtie/main.nf b/src/nf_modules/bowtie/main.nf index c95c47f087dac91274a4c255d3ea1e535d2ffe63..d250e21f754a9ecb9c9c1bb84d174feb8b528fdd 100644 --- a/src/nf_modules/bowtie/main.nf +++ b/src/nf_modules/bowtie/main.nf @@ -25,6 +25,55 @@ fi """ } +process mapping_fastq { + container = "${container_url}" + label "big_mem_multi_cpus" + tag "$pair_id" + + input: + path index + tuple val(pair_id), path(reads) + + output: + tuple val(pair_id), path("*.bam"), emit: bam + path "*_report.txt", emit: report + + script: + index_id = index[0] + for (index_file in index) { + if (index_file =~ /.*\.1\.bt2/ && !(index_file =~ /.*\.rev\.1\.bt2/)) { + index_id = ( index_file =~ /(.*)\.1\.bt2/)[0][1] + } + } +if (reads instanceof List) +""" +# -v specify the max number of missmatch, -k the number of match reported per +# reads +bowtie --best -v 3 -k 1 --sam -p ${task.cpus} ${index_id} \ + -1 ${reads[0]} -2 ${reads[1]} 2> \ + ${pair_id}_bowtie_report_tmp.txt | \ + samtools view -Sb - > ${pair_id}.bam + +if grep -q "Error" ${pair_id}_bowtie_report_tmp.txt; then + exit 1 +fi +tail -n 19 ${pair_id}_bowtie_report_tmp.txt > \ + ${pair_id}_bowtie_mapping_report.txt +""" +else +""" +bowtie --best -v 3 -k 1 --sam -p ${task.cpus} ${index_id} \ + -q ${reads} 2> \ + ${file_id}_bowtie_report_tmp.txt | \ + samtools view -Sb - > ${file_id}.bam + +if grep -q "Error" ${file_id}_bowtie_report_tmp.txt; then + exit 1 +fi +tail -n 19 ${file_id}_bowtie_report_tmp.txt > \ + ${file_id}_bowtie_mapping_report.txt +""" +} process mapping_fastq_pairedend { container = "${container_url}" diff --git a/src/nf_modules/bowtie2/main.nf b/src/nf_modules/bowtie2/main.nf index c852c31df95fe86d2dbb644056a0152bca0fd391..02d2663540b393f17b935bb4f4f0623bb5e2b2f3 100644 --- a/src/nf_modules/bowtie2/main.nf +++ b/src/nf_modules/bowtie2/main.nf @@ -27,6 +27,59 @@ fi } +process mapping_fastq { + container = "${container_url}" + label "big_mem_multi_cpus" + tag "$pair_id" + + input: + path index + tuple val(pair_id), path(reads) + + output: + tuple val(pair_id), path("*.bam"), emit: bam + path "*_report.txt", emit: report + + script: + index_id = index[0] + for (index_file in index) { + if (index_file =~ /.*\.1\.bt2/ && !(index_file =~ /.*\.rev\.1\.bt2/)) { + index_id = ( index_file =~ /(.*)\.1\.bt2/)[0][1] + } + } +if (reads instanceof List) +""" +bowtie2 --very-sensitive \ + -p ${task.cpus} \ + -x ${index_id} \ + -1 ${reads[0]} \ + -2 ${reads[1]} 2> \ + ${pair_id}_bowtie2_mapping_report_tmp.txt | \ + samtools view -Sb - > ${pair_id}.bam + +if grep -q "Error" ${pair_id}_bowtie2_mapping_report_tmp.txt; then + exit 1 +fi +tail -n 19 ${pair_id}_bowtie2_mapping_report_tmp.txt > \ + ${pair_id}_bowtie2_mapping_report.txt +""" +else +""" +bowtie2 --very-sensitive \ + -p ${task.cpus} \ + -x ${index_id} \ + -U ${reads} 2> \ + ${reads.baseName}_bowtie2_mapping_report_tmp.txt | \ + samtools view -Sb - > ${reads.baseName}.bam + +if grep -q "Error" ${reads.baseName}_bowtie2_mapping_report_tmp.txt; then + exit 1 +fi +tail -n 19 ${reads.baseName}_bowtie2_mapping_report_tmp.txt > \ + ${reads.baseName}_bowtie2_mapping_report.txt +""" +} + process mapping_fastq_pairedend { container = "${container_url}" label "big_mem_multi_cpus" diff --git a/src/nf_modules/cutadapt/main.nf b/src/nf_modules/cutadapt/main.nf index 020101fe0d7ac3557a748f7d0225ce3bda9844d9..6464935194f9cb9ce88f7175669a15d770fbd74f 100644 --- a/src/nf_modules/cutadapt/main.nf +++ b/src/nf_modules/cutadapt/main.nf @@ -6,6 +6,33 @@ adapter_5_prim = "CTCTTCCGATCT" trim_quality = "20" +process adaptor_removal { + container = "${container_url}" + label "big_mem_mono_cpus" + tag "$pair_id" + + input: + tuple val(pair_id), path(reads) + + output: + tuple val(pair_id), path("*_cut_R{1,2}.fastq.gz"), emit: fastq + path "*_report.txt", emit: report + + script: +if (reads instanceof List) + """ + cutadapt -a ${adapter_3_prim} -g ${adapter_5_prim} -A ${adapter_3_prim} -G ${adapter_5_prim} \ + -o ${pair_id}_cut_R1.fastq.gz -p ${pair_id}_cut_R2.fastq.gz \ + ${reads[0]} ${reads[1]} > ${pair_id}_report.txt + """ +else: + """ + cutadapt -a ${adapter_3_prim} -g ${adapter_5_prim} \ + -o ${file_id}_cut.fastq.gz \ + ${reads} > ${file_id}_report.txt + """ +} + process adaptor_removal_pairedend { container = "${container_url}" label "big_mem_mono_cpus" @@ -46,6 +73,33 @@ process adaptor_removal_singleend { """ } +process trimming_pairedend { + container = "${container_url}" + label "big_mem_mono_cpus" + tag "$pair_id" + + input: + tuple val(pair_id), path(reads) + + output: + tuple val(pair_id), path("*_trim_R{1,2}.fastq.gz"), emit:fastq + path "*_report.txt", emit: report + + script: +if (reads instanceof List) + """ + cutadapt -q ${trim_quality},${trim_quality} \ + -o ${pair_id}_trim_R1.fastq.gz -p ${pair_id}_trim_R2.fastq.gz \ + ${reads[0]} ${reads[1]} > ${pair_id}_report.txt + """ +else + """ + cutadapt -q ${trim_quality},${trim_quality} \ + -o ${file_id}_trim.fastq.gz \ + ${reads} > ${file_id}_report.txt + """ +} + process trimming_pairedend { container = "${container_url}" label "big_mem_mono_cpus"