5 `A short video showing Hooke in action`_! (courtesy of Fabrizio
6 Benedetti, EPFL, Lausanne)
8 .. _A short video showing Hooke in action:
9 https://documents.epfl.ch/users/f/fb/fbenedet/www/hooke_short_demostration.ogv
19 This tutorial will focus on the command-line interface as the most
20 powerful, and leave the :doc:`gui` interface to another document.
22 .. _command-line: `Command-line interface`_
27 See :doc:`install` for details on downloading and installing Hooke.
30 Command-line interface
31 ======================
33 Running the hooke shell
34 -----------------------
36 Hooke has a set of commands that depend on the loaded
37 :class:`hooke.plugin.Plugin`\s. To access these commands, you'll need
38 to run the Hooke shell.::
42 If you are running hooke from the source directory (see
43 :doc:`install`), the equivalent command is::
47 You may need to give the full path for Python on Windows systems, and
48 also check that the current working directory (`.`) is in your
49 `PYTHONPATH`. See :manpage:`python(1)` for details.
51 As Hooke launches, you should see something like the following in your
54 Hooke version 0.9.0.devel (Kenzo)
56 Copyright (C) 2006-2010 A. Seeholzer, Alberto Gomez-Casado, Allen
57 Chen, Fabrizio Benedetti, Francesco Musiani, Marco Brucale, Massimo
58 Sandal, Pancaldi Paolo, Richard Naud, Rolf Schmidt, W. Trevor King
60 Hooke comes with ABSOLUTELY NO WARRANTY and is licensed under the GNU
61 Lesser General Public License. For details, run `license`.
65 The final line, ``hooke>``, is the Hooke prompt. It allows you to
66 enter commands to interact with the interpreter.
71 All commands have help text explaining their purpose and usage. The
72 text is stored in the code itself, and therefore more likely to be up
73 to date than this tutorial. You can get a list of commands and topics
78 Or see specific help on ``TOPIC`` with::
84 hooke> help load_playlist
86 will give help on the ``load_playlist`` command.
91 When you're done with an interactive Hooke session, you can close the
92 session with ``exit`` or its aliases ``quit`` and ``EOF`` (``EOF`` is
93 the end of the stdin stream, which is Ctrl-d in many shells).
98 To start analyzing your curves, you first have to build a playlist.
99 The playlist is just an index of the force curve files you want to
100 analyze. Imagine it as a music playlist (that’s why it is called a
101 playlist), but with data files instead of audio files.
103 Suppose you have 100 PicoForce curve files in your curves directory,
104 starting from :file:`mycurve.000` and ending in :file:`mycurve.100`
105 and you want to analyze them all.
107 You then can ``cd`` (change directory) to the directory::
109 hooke> cd --path c:\curves
111 Type ``pwd`` (print working directory) to check the directory is correct.::
116 You can list the files in the directory using ``ls`` or ``dir``
117 (they’re synonyms).::
124 Now you are ready to generate the playlist. First, create a blank playlist::
126 hooke> new_playlist --output_playlist mylist
128 Ensure that the new playlist is active::
130 hooke> jump_to_playlist -- -1
132 <FilePlaylist mylist>
134 The ``--`` in the ``jump_to_playlist`` command lets
135 ``jump_to_playlist`` know that ``-1`` is an argument and not an
136 option. Using the bare ``--`` is a POSIX specification [#POSIX]_
137 supported by the `optparse module`_. You don't need to jump if
138 the new playlist is your only loaded playlist.
141 http://docs.python.org/library/optparse.html#callback-example-6-variable-arguments
143 .. [#POSIX] `Guideline 10 of POSIX:2008's section 12.2 <http://www.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html#tag_12_02>`_ states:
145 "The first ``--`` argument that is not an option-argument should be
146 accepted as a delimiter indicating the end of options. Any
147 following arguments should be treated as operands, even if they
148 begin with the ``-`` character."
150 Then glob your curves onto the new list::
152 hooke> glob_curves_to_playlist mycurve.*
154 You can also be more specific with wildcards. For example::
156 hooke> glob_curve_to_playlist mycurve.05*
158 will take only curves from :file:`mycurve.050` to :file:`mycurve.059`.
160 Note that by using ``glob_curves_to_playlist`` you just generate the
161 playlist in the local session. To save your playlist to a file for
164 hooke> save_playlist --output mylist
166 In this example, the list will be saved in the file
167 :file:`mylist.hkp`. Hooke will add the extension ``.hkp`` (Hooke
168 playlist) to the playlist if you forget to. The ``.hkp`` file is an
169 XML file you can read and edit with any text editor (i.e. Wordpad), if
170 needed. If you want to load it, simply issue ``load_playlist
171 mylist.hkp`` or ``load_playlist mylist``, Hooke will add ``.hkp`` if
174 If, generating the playlist, you are including by chance a non-force
175 curve file that Hooke cannot open, Hooke will log a warning and
178 Navigating the playlist
179 -----------------------
181 Now you can navigate through your playlist using the commands
182 ``next_curve`` and ``previous_curve``. You don’t need to type
183 ``next_curve`` every time to run along a list of curves. You can
184 navigate through the command history by using the up and down arrows,
185 or auto-complete partial commands with TAB. From the last curve of
186 your playlist, ``next_curve`` will wrap around to the first curve.
187 Analogously, issuing ``previous_curve`` at the first curve will jump
190 You can also jump to a given curve::
192 hooke> jump_to_curve 14
194 will jump to the 14th curve in the zero-indexed playlist.
196 .. todo:: ``jump_to_curve <PATH>``, where the path can be either an
197 absolute path or a path relative to the directory holding the
200 Replace ``curve`` with ``playlist`` in the above commands to navigate
201 around through the list of loaded playlists.
206 You can take notes about the curves you are looking at. Just type
207 ``set_note`` followed by the text you want to attach to that curve.
208 Hooke will save the text in your current playlist and in an external
211 .. todo:: No external file yet. Is this important?
213 The output will look like this::
215 Notes taken at Sun Sep 17 20:42:07 2006
216 /home/cyclopia/work/tris/20060620a.041 | This is a note
217 /home/cyclopia/work/tris/20060620a.207 | This is another note
218 /home/cyclopia/work/tris/20060620a.286 | This is a third one
220 The log file name can be configured (:doc:`config`), but it defaults
221 to :file:`hooke.log`.
223 Usually curves you annotated are useful later. You can create a
224 playlist for only annotated curves with
226 hooke> note_filter_playlist --output_playlist nice_list
228 will create sub-playlist `nice_list`. Remember to save the new list
231 If you change your mind about a note, you can remove it by setting a
232 blank note string with ``set_note ''``.
237 You can export Hooke curves as images and as text columns. To export
238 as images or text, use the ``export_block`` command. Supported
239 formats are PNG (Portable Network Graphic, raster) and EPS
240 (Encapsulated Postscript, vector). The export format is determined by
241 the filename extension, so ``export_block --output foo.png``,
242 ``export_block --output foo.eps``, and ``export_block --output
243 foo.txt`` will save PNG, EPS, and TAB-delimited text files
246 .. todo:: Currently no PNG or EPS output, use the GUI and the plot
247 panel's toolbar for non-text exports.
249 .. todo:: Multiple cycles in exported data? Solution: blank lines for
250 "breaks", add option to extract specific sections using Python's
253 If you don't want the entire block, try the ``cut`` command.
255 Interacting with the plot
256 -------------------------
258 (no plots in command line mode...)
260 Measuring distances and forces
261 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
263 To measure the distance between points, use the ``delta`` command.
268 will measure the distance between the 300th point and the 500th point.
269 One difficulty with the command line interface is that is difficult
270 to know which points you're interested without seeing the plot. The
271 two ways around this are:
273 1) Export the block (with ``export_block``), and graph the exported
274 file with a program of your choice (e.g. Gnuplot_). Use the
275 resulting graph to determine the indices of the points you are
277 2) Run Hooke's GUI instead of the command line when you need to make
278 manual measurements. See :doc:`gui` for details.
280 .. _Gnuplot: http://gnuplot.sourceforge.net/
282 Worm like chain and freely jointed chain fitting
283 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
285 .. todo:: Update WLC fitting tutorial section.
287 You can measure by hand the parameters relative to a force peak using
288 a worm-like chain fitting with the ``fit`` command. The command by
289 default automatically finds the contact point, asks for two points
290 delimiting the portion to fit, and performs a two-variable fit, with
291 contour length, persistence length, and their relative errors as
292 output. If desired, one can use the ``noauto`` option to manually
293 click the contact point, and/or the ``pl=NUMBER`` options to impose a
294 specific persistence or Kuhn length (in nanometers). You can choose
295 which model to use with ``set fit_function wlc`` or ``set fit_function
296 fjc``. See the help of the ``fit`` command from the Hooke command
299 Multiple curve fitting and measuring
300 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
301 .. todo:: Update multiple curve fitting tutorial section.
303 You can cycle through all your current playlist obtaining WLC fit, FJC
304 fit, rupture force and slope (loading rate) information from each
305 curve using the ``multifit`` command. The collected data can be saved
306 in a text file for further analysis in your favourite spreadsheet or
307 statistical program. If you want to check your parameters on the
308 current curve before fitting all the files in your playlist, use
309 ``multifit justone``. See the ``multifit`` help for more options.
311 Fast curve reviewing and saving
312 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
314 .. todo:: Update curve review tutorial section.
316 When automatic routines are not good enough to filter your data, use
317 ``review`` command to cycle through your playlist presenting ten
318 curves in the same graph. You can then enter the numbers of the
319 interesting curves and automatically save a copy of them into another
325 You can set environment variables to influence the behaviour of Hooke.
326 The command to use is ``set_config``. Use ``get_config`` to read a
327 particular option and ``print_config`` to display the entire
328 configuration file. To save changes, either run ``save_config`` or
329 start Hooke with the ``--save-config`` option. See :doc:`config` for