Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,306 changes: 1,306 additions & 0 deletions assets/bindcraft_reporting.qmd

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions conf/gadi.config
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ params {
use_dgxa100 = false
}

env.OPENMM_PLATFORM_ORDER="CPU"
env.OPENMM_DEFAULT_PLATFORM="CPU"

process {
executor = "pbspro"
storage = "gdata/if89+scratch/${params.project}+gdata/${params.project}"
Expand Down
3 changes: 2 additions & 1 deletion conf/modules.config
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ process {
withName: 'JSONMANAGER' {
memory = 2.GB
time = 1.h
ext.args2 = "${params.quote_char}"
//ext.args2 = "${params.quote_char}"
}

withName: 'RANKER' {
Expand All @@ -42,6 +42,7 @@ process {
withName: 'BINDCRAFT' {
container = "${params.bindcraft_container}"
memory = 24.GB
time = 24.h
errorStrategy = params.error_strategy ?: "terminate"
afterScript = {
def output_path = new File("${params.outdir}")
Expand Down
42 changes: 42 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Use the latest official Ubuntu image from Docker Hub
FROM mambaorg/micromamba:2.3.3
LABEL maintainer="Ziad Al Bkhetan <ziad.albkhetan@gmail.come>"
LABEL version="1.0.3"
LABEL description="A Docker image for running Free Bindcraft "
LABEL org.opencontainers.image.authors="Ziad Al Bkhetan"
LABEL org.opencontainers.image.licenses="MIT"

# Prevent interactive prompts during package installation
ENV DEBIAN_FRONTEND=noninteractive
ARG MAMBA_DOCKERFILE_ACTIVATE=1

WORKDIR /
USER root
RUN mkdir -p /work && chown -R mambauser:mambauser /work
USER mambauser
WORKDIR /work
RUN micromamba install -y -n base -c conda-forge git wget gcc && micromamba clean -a -y
RUN git clone --branch v1.0.3 --depth 1 https://github.com/cytokineking/FreeBindCraft
WORKDIR FreeBindCraft

# making it work for micromamba by replacing conda by micromamba and installing to the base env

RUN sed -i '/\$pkg_manager create --name BindCraft/s/^/#/' install_bindcraft.sh
RUN sed -i '/conda env list | grep -w/s/^/#/' install_bindcraft.sh
RUN sed -i '/source ${CONDA_BASE}\/bin\/activate/s/^/#/' install_bindcraft.sh
RUN sed -i '/[[:space:]]*\[ "\$CONDA_DEFAULT_ENV" = "BindCraft" \]/s/^/#/' install_bindcraft.sh
RUN sed -i 's/\<conda\>/micromamba/g' install_bindcraft.sh
RUN sed -i 's/\<micromamba-forge\>/conda-forge/g' install_bindcraft.sh

RUN bash install_bindcraft.sh --cuda '12.4' --pkg_manager 'micromamba' --no-pyrosetta
ENV PATH="$PATH:/work/FreeBindCraft"
USER root
RUN apt-get update && apt-get install -y --no-install-recommends procps && rm -rf /var/lib/apt/lists/*
USER mambauser
RUN micromamba install -y -n base -c conda-forge ffmpeg && \
micromamba clean -a -y
ENV PATH=/opt/conda/bin:$PATH
ENV PYTHONPATH="/work/FreeBindCraft"

# Set default command
CMD ["python", "-u", "bindcraft.py"]
105 changes: 105 additions & 0 deletions docker/Dockerfile-1
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# This Dockerfile was adapted from the below to create a bindcraft container by Uwe Winter <uwe@biocommons.org.au>
# This Dockerfile was adapted for running on Azure CycleCloud by Felipe Ayora
# (bizdata.co.nz)

# Copyright 2021 DeepMind Technologies Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Look for latest version that matches NVIDIA drivers on the Azure GPU machines:
# https://hub.docker.com/r/nvidia/cuda/tags?page=1&name=cudnn8-runtime-ubuntu18

# Build image:
# 1. Run:
# git clone https://github.com/deepmind/alphafold/releases/tag/vx.x.x
# cd ./alphafold
# 2. Run:
# sudo docker build -t <repo/tag:version> -f ./path/to/this/Dockerfile .

ARG CUDA=12.4.1
FROM nvidia/cuda:${CUDA}-cudnn-runtime-ubuntu22.04

# Remove entrypoint messaging to stdout
RUN rm /opt/nvidia/entrypoint.d/*

# FROM directive resets ARGS, so we specify again

ARG CUDA_MAJOR=12
ARG CUDACMDTOOLS=12.4

# Use bash to support string substitution.
SHELL ["/bin/bash", "-c"]

RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
build-essential \
cmake \
cuda-command-line-tools-${CUDACMDTOOLS/./-} \
wget \
git \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get autoremove -y \
&& apt-get clean

# Install Miniconda package manager.
RUN wget -q -P /tmp \
https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh \
&& bash /tmp/Miniconda3-latest-Linux-x86_64.sh -b -p /opt/conda \
&& rm /tmp/Miniconda3-latest-Linux-x86_64.sh

# Install conda packages.
ENV PATH="/opt/conda/bin:$PATH"

RUN conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/main
RUN conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/r

COPY bindcraft /app/
RUN chmod +x /app/install_bindcraft.sh

WORKDIR /app/
RUN /app/install_bindcraft.sh --cuda 12.4.1 --pkg_manager 'conda'

# Install pip packages.

# Add SETUID bit to the ldconfig binary so that non-root users can run it.
RUN chmod u+s /sbin/ldconfig.real

# properly configure ldconfig and run it
RUN echo "/opt/conda/lib" > /etc/ld.so.conf.d/conda.conf \
&& echo "/opt/conda/envs/BindCraft/lib" >> /etc/ld.so.conf.d/conda.conf \
&& ldconfig

# ENTRYPOINT does not support easily running multiple commands, so instead we
# write a shell script to wrap them up.
# We need to run `ldconfig` first to ensure GPUs are visible, due to some quirk
# with Debian. See https://github.com/NVIDIA/nvidia-docker/issues/1399 for
# details.
RUN printf '#!/bin/bash\n\
ldconfig\n\
__conda_setup="$('/opt/conda/bin/conda' '\''shell.bash'\'' '\''hook'\'' 2> /dev/null)"\n\
if [ $? -eq 0 ]; then\n\
eval "$__conda_setup"\n\
else\n\
if [ -f "/opt/conda/etc/profile.d/conda.sh" ]; then\n\
. "/opt/conda/etc/profile.d/conda.sh"\n\
else\n\
export PATH="/opt/conda/bin:$PATH"\n\
fi\n\
fi\n\
unset __conda_setup\n\
conda activate BindCraft\n\
python -u /app/bindcraft.py "$@"\n' > /app/run_bindcraft.sh \
&& chmod +x /app/run_bindcraft.sh

# Removed entry point to facilitate running via Galaxy bash scripts
ENTRYPOINT ["/app/run_bindcraft.sh"]
2 changes: 1 addition & 1 deletion docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

`outdir`: the output directory where the results will be stored.

`bindcraft_container`: the path to bindcraft container that is needed run the workflow.
`bindcraft_container`: the path to bindcraft container that is needed run the workflow. By default, teh workflow uses n open source version of Bindcraft ([FreeBindCraft](https://github.com/cytokineking/FreeBindCraft)) that is is hosted at Docker hub ([freebindcraft:1.0.3](https://hub.docker.com/r/australianbiocommons/freebindcraft)).

### Optional

Expand Down
6 changes: 5 additions & 1 deletion modules/local/bindcraft/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ process BINDCRAFT {
tuple val(meta), path("*_output/Accepted/Ranked"), emit: accepted_ranked
tuple val(meta), path("*_output/Accepted/*pdb"), emit: accepted
tuple val(meta), path("*_output"), emit: output_dir
tuple val(meta), path("*_output/failure_csv.csv") , emit: failure_csv
tuple val(meta), path("*_output/final_design_stats.csv"), emit: final_design_stats
tuple val(meta), path("*_output/mpnn_design_stats.csv"), emit: mpnn_design_stats
tuple val(meta), path("*_output/trajectory_stats.csv"), emit: trajectory_stats
path "versions.yml", emit: versions

when:
Expand All @@ -22,7 +26,7 @@ process BINDCRAFT {
def args = task.ext.args ?: ''

"""
/app/run_bindcraft.sh \\
python /work/FreeBindCraft/bindcraft.py \\
--settings ${target_file} \\
--filters ${filters} \\
--advanced ${advanced_settings} \\
Expand Down
51 changes: 51 additions & 0 deletions modules/local/generate_report.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
process GENERATE_REPORT {
tag "all-run"
label 'process_single'
container 'ghcr.io/australian-protein-design-initiative/containers/nf-binder-design-utils:0.1.5'

input:
// Stage all batch result directories under ./batches/{n}/
// Note the {n} in this case is a list index and may not match the batch_id
// For the purposes of generating aggregate stats, the batch_id is not important
path ('batches/*')
path('failure_csv.csv')
path('final_design_stats.csv')
path('mpnn_design_stats.csv')
path('trajectory_stats.csv')
path (qmd_template)

output:
path('bindcraft_report.html'), emit: report

when:
task.ext.when == null || task.ext.when

script:
def args = task.ext.args ?: ''
"""
export XDG_CACHE_HOME="./.cache"
export XDG_DATA_HOME="./.local/share"
export JUPYTER_RUNTIME_DIR="./.jupyter"
export XDG_RUNTIME_DIR="/tmp"

quarto render ${qmd_template} \\
--execute-dir \${PWD} \\
--output - > bindcraft_report.html

cat <<-END_VERSIONS > versions.yml
"${task.process}":
quarto: \$(quarto --version)
END_VERSIONS
"""

stub:
"""

touch bindcraft_report.html

cat <<-END_VERSIONS > versions.yml
"${task.process}":
quarto: \$(quarto --version)
END_VERSIONS
"""
}
Empty file added modules/local/reporting/main.nf
Empty file.
18 changes: 9 additions & 9 deletions nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ params {
settings_advanced = null
batches = 1
quote_char = "\""
bindcraft_container = null
bindcraft_container = "australianbiocommons/freebindcraft:1.0.3"

// MultiQC options
multiqc_config = null
Expand Down Expand Up @@ -186,14 +186,14 @@ env {
}

// Set bash options
process.shell = """\
bash

set -e # Exit if a tool returns a non-zero status/exit code
set -u # Treat unset variables and parameters as an error
set -o pipefail # Returns the status of the last command to exit with a non-zero status or zero if all successfully execute
set -C # No clobber - prevent output redirection from overwriting files.
"""
process.shell = [
"bash",
"-C", // No clobber - prevent output redirection from overwriting files.
"-e", // Exit if a tool returns a non-zero status/exit code
"-u", // Treat unset variables and parameters as an error
"-o", // Returns the status of the last command to exit..
"pipefail" // ..with a non-zero status or zero if all successfully execute
]

// Disable process selector warnings by default. Use debug profile to enable warnings.
nextflow.enable.configProcessNamesValidation = false
Expand Down
2 changes: 0 additions & 2 deletions nextflow_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@
"properties": {
"bindcraft_container": {
"type": "string",
"format": "file-path",
"exists": true,
"description": "Path to bindcraft container to be used during execution.",
"help_text": "",
"fa_icon": "fas fa-file-csv"
Expand Down
31 changes: 31 additions & 0 deletions subworkflows/local/run_bindcraft.nf
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ include { JSONMANAGER } from '../../modules/local/jsonmanager'
include { samplesheetToList } from 'plugin/nf-schema'
include { BINDCRAFT } from '../../modules/local/bindcraft'
include { RANKER } from '../../modules/local/ranker'
include { GENERATE_REPORT } from '../../modules/local/generate_report'

/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SUBWORKFLOW TO INITIALISE PIPELINE
Expand Down Expand Up @@ -83,6 +85,34 @@ workflow RUN_BINDCRAFT {
BINDCRAFT.out.accepted_ranked.map{[["id": it[0].id], it[1]]}.groupTuple()
)

GENERATE_REPORT(
BINDCRAFT.out.output_dir.map{it[1]}.collect(),
BINDCRAFT.out.failure_csv
.map{it[1]}
.splitCsv( header: true )
.collect()
.map{
it.inject([:]) { acc, map ->
map.each { k, v ->
def num = v?.toString()?.isNumber() ? v.toBigDecimal() : 0
acc[k] = (acc[k] ?: 0) + num
}
def keys = acc.keySet().toList()
def values = keys.collect { acc[it] }
keys.join(',') + "\n" + values.join(',')
}
}.collectFile( name: "failure_csv.csv")
,
RANKER.out.stats.map{it[1]},
BINDCRAFT.out.mpnn_design_stats
.map{it[1].text}
.collectFile( name: "mpnn_design_stats.csv" ),
BINDCRAFT.out.trajectory_stats
.map{it[1].text}
.collectFile( name: "trajectory_stats.csv" ),
Channel.fromPath("${projectDir}/assets/bindcraft_reporting.qmd").first()
)

emit:
input_json = JSONMANAGER.out.json
.flatten()
Expand All @@ -93,6 +123,7 @@ workflow RUN_BINDCRAFT {
output_dir = BINDCRAFT.out.output_dir
stats = RANKER.out.stats
ranked = RANKER.out.accepted_ranked
reports = GENERATE_REPORT.out.report
versions = ch_versions
}

Expand Down
2 changes: 1 addition & 1 deletion subworkflows/local/utils_nfcore_bindflow_pipeline/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -223,5 +223,5 @@ def validateInputParameters() {
// Print a warning when using Bindcraft
//
def checkBindcraftContainer() {
log.warn "You need to provide a valid path for the singularity/Docker container! or bindcraft needs to be avaialble on the system!"
error ("You need to provide a valid path for the singularity/Docker container! or bindcraft needs to be avaialble on the system!")
}
7 changes: 5 additions & 2 deletions tower.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
reports:
multiqc_report.html:
display: "MultiQC HTML report"
"*_report.html":
display: "HTML report"
samplesheet.csv:
display: "Auto-created samplesheet with collated metadata and FASTQ paths"
"*_final_design_stats.csv":
display: "Stats and Ranking"

1 change: 1 addition & 0 deletions workflows/bindflow.nf
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ workflow BINDFLOW {
ch_batches,
quote_char
)

//
// Collate and save software versions
//
Expand Down
Loading