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