Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for apptainer containers #39

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ Validation_notes.md
.Rproj.user
*/__pycache__/*.pyc
assets/genoflu/GenoFLU
*sif
43 changes: 43 additions & 0 deletions environments/base.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
BootStrap: docker
From: python:3.9-slim

%files
environment.yml /opt/environment.yml

%post
# Install system dependencies
apt-get update && apt-get install -y \
wget \
bzip2 \
procps \
ca-certificates \
git \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# Install Miniforge
wget -q https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-x86_64.sh && \
bash Miniforge3-Linux-x86_64.sh -b -f -p /opt/mamba && \
rm Miniforge3-Linux-x86_64.sh

# Add conda to PATH
. /opt/mamba/bin/activate

# Initialize mamba
mamba init
. /root/.bashrc

# Create conda environment
mamba env create -f /opt/environment.yml

# Clean up
mamba clean -afy


%environment
. /root/.bashrc && \
export CONDA_ENV_NAME=$(head -n1 /opt/environment.yml | cut -d' ' -f2) && \
mamba activate $CONDA_ENV_NAME

%runscript
exec "$@"
41 changes: 41 additions & 0 deletions environments/fluviewer.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
BootStrap: docker
From: python:3.9-slim

%files
fluviewer.yml /opt/environment.yml

%post
# Install system dependencies
apt-get update && apt-get install -y \
wget \
bzip2 \
procps \
ca-certificates \
git && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# Install Miniforge
wget -q https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-x86_64.sh && \
bash Miniforge3-Linux-x86_64.sh -b -f -p /opt/mamba && \
rm Miniforge3-Linux-x86_64.sh

# Add conda to PATH
. /opt/mamba/bin/activate && \
mamba init && \
. /root/.bashrc

# Create conda environment
mamba env create -f /opt/environment.yml

# Clean up
mamba clean -afy


%environment
. /root/.bashrc && \
export CONDA_ENV_NAME=$(head -n1 /opt/environment.yml | cut -d' ' -f2) && \
mamba activate $CONDA_ENV_NAME

%runscript
exec "$@"
41 changes: 41 additions & 0 deletions environments/nextclade.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
BootStrap: docker
From: python:3.9-slim

%files
nextclade.yml /opt/environment.yml

%post
# Install system dependencies
apt-get update && apt-get install -y \
wget \
bzip2 \
procps \
ca-certificates \
git && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# Install Miniforge
wget -q https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-x86_64.sh && \
bash Miniforge3-Linux-x86_64.sh -b -f -p /opt/mamba && \
rm Miniforge3-Linux-x86_64.sh

# Add conda to PATH
. /opt/mamba/bin/activate && \
mamba init && \
. /root/.bashrc

# Create conda environment
mamba env create -f /opt/environment.yml

# Clean up
mamba clean -afy


%environment
. /root/.bashrc && \
export CONDA_ENV_NAME=$(head -n1 /opt/environment.yml | cut -d' ' -f2) && \
mamba activate $CONDA_ENV_NAME

%runscript
exec "$@"
2 changes: 1 addition & 1 deletion main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ workflow {

ch_pipeline_provenance = pipeline_provenance(ch_workflow_metadata)

ch_primers = Channel.fromPath(params.primer_path)
ch_primers = Channel.fromPath(params.primers)

ch_db = Channel.fromPath(params.db)

Expand Down
57 changes: 36 additions & 21 deletions nextflow.config
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
manifest {
author = 'James Zlosnik (nextflow pipeline)/Kevin Kuchinski (FluViewer)'
name = 'BCCDC-PHL/fluviewer-nf'
version = '0.3.0'
description = 'BCCDC-PHL FluViewer'
mainScript = 'main.nf'
nextflowVersion = '>=20.01.0'
author = 'James Zlosnik (nextflow pipeline)/Kevin Kuchinski (FluViewer)'
name = 'BCCDC-PHL/fluviewer-nf'
version = '0.3.0'
description = 'BCCDC-PHL FluViewer'
mainScript = 'main.nf'
nextflowVersion = '>=20.01.0'
}

params {
Expand All @@ -17,7 +17,7 @@ params {
fastq_exts = ['.fastq.gz', '.fq.gz', '.fastq', '.fq']
fastq_search_path = makeFastqSearchPath( illumina_suffixes, fastq_exts )
primer_path = "${baseDir}/assets/"
primers = "${baseDir}/assets/primers.fa"
primers = "${projectDir}/assets/primers.fa"
rev_primers = "${baseDir}/assets/primers_rev_comp.fa"
pipeline_short_name = parsePipelineName(manifest.toMap().get('name'))
pipeline_minor_version = parseMinorVersion(manifest.toMap().get('version'))
Expand Down Expand Up @@ -51,7 +51,7 @@ def makeFastqSearchPath ( illumina_suffixes, fastq_exts ) {
def parseRunName ( fastq_input ) {
run_name = (params.fastq_input =~ /([^\/]+)\/?$/)[0][1]
if (!run_name) {
throw new RuntimeException("ERROR: Parsing run name from FASTQ path failed.")
throw new RuntimeException("ERROR: Parsing run name from FASTQ path failed.")
}
return run_name
}
Expand All @@ -69,33 +69,48 @@ def parsePipelineName(name) {

profiles {
conda {
conda.enabled = true
process.conda = "$baseDir/environments/environment.yml"
if (params.cache) {
conda.cacheDir = params.cache
}
conda.useMamba = true
conda.enabled = true
process.conda = "$baseDir/environments/environment.yml"
if (params.cache) {
conda.cacheDir = params.cache
}
conda.useMamba = true
}

apptainer {
apptainer.enabled = true
}
}


trace.overwrite = true
report.overwrite = true
timeline.overwrite = true

process {
container = "${projectDir}/environments/base.sif"

withName: normalize_depth {
conda = "$baseDir/environments/fluviewer.yml"
memory = '50 GB'
conda = "${projectDir}/environments/fluviewer.yml"
container = "${projectDir}/environments/fluviewer.sif"
memory = '50 GB'
cpus = 4
}

withName: fluviewer {
conda = "$baseDir/environments/fluviewer.yml"
cpus = 8
conda = "${projectDir}/environments/fluviewer.yml"
container = "${projectDir}/environments/fluviewer.sif"
cpus = 8
}

withName: cutadapt {
cpus = 8
cpus = 8
}

withName: clade_calling {
conda = "$baseDir/environments/nextclade.yml"
cpus = 4
conda = "${projectDir}/environments/nextclade.yml"
container = "${projectDir}/environments/nextclade.sif"
cpus = 4
}
}

Expand Down