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