Skip to content

Commit 7e296a9

Browse files
authored
Merge pull request #3 from m-jahn/style_options
feat: expose more options to style DAGs formatting and creating module based python package.
2 parents 9933f6c + 83f4db3 commit 7e296a9

File tree

15 files changed

+849
-436
lines changed

15 files changed

+849
-436
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
on:
2+
push:
3+
branches:
4+
- main
5+
6+
permissions:
7+
contents: write
8+
pull-requests: write
9+
issues: write
10+
11+
name: release-please
12+
13+
jobs:
14+
release-please:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: googleapis/release-please-action@v4
18+
with:
19+
token: ${{ secrets.GITHUB_TOKEN }}
20+
release-type: python # this will auto-increment versions in the pyproject.toml and snakevision/__init__.py files

.github/workflows/testing.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Testing
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
7+
jobs:
8+
Formatting:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
with:
13+
fetch-depth: 0
14+
- name: Formatting
15+
uses: super-linter/super-linter@v8
16+
env:
17+
VALIDATE_ALL_CODEBASE: false
18+
DEFAULT_BRANCH: main
19+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
20+
VALIDATE_YAML_PRETTIER: true
21+
VALIDATE_MARKDOWN_PRETTIER: true
22+
VALIDATE_PYTHON_BLACK: true
23+
24+
Testing:
25+
runs-on: ubuntu-latest
26+
strategy:
27+
matrix:
28+
python-version: ["3.8", "3.10", "3.12", "3.14"]
29+
steps:
30+
- uses: actions/checkout@v4
31+
- name: Set up Python
32+
uses: actions/setup-python@v5
33+
with:
34+
python-version: ${{ matrix.python-version }}
35+
cache: pip
36+
- name: Test DAG visualization
37+
run: |
38+
python -m pip install --upgrade pip
39+
python -m pip install .
40+
snakevision \
41+
-s all multiqc \
42+
-y scale=15.0 node_stroke=white edge_stroke_width=3 \
43+
-o examples/atac_dag_test.svg \
44+
examples/atac_rulegraph.dot

README.md

Lines changed: 41 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@
44

55
**_An awesome tool to visualize Snakemake DAGs_**
66

