contents = node.get_contents() # for older versions of SCons, fall back on binary read
ret = []
for string in double_quoted_string_re.findall(contents):
+ if string in ret:
+ continue # we've already added this dependency
+ if len(string) == 0:
+ continue # empty string not much of a dependency ;)
p = os.path.join(node.dir.srcnode().abspath, string)
- if len(string) > 0 and \
- ((string not in ret and os.path.exists(p))
- or string.endswith('.dat')):
+ if os.path.exists(p) and os.path.isfile(p): # probably an include file
+ ret.append(string)
+ elif string.endswith('.dat'): # marker for auto-generated include files
ret.append(string)
return ret
+from site_cons.site_init import link_wtk_graph
+
+
+FIGURES = ['kappa-sawteeth']
+
# Get the passed in environment.
Import('env')
-for gp in Glob('*.gp'):
- env.Gnuplot(gp)
+# we generate include files on the fly in kappa-sawteeth.asy, my
+# default Asymptote scanner won't work. As a fallback, we set the
+# dependencies explicitly.
+kappa_sawteeth_data = env.Glob("k-*.dat");
+
+wtk_graph = link_wtk_graph(env)
+
+for fig in FIGURES:
+ asyfile = '%s.asy' % fig # static .asy file
+ pyfig = fig.replace('-', '_')
+ data = '%s_data' % (pyfig)
+ asydata = []
+ if data in globals(): # generated data dependencies
+ asydata = globals()[data]
+ env.Asymptote([asyfile, wtk_graph] + asydata)
# Pass back the modified environment.
Return('env')
+++ /dev/null
-set terminal pdf enhanced font 'Times,7' size 9cm, 9cm
-set output 'fig.pdf'
-unset key
-set style data lines
-set xrange [-40:250]
-set yrange [0:400]
-set ytics 0,200
-set xtics nomirror
-set ytics nomirror
-# border 3 = bottom & left
-set border 3
-set lmargin 9
-
-set multiplot
-
-set size 1,0.22;
-set origin 0.0,0.0;
-set xlabel 'Extension (nm)'
-set label 1 "{/Symbol k}_c = 1 pN/nm" at -35,300
-plot 'data-0.001' using (($1-$2/0.001)*1e9):($2*1e12)
-
-set size 1,0.13
-set bmargin 0
-unset xlabel
-set xtics format ""
-
-set origin 0.0,0.22;
-set label 1 "{/Symbol k}_c = 10 pN/nm" at -35,300
-plot 'data-0.01' using (($1-$2/0.01)*1e9):($2*1e12)
-
-set origin 0.0,0.35;
-set label 1 "{/Symbol k}_c = 50 pN/nm" at -35,300
-plot 'data-0.05' using (($1-$2/0.05)*1e9):($2*1e12)
-
-set origin 0.0,0.48;
-set ylabel "Force (pN)"
-set label 1 "{/Symbol k}_c = 100 pN/nm" at -35,300
-plot 'data-0.1' using (($1-$2/0.1)*1e9):($2*1e12)
-
-set origin 0.0,0.61;
-unset ylabel
-set label 1 "{/Symbol k}_c = 500 pN/nm" at -35,300
-plot 'data-0.5' using (($1-$2/0.5)*1e9):($2*1e12)
-
-set origin 0.0,0.74;
-set label 1 "{/Symbol k}_c = 1 nN/nm" at -35,300
-plot 'data-1' using (($1-$2/1)*1e9):($2*1e12)
-
-set origin 0.0,0.87;
-set label 1 "{/Symbol k}_c = 10 nN/nm" at -35,300
-plot 'data-10' using (($1-$2/10)*1e9):($2*1e12)
-
-unset multiplot
--- /dev/null
+import wtk_graph;
+
+size(15cm,10cm,IgnoreAspect);
+
+scale(Linear, Linear);
+real xscale=1e9;
+real fscale=1e12;
+
+void graphSawtooth(string file="datafile", real k,
+ int xcol=0, int fcol=1,
+ real xscale=1, real fscale=1, real dx=0, real df=0,
+ pen p=red, string t="Title") {
+ file fin=input(file).line();
+ real[][] a=fin.dimension(0,0);
+ a=transpose(a);
+ real[] x=a[xcol];
+ real[] f=a[fcol];
+ x = x - f/k; /* Remove cantilever extension */
+ graphData(x=x, y=f, xscale=xscale, yscale=fscale,
+ dx=dx, dy=df, p=p, t=t, dots=false);
+}
+
+real[] k = {0.001, 0.01, 0.05, 0.1, 0.5, 1, 10};
+int i;
+for (i=k.length-1; i>=0; --i) {/* count down so legend and plot orders match */
+ string file = format("k-%f", k[i])+"."+"dat";
+ /* We break up .dat so the Asymptote scanner doesn't pick up
+ * .dat as a dependency (which obviously doesn't exist). */
+ string label = format("$k=%f\mbox{ pN/nm}$", k[i]*1e3);
+ if (k[i] >= 1)
+ label = format("$k=%f\mbox{ nN/nm}$", k[i]);
+ // TODO: rainbow pen(N, i)
+ graphSawtooth(file=file, k=k[i], xscale=xscale, fscale=fscale,
+ df=300e-12*i, p=psoft, t=label);
+}
+
+xlimits(0, 300e-9*xscale, crop=true);
+xaxis(sLabel("Distance (nm)"), BottomTop, LeftTicks);
+yaxis(sLabel("Force (pN)"), LeftRight, RightTicks);
+label(sLabel("Simulated force curves"), point(N), N);
+
+add(legend(), point(E), 20E);
+//add(lengend(). point(E), 20E); //, UnFill);
\begin{figure}
\begin{center}
-\includegraphics{figures/kappa-sawteeth/fig}
+\asyfig{figures/kappa-sawteeth/kappa-sawteeth}
\caption{Simulated force curves obtained from pulling a polymer with
eight protein molecules using cantilevers with different force
constants $\kappa_c$. Parameters used in generating these curves
are the same as those used in \cref{fig:sawsim:sim-all}, except the
- cantilever force constant.\label{fig:sawsim:kappa-sawteeth}}
+ cantilever force constant. Successive force curves are offset by
+ $300\U{pN}$ for clarity.\label{fig:sawsim:kappa-sawteeth}}
\end{center}
\end{figure}