forked from mwaskom/lyman
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwrite_graphs.py
46 lines (36 loc) · 1.19 KB
/
write_graphs.py
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
"""Save graphical representations of all the lyman workflows."""
from __future__ import print_function
import os
import re
import sys
from glob import glob
from lyman import workflows as wf
from nipype import config
def main(arglist):
config.set('logging', 'workflow_level', 'CRITICAL')
# Find the functions that create workflows
wf_funcs = [k for k in dir(wf) if re.match("create_.*_workflow", k)]
for func in wf_funcs:
try:
out = getattr(wf, func)()
except:
print("ERROR: call to %s failed" % func)
# Some of the workflow functions return (flow, inputs, outputs)
try:
flow, _, _ = out
except TypeError:
flow = out
# Write the graphs
name = flow.name
if arglist:
if name in arglist:
flow.write_graph("graphs/%s.dot" % name, "orig", format="svg")
else:
flow.write_graph("graphs/%s.dot" % name, "orig", format="svg")
# Remove the .dot files as they are not of use to us
files = glob("graphs/*")
for f in files:
if f.endswith(".dot"):
os.remove(f)
if __name__ == "__main__":
main(sys.argv[1:])