aboutsummaryrefslogtreecommitdiff
path: root/snakemake-file-targets
blob: 12dca781f13431b9ca6ba2ef99812f56da9c6a02 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/env python3
"""Print all concrete file targets.

Usage: snakemake-file-targets [SNAKEFILE]
"""
import sys
from snakemake.workflow import Workflow

if len(sys.argv) == 1:
    snakefile = "Snakefile"
elif len(sys.argv) == 2 and sys.argv[1] not in ["-h", "--help"]:
    snakefile = sys.argv[1]
else:
    sys.exit(__doc__)

workflow = Workflow(snakefile=snakefile, snakemakepath="snakemake")
workflow.include(snakefile)

for rule in workflow.rules:
    for fname in rule.output:
        if not callable(fname) and not fname.contains_wildcard():
            try:
                print(fname)
            except BrokenPipeError:
                sys.exit(0)