test/data/vclamp_jpk/README: Document sample versions
[hooke.git] / test / tutorial.py
1 # Copyright (C) 2010-2012 W. Trevor King <wking@tremily.us>
2 #
3 # This file is part of Hooke.
4 #
5 # Hooke is free software: you can redistribute it and/or modify it under the
6 # terms of the GNU Lesser General Public License as published by the Free
7 # Software Foundation, either version 3 of the License, or (at your option) any
8 # later version.
9 #
10 # Hooke is distributed in the hope that it will be useful, but WITHOUT ANY
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12 # A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
13 # details.
14 #
15 # You should have received a copy of the GNU Lesser General Public License
16 # along with Hooke.  If not, see <http://www.gnu.org/licenses/>.
17
18 """
19 Test the commands listed in :file:`doc/tutorial.txt`.
20
21 >>> import os
22 >>> import os.path
23 >>> from hooke.hooke import Hooke, HookeRunner
24 >>> h = Hooke()
25 >>> r = HookeRunner()
26
27 *Help*
28
29 >>> h = r.run_lines(h, ['help'])  # doctest: +ELLIPSIS
30 <BLANKLINE>
31 Documented commands (type help <topic>):
32 ========================================
33 ...
34 >>> h = r.run_lines(h, ['help load_playlist'])
35 Usage: load_playlist [options]
36 <BLANKLINE>
37 Options:
38   -h, --help            show this help message and exit
39   --disable-stack       Add this command to appropriate command stacks. (True)
40   --output_playlist=OUTPUT_PLAYLIST
41                         Name of the new playlist (defaults to an auto-
42                         generated name). (None)
43   --drivers=DRIVERS     Drivers for loading curves. (None)
44 <BLANKLINE>
45 Load a playlist.
46 <BLANKLINE>
47 ----
48 Usage: load_playlist [options] input
49
50 *Creating a playlist*
51
52 >>> h = r.run_lines(h, ['cd --path .'])
53 Success
54 <BLANKLINE>
55 >>> h = r.run_lines(h, ['pwd'])  # doctest: +ELLIPSIS
56 /.../hooke
57 Success
58 <BLANKLINE>
59 >>> h = r.run_lines(h, ['ls'])  # doctest: +ELLIPSIS +REPORT_UDIFF
60 .git
61 ...
62 AUTHORS
63 ...
64 README
65 ...
66 hooke
67 ...
68 Success
69 <BLANKLINE>
70 >>> h = r.run_lines(h, ['new_playlist --output_playlist mylist'])
71 <FilePlaylist mylist>
72 Success
73 <BLANKLINE>
74 >>> h = r.run_lines(h, ['jump_to_playlist -- -1'])
75 Success
76 <BLANKLINE>
77 >>> h = r.run_lines(h, ['get_playlist'])
78 <FilePlaylist mylist>
79 Success
80 <BLANKLINE>
81 >>> h = r.run_lines(h, ['glob_curves_to_playlist test/data/vclamp_picoforce/*']
82 ...     )  # doctest: +ELLIPSIS, +REPORT_UDIFF
83 <Curve 0x05120005>
84 <Curve 0x06130001>
85 <Curve 0x07200000>
86 <Curve 20071120a_i27_t33.100>
87 <Curve 20071120a_i27_t33.101>
88 ...
89 <Curve 20071120a_i27_t33.199>
90 Success
91 <BLANKLINE>
92 >>> playlist_already_exists = os.path.exists('mylist.hkp')
93 >>> playlist_already_exists
94 False
95 >>> h = r.run_lines(h, ['save_playlist --output mylist'])
96 Success
97 <BLANKLINE>
98 >>> h = r.run_lines(h, ['name_playlist my_old_list'])
99 <FilePlaylist my_old_list>
100 Success
101 <BLANKLINE>
102 >>> os.path.isfile('mylist.hkp')
103 True
104 >>> h = r.run_lines(h, ['load_playlist mylist.hkp'])
105 <FilePlaylist mylist>
106 Success
107 <BLANKLINE>
108 >>> if playlist_already_exists == False:
109 ...     os.remove('mylist.hkp')
110
111 *Navigating the playlist*
112
113 >>> h = r.run_lines(h, ['get_curve'])
114 <Curve 0x05120005>
115 Success
116 <BLANKLINE>
117 >>> h = r.run_lines(h, ['next_curve'])
118 Success
119 <BLANKLINE>
120 >>> h = r.run_lines(h, ['get_curve'])
121 <Curve 0x06130001>
122 Success
123 <BLANKLINE>
124 >>> h = r.run_lines(h, ['previous_curve'])
125 Success
126 <BLANKLINE>
127 >>> h = r.run_lines(h, ['get_curve'])
128 <Curve 0x05120005>
129 Success
130 <BLANKLINE>
131 >>> h = r.run_lines(h, ['curve_index'])
132 0
133 Success
134 <BLANKLINE>
135 >>> h = r.run_lines(h, ['previous_curve'])
136 Success
137 <BLANKLINE>
138 >>> h = r.run_lines(h, ['get_curve'])
139 <Curve 20071120a_i27_t33.199>
140 Success
141 <BLANKLINE>
142 >>> h = r.run_lines(h, ['curve_index'])
143 102
144 Success
145 <BLANKLINE>
146 >>> h = r.run_lines(h, ['next_curve'])
147 Success
148 <BLANKLINE>
149 >>> h = r.run_lines(h, ['get_curve'])
150 <Curve 0x05120005>
151 Success
152 <BLANKLINE>
153 >>> h = r.run_lines(h, ['curve_index'])
154 0
155 Success
156 <BLANKLINE>
157 >>> h = r.run_lines(h, ['jump_to_curve 14'])
158 Success
159 <BLANKLINE>
160 >>> h = r.run_lines(h, ['get_curve'])
161 <Curve 20071120a_i27_t33.111>
162 Success
163 <BLANKLINE>
164 >>> h = r.run_lines(h, ['curve_index'])
165 14
166 Success
167 <BLANKLINE>
168
169 >>> [p for p in h.playlists]
170 [<FilePlaylist my_old_list>, <FilePlaylist mylist>]
171 >>> h = r.run_lines(h, ['get_playlist'])
172 <FilePlaylist my_old_list>
173 Success
174 <BLANKLINE>
175 >>> h = r.run_lines(h, ['next_playlist'])
176 Success
177 <BLANKLINE>
178 >>> h = r.run_lines(h, ['get_playlist'])
179 <FilePlaylist mylist>
180 Success
181 <BLANKLINE>
182 >>> h = r.run_lines(h, ['previous_playlist'])
183 Success
184 <BLANKLINE>
185 >>> h = r.run_lines(h, ['get_playlist'])
186 <FilePlaylist my_old_list>
187 Success
188 <BLANKLINE>
189 >>> h = r.run_lines(h, ['playlist_index'])
190 0
191 Success
192 <BLANKLINE>
193 >>> h = r.run_lines(h, ['previous_playlist'])
194 Success
195 <BLANKLINE>
196 >>> h = r.run_lines(h, ['get_playlist'])
197 <FilePlaylist mylist>
198 Success
199 <BLANKLINE>
200 >>> h = r.run_lines(h, ['playlist_index'])
201 1
202 Success
203 <BLANKLINE>
204 >>> h = r.run_lines(h, ['next_playlist'])
205 Success
206 <BLANKLINE>
207 >>> h = r.run_lines(h, ['get_playlist'])
208 <FilePlaylist my_old_list>
209 Success
210 <BLANKLINE>
211 >>> h = r.run_lines(h, ['playlist_index'])
212 0
213 Success
214 <BLANKLINE>
215 >>> h = r.run_lines(h, ['jump_to_playlist 1'])
216 Success
217 <BLANKLINE>
218 >>> h = r.run_lines(h, ['get_playlist'])
219 <FilePlaylist mylist>
220 Success
221 <BLANKLINE>
222 >>> h = r.run_lines(h, ['playlist_index'])
223 1
224 Success
225 <BLANKLINE>
226
227 *Taking notes*
228
229 See :file:`note.py`.
230
231 *Exporting curves*
232
233 See :file:`export_block.py`.
234
235 *Measuring distances and forces*
236
237 See :file:`delta.py`.
238
239 *Worm like chain and freely jointed chain fitting*
240
241 *Command stacks*
242
243 See :file:`command_stack.py`,
244 :file:`apply_command_stack_to_playlist.py`, and
245 :file:`command_stack_save_load.py`.
246
247 *Multiple curve analysis*
248
249 See :file:`multiple_curve_analysis`.
250
251 *Configuring Hooke*
252
253 See :file:`config.py`.
254 """