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
60 changes: 60 additions & 0 deletions .github/workflows/snakemake.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Run Snakemake Workflow

on:
pull_request:
branches:
- main
workflow_dispatch:

jobs:
snakemake:
runs-on: ubuntu-latest
permissions:
contents: read

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Miniforge
uses: conda-incubator/setup-miniconda@v3
with:
miniforge-variant: Miniforge3
miniforge-version: latest
activate-environment: snakemake
use-mamba: true

- name: Install mamba
shell: bash -el {0}
run: |
conda install -n base -c conda-forge mamba

- name: Install Snakemake
shell: bash -el {0}
run: |
mamba install -c conda-forge -c bioconda snakemake

- name: Run Snakemake workflow
shell: bash -el {0}
run: |
cd workflow
snakemake --use-conda --cores 1

- name: Check logs
shell: bash -el {0}
run: |
tail -1000 log/*log
# cat workflow/output/hello_output.txt
# if [ "$(cat workflow/output/hello_output.txt)" = "Hello World!" ]; then
# echo "✓ Output verified successfully!"
# else
# echo "✗ Output verification failed!"
# exit 1
# fi

- name: Upload output artifact
uses: actions/upload-artifact@v4
if: always()
with:
name: workflow-output
path: workflow/output/
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
build/
output/
.snakemake/
_codeql_detected_source_root
src/_codeql_build_dir/
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,39 @@
# drab

RNA-seq count tables, revisited

### Structure

- `src/`: Contains C++ source code and CMakeLists.txt
- `env/`: Contains Conda environment specifications
- `workflow/`: Contains Snakefile for build automation

### Running with snmk

To build and run the example using Snakemake:

```bash
cd workflow
snakemake --use-conda --cores 1
```

This will:
1. Create a conda environment with cmake and g++
2. Compile the C++ code
3. Run the executable and save output to `output/hello_output.txt`

### Building `src`

To build manually without Snakemake:

```bash
mkdir -p build
cd build
cmake ../src
cmake --build .
./hello
```

### CI/CD

- `snakemake.yml` to run the workflow (serially)
7 changes: 7 additions & 0 deletions env/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
channels:
- conda-forge
- bioconda
- nodefaults
dependencies:
- cmake>=4.1
- cxx-compiler
8 changes: 8 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.10)

project(HelloWorld)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)

add_executable(hello hello.cpp)
6 changes: 6 additions & 0 deletions src/hello.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include <iostream>

int main() {
std::cout << "Hello World!" << std::endl;
return 0;
}
38 changes: 38 additions & 0 deletions workflow/Snakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env snakemake -s

rule all:
input:
"output/hello_output.txt"

rule compile:
conda:
"../env/build.yaml"
input:
cpp="src/hello.cpp",
cmake="src/CMakeLists.txt"
log:
"../log/compile.log"
output:
"build/hello"
shell:
"""
mkdir -p build log
cd build
cmake ../src &> {log}
cmake --build . &>> {log}
"""

rule run:
conda:
"../env/build.yaml"
input:
"build/hello"
output:
"output/hello_output.txt"
log:
"log/run.log"
shell:
"""
mkdir -p output
{input} > {output} &> {log}
"""
1 change: 1 addition & 0 deletions workflow/src
Loading