From 8b596e95edfcc7c5895e43c2a0add5ec9bcad9d8 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Fri, 30 Apr 2010 09:51:22 -0400 Subject: [PATCH] Converted figures/v-dep from Gnuplot to Asympote (except for embedded histograms) --- tex/src/figures/asy/wtk_graph.asy | 27 +++++++++++++ tex/src/figures/v-dep/SConscript | 55 ++++++++++++++++++++++++- tex/src/figures/v-dep/fig-sd.gp | 57 -------------------------- tex/src/figures/v-dep/fig.gp | 19 --------- tex/src/figures/v-dep/v-dep-sd.asy | 65 ++++++++++++++++++++++++++++++ tex/src/figures/v-dep/v-dep.asy | 29 +++++++++++++ tex/src/sawsim/discussion.tex | 4 +- 7 files changed, 176 insertions(+), 80 deletions(-) delete mode 100644 tex/src/figures/v-dep/fig-sd.gp delete mode 100644 tex/src/figures/v-dep/fig.gp create mode 100644 tex/src/figures/v-dep/v-dep-sd.asy create mode 100644 tex/src/figures/v-dep/v-dep.asy diff --git a/tex/src/figures/asy/wtk_graph.asy b/tex/src/figures/asy/wtk_graph.asy index 40dd933..fff4aa5 100644 --- a/tex/src/figures/asy/wtk_graph.asy +++ b/tex/src/figures/asy/wtk_graph.asy @@ -1,6 +1,7 @@ import graph; import palette; + real fsize=10; Label sLabel(string s, align align=NoAlign, int extra_spaces=0) { @@ -37,6 +38,32 @@ void graphFile(picture pic=currentpicture, string file="datafile", } } +void fitFile(picture pic=currentpicture, string file="fitparamfile", + int pcol=0, real f(real x, real[] params), + real xmin=realMin, real xmax=realMax, + real xscale=1, real yscale=1, pen p=red, + string t="Title") { + file fin=input(file).line(); + real[][] a=fin.dimension(0,0); + a=transpose(a); + real[] params=a[pcol]; + real fn(real x) { + return f(x / xscale, params) * yscale; + } + /* should be able to extract xmin and xmax from the figure... + if (xmin == realMin) + xmin = point(pic, W).x / xscale; + if (xmax == realMax) + xmax = point(pic, E).x / xscale; + */ + if (t != "Title") { + draw(pic=pic, graph(pic, fn, a=xmin*xscale, b=xmax*xscale), p=p, + legend=sLabel(t,extra_spaces=1)); + } else { + draw(pic=pic, graph(pic, fn, a=xmin*xscale, b=xmax*xscale), p=p); + } +} + real[] identity_zfn(real[] z) { return z; } diff --git a/tex/src/figures/v-dep/SConscript b/tex/src/figures/v-dep/SConscript index d8ff28f..d24a713 100644 --- a/tex/src/figures/v-dep/SConscript +++ b/tex/src/figures/v-dep/SConscript @@ -1,8 +1,59 @@ +import os.path + +from site_cons.site_init import subdirs, link_wtk_graph + + +FIGURES = ['v-dep', 'v-dep-sd'] + # Get the passed in environment. Import('env') -for gp in Glob('*.gp'): - env.Gnuplot(gp) +data_dirs = [env.Dir(d) for d in subdirs(env, '*')] +data_files = [env.File(os.path.join(str(d), 'v_dep')) + for d in data_dirs] + +pyfit = env.Alias('pyfit') +# Extract the first source Node required to build the 'pyfit' Alias +# (i.e. the File('pyfit') node). +pyfit = pyfit[0].get_binfo().bsources[0] + +fit_files = [] +sd_fit_files = [] +for f in data_files: + fit = env.Command( + str(f)+'.fit', + [f, pyfit], + "python %s -m math:log -f 'A*log(x,10)+B' -v $SOURCE > $TARGET" + % str(pyfit)) + fit_dat = env.Command( + str(fit[0])+'.dat', + fit, + "sed -n 's/^[A-Z]: //p' $SOURCE > $TARGET") + fit_files.append(fit_dat) + sd_fit = env.Command( + str(f)+'-sd.fit', + [f, pyfit], + "python %s -m math:log -f 'A*log(x,10)+B' -y 2 -v $SOURCE > $TARGET" + % str(pyfit)) + sd_fit_dat = env.Command( + str(sd_fit[0])+'.dat', + sd_fit, + "sed -n 's/^[A-Z]: //p' $SOURCE > $TARGET") + sd_fit_files.append(sd_fit_dat) + +v_dep_data = data_files + fit_files +v_dep_sd_data = data_files + sd_fit_files + +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') diff --git a/tex/src/figures/v-dep/fig-sd.gp b/tex/src/figures/v-dep/fig-sd.gp deleted file mode 100644 index edac8b6..0000000 --- a/tex/src/figures/v-dep/fig-sd.gp +++ /dev/null @@ -1,57 +0,0 @@ -set terminal pdf enhanced font 'Times,7' size 9cm, 6cm -set output 'fig-sd.pdf' -set xtics nomirror -set ytics nomirror -# border 3 = bottom & left -set border 3 -set lmargin 9 - -set multiplot - -set size 1.0,0.6 -set origin 0.0,0.0 -unset key -set tmargin 0 -set style data linespoints -set logscale x -set xtics format "10^{%L}" -set xlabel 'Pulling Speed (m/s)' -set ylabel 'Standard Deviation (pN)' -plot 'v_dep-5e-5_0.1e-9/v_dep' using ($1):($3*1e12) \ - title '{/Times-Italic k_{u0} = 5{\267}10^{-5}} s^{-1}, {/Times-Italic {/Symbol D}x_u=0.100} nm', \ - 'v_dep-1e-5_0.225e-9/v_dep' using ($1):($3*1e12) \ - title '{/Times-Italic k_{u0} = 1{\267}10^{-5}} s^{-1}, {/Times-Italic {/Symbol D}x_u=0.225} nm', \ - 'v_dep-5e-5_0.225e-9/v_dep' using ($1):($3*1e12) \ - title '{/Times-Italic k_{u0} = 5{\267}10^{-5}} s^{-1}, {/Times-Italic {/Symbol D}x_u=0.225} nm' - -set size 0.33,0.4 -unset key -set tmargin -1 -set xrange [100:900] -#set yrange [1e-4:1e-1] -unset logscale x -set logscale y -set xtics 100,200 -set ytics format "10^{%L}" -set xtics format "%g" -set xlabel 'Force (pN)' -set ylabel 'Frequency' -set boxwidth 20 -set style data boxes -set style fill solid 0.3 -#set style fill pattern 4 - -# dummy plot to fix some sizing issue... -set origin 1,1 -plot x - -set origin 0.0,0.6 -plot 'fig4i-5e-5_0.1e-9.hist' using ($1*1e12+10):($2/3200) - -set origin 0.33,0.6 -plot 'fig4i-1e-5_0.225e-9.hist' using ($1*1e12+10):($2/3200) - -set origin 0.67,0.6 -plot 'fig4i-5e-5_0.225e-9.hist' using ($1*1e12+10):($2/3200) - -unset multiplot diff --git a/tex/src/figures/v-dep/fig.gp b/tex/src/figures/v-dep/fig.gp deleted file mode 100644 index 4b4028e..0000000 --- a/tex/src/figures/v-dep/fig.gp +++ /dev/null @@ -1,19 +0,0 @@ -set terminal pdf enhanced font 'Times,7' size 9cm, 6cm -set output 'fig.pdf' -set xtics nomirror -set ytics nomirror -# border 3 = bottom & left -set border 3 - -set key left top -set style data linespoints -set logscale x -set xtics format "10^{%L}" -set xlabel 'Pulling Speed (m/s)' -set ylabel 'Unfolding Force (pN)' -plot 'v_dep-5e-5_0.1e-9/v_dep' using ($1):($2*1e12) \ - title '{/Times-Italic k_{u0} = 5{\267}10^{-5}} s^{-1}, {/Times-Italic {/Symbol D}x_u=0.100} nm', \ - 'v_dep-1e-5_0.225e-9/v_dep' using ($1):($2*1e12) \ - title '{/Times-Italic k_{u0} = 1{\267}10^{-5}} s^{-1}, {/Times-Italic {/Symbol D}x_u=0.225} nm', \ - 'v_dep-5e-5_0.225e-9/v_dep' using ($1):($2*1e12) \ - title '{/Times-Italic k_{u0} = 5{\267}10^{-5}} s^{-1}, {/Times-Italic {/Symbol D}x_u=0.225} nm' diff --git a/tex/src/figures/v-dep/v-dep-sd.asy b/tex/src/figures/v-dep/v-dep-sd.asy new file mode 100644 index 0000000..b578767 --- /dev/null +++ b/tex/src/figures/v-dep/v-dep-sd.asy @@ -0,0 +1,65 @@ +import wtk_graph; + +size(15cm,10cm,IgnoreAspect); + +scale(Log, Linear); +real xscale=1e9; +real yscale=1e12; + +/* f(x) = A + log10(x) + B */ +real fn_logxliny(real x, real[] params) { + return params[0] * log10(x) + params[1]; +} + +graphFile("v_dep-5e-5_0.1e-9/v_dep", ycol=2, xscale=xscale, yscale=yscale, + p=psoft, + t="$k_{u0}=5\E{-5}\U{s$^-1$}, \Delta x_u=0.100\U{nm}", dots=true); +graphFile("v_dep-1e-5_0.225e-9/v_dep", ycol=2, xscale=xscale, yscale=yscale, + p=pmed, + t="$k_{u0}=1\E{-5}\U{s$^-1$}, \Delta x_u=0.225\U{nm}", dots=true); +graphFile("v_dep-5e-5_0.225e-9/v_dep", ycol=2, xscale=xscale, yscale=yscale, + p=phard, + t="$k_{u0}=5\E{-5}\U{s$^-1$}, \Delta x_u=0.225\U{nm}", dots=true); +fitFile("v_dep-5e-5_0.1e-9/v_dep-sd.fit.dat", f=fn_logxliny, + xmin=1e-9, xmax=1e-5, xscale=xscale, yscale=yscale, p=psoft); +fitFile("v_dep-1e-5_0.225e-9/v_dep-sd.fit.dat", f=fn_logxliny, + xmin=1e-9, xmax=1e-5, xscale=xscale, yscale=yscale, p=pmed); +fitFile("v_dep-5e-5_0.225e-9/v_dep-sd.fit.dat", f=fn_logxliny, + xmin=1e-9, xmax=1e-5, xscale=xscale, yscale=yscale, p=phard); + +label(sLabel("Pulling speed dependence"), point(N),N); +xaxis(sLabel("Pulling speed (nm/s)"),BottomTop,LeftTicks); +yaxis(sLabel("Unfolding force (pN)"),LeftRight,RightTicks); +/* +set size 0.33,0.4 +unset key +set tmargin -1 +set xrange [100:900] +#set yrange [1e-4:1e-1] +unset logscale x +set logscale y +set xtics 100,200 +set ytics format "10^{%L}" +set xtics format "%g" +set xlabel 'Force (pN)' +set ylabel 'Frequency' +set boxwidth 20 +set style data boxes +set style fill solid 0.3 +#set style fill pattern 4 + +# dummy plot to fix some sizing issue... +set origin 1,1 +plot x + +set origin 0.0,0.6 +plot 'fig4i-5e-5_0.1e-9.hist' using ($1*1e12+10):($2/3200) + +set origin 0.33,0.6 +plot 'fig4i-1e-5_0.225e-9.hist' using ($1*1e12+10):($2/3200) + +set origin 0.67,0.6 +plot 'fig4i-5e-5_0.225e-9.hist' using ($1*1e12+10):($2/3200) + +unset multiplot +*/ diff --git a/tex/src/figures/v-dep/v-dep.asy b/tex/src/figures/v-dep/v-dep.asy new file mode 100644 index 0000000..da0e02a --- /dev/null +++ b/tex/src/figures/v-dep/v-dep.asy @@ -0,0 +1,29 @@ +import wtk_graph; + +size(15cm,10cm,IgnoreAspect); + +scale(Log, Linear); +real xscale=1e9; +real yscale=1e12; + +/* f(x) = A + log10(x) + B */ +real fn_logxliny(real x, real[] params) { + return params[0] * log10(x) + params[1]; +} + +graphFile("v_dep-5e-5_0.1e-9/v_dep", xscale=xscale, yscale=yscale, p=psoft, + t="$k_{u0}=5\E{-5}\U{s$^-1$}, \Delta x_u=0.100\U{nm}", dots=true); +graphFile("v_dep-1e-5_0.225e-9/v_dep", xscale=xscale, yscale=yscale, p=pmed, + t="$k_{u0}=1\E{-5}\U{s$^-1$}, \Delta x_u=0.225\U{nm}", dots=true); +graphFile("v_dep-5e-5_0.225e-9/v_dep", xscale=xscale, yscale=yscale, p=phard, + t="$k_{u0}=5\E{-5}\U{s$^-1$}, \Delta x_u=0.225\U{nm}", dots=true); +fitFile("v_dep-5e-5_0.1e-9/v_dep.fit.dat", f=fn_logxliny, + xmin=1e-9, xmax=1e-5, xscale=xscale, yscale=yscale, p=psoft); +fitFile("v_dep-1e-5_0.225e-9/v_dep.fit.dat", f=fn_logxliny, + xmin=1e-9, xmax=1e-5, xscale=xscale, yscale=yscale, p=pmed); +fitFile("v_dep-5e-5_0.225e-9/v_dep.fit.dat", f=fn_logxliny, + xmin=1e-9, xmax=1e-5, xscale=xscale, yscale=yscale, p=phard); + +label(sLabel("Pulling speed dependence"), point(N), N); +xaxis(sLabel("Pulling speed (nm/s)"), BottomTop, LeftTicks); +yaxis(sLabel("Unfolding force (pN)"), LeftRight, RightTicks); diff --git a/tex/src/sawsim/discussion.tex b/tex/src/sawsim/discussion.tex index f3d52df..8420223 100644 --- a/tex/src/sawsim/discussion.tex +++ b/tex/src/sawsim/discussion.tex @@ -297,10 +297,10 @@ about the protein from other sources. \begin{figure} \begin{center} - \subfloat[][]{\includegraphics{figures/v-dep/fig}% + \subfloat[][]{\asyfig{figures/v-dep/v-dep}% \label{fig:sawsim:v-dep}% } \\ - \subfloat[][]{\includegraphics{figures/v-dep/fig-sd}% + \subfloat[][]{\asyfig{figures/v-dep/v-dep-sd}% \label{fig:sawsim:width-v-dep}% } \caption{(a) The dependence of the unfolding forces on the pulling -- 2.26.2