From 7aafb53f4301f6c4f06969e4df469210f23bdccd Mon Sep 17 00:00:00 2001 From: Laurent Modolo <laurent.modolo@ens-lyon.fr> Date: Wed, 22 Aug 2018 14:31:38 +0200 Subject: [PATCH] Bowtie2: update nf structure --- src/nf_modules/Bowtie2/bowtie2.nf | 141 ------------------ src/nf_modules/Bowtie2/indexing.config | 18 +++ .../Bowtie2/{tests/index.nf => indexing.nf} | 0 .../{bowtie2.config => mapping_paired.config} | 6 - .../Bowtie2/{tests => }/mapping_paired.nf | 0 src/nf_modules/Bowtie2/mapping_single.config | 18 +++ .../Bowtie2/{tests => }/mapping_single.nf | 0 src/nf_modules/Bowtie2/{tests => }/tests.sh | 12 +- 8 files changed, 42 insertions(+), 153 deletions(-) delete mode 100644 src/nf_modules/Bowtie2/bowtie2.nf create mode 100644 src/nf_modules/Bowtie2/indexing.config rename src/nf_modules/Bowtie2/{tests/index.nf => indexing.nf} (100%) rename src/nf_modules/Bowtie2/{bowtie2.config => mapping_paired.config} (66%) rename src/nf_modules/Bowtie2/{tests => }/mapping_paired.nf (100%) create mode 100644 src/nf_modules/Bowtie2/mapping_single.config rename src/nf_modules/Bowtie2/{tests => }/mapping_single.nf (100%) rename src/nf_modules/Bowtie2/{tests => }/tests.sh (50%) diff --git a/src/nf_modules/Bowtie2/bowtie2.nf b/src/nf_modules/Bowtie2/bowtie2.nf deleted file mode 100644 index efee164..0000000 --- a/src/nf_modules/Bowtie2/bowtie2.nf +++ /dev/null @@ -1,141 +0,0 @@ -/* -* Bowtie2 : -* Imputs : fastq files -* Imputs : fasta files -* Output : bam files -*/ - -/* fasta indexing */ -params.fasta = "$baseDir/data/bam/*.fasta" - -log.info "fasta files : ${params.fasta}" - -Channel - .fromPath( params.fasta ) - .ifEmpty { error "Cannot find any bam files matching: ${params.fasta}" } - .set { fasta_file } - -process index_fasta { - tag "$fasta.baseName" - cpus 4 - publishDir "results/mapping/index/", mode: 'copy' - - input: - file fasta from fasta_file - - output: - file "*.index*" into index_files - file "*_report.txt" into indexing_report - - script: -""" -bowtie2-build --threads ${task.cpus} ${fasta} ${fasta.baseName}.index &> ${fasta.baseName}_bowtie2_report.txt - -if grep -q "Error" ${fasta.baseName}_bowtie2_report.txt; then - exit 1 -fi -""" -} - - -/* -* for paired-end data -*/ - -params.fastq = "$baseDir/data/fastq/*_{1,2}.fastq" -params.index = "$baseDir/data/index/*.index.*" - -log.info "fastq files : ${params.fastq}" -log.info "index files : ${params.index}" - -Channel - .fromFilePairs( params.fastq ) - .ifEmpty { error "Cannot find any fastq files matching: ${params.fastq}" } - .set { fastq_files } -Channel - .fromPath( params.index ) - .ifEmpty { error "Cannot find any index files matching: ${params.index}" } - .set { index_files } - -process mapping_fastq { - tag "$pair_id" - cpus 4 - publishDir "results/mapping/bams/", mode: 'copy' - - input: - set pair_id, file(reads) from fastq_files - file index from index_files.collect() - - output: - set pair_id, "*.bam" into bam_files - file "*_report.txt" into mapping_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] - } - } -""" -bowtie2 --very-sensitive -p ${task.cpus} -x ${index_id} \ --1 ${reads[0]} -2 ${reads[1]} 2> \ -${pair_id}_bowtie2_report.txt | \ -samtools view -Sb - > ${pair_id}.bam - -if grep -q "Error" ${pair_id}_bowtie2_report.txt; then - exit 1 -fi -""" -} - -/* -* for single-end data -*/ - -params.fastq = "$baseDir/data/fastq/*.fastq" - -log.info "fastq files : ${params.fastq}" -log.info "index files : ${params.index}" - -Channel - .fromPath( params.fastq ) - .ifEmpty { error "Cannot find any fastq files matching: ${params.fastq}" } - .map { it -> [(it.baseName =~ /([^\.]*)/)[0][1], it]} - .set { fastq_files } -Channel - .fromPath( params.index ) - .ifEmpty { error "Cannot find any index files matching: ${params.index}" } - .set { index_files } - -process mapping_fastq { - tag "$file_id" - cpus 4 - publishDir "results/mapping/bams/", mode: 'copy' - - input: - set file_id, file(reads) from fastq_files - file index from index_files.collect() - - output: - set file_id, "*.bam" into bam_files - file "*_report.txt" into mapping_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] - } - } -""" -bowtie2 --very-sensitive -p ${task.cpus} -x ${index_id} \ --U ${reads} 2> \ -${file_id}_bowtie2_report.txt | \ -samtools view -Sb - > ${file_id}.bam - -if grep -q "Error" ${file_id}_bowtie2_report.txt; then - exit 1 -fi -""" -} diff --git a/src/nf_modules/Bowtie2/indexing.config b/src/nf_modules/Bowtie2/indexing.config new file mode 100644 index 0000000..60f6054 --- /dev/null +++ b/src/nf_modules/Bowtie2/indexing.config @@ -0,0 +1,18 @@ +profiles { + docker { + docker.temp = 'auto' + docker.enabled = true + process { + $index_fasta { + container = "bowtie2:2.3.4.1" + } + } + } + sge { + process{ + $index_fasta { + beforeScript = "module purge; module load Bowtie2/2.3.4.1" + } + } + } +} diff --git a/src/nf_modules/Bowtie2/tests/index.nf b/src/nf_modules/Bowtie2/indexing.nf similarity index 100% rename from src/nf_modules/Bowtie2/tests/index.nf rename to src/nf_modules/Bowtie2/indexing.nf diff --git a/src/nf_modules/Bowtie2/bowtie2.config b/src/nf_modules/Bowtie2/mapping_paired.config similarity index 66% rename from src/nf_modules/Bowtie2/bowtie2.config rename to src/nf_modules/Bowtie2/mapping_paired.config index e34b42f..a8cd299 100644 --- a/src/nf_modules/Bowtie2/bowtie2.config +++ b/src/nf_modules/Bowtie2/mapping_paired.config @@ -3,9 +3,6 @@ profiles { docker.temp = 'auto' docker.enabled = true process { - $index_fasta { - container = "bowtie2:2.3.4.1" - } $mapping_fastq { container = "bowtie2:2.3.4.1" } @@ -13,9 +10,6 @@ profiles { } sge { process{ - $index_fasta { - beforeScript = "module purge; module load Bowtie2/2.3.4.1" - } $mapping_fastq { beforeScript = "module purge; module load SAMtools/1.7; module load Bowtie2/2.3.4.1" } diff --git a/src/nf_modules/Bowtie2/tests/mapping_paired.nf b/src/nf_modules/Bowtie2/mapping_paired.nf similarity index 100% rename from src/nf_modules/Bowtie2/tests/mapping_paired.nf rename to src/nf_modules/Bowtie2/mapping_paired.nf diff --git a/src/nf_modules/Bowtie2/mapping_single.config b/src/nf_modules/Bowtie2/mapping_single.config new file mode 100644 index 0000000..a8cd299 --- /dev/null +++ b/src/nf_modules/Bowtie2/mapping_single.config @@ -0,0 +1,18 @@ +profiles { + docker { + docker.temp = 'auto' + docker.enabled = true + process { + $mapping_fastq { + container = "bowtie2:2.3.4.1" + } + } + } + sge { + process{ + $mapping_fastq { + beforeScript = "module purge; module load SAMtools/1.7; module load Bowtie2/2.3.4.1" + } + } + } +} diff --git a/src/nf_modules/Bowtie2/tests/mapping_single.nf b/src/nf_modules/Bowtie2/mapping_single.nf similarity index 100% rename from src/nf_modules/Bowtie2/tests/mapping_single.nf rename to src/nf_modules/Bowtie2/mapping_single.nf diff --git a/src/nf_modules/Bowtie2/tests/tests.sh b/src/nf_modules/Bowtie2/tests.sh similarity index 50% rename from src/nf_modules/Bowtie2/tests/tests.sh rename to src/nf_modules/Bowtie2/tests.sh index 1db702a..ab14838 100755 --- a/src/nf_modules/Bowtie2/tests/tests.sh +++ b/src/nf_modules/Bowtie2/tests.sh @@ -1,16 +1,16 @@ -./nextflow src/nf_modules/Bowtie2/tests/index.nf \ - -c src/nf_modules/Bowtie2/bowtie2.config \ +./nextflow src/nf_modules/Bowtie2/indexing.nf \ + -c src/nf_modules/Bowtie2/indexing.config \ -profile docker \ --fasta "data/tiny_dataset/fasta/tiny_v2.fasta" -./nextflow src/nf_modules/Bowtie2/tests/mapping_single.nf \ - -c src/nf_modules/Bowtie2/bowtie2.config \ +./nextflow src/nf_modules/Bowtie2/mapping_single.nf \ + -c src/nf_modules/Bowtie2/mapping_single.config \ -profile docker \ --index "data/tiny_dataset/fasta/*.bt2" \ --fastq "data/tiny_dataset/fastq/tiny*_S.fastq" -./nextflow src/nf_modules/Bowtie2/tests/mapping_paired.nf \ - -c src/nf_modules/Bowtie2/bowtie2.config \ +./nextflow src/nf_modules/Bowtie2/mapping_paired.nf \ + -c src/nf_modules/Bowtie2/mapping_paired.config \ -profile docker \ --index "data/tiny_dataset/fasta/*.bt2" \ --fastq "data/tiny_dataset/fastq/tiny*_R{1,2}.fastq" -- GitLab