Skip to content

Commit bbdb8e1

Browse files
committed
Added script(s) for making mixmaster's flux graphs prettier.
mixmaster.py just loads Mixmaster pretty.bat is a batch/shell script you can set in mixmaster as the command used to draw graphs prettyDot.py is the script that reads an ugly rxnpath.dot and makes a prettier rxnpath2.dot You'll need a folder of pics/*.png alongside wherever you run dot.
1 parent 2181a30 commit bbdb8e1

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

mixmaster.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from MixMaster import MixMaster
2+
o = MixMaster()
3+

pretty.bat

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
python prettydot.py
2+
dot -T gif rxnpath2.dot > rxnpath.gif

prettyDot.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# this version updated by RHW in November 2008
2+
"""
3+
make the dot file prettier
4+
"""
5+
import os, sys, re
6+
7+
StripLineLabels=False
8+
if StripLineLabels:
9+
print "stripping edge (line) labels"
10+
11+
infile=file('rxnpath.dot')
12+
outfile=file('rxnpath2.dot','w')
13+
14+
# replace this:
15+
# s10 [ fontname="Helvetica", label="C11H23J"];
16+
# with this:
17+
# s10 [ shapefile="mols/C11H23J.png" label="" width="1" height="1" imagescale=true fixedsize=true color="white" ];
18+
19+
reSize=re.compile('size=\"5,6\"\;page=\"5,6\"')
20+
reNode=re.compile('(?P<node>s\d+)\ \[\ fontname=\"Helvetica\",\ label=\"(?P<label>[^\"]*)\"\]\;')
21+
22+
for line in infile:
23+
(line,changedSize)=reSize.subn('size="12,12";page="12,12"',line)
24+
match=reNode.search(line)
25+
if match:
26+
if os.path.isfile("pics/%s.png"%match.group('label')):
27+
line='%s [ image="pics/%s.png" label="" width="0.5" height="0.5" imagescale=false fixedsize=false color="none" ];\n'%(match.group('node'),match.group('label'))
28+
29+
# rankdir="LR" to make graph go left>right instead of top>bottom
30+
31+
if StripLineLabels:
32+
line=re.sub('label\s*=\s*\"\s*[\d.]+\"','label=""',line)
33+
34+
# change colours
35+
line=re.sub('color="0.7,\ (.*?),\ 0.9"',r'color="1.0, \1, 0.7*\1"',line)
36+
37+
outfile.write(line)
38+
39+
outfile.close()
40+
infile.close()
41+
42+
print "now try:\n dot -O -Tpdf rxnpath2.dot"

0 commit comments

Comments
 (0)