summaryrefslogtreecommitdiff
path: root/snakemake.el
diff options
context:
space:
mode:
Diffstat (limited to 'snakemake.el')
-rw-r--r--snakemake.el26
1 files changed, 26 insertions, 0 deletions
diff --git a/snakemake.el b/snakemake.el
index 20ec2cd..f6d769b 100644
--- a/snakemake.el
+++ b/snakemake.el
@@ -350,6 +350,32 @@ targets."
(snakemake-all-rules))
" "))
+;;;###autoload
+(defun snakemake-graph (rules &optional rule-graph)
+ "Display graph for DAG of RULES.
+
+The graph will be processed by `snakemake-dot-program' and
+displayed with `image-mode'.
+
+If prefix argument RULE-GRAPH is non-nil, pass --rulegraph
+instead of --dag to snakemake.
+
+$ snakemake --{dag,rulegraph} -- RULES | display"
+ (interactive (list (or (snakemake-file-targets-at-point 'check)
+ (snakemake-rule-at-point 'target)
+ (snakemake-read-rule 'targets))
+ current-prefix-arg))
+ (let ((dir (snakemake-snakefile-directory)))
+ (with-current-buffer (get-buffer-create "*Snakemake graph*")
+ (setq default-directory dir)
+ (let ((inhibit-read-only t))
+ (erase-buffer)
+ (apply #'call-process snakemake-program nil t nil
+ (if rule-graph "--rulegraph" "--dag")
+ (if (listp rules) rules (list rules))))
+ (image-mode)
+ (pop-to-buffer (current-buffer)))))
+
;;; Compilation commands