Ran update_copyright.py.
[hooke.git] / test / tutorial.py
1 # Copyright (C) 2010-2012 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 Usage: load_playlist [options]
37 <BLANKLINE>
38 Options:
39   -h, --help            show this help message and exit
40   --disable-stack       Add this command to appropriate command stacks. (True)
41   --output_playlist=OUTPUT_PLAYLIST
42                         Name of the new playlist (defaults to an auto-
43                         generated name). (None)
44   --drivers=DRIVERS     Drivers for loading curves. (None)
45 <BLANKLINE>
46 Load a playlist.
47 <BLANKLINE>
48 ----
49 Usage: load_playlist [options] input
50
51 *Creating a playlist*
52
53 >>> h = r.run_lines(h, ['cd --path .'])
54 Success
55 <BLANKLINE>
56 >>> h = r.run_lines(h, ['pwd'])  # doctest: +ELLIPSIS
57 /.../hooke
58 Success
59 <BLANKLINE>
60 >>> h = r.run_lines(h, ['ls'])  # doctest: +ELLIPSIS +REPORT_UDIFF
61 .hg
62 ...
63 AUTHORS
64 ...
65 README
66 ...
67 hooke
68 ...
69 Success
70 <BLANKLINE>
71 >>> h = r.run_lines(h, ['new_playlist --output_playlist mylist'])
72 <FilePlaylist mylist>
73 Success
74 <BLANKLINE>
75 >>> h = r.run_lines(h, ['jump_to_playlist -- -1'])
76 Success
77 <BLANKLINE>
78 >>> h = r.run_lines(h, ['get_playlist'])
79 <FilePlaylist mylist>
80 Success
81 <BLANKLINE>
82 >>> h = r.run_lines(h, ['glob_curves_to_playlist test/data/vclamp_picoforce/*']
83 ...     )  # doctest: +ELLIPSIS
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 0x06130001>
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 0x07200000>
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 0x06130001>
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 101
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 0x06130001>
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.112>
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 """