From 4afb198104499ea211dd29c2fdd7de8bcfecccb4 Mon Sep 17 00:00:00 2001 From: Laurent Modolo <laurent.modolo@ens-lyon.fr> Date: Wed, 22 Aug 2018 14:14:08 +0200 Subject: [PATCH] Bowtie: update nf structure --- src/nf_modules/Bowtie/bowtie.nf | 138 ------------------ src/nf_modules/Bowtie/indexing.config | 18 +++ .../Bowtie/{tests/index.nf => indexing.nf} | 2 + .../{bowtie.config => mapping_paired.config} | 6 - .../Bowtie/{tests => }/mapping_paired.nf | 4 + src/nf_modules/Bowtie/mapping_single.config | 18 +++ .../Bowtie/{tests => }/mapping_single.nf | 4 + src/nf_modules/Bowtie/{tests => }/tests.sh | 12 +- 8 files changed, 52 insertions(+), 150 deletions(-) delete mode 100644 src/nf_modules/Bowtie/bowtie.nf create mode 100644 src/nf_modules/Bowtie/indexing.config rename src/nf_modules/Bowtie/{tests/index.nf => indexing.nf} (89%) rename src/nf_modules/Bowtie/{bowtie.config => mapping_paired.config} (66%) rename src/nf_modules/Bowtie/{tests => }/mapping_paired.nf (97%) create mode 100644 src/nf_modules/Bowtie/mapping_single.config rename src/nf_modules/Bowtie/{tests => }/mapping_single.nf (97%) rename src/nf_modules/Bowtie/{tests => }/tests.sh (50%) diff --git a/src/nf_modules/Bowtie/bowtie.nf b/src/nf_modules/Bowtie/bowtie.nf deleted file mode 100644 index 0344760..0000000 --- a/src/nf_modules/Bowtie/bowtie.nf +++ /dev/null @@ -1,138 +0,0 @@ -/* -* Bowtie : -* 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: -""" -bowtie-build --threads ${task.cpus} -f ${fasta} ${fasta.baseName}.index &> ${fasta.baseName}_bowtie_report.txt - -if grep -q "Error" ${fasta.baseName}_bowtie_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: - file "*.bam" into bam_files - file "*_report.txt" into mapping_report - - script: - index_id = index[0] - for (index_file in index) { - if (index_file =~ /.*\.1\.ebwt/ && !(index_file =~ /.*\.rev\.1\.ebwt/)) { - index_id = ( index_file =~ /(.*)\.1\.ebwt/)[0][1] - } - } -""" -# -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.txt | \ -samtools view -Sb - > ${pair_id}.bam - -if grep -q "Error" ${pair_id}_bowtie_report.txt; then - exit 1 -fi -""" -} - - -/* -* for single-end data -*/ -params.mean = 200 -params.sd = 100 - -log.info "fastq files : ${params.fastq}" -log.info "index files : ${params.index}" -log.info "mean read size: ${params.mean}" -log.info "sd read size: ${params.sd}" - -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/quantification/", mode: 'copy' - - input: - set file_id, file(reads) from fastq_files - file index from index_files.collect() - - output: - file "*" into count_files - - script: -""" -mkdir ${file_id} -kallisto quant -i ${index} -t ${task.cpus} --single \ ---bias --bootstrap-samples 100 -o ${file_id} \ --l ${params.mean} -s ${params.sd} \ -${reads} > ${file_id}_kallisto_report.txt -""" -} - diff --git a/src/nf_modules/Bowtie/indexing.config b/src/nf_modules/Bowtie/indexing.config new file mode 100644 index 0000000..d585100 --- /dev/null +++ b/src/nf_modules/Bowtie/indexing.config @@ -0,0 +1,18 @@ +profiles { + docker { + docker.temp = 'auto' + docker.enabled = true + process { + $index_fasta { + container = "bowtie:1.2.2" + } + } + } + sge { + process{ + $index_fasta { + beforeScript = "module purge; module load Bowtie/1.2.2" + } + } + } +} diff --git a/src/nf_modules/Bowtie/tests/index.nf b/src/nf_modules/Bowtie/indexing.nf similarity index 89% rename from src/nf_modules/Bowtie/tests/index.nf rename to src/nf_modules/Bowtie/indexing.nf index f9ee2eb..537d684 100644 --- a/src/nf_modules/Bowtie/tests/index.nf +++ b/src/nf_modules/Bowtie/indexing.nf @@ -1,3 +1,5 @@ +/* fasta indexing */ + params.fasta = "$baseDir/data/bam/*.fasta" log.info "fasta files : ${params.fasta}" diff --git a/src/nf_modules/Bowtie/bowtie.config b/src/nf_modules/Bowtie/mapping_paired.config similarity index 66% rename from src/nf_modules/Bowtie/bowtie.config rename to src/nf_modules/Bowtie/mapping_paired.config index 93fe4a4..86cc4bb 100644 --- a/src/nf_modules/Bowtie/bowtie.config +++ b/src/nf_modules/Bowtie/mapping_paired.config @@ -3,9 +3,6 @@ profiles { docker.temp = 'auto' docker.enabled = true process { - $index_fasta { - container = "bowtie:1.2.2" - } $mapping_fastq { container = "bowtie:1.2.2" } @@ -13,9 +10,6 @@ profiles { } sge { process{ - $index_fasta { - beforeScript = "module purge; module load Bowtie/1.2.2" - } $mapping_fastq { beforeScript = "module purge; module load SAMtools/1.7; module load Bowtie/1.2.2" } diff --git a/src/nf_modules/Bowtie/tests/mapping_paired.nf b/src/nf_modules/Bowtie/mapping_paired.nf similarity index 97% rename from src/nf_modules/Bowtie/tests/mapping_paired.nf rename to src/nf_modules/Bowtie/mapping_paired.nf index 600e295..cc9f40b 100644 --- a/src/nf_modules/Bowtie/tests/mapping_paired.nf +++ b/src/nf_modules/Bowtie/mapping_paired.nf @@ -1,3 +1,7 @@ +/* +* mapping paired fastq +*/ + params.fastq = "$baseDir/data/fastq/*_{1,2}.fastq" params.index = "$baseDir/data/index/*.index.*" diff --git a/src/nf_modules/Bowtie/mapping_single.config b/src/nf_modules/Bowtie/mapping_single.config new file mode 100644 index 0000000..86cc4bb --- /dev/null +++ b/src/nf_modules/Bowtie/mapping_single.config @@ -0,0 +1,18 @@ +profiles { + docker { + docker.temp = 'auto' + docker.enabled = true + process { + $mapping_fastq { + container = "bowtie:1.2.2" + } + } + } + sge { + process{ + $mapping_fastq { + beforeScript = "module purge; module load SAMtools/1.7; module load Bowtie/1.2.2" + } + } + } +} diff --git a/src/nf_modules/Bowtie/tests/mapping_single.nf b/src/nf_modules/Bowtie/mapping_single.nf similarity index 97% rename from src/nf_modules/Bowtie/tests/mapping_single.nf rename to src/nf_modules/Bowtie/mapping_single.nf index 6697681..ad9754d 100644 --- a/src/nf_modules/Bowtie/tests/mapping_single.nf +++ b/src/nf_modules/Bowtie/mapping_single.nf @@ -1,3 +1,7 @@ +/* +* mapping single end fastq +*/ + params.fastq = "$baseDir/data/fastq/*.fastq" log.info "fastq files : ${params.fastq}" diff --git a/src/nf_modules/Bowtie/tests/tests.sh b/src/nf_modules/Bowtie/tests.sh similarity index 50% rename from src/nf_modules/Bowtie/tests/tests.sh rename to src/nf_modules/Bowtie/tests.sh index 3b67514..803f628 100755 --- a/src/nf_modules/Bowtie/tests/tests.sh +++ b/src/nf_modules/Bowtie/tests.sh @@ -1,16 +1,16 @@ -./nextflow src/nf_modules/Bowtie/tests/index.nf \ - -c src/nf_modules/Bowtie/bowtie.config \ +./nextflow src/nf_modules/Bowtie/indexing.nf \ + -c src/nf_modules/Bowtie/indexing.config \ -profile docker \ --fasta "data/tiny_dataset/fasta/tiny_v2.fasta" -./nextflow src/nf_modules/Bowtie/tests/mapping_single.nf \ - -c src/nf_modules/Bowtie/bowtie.config \ +./nextflow src/nf_modules/Bowtie/mapping_single.nf \ + -c src/nf_modules/Bowtie/mapping_single.config \ -profile docker \ --index "results/mapping/index/*.ebwt" \ --fastq "data/tiny_dataset/fastq/tiny*_S.fastq" -./nextflow src/nf_modules/Bowtie/tests/mapping_paired.nf \ - -c src/nf_modules/Bowtie/bowtie.config \ +./nextflow src/nf_modules/Bowtie/mapping_paired.nf \ + -c src/nf_modules/Bowtie/mapping_paired.config \ -profile docker \ --index "results/mapping/index/*.ebwt" \ --fastq "data/tiny_dataset/fastq/tiny*_R{1,2}.fastq" -- GitLab