Last active
October 20, 2023 04:28
-
-
Save clintval/69e7bd436c2d4aa9928b6a536c38740d to your computer and use it in GitHub Desktop.
Render Snakemake DAGs in your terminal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Convert DOT graph data into a terminal-ready visualization | |
function idot { | |
dot \ | |
-Tpng -Gdpi=300 \ | |
-Efontsize=18 -Efontname=sans -Nfontname=sans \ | |
-Gbgcolor=black -Gcolor=white -Ecolor=white -Efontcolor=white -Ncolor=white -Nfontcolor=white \ | |
| convert -trim -bordercolor black -border 20 -transparent black -resize "60%" - - \ | |
| imgcat # Or swap with your favorite terminal image viewer | |
} | |
# Render a visualization of the Snakemake pipeline to the terminal | |
function snakegraph { | |
local dag | |
local snakefile="${1:-Snakefile}" | |
if [ ! -f $snakefile ]; then print "USAGE: snakegraph <Snakefile>"; return 1; fi | |
dag=$( snakemake -s "${snakefile}" --forceall --dag ) || return 1 | |
echo $dag | idot | |
} | |
# Inspired by: https://twitter.com/thingskatedid/status/1386077306381242371 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
nice!