1158aad3974ffa022b777fb16023be28fd781130
[hooke.git] / doc / tutorial.txt
1 ********
2 Tutorial
3 ********
4
5 `A short video showing Hooke in action`_! (courtesy of Fabrizio
6 Benedetti, EPFL, Lausanne)
7
8 .. _A short video showing Hooke in action:
9   https://documents.epfl.ch/users/f/fb/fbenedet/www/hooke_short_demostration.ogv
10
11 Introduction
12 ============
13
14 This tutorial will focus on the command-line interface as the most
15 powerful, and leave the GUI interface to another document.
16
17 .. _command-line: `Command-line interface`_
18 .. _GUI: gui.txt
19
20 Installation
21 ============
22
23 See the Installation_ page for details on downloading and installing
24 Hooke.
25
26 .. _Installation: install.txt
27
28
29 Command-line interface
30 ======================
31
32 Running the hooke shell
33 -----------------------
34
35 Hooke has a set of commands that depend on the loaded plugins_.
36 To access these commands, you'll need to run the Hooke shell.::
37
38     $ hooke
39
40 If you are running hooke from the source directory (see
41 Installation_), the equivalent command is::
42
43     $ python bin/hooke
44
45 You may need to give the full path for Python on Windows systems.
46
47 As Hooke launches, you should see something like the following in your
48 terminal::
49
50     Starting Hooke.
51     Imported plugin fit
52     Imported plugin procplots
53     Imported plugin flatfilts
54     Imported plugin generalclamp
55     Imported plugin generalvclamp
56     Imported plugin massanalysis
57     Imported plugin macro
58     Imported driver picoforce
59     Imported driver hemingclamp
60     Imported driver csvdriver
61     Imported driver tutorialdriver
62     
63     Warning: Invalid work directory.
64     This is Hooke, version 0.8.0 Seinei
65     (c) Massimo Sandal, 2006. Released under the GNU General Public License Version 2
66     Hooke is Free software.
67     ----
68     hooke>
69
70 The final line, ``hooke>``, is the Hooke prompt.  It allows you to
71 enter commans to interact with the interpreter.
72
73 Help
74 ----
75
76 All commands have help text explaining their purpose and usage.  The
77 text is stored in the code itself, and therefore more likely to be up
78 to date than this tutorial.  You can get a list of commands and topics
79 with::
80
81     hooke> help
82
83 Or see specific help on ``TOPIC`` with::
84
85     hooke> help TOPIC
86
87 for example::
88
89     hooke> help current
90
91 will give help on the ``current`` command.
92
93 Creating a playlist
94 -------------------
95
96 To start analyzing your curves, you first have to build a playlist. The
97 playlist is just an index of the force curve files you want to
98 analyze. Imagine it as a music playlist (that’s why it is called a
99 playlist), but with data files instead of audio files.
100
101 Suppose you have 100 PicoForce curve files in your curves directory,
102 starting from ``mycurve.000`` and ending in ``mycurve.100`` and you
103 want to analyze them all.
104
105 You then can ``cd`` (change directory) to the directory::
106
107     hooke> cd c:\curves
108
109 Type ``pwd`` (print working directory) to check the directory is correct.::
110
111       hooke> pwd
112       c:\curves
113
114 You can list the files in the directory using ``ls`` or ``dir`` (they’re
115 synonyms).::
116
117     hooke> ls
118     [’mycurve.000’, ’mycurve.001’, ...
119     ]
120
121 Now you are ready to generate the playlist. The command to use is
122 ``genlist``.::
123
124     hooke> genlist mycurve.*
125
126 You can also generate a playlist containing all what you find in the
127 directory by typing:
128
129     hooke> genlist c:\curves
130
131 If you want to select what curves to see, based on the filename, you
132 can use wildcards.  For example::
133
134     hooke> genlist mycurve.05*
135
136 will take only curves from mycurve.050 to mycurve.059.
137
138 Note that by using ``genlist`` you just generate the playlist in the
139 local session. To save your playlist to a file for future reuse,
140 type::
141
142     hooke> savelist mylist
143
144 In this example, the list will be saved in the file ``mylist.hkp``.
145 Hooke will add the extension ``.hkp`` (Hooke playlist) to the playlist
146 if you forget to.  The ``.hkp`` file is an XML file you can read and
147 edit with any text editor (i.e. Wordpad), if needed.  If you want to
148 load it, simply issue ``loadlist mylist.hkp`` or ``loadlist mylist``,
149 Hooke will add ``.hkp`` if necessary.
150
151 If, generating the playlist, you are including by chance a non-force
152 curve file that Hooke cannot open, Hooke will print an error and
153 continue on.
154
155 Navigating the playlist
156 -----------------------
157
158 Now you can navigate through your playlist using the commands ``next``
159 and ``previous`` or, their aliases ``n`` and ``p``. You don’t need to
160 type ``n`` every time to run along a list of curves.  If you press
161 Return to an empty prompt, Hooke will repeat the last command you
162 issued explicitly.  You can also navigate through the command history
163 by using the up and down arrows.  From the last curve of your
164 playlist, ``n`` will wrap around to the first curve.  Analogously,
165 issuing ``p`` at the first curve will jump to the last.
166
167 You can also jump to a given curve::
168
169     hooke> jump c:\curves\mycurve.012
170
171 where the path can be either an absolute path, or a path relative to
172 the directory holding the playlist file.
173
174 Taking notes
175 ------------
176
177 You can take notes about the curves you are looking at.  Just type
178 ``note`` followed by the text you want to append to that curve.  Hooke
179 will save the text in your current playlist and in an external log
180 file.  The output will look like this:
181
182 Notes taken at Sun Sep 17 20:42:07 2006
183 /home/cyclopia/work/tris/20060620a.041 |             This is a note
184 /home/cyclopia/work/tris/20060620a.207 |             This is another note
185 /home/cyclopia/work/tris/20060620a.286 |             This is a third one
186
187 The log file name can be configured_, but it defaults to hooke.log.
188
189 .. _configured: config.txt
190
191 Usually curves you annotated are useful later.  You can copy the curves
192 you annotated to a different directory by using the ``copylog``
193 command.
194
195     hooke> copylog c:\nicecurves
196
197 will copy all curves you have annotated to the c:\nicecurves
198 directory.  Make sure that the directory already exists before doing
199 that.  TODO: replace with::
200
201     hooke> copylist --log c:\curves\nice.hkp
202
203 Exporting curves
204 ----------------
205
206 You can export Hooke curves as images and as text columns. To export
207 as images, issue the ``export`` command followed by the filename.
208 Supported formats are PNG (raster) and EPS (Encapsulated Postscript,
209 vectorial).  The export format is determined by the filename
210 extension, so ``export foo.png`` and ``export foo.eps`` will save
211 PNG and EPS files respectively.
212
213 To export as text, use the ``txt`` command, followed by the
214 filename. The output is a text file containing columns (first two are
215 X and Y of extension, second two are X and Y of retraction).
216
217 TODO: multiple cycles?  Solution: blank lines for "breaks", add option
218 to extract specific sections using Python's slice notation.
219
220
221 Interacting with the plot (no plots in command line mode...)
222 -------------------------
223
224 Measuring distances and forces
225 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
226
227 You can easily zoom in the plot by dragging a rectangle on it with the
228 left mouse button.  To zoom out, click the right mouse
229 button. Sometimes by zooming in and out too much, you can lose the
230 picture (this is probably a small bug in Matplotlib).  Just type
231 ``plot`` at the command line and the curve will be refreshed.
232
233 You can measure distances and forces directly in the plot. Just issue
234 the command ``distance``.  You will be asked to click two points.
235 When you click a point, a blue dot should appear.  When you click the
236 second point, the distances (in nanometers and piconewtons) will
237 appear on the command line.  You can use ``delta`` if you prefer,
238 which gives meaningful values for every kind of graph (not only force
239 curves). If you want to know the coordinates of a single point, use
240 ``point``.
241
242 Hooke automatically adjusts the position of the clicked point to the
243 nearest point in the graph, so you will be always measuring distances
244 and forces between points in the graph.
245
246 The commands ``force`` and ``distance`` are present in the
247 ``generalvclamp`` plugin.
248
249 Worm like chain and freely jointed chain fitting
250 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
251
252 You can measure by hand the parameters relative to a force peak using
253 a worm-like chain fitting with the ``fit`` command.  The command by
254 default automatically finds the contact point, asks for two points
255 delimiting the portion to fit, and performs a two-variable fit, with
256 contour length, persistence length, and their relative errors as
257 output.  If desired, one can use the ``noauto`` option to manually
258 click the contact point, and/or the ``pl=NUMBER`` options to impose a
259 specific persistence or Kuhn length (in nanometers). You can choose
260 which model to use with ``set fit_function wlc`` or ``set fit_function
261 fjc``.  See the help of the ``fit`` command from the Hooke
262 command line for details.
263
264 Multiple curve fitting and measuring
265 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
266
267 You can cycle through all your current playlist obtaining WLC fit, FJC
268 fit, rupture force and slope (loading rate) information from each
269 curve using the ``multifit`` command.  The collected data can be saved
270 in a text file for further analysis in your favourite spreadsheet or
271 statistical program.  If you want to check your parameters on the
272 current curve before fitting all the files in your playlist, use
273 ``multifit justone``.  See the ``multifit`` help for more options.
274
275 Fast curve reviewing and saving
276 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
277
278 When automatic routines are not good enough to filter your data, use
279 ``review`` command to cycle through your playlist presenting ten
280 curves in the same graph.  You can then enter the numbers of the
281 interesting curves and automatically save a copy of them into another
282 directory.
283
284 Configuring Hooke
285 -----------------
286
287 You can set environment variables to influence the behaviour of
288 Hooke. The command to use is ``set``.
289
290 You can alter permanently the behaviour of Hooke by setting these
291 variables in a Hooke configuration file.  See the `Configuring Hooke`_
292 section for details.
293
294 .. _Configuring Hooke: config.txt