diff --git a/.gitignore b/.gitignore index 8867849..8b482ab 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ Validation_notes.md .Rproj.user */__pycache__/*.pyc assets/genoflu/GenoFLU +*sif diff --git a/environments/base.def b/environments/base.def new file mode 100644 index 0000000..a455b4d --- /dev/null +++ b/environments/base.def @@ -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 "$@" \ No newline at end of file diff --git a/environments/fluviewer.def b/environments/fluviewer.def new file mode 100644 index 0000000..85b8872 --- /dev/null +++ b/environments/fluviewer.def @@ -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 "$@" \ No newline at end of file diff --git a/environments/nextclade.def b/environments/nextclade.def new file mode 100644 index 0000000..611764a --- /dev/null +++ b/environments/nextclade.def @@ -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 "$@" \ No newline at end of file diff --git a/main.nf b/main.nf index c52d108..467205b 100644 --- a/main.nf +++ b/main.nf @@ -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) diff --git a/nextflow.config b/nextflow.config index e1855d5..561f7c6 100644 --- a/nextflow.config +++ b/nextflow.config @@ -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 { @@ -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')) @@ -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 } @@ -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 } }