From f92cde7ca41e42c35673f28ce54a8b551a7bd4d9 Mon Sep 17 00:00:00 2001 From: Laurent Modolo <laurent.modolo@ens-lyon.fr> Date: Fri, 7 Jun 2019 11:05:07 +0200 Subject: [PATCH] subread nf: add nf config and test files --- src/nf_modules/htseq/tests.sh | 2 +- src/nf_modules/subread/subread.config | 109 ++++++++++++++++++++++++++ src/nf_modules/subread/subread.nf | 52 ++++++++++++ src/nf_modules/subread/tests.sh | 15 ++++ 4 files changed, 177 insertions(+), 1 deletion(-) create mode 100644 src/nf_modules/subread/subread.config create mode 100644 src/nf_modules/subread/subread.nf create mode 100755 src/nf_modules/subread/tests.sh diff --git a/src/nf_modules/htseq/tests.sh b/src/nf_modules/htseq/tests.sh index 904b42b3..eada26b6 100755 --- a/src/nf_modules/htseq/tests.sh +++ b/src/nf_modules/htseq/tests.sh @@ -8,7 +8,7 @@ if [ -x "$(command -v singularity)" ]; then ./nextflow src/nf_modules/htseq/htseq.nf \ -c src/nf_modules/htseq/htseq.config \ - -profile docker \ + -profile singularity \ --gtf "data/tiny_dataset/annot/tiny.gff" \ --bam "data/tiny_dataset/map/tiny_v2.bam" \ -resume diff --git a/src/nf_modules/subread/subread.config b/src/nf_modules/subread/subread.config new file mode 100644 index 00000000..19f20463 --- /dev/null +++ b/src/nf_modules/subread/subread.config @@ -0,0 +1,109 @@ +profiles { + docker { + docker.temp = 'auto' + docker.enabled = true + process { + withName: sort_bam { + container = "samtools:1.7" + cpus = 1 + } + withName: counting { + container = "subread:1.6.4" + cpus = 1 + } + } + } + singularity { + singularity.enabled = true + process { + withName: sort_bam { + container = "file://bin/samtools:1.7.img" + cpus = 1 + } + withName: counting { + container = "file://bin/subread:1.6.4.img" + cpus = 1 + } + } + } + psmn{ + process{ + withName: sort_bam { + beforeScript = "source /usr/share/lmod/lmod/init/bash; module use ~/privatemodules" + module = "samtools/1.7" + executor = "sge" + clusterOptions = "-cwd -V" + cpus = 1 + memory = "20GB" + time = "12h" + queue = 'monointeldeb128,monointeldeb48,h48-E5-2670deb128,h6-E5-2667v4deb128' + } + withName: counting { + beforeScript = "source /usr/share/lmod/lmod/init/bash; module use ~/privatemodules" + module = "subread/1.6.4" + executor = "sge" + clusterOptions = "-cwd -V" + cpus = 1 + memory = "20GB" + time = "12h" + queue = 'monointeldeb128,monointeldeb48,h48-E5-2670deb128,h6-E5-2667v4deb128' + } + } + } + ccin2p3_conda { + process{ + withName: sort_bam { + beforeScript = "source /sps/lbmc/common/miniconda3/init.sh" + conda = "/sps/lbmc/common/miniconda3/envs/samtools_1.7" + scratch = true + stageInMode = "copy" + stageOutMode = "rsync" + executor = "sge" + clusterOptions = "-P P_lbmc -l os=cl7 -l sps=1 -r n\ + " + cpus = 1 + queue = 'huge' + } + withName: counting { + beforeScript = "source /sps/lbmc/common/miniconda3/init.sh" + conda = "/sps/lbmc/common/miniconda3/envs/subread_1.6.4" + scratch = true + stageInMode = "copy" + stageOutMode = "rsync" + executor = "sge" + clusterOptions = "-P P_lbmc -l os=cl7 -l sps=1 -r n\ + " + cpus = 1 + queue = 'huge' + } + } + } + ccin2p3 { + singularity.enabled = true + singularity.runOptions = "--bind /pbs,/sps,/scratch" + process{ + withName: sort_bam { + container = "/sps/lbmc/common/singularity/samtools:1.7.img" + scratch = true + stageInMode = "copy" + stageOutMode = "rsync" + executor = "sge" + clusterOptions = "-P P_lbmc -l os=cl7 -l sps=1 -r n\ + " + cpus = 1 + queue = 'huge' + } + withName: counting { + container = "/sps/lbmc/common/singularity/subread:1.6.4.img" + scratch = true + stageInMode = "copy" + stageOutMode = "rsync" + executor = "sge" + clusterOptions = "-P P_lbmc -l os=cl7 -l sps=1 -r n\ + " + cpus = 1 + queue = 'huge' + } + } + } +} diff --git a/src/nf_modules/subread/subread.nf b/src/nf_modules/subread/subread.nf new file mode 100644 index 00000000..f0b53e39 --- /dev/null +++ b/src/nf_modules/subread/subread.nf @@ -0,0 +1,52 @@ +params.bam = "$baseDir/data/bam/*.bam" +params.gtf = "$baseDir/data/annotation/*.gtf" + +log.info "bam files : ${params.bam}" +log.info "gtf files : ${params.gtf}" + +Channel + .fromPath( params.bam ) + .ifEmpty { error "Cannot find any fastq files matching: ${params.bam}" } + .map { it -> [(it.baseName =~ /([^\.]*)/)[0][1], it]} + .set { bam_files } +Channel + .fromPath( params.gtf ) + .ifEmpty { error "Cannot find any gtf file matching: ${params.gtf}" } + .set { gtf_file } + +process sort_bam { + tag "$file_id" + cpus 4 + + input: + set file_id, file(bam) from bam_files + + output: + set file_id, "*_sorted.sam" into sorted_bam_files + + script: +""" +# sort bam by name +samtools sort -@ ${task.cpus} -n -O SAM -o ${file_id}_sorted.sam ${bam} +""" +} + +process counting { + tag "$file_id" + publishDir "results/quantification/", mode: 'copy' + + input: + set file_id, file(bam) from sorted_bam_files + file gtf from gtf_file + + output: + file "*.count" into count_files + + script: +""" +featureCounts ${bam} -a ${gtf} -p \ + -o ${file_id}.count \ + -R BAM +""" +} + diff --git a/src/nf_modules/subread/tests.sh b/src/nf_modules/subread/tests.sh new file mode 100755 index 00000000..c50b20e3 --- /dev/null +++ b/src/nf_modules/subread/tests.sh @@ -0,0 +1,15 @@ +./nextflow src/nf_modules/subread/subread.nf \ + -c src/nf_modules/subread/subread.config \ + -profile docker \ + --gtf "data/tiny_dataset/annot/tiny.gff" \ + --bam "data/tiny_dataset/map/tiny_v2.bam" \ + -resume + +if [ -x "$(command -v singularity)" ]; then +./nextflow src/nf_modules/subread/subread.nf \ + -c src/nf_modules/subread/subread.config \ + -profile singularity \ + --gtf "data/tiny_dataset/annot/tiny.gff" \ + --bam "data/tiny_dataset/map/tiny_v2.bam" \ + -resume +fi -- GitLab