if [ $# -eq 0 ] 
then
	root="scr"
else
	root="$1"
fi

# create root.m file
cat <<EOF | grep -v "^#" >${root}.m
#rate constant		reactants -> products
#values for lysozyme, from banerjee et al, jbc 250, 4355 (1975)
#pH = 6.3, 25 deg
20	EU2 -> EU1
200	EU1 -> EU2
6.25e3	EU1 -> E + S
1.e8	E + S -> EU1
1.e8	E + S -> ESB1
5e3	ESB1 -> E + S
14	ESB1 -> ESB2
5	ESB2 -> ESB1
.46	ESB2 -> ESG
.13	ESG -> ESB2
.038	ESG -> E + P1 + P2
EOF

# create root.p file
cat <<EOF | grep -v "^#" >${root}.p
#iopt
1
#itol	istate	jt	itask
4	1	2	1
#ml	mu	ixpr	mxstep	mxhnil	mxordn	mxords
#iwork1	iwork2	iwork5	iwork6	iwork7	iwork8	iwork9
0	0	0	500	0	0	0
#tcrit	h0	hmax	hmin
#rwork1	rwork5	rwork6	rwork7
0.	0.	0.	0.
#start_time  end_time  {time_step|0}  deflt_tolerance  [first_time  time_factor]
#0.0	0.0001	.000003	1.0e-10
#0	1.0e6	0	1.0e-10	1.e-9	1.2589253
0	1.0e6	0	1.0e-10	1.e-9	1.2589254117
#species	initial concn		absol. tolerance	relat. tolerance
E	1.e-5	1.e-15	1.e-10
S	1.e-5	1.e-15	1.e-10
EU2	0	1.e-15	1.e-10
EU1	0	1.e-15	1.e-10
ESB1	0	1.e-15	1.e-10
ESB2	0	1.e-15	1.e-10
ESG	0	1.e-15	1.e-10
P1	0	1.e-15	1.e-10
P2	0	1.e-15	1.e-10
EOF

#run it and graph it
react ${root} | tee ${root}.r | prep | ttygraph
