From 1702cdbd19d226f4568927b6bd3900d9720da243 Mon Sep 17 00:00:00 2001 From: Ivan Blagoev Topolsky Date: Wed, 26 Jul 2023 22:43:15 +0200 Subject: [PATCH] Snakedeploy Tests - runs V-pipe straight from the git as per Snakemake Workflow Catalog --- .github/workflows/snakedeploy_tests.yaml | 87 ++++++++++++++++++++++++ README.md | 2 +- tests/conda_snakedeploy_env.yaml | 8 +++ tests/configure_for_virus.sh | 81 ++++++++++++++++++++++ 4 files changed, 177 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/snakedeploy_tests.yaml create mode 100644 tests/conda_snakedeploy_env.yaml create mode 100755 tests/configure_for_virus.sh diff --git a/.github/workflows/snakedeploy_tests.yaml b/.github/workflows/snakedeploy_tests.yaml new file mode 100644 index 00000000..c0cb35b7 --- /dev/null +++ b/.github/workflows/snakedeploy_tests.yaml @@ -0,0 +1,87 @@ +name: Snakedeploy + +on: + push: + pull_request: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + +jobs: + runtime_tests: + env: + THREADS: 5 + + strategy: + max-parallel: 5 + fail-fast: false + matrix: + # python-version: [ "3.11"] + virus: ["hiv"] + #, "sars-cov-2"] + + runs-on: ubuntu-latest + + defaults: + run: + shell: bash -l {0} + + steps: + - name: Checkout test data + uses: actions/checkout@v3 + with: + sparse-checkout: | + tests + sparse-checkout-cone-mode: false + lfs: false + # NOTE to save on bandwidth costs, GitHub Action will not use GitHub's own LFS + + - name: Install conda environment dependencies + uses: conda-incubator/setup-miniconda@v2 + with: + miniforge-version: latest + miniforge-variant: Mambaforge + # python-version: ${{ matrix.python-version }} + mamba-version: "*" + channels: conda-forge,bioconda + channel-priority: strict + activate-environment: snakemake + auto-update-conda: true + environment-file: tests/conda_snakedeploy_env.yaml + + - name: Snakedeploy + # snakedeploy will issue error message if workflow/ or config/ exist, i.e. if tests/ was not sparsely checked out + run: | + snakedeploy deploy-workflow "$(git remote get-url origin)" . --branch "$(git rev-parse HEAD)" + + - name: Configure + run: | + tests/configure_for_virus.sh "${{ matrix.virus }}" "${THREADS}" + + - name: Run test + run: | + PYTHONUNBUFFERED=1 snakemake \ + --use-conda \ + --cores "${THREADS}" \ + --dry-run + + echo + cat config/samples.tsv + echo + + PYTHONUNBUFFERED=1 snakemake \ + --use-conda \ + --cores "${THREADS}" \ + -p \ + --keep-going + + - name: Archive test results + uses: actions/upload-artifact@v3 + with: + name: test_output + path: | + ./* + !./.git + !./.snakemake/conda/*/ + if-no-files-found: ignore diff --git a/README.md b/README.md index c449dd74..0571757d 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,7 @@ docker run --rm -it -v $PWD:/work ghcr.io/cbg-ethz/v-pipe:master --jobs 4 --prin First install [mamba](https://github.com/conda-forge/miniforge#mambaforge), then create and activate an environment with Snakemake and Snakedeploy: ```bash -mamba create -c bioconda -c conda-forge --name snakemake snakemake snakedeploy +mamba create -c conda-forge -c bioconda --name snakemake snakemake snakedeploy conda activate snakemake ``` diff --git a/tests/conda_snakedeploy_env.yaml b/tests/conda_snakedeploy_env.yaml new file mode 100644 index 00000000..ee97b897 --- /dev/null +++ b/tests/conda_snakedeploy_env.yaml @@ -0,0 +1,8 @@ +name: snakemake +channels: + - conda-forge + - bioconda +dependencies: + - snakemake-minimal + - snakedeploy + - go-yq diff --git a/tests/configure_for_virus.sh b/tests/configure_for_virus.sh new file mode 100755 index 00000000..dc493130 --- /dev/null +++ b/tests/configure_for_virus.sh @@ -0,0 +1,81 @@ +#!/usr/bin/env bash + +if [[ -z "$1" || "$1" == '-h' || "$1" == '--help' ]]; then + echo "usage: $0 [threads] + +Description: + creates configuraiton and samples directory for virus in current working directory + +Arguments: + virus - name of the virus to test [ 'hiv', 'sars-cov-2' ] + threads - overides envrionment variable THREADS [ default: 4 ]" + exit 0 +fi + +virus="$1" +threads="${2:-${THREADS:-4}}" +trim_primers="false" + +echo "Configuring for ${virus}, using ${threads} threads" + +# samples data +data_root="tests/data/${virus}" +mkdir -p samples +cp --link -vrf "${data_root}"/*/ samples/ + +if [ -e "${data_root}/samples.tsv" ]; then + cp -vrf "${data_root}/samples.tsv" samples/ + # automatically turn trimming on if 4-columns format in TSV + # shellcheck disable=SC2162 + while read s b l p o; do + # no proto? + if [[ -z "${p}" ]]; then + continue + fi + + # proto => trim! + trim_primers="true" + echo "with trimming" + break + + : "${s} ${b} ${l} ${o}" are unused + done < "samples/samples.tsv" +fi + +# configuration file +cat > config/config.yaml <