\appendix
\appendixpage
\addappheadtotoc

\section{An example client script}\label{sec.approach_surface}

\begin{verbatim}
#!/bin/sh
TARGET_DEF=1 # Volts
MIN_TPHOTO=3 # Volts
DEF=0 ; TPHOTO=0 ; ANS=0 ;
get_feedback() {
  DEF=`cmmdline -c ':AFM|Get:Deflection'`
  TPHOTO=`cmmdline -c ':AFM|Get:TotalPhotodiode'`
}
step_closer() {
  ANS=`cmmdline -c 'Stepper|Set:RelPos 1'`
}
get_feedback
while [ $DEF -lt $TARGET_DEF ] && [ $TPHOTO -gt $MIN_TPHOTO ]; do
  step_closer
  get_feedback
done
\end{verbatim}

\section{An example command-line experiment}\label{sec.cmmdline_example}
This artist's representation should give a feel for how an experiment-server run experiment looks from the command line.
\begin{verbatim}
 > approach_surface
 Lost signal!
 > approach_surface
 > piezo_measure_distance
 372 nm
 > pull_protein --save 'D:\data\' &
 saving data to 'D:\data\070510\'
 > monitor_unfolding
 > sort_data --dir 'D:\data\070510\'
 ...
 > ls
 pulls_good
 pulls_bad_structure
 pulls_no_unfolding
 ...
\end{verbatim}

\section{Sorting criteria}
\label{sec.sorting_criteria}

The current procedure for sorting force curves is summarized in the flow chart in Figure~\ref{fig.sort_logic}.
\begin{figure}[bt]
 \centering
 \includegraphics[width=0.7\textwidth]{data_sorter}
 \caption{Automatic data sorting logic.}
 \label{fig.sort_logic}
\end{figure}
An explanation of what the criteria are and whee they come from follows:
\begin{packed_item}
 \item The last quarter of the data is fit to a straight line.
   If the fit line is steeper than a given threshold, the curve has forces as far out as we pulled, so it is thrown out.  Otherwise, we use the average value at the end of the line to define zero force.
 \item Once we know what zero force is, we can pick out the upward deflected contact region from the beginning of the curve.  We also fit this to a line.
 \item We slide down the curve from the zero force side until we find a downward deflection force above a given threshold.
   This marks snapping-off of the end of protein (or the surface, if there was no protein attachment).
 \item Once we've isolated the protein portion of the curve, we can check to see if it is approximately the right length, culling curves that are too long or too short.
 \item Now we look for peaks for possibly matching a clean sawtooth.
  We low pass the protein to reduce noise, and pick out large trough minimums.
  Going back to the non-lowpassed data, we find the point of most force between each pair of minimums.
 \item We then check to see that the drop following the high force is deep and steep enough for a clean sawtooth.
  This is the unreliable node, which should be replaced by a WLC fit to improve selection efficiency.
\end{packed_item}