7-
[![GitHub issues](https://img.shields.io/github/issues/OpenOmics/snakevision?color=brightgreen)](https://github.com/OpenOmics/snakevision/issues) [![GitHub license](https://img.shields.io/github/license/OpenOmics/snakevision)](https://github.com/OpenOmics/snakevision/blob/main/LICENSE)
8-
7+
[![GitHub issues](https://img.shields.io/github/issues/OpenOmics/snakevision?color=brightgreen)](https://github.com/OpenOmics/snakevision/issues)
8+
[![GitHub license](https://img.shields.io/github/license/OpenOmics/snakevision)](https://github.com/OpenOmics/snakevision/blob/main/LICENSE)
9+
910
</div>
1011

1112
## Overview
13+
1214
Welcome to snakevision! Before getting started, we highly recommend reading through our documentation below.
1315

14-
**`./snakevision`** provides a simplified command-line interface to visualize Snakemake DAGs or rule graphs. If you are familiar with other existing tools to visualize DAGs like [graphviz](https://graphviz.org/), getting started with `snakevision` should be a breeze.
16+
**`./snakevision`** provides a simplified command-line interface to visualize Snakemake DAGs or rule graphs. If you are familiar with other existing tools to visualize DAGs like [graphviz](https://graphviz.org/), getting started with `snakevision` should be a breeze.
1517

1618
## Examples
1719

@@ -36,40 +38,45 @@ Here are a few Snakemake rule graphs rendered by snakevision. These DAGs come fr
3638
</p>
3739

3840
## Dependencies
41+
3942
**Requires:** `snakemake` `python>=3.7`
4043

41-
At the current moment, the tool is designed to visualize rule graphs of existing snakemake pipelines. As so, [Snakemake<sup>1</sup>](https://snakemake.readthedocs.io/en/stable/) and any dependencies of the pipeline should be installed on the target system. This tool relies on a few 3rd-party pypi python packages which can be installed via pip from the provided [requirements.txt](https://github.com/OpenOmics/snakevision/blob/main/requirements.txt).
44+
At the current moment, the tool is designed to visualize rule graphs of existing snakemake pipelines. As so, [Snakemake<sup>1</sup>](https://snakemake.readthedocs.io/en/stable/) and any dependencies of the pipeline should be installed on the target system. This tool relies on a few 3rd-party pypi python packages which can be installed via pip from the provided [requirements.txt](https://github.com/OpenOmics/snakevision/blob/main/requirements.txt).
4245

4346
Please follow the instructions directly below to install snakevision on your local system.
4447

4548
## Installation
49+
50+
### Github
51+
4652
Please clone this repository to your local filesystem using the following command:
53+
4754
```bash
4855
# Clone Repository from Github
4956
git clone https://github.com/OpenOmics/snakevision.git
57+
5058
# Change your working directory
5159
cd snakevision/
60+
5261
# Create a python virtual environment
5362
# to install required python packages
5463
python -m venv .venv
64+
5565
# Activate the virtual environment
5666
source .venv/bin/activate
67+
5768
# Upgrade pip and install the list
5869
# of required python packages
5970
pip install -U pip
60-
pip install -r requirements.txt
61-
# Get check installation, get
62-
# usage information of tool
63-
./bin/snakevision -h
64-
# Add snakevision to $PATH
65-
export PATH="${PATH}:$PWD/bin"
71+
pip install -e .
6672
```
6773

6874
## Getting Started
6975

7076
Snakevision can read an input snakemake rulegraph via an input file or via standard input directly from a pipe. To create an input rule graph to the `snakevision`, please run snakemake with the `--rulegraph` and `--forceall` options.
7177

72-
Here is an basic example:
78+
### Basic example
79+
7380
```bash
7481
# Create a input file for snakevision
7582
snakemake --configfile=$pipeline_outdir/config.json \
@@ -80,21 +87,38 @@ snakemake --configfile=$pipeline_outdir/config.json \
8087
> pipeline_rulegraph.dot
8188

8289
# Run snakevision, do not include
83-
# rule all and multiqc in the image,
90+
# rule all and multiqc in the image,
8491
# makes final image less cluttered
8592
snakevision \
8693
-s all mutliqc \
8794
-o pipeline_rulegraph.svg \
8895
pipeline_rulegraph.dot
8996
```
9097

91-
## Contribute
92-
This site is a living document, created for and by members like you. snakevision is maintained by the members of OpenOmics and is improved by continuous feedback! We encourage you to contribute new content and make improvements to existing content via pull requests to our [GitHub repository](https://github.com/OpenOmics/snakevision).
98+
### Customize DAG
99+
100+
Snakevision provides a few options to customize the style of the DAG output.
101+
You can specify these options using the `-y` or `--styles` flag followed by the key-value pairs.
102+
Use `-y` multiple times to specify multiple style attributes.
103+
For example, you can change the size of the nodes and edges in the DAG by using the following command:
104+
105+
```bash
106+
snakevision \
107+
-y node_radius=10.0 \
108+
-y edge_stroke_width=8.0 \
109+
-o pipeline_rulegraph.svg \
110+
pipeline_rulegraph.dot
111+
```
112+
113+
For the full list of available options, run `snakevision -h`.
93114

115+
## Contribute
116+
117+
This site is a living document, created for and by members like you. snakevision is maintained by the members of OpenOmics and is improved by continuous feedback! We encourage you to contribute new content and make improvements to existing content via pull requests to our [GitHub repository](https://github.com/OpenOmics/snakevision).
94118

95119
## Cite
96120

97-
If you use this software, please cite it as below:
121+
If you use this software, please cite it as below:
98122

99123
<details>
100124
<summary><b><i>@BibText</i></b></summary>
@@ -115,4 +139,5 @@ Citation coming soon!
115139
</details>
116140

117141
## References
118-
<sup>**1.** Koster, J. and S. Rahmann (2018). "Snakemake-a scalable bioinformatics workflow engine." Bioinformatics 34(20): 3600.</sup>
142+
143+
<sup>**1.** Koster, J. and S. Rahmann (2018). "Snakemake-a scalable bioinformatics workflow engine." Bioinformatics 34(20): 3600.</sup>

bin/snakevision

Lines changed: 0 additions & 1 deletion
This file was deleted.

pyproject.toml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
[build-system]
2+
requires = ["setuptools>=68", "wheel"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "snakevision"
7+
version = "0.1.0"
8+
description = "A tool to visualize Snakemake workflows."
9+
authors = [
10+
{ name = "Skyler Kuhn" },
11+
{ name = "Michael Jahn" },
12+
]
13+
readme = "README.md"
14+
requires-python = ">=3.7,<4"
15+
license = { file = "LICENSE" }
16+
keywords = ["snakemake", "workflow", "visualization", "graphviz", "bioinformatics"]
17+
classifiers = [
18+
"Operating System :: OS Independent",
19+
"Programming Language :: Python :: 3",
20+
"Programming Language :: Python :: 3.7",
21+
"Programming Language :: Python :: 3.8",
22+
"Programming Language :: Python :: 3.9",
23+
"Programming Language :: Python :: 3.10",
24+
"Programming Language :: Python :: 3.11",
25+
"Programming Language :: Python :: 3.12",
26+
"Programming Language :: Python :: 3.13",
27+
"Programming Language :: Python :: 3.14",
28+
"Topic :: Scientific/Engineering :: Bio-Informatics"
29+
]
30+
31+
# Main package dependencies
32+
dependencies = [
33+
"dagviz>=0.4.0,<1",
34+
"networkx>=2.5.1,<4"
35+
]
36+
37+
# Testing, linting, ci, and build dependencies
38+
[project.optional-dependencies]
39+
dev = [
40+
"black>=24.0.0",
41+
"pytest>=8.0.0",
42+
"build>=1.2.0",
43+
"twine>=5.0.0",
44+
]
45+
46+
[project.urls]
47+
Repository = "https://github.com/OpenOmics/snakevision"
48+
Issues = "https://github.com/OpenOmics/snakevision/issues"
49+
50+
# Main entry point for the command-line interface
51+
[project.scripts]
52+
snakevision = "snakevision.cli:main"
53+
54+
[tool.setuptools]
55+
packages = ["snakevision"]

requirements.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

snakevision/__init__.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
"""Top-level package for snakevision.
2+
3+
This package provides tools for parsing Snakemake rule graphs, constructing
4+
directed acyclic graph (DAG) representations, and rendering workflow
5+
visualizations. The package exposes the `SnakeVision` class as its primary
6+
public interface, along with other package metadata (such as the version).
7+
"""
8+
from .snakevision import SnakeVision
9+
from .version import __version__
10+
11+
12+
# Expose the SnakeVision class along
13+
# with its version information
14+
__all__ = ["SnakeVision", "__version__"]

snakevision/__main__.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
"""Command-line entry point for the snakevision package.
2+
3+
This module is executed when running `python -m snakevision`. The `main()`
4+
function from `cli.py` validates the Python version, parses command-line
5+
arguments, normalizes selected multi-value CLI options, constructs a
6+
`SnakeVision` DAG object from the provided Snakemake rule graph input,
7+
and writes the rendered DAG to an output file.
8+
9+
This module is intended as an execution wrapper around the package's reusable
10+
library components and is not the primary location for core parsing or graph
11+
construction logic. Please see `snakevision.py` for the main implementation
12+
of the `SnakeVision` class. This contains the core logic for parsing Snakemake
13+
rule graph, building a DAG, and writing the resulting DAG as a snakevision
14+
image.
15+
16+
To run the command-line interface, execute the following command in your terminal:
17+
$ python -m snakevision [OPTIONS] snakemake_rulegraph
18+
19+
For more information about available options and usage, run:
20+
$ python -m snakevision --help
21+
"""
22+
# Local relative imports
23+
from .cli import main
24+
25+
26+
# Main entry-point to the command-line interface
27+
main()

0 commit comments

Comments
 (0)