diff --git a/src/nf_modules/BWA/indexing.config b/src/nf_modules/BWA/indexing.config new file mode 100644 index 0000000000000000000000000000000000000000..607bda58f1061ef449df15d8eef17aa98a2b992d --- /dev/null +++ b/src/nf_modules/BWA/indexing.config @@ -0,0 +1,26 @@ +profiles { + docker { + docker.temp = 'auto' + docker.enabled = true + process { + $index_fasta { + container = "bwa:0.7.17" + } + } + } + sge { + process{ + $index_fasta { + beforeScript = "module purge; module load BWA/0.7.17" + executor = "sge" + cpus = 1 + memory = "5GB" + time = "6h" + queueSize = 1000 + pollInterval = '60sec' + queue = 'h6-E5-2667v4deb128' + penv = 'openmp8' + } + } + } +} diff --git a/src/nf_modules/BWA/indexing.nf b/src/nf_modules/BWA/indexing.nf new file mode 100644 index 0000000000000000000000000000000000000000..67ea3287bf374808ab4b01007fe05c381d711151 --- /dev/null +++ b/src/nf_modules/BWA/indexing.nf @@ -0,0 +1,29 @@ +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}" } + .map { it -> [(it.baseName =~ /([^\.]*)/)[0][1], it]} + .set { fasta_file } + +process index_fasta { + tag "$fasta_id" + cpus 4 + publishDir "results/mapping/index/", mode: 'copy' + + input: + set fasta_id, file(fasta) from fasta_file + + output: + set fasta_id, "${fasta.baseName}.*" into index_files + file "*_bwa_report.txt" into index_files_report + + script: +""" +bwa index -p ${fasta.baseName} ${fasta} \ +&> ${fasta.baseName}_bwa_report.txt +""" +} + diff --git a/src/nf_modules/BWA/mapping_paired.config b/src/nf_modules/BWA/mapping_paired.config new file mode 100644 index 0000000000000000000000000000000000000000..c0370c3cc76f7048a03382a6ee7985ec1085d9b5 --- /dev/null +++ b/src/nf_modules/BWA/mapping_paired.config @@ -0,0 +1,26 @@ +profiles { + docker { + docker.temp = 'auto' + docker.enabled = true + process { + $mapping_fastq { + container = "bwa:0.7.17" + } + } + } + sge { + process{ + $mapping_fastq { + beforeScript = "module purge; module load BWA/0.7.17" + executor = "sge" + cpus = 4 + memory = "5GB" + time = "6h" + queueSize = 1000 + pollInterval = '60sec' + queue = 'h6-E5-2667v4deb128' + penv = 'openmp8' + } + } + } +} diff --git a/src/nf_modules/BWA/mapping_paired.nf b/src/nf_modules/BWA/mapping_paired.nf new file mode 100644 index 0000000000000000000000000000000000000000..5ac50ef555dc42b2415f76e72c1a36e932637894 --- /dev/null +++ b/src/nf_modules/BWA/mapping_paired.nf @@ -0,0 +1,38 @@ +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}" } + .map { it -> [(it.baseName =~ /([^\.]*)/)[0][1], it]} + .groupTuple() + .set { index_files } + +process mapping_fastq { + tag "$reads" + cpus 4 + publishDir "results/mapping/sam/", mode: 'copy' + + input: + set pair_id, file(reads) from fastq_files + set index_id, file(index) from index_files.collect() + + output: + file "${pair_id}.sam" into sam_files + file "${pair_id}_bwa_report.txt" into mapping_repport_files + + script: +""" +bwa mem -t ${task.cpus} \ +${index_id} ${reads[0]} ${reads[1]} \ +-o ${pair_id}.sam &> ${pair_id}_bwa_report.txt +""" +} + diff --git a/src/nf_modules/BWA/tests.sh b/src/nf_modules/BWA/tests.sh new file mode 100755 index 0000000000000000000000000000000000000000..1f3150cf8debc2d6be9ccf19167d25418af42223 --- /dev/null +++ b/src/nf_modules/BWA/tests.sh @@ -0,0 +1,17 @@ +./nextflow src/nf_modules/BWA/indexing.nf \ + -c src/nf_modules/BWA/indexing.config \ + -profile docker \ + --fasta "data/tiny_dataset/fasta/tiny_v2.fasta" + +# ./nextflow src/nf_modules/BWA/mapping_single.nf \ +# -c src/nf_modules/BWA/mapping_single.config \ +# -profile docker \ +# --index "results/mapping/index/tiny_v2.index" \ +# --fastq "data/tiny_dataset/fastq/tiny*_S.fastq" + +./nextflow src/nf_modules/BWA/mapping_paired.nf \ + -c src/nf_modules/BWA/mapping_paired.config \ + -profile docker \ + --index "results/mapping/index/tiny_v2*" \ + --fastq "data/tiny_dataset/fastq/tiny*_R{1,2}.fastq" +