File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Run Snakemake Workflow
2+
3+ on :
4+ pull_request :
5+ branches :
6+ - main
7+ workflow_dispatch :
8+
9+ jobs :
10+ snakemake :
11+ runs-on : ubuntu-latest
12+ permissions :
13+ contents : read
14+
15+ steps :
16+ - name : Checkout repository
17+ uses : actions/checkout@v4
18+
19+ - name : Setup Miniforge
20+ uses : conda-incubator/setup-miniconda@v3
21+ with :
22+ miniforge-variant : Miniforge3
23+ miniforge-version : latest
24+ activate-environment : snakemake
25+ use-mamba : true
26+
27+ - name : Install mamba
28+ shell : bash -el {0}
29+ run : |
30+ conda install -n base -c conda-forge mamba
31+
32+ - name : Install Snakemake
33+ shell : bash -el {0}
34+ run : |
35+ mamba install -c conda-forge -c bioconda snakemake
36+
37+ - name : Run Snakemake workflow
38+ shell : bash -el {0}
39+ run : |
40+ cd workflow
41+ snakemake --use-conda --cores 1
42+
43+ - name : Check logs
44+ shell : bash -el {0}
45+ run : |
46+ tail -1000 log/*log
47+ # cat workflow/output/hello_output.txt
48+ # if [ "$(cat workflow/output/hello_output.txt)" = "Hello World!" ]; then
49+ # echo "✓ Output verified successfully!"
50+ # else
51+ # echo "✗ Output verification failed!"
52+ # exit 1
53+ # fi
54+
55+ - name : Upload output artifact
56+ uses : actions/upload-artifact@v4
57+ if : always()
58+ with :
59+ name : workflow-output
60+ path : workflow/output/
Original file line number Diff line number Diff line change 1+ build /
2+ output /
3+ .snakemake /
4+ _codeql_detected_source_root
5+ src /_codeql_build_dir /
Original file line number Diff line number Diff line change 11# drab
2+
23RNA-seq count tables, revisited
4+
5+ ### Structure
6+
7+ - ` src/ ` : Contains C++ source code and CMakeLists.txt
8+ - ` env/ ` : Contains Conda environment specifications
9+ - ` workflow/ ` : Contains Snakefile for build automation
10+
11+ ### Running with snmk
12+
13+ To build and run the example using Snakemake:
14+
15+ ``` bash
16+ cd workflow
17+ snakemake --use-conda --cores 1
18+ ```
19+
20+ This will:
21+ 1 . Create a conda environment with cmake and g++
22+ 2 . Compile the C++ code
23+ 3 . Run the executable and save output to ` output/hello_output.txt `
24+
25+ ### Building ` src `
26+
27+ To build manually without Snakemake:
28+
29+ ``` bash
30+ mkdir -p build
31+ cd build
32+ cmake ../src
33+ cmake --build .
34+ ./hello
35+ ```
36+
37+ ### CI/CD
38+
39+ - ` snakemake.yml ` to run the workflow (serially)
Original file line number Diff line number Diff line change 1+ channels :
2+ - conda-forge
3+ - bioconda
4+ - nodefaults
5+ dependencies :
6+ - cmake>=4.1
7+ - cxx-compiler
Original file line number Diff line number Diff line change 1+ cmake_minimum_required (VERSION 3.10 )
2+
3+ project (HelloWorld)
4+
5+ set (CMAKE_CXX_STANDARD 11)
6+ set (CMAKE_CXX_STANDARD_REQUIRED True )
7+
8+ add_executable (hello hello.cpp )
Original file line number Diff line number Diff line change 1+ #include < iostream>
2+
3+ int main () {
4+ std::cout << " Hello World!" << std::endl;
5+ return 0 ;
6+ }
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env snakemake -s
2+
3+ rule all :
4+ input :
5+ "output/hello_output.txt"
6+
7+ rule compile :
8+ conda :
9+ "../env/build.yaml"
10+ input :
11+ cpp = "src/hello.cpp" ,
12+ cmake = "src/CMakeLists.txt"
13+ log :
14+ "../log/compile.log"
15+ output :
16+ "build/hello"
17+ shell :
18+ """
19+ mkdir -p build log
20+ cd build
21+ cmake ../src &> {log}
22+ cmake --build . &>> {log}
23+ """
24+
25+ rule run :
26+ conda :
27+ "../env/build.yaml"
28+ input :
29+ "build/hello"
30+ output :
31+ "output/hello_output.txt"
32+ log :
33+ "log/run.log"
34+ shell :
35+ """
36+ mkdir -p output
37+ {input} > {output} &> {log}
38+ """
Original file line number Diff line number Diff line change 1+ ../src/
You can’t perform that action at this time.
0 commit comments