Skip to content

Commit

Permalink
Snakedeploy Tests
Browse files Browse the repository at this point in the history
- runs V-pipe straight from the git as per Snakemake Workflow Catalog
  • Loading branch information
DrYak committed Jul 26, 2023
1 parent c691df2 commit 7970894
Show file tree
Hide file tree
Showing 3 changed files with 153 additions and 1 deletion.
144 changes: 144 additions & 0 deletions .github/workflows/snakedeploy_tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
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_test_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: |
virus="${{ matrix.virus }}"
threads="${THREADS}"
trim_primers="false"
# samples data
data_root="tests/data/${virus}"
mkdir -p samples
mv -v "${data_root}"/*/ samples/
if [ -e "${data_root}/samples.tsv" ]; then
mv -v "${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 <<CONFIG
general:
virus_base_config: "${virus}"
output:
snv: true
local: true
global: false
visualization: true
diversity: true
QA: true
upload: true
trim_primers: ${trim_primers}
upload:
orig_cram: true
snv:
threads: ${threads}
CONFIG
# does this test data provides extra configuration options
if [ -e "${data_root}/config-extra.yaml" ]; then
echo "with extra config:"
cat "${data_root}/config-extra.yaml"
echo
# recursively merge using go-yq
yq eval-all --inplace '. as $item ireduce ({}; . * $item )' config/config.yaml "${data_root}/config-extra.yaml"
fi
- 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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand Down
8 changes: 8 additions & 0 deletions tests/conda_snakedeploy_env.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: snakemake
channels:
- conda-forge
- bioconda
dependencies:
- snakemake-minimal
- snakedeploy
- go-yq

0 comments on commit 7970894

Please sign in to comment.