Skip to content
Snippets Groups Projects
Verified Commit 88ce59a0 authored by Laurent Modolo's avatar Laurent Modolo
Browse files

Merge branch 'nfontrod/nextflow-master' into dev

parents ad48514d e5bd9289
No related branches found
No related tags found
1 merge request!12Creation of a nexflow module for Hisat2
FROM ubuntu:18.04 FROM samtools:1.7
MAINTAINER Nicolas Fontrodona MAINTAINER Nicolas Fontrodona
ENV HISAT2_VERSION=2.0.0 ENV HISAT2_VERSION=2.0.0
ENV PACKAGES unzip=6.0* \ ENV PACKAGES curl \
gcc=4:7.3.0* \ zip \
g++=4:7.3.0* \ g++ \
make=4.1* \ perl \
curl=7.58.0* \ python
ca-certificates=20180409
RUN apt-get update && \ RUN apk update && \
apt-get install -y --no-install-recommends ${PACKAGES} && \ apk add ${PACKAGES}
apt-get clean
RUN curl -k -L http://ccb.jhu.edu/software/hisat2/downloads/hisat2-${HISAT2_VERSION}-beta-source.zip -o hisat2_linux-v${HISAT2_VERSION}.zip && \ RUN curl -k -L http://ccb.jhu.edu/software/hisat2/downloads/hisat2-${HISAT2_VERSION}-beta-source.zip -o hisat2_linux-v${HISAT2_VERSION}.zip && \
unzip hisat2_linux-v${HISAT2_VERSION}.zip && \ unzip hisat2_linux-v${HISAT2_VERSION}.zip && \
...@@ -19,5 +17,4 @@ cd hisat2-${HISAT2_VERSION}-beta && \ ...@@ -19,5 +17,4 @@ cd hisat2-${HISAT2_VERSION}-beta && \
make && \ make && \
cp hisat2 /usr/bin && \ cp hisat2 /usr/bin && \
cp hisat2-* /usr/bin && \ cp hisat2-* /usr/bin && \
rm -Rf hisat2-${HISAT2_VERSION}-beta rm -Rf hisat2-${HISAT2_VERSION}-beta
profiles {
docker {
docker.temp = 'auto'
docker.enabled = true
process {
withName: index_fasta {
container = "hisat2:2.0.0"
cpus = 4
}
}
}
singularity {
singularity.enabled = true
process {
withName: index_fasta {
cpus = 4
container = "file://bin/hisat2:2.0.0.sif"
}
}
}
psmn {
process{
withName: index_fasta {
beforeScript = "source /usr/share/lmod/lmod/init/bash; module use ~/privatemodules"
module = "hisat2/2.0.0"
executor = "sge"
clusterOptions = "-cwd -V"
memory = "20GB"
cpus = 16
time = "12h"
queue = 'E5-2670deb128A,E5-2670deb128B,E5-2670deb128C,E5-2670deb128D,E5-2670deb128E,E5-2670deb128F'
penv = 'openmp16'
}
}
}
}
/*
* Hisat2 :
* 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 fasta files matching: ${params.fasta}" }
.set { fasta_file }
process index_fasta {
tag "$fasta.baseName"
publishDir "results/mapping/index/", mode: 'copy'
input:
file fasta from fasta_file
output:
file "*.index*" into index_files
script:
"""
hisat2-build -p ${task.cpus} ${fasta} ${fasta.baseName}.index
"""
}
profiles {
docker {
docker.temp = 'auto'
docker.enabled = true
process {
withName: mapping_fastq {
cpus = 4
container = "hisat2:2.0.0"
}
}
}
singularity {
singularity.enabled = true
process {
withName: mapping_fastq {
cpus = 4
container = "file://bin/hisat2:2.0.0.sif"
}
}
}
sge {
process{
withName: mapping_fastq {
beforeScript = "source /usr/share/lmod/lmod/init/bash; module use ~/privatemodules"
module = "hisat2/2.0.0"
executor = "sge"
clusterOptions = "-cwd -V"
memory = "20GB"
cpus = 16
time = "12h"
queue = 'E5-2670deb128A,E5-2670deb128B,E5-2670deb128C,E5-2670deb128D,E5-2670deb128E,E5-2670deb128F'
penv = 'openmp16'
}
}
}
}
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"
publishDir "results/mapping/", mode: 'copy'
input:
set pair_id, file(reads) from fastq_files
file index from index_files.collect()
output:
file "*" into counts_files
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\.ht2/ && !(index_file =~ /.*\.rev\.1\.ht2/)) {
index_id = ( index_file =~ /(.*)\.1\.ht2/)[0][1]
}
}
"""
hisat2 -p ${task.cpus} \
-x ${index_id} \
-1 ${reads[0]} \
-2 ${reads[1]} 2> \
${pair_id}_hisat2_report.txt | \
samtools view -Sb - > ${pair_id}.bam
if grep -q "Error" ${pair_id}_hisat2_report.txt; then
exit 1
fi
"""
}
profiles {
docker {
docker.temp = 'auto'
docker.enabled = true
process {
withName: mapping_fastq {
cpus = 4
container = "hisat2:2.0.0"
}
}
}
singularity {
singularity.enabled = true
process {
withName: mapping_fastq {
cpus = 4
container = "file://bin/hisat2:2.0.0.sif"
}
}
}
sge {
process{
withName: mapping_fastq {
beforeScript = "source /usr/share/lmod/lmod/init/bash; module use ~/privatemodules"
module = "hisat2/2.0.0"
executor = "sge"
clusterOptions = "-cwd -V"
memory = "20GB"
cpus = 16
time = "12h"
queue = 'E5-2670deb128A,E5-2670deb128B,E5-2670deb128C,E5-2670deb128D,E5-2670deb128E,E5-2670deb128F'
penv = 'openmp16'
}
}
}
}
/*
* for single-end data
*/
params.fastq = "$baseDir/data/fastq/*.fastq"
params.index = "$baseDir/data/index/*.index*"
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"
publishDir "results/mapping/", mode: 'copy'
input:
set file_id, file(reads) from fastq_files
file index from index_files.collect()
output:
file "*" into count_files
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\.ht2/ && !(index_file =~ /.*\.rev\.1\.ht2/)) {
index_id = ( index_file =~ /(.*)\.1\.ht2/)[0][1]
}
}
"""
hisat2 -p ${task.cpus} \
-x ${index_id} \
-U ${reads} 2> \
${file_id}_hisat2_report.txt | \
samtools view -Sb - > ${file_id}.bam
if grep -q "Error" ${file_id}_hisat2_report.txt; then
exit 1
fi
"""
}
./nextflow src/nf_modules/hisat2/indexing.nf \
-c src/nf_modules/hisat2/indexing.config \
-profile docker \
--fasta "data/tiny_dataset/fasta/tiny_v2.fasta" \
-resume
./nextflow src/nf_modules/hisat2/mapping_paired.nf \
-c src/nf_modules/hisat2/mapping_paired.config \
-profile docker \
--index "results/mapping/index/tiny_v2.index*" \
--fastq "data/tiny_dataset/fastq/tiny*_R{1,2}.fastq" \
-resume
./nextflow src/nf_modules/hisat2/mapping_single.nf \
-c src/nf_modules/hisat2/mapping_single.config \
-profile docker \
--index "results/mapping/index/tiny_v2.index*" \
--fastq "data/tiny_dataset/fastq/tiny*_S.fastq" \
-resume
if [ -x "$(command -v singularity)" ]; then
./nextflow src/nf_modules/hisat2/indexing.nf \
-c src/nf_modules/hisat2/indexing.config \
-profile singularity \
--fasta "data/tiny_dataset/fasta/tiny_v2.fasta" \
-resume
./nextflow src/nf_modules/hisat2/mapping_paired.nf \
-c src/nf_modules/hisat2/mapping_paired.config \
-profile singularity \
--index "results/mapping/index/tiny_v2.index*" \
--fastq "data/tiny_dataset/fastq/tiny*_R{1,2}.fastq"
./nextflow src/nf_modules/hisat2/mapping_single.nf \
-c src/nf_modules/hisat2/mapping_single.config \
-profile singularity \
--index "results/mapping/index/tiny_v2.index*" \
--fastq "data/tiny_dataset/fastq/tiny*_S.fastq"
fi
Bootstrap: docker Bootstrap: docker
From: ubuntu:18.04 From: alpine:3.8
%labels %labels
MAINTAINER Nicolas Fontrodona MAINTAINER Laurent Modolo
%post %post
SAMTOOLS_VERSION=1.7
HISAT2_VERSION=2.0.0 HISAT2_VERSION=2.0.0
PACKAGES="unzip \ PACKAGES="git \
gcc \ make \
g++ \ gcc \
make \ musl-dev \
curl \ zlib-dev \
ca-certificates" ncurses-dev \
bzip2-dev \
xz-dev \
bash \
curl \
zip \
g++ \
perl \
python"
apk update && \
apk add ${PACKAGES}
apt-get update && \ git clone https://github.com/samtools/htslib.git && \
apt-get install -y --no-install-recommends ${PACKAGES} && \ cd htslib && \
apt-get clean git checkout ${SAMTOOLS_VERSION} && \
cd .. && \
git clone https://github.com/samtools/samtools.git && \
cd samtools && \
git checkout ${SAMTOOLS_VERSION} && \
make && \
cp samtools /usr/bin/
curl -k -L http://ccb.jhu.edu/software/hisat2/downloads/hisat2-${HISAT2_VERSION}-beta-source.zip -o hisat2_linux-v${HISAT2_VERSION}.zip && \ curl -k -L http://ccb.jhu.edu/software/hisat2/downloads/hisat2-${HISAT2_VERSION}-beta-source.zip -o hisat2_linux-v${HISAT2_VERSION}.zip && \
unzip hisat2_linux-v${HISAT2_VERSION}.zip && \ unzip hisat2_linux-v${HISAT2_VERSION}.zip && \
...@@ -26,6 +43,7 @@ cp hisat2-* /usr/bin && \ ...@@ -26,6 +43,7 @@ cp hisat2-* /usr/bin && \
rm -Rf hisat2-${HISAT2_VERSION}-beta rm -Rf hisat2-${HISAT2_VERSION}-beta
%environment %environment
export SAMTOOLS_VERSION=1.7
export HISAT2_VERSION=2.0.0 export HISAT2_VERSION=2.0.0
%runscript %runscript
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment