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