diff --git a/src/nf_modules/htseq/tests.sh b/src/nf_modules/htseq/tests.sh index 904b42b3476e4daf3e97b6e52f435a507c033cd0..eada26b6d280b80f6ebb7db3d3dc5bf652013b27 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 0000000000000000000000000000000000000000..19f20463dd9f908edd35771ad578e2dc7be0e6d0 --- /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 0000000000000000000000000000000000000000..f0b53e396a27b871f9091ecd5cff4858550fa98f --- /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 0000000000000000000000000000000000000000..c50b20e3601efeaa8a0d3721ad6ab20739c3db48 --- /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