1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 from os import F_OK, access, sep
25 import wx
26
27
28 from data import Relax_data_store; ds = Relax_data_store()
29 from generic_fns.mol_res_spin import spin_loop
30 from generic_fns.pipes import cdp_name
31 from status import Status; status = Status()
32 from test_suite.gui_tests.base_classes import GuiTestCase
33
34
35 from gui.interpreter import Interpreter; interpreter = Interpreter()
36 from gui.misc import bool_to_gui, float_to_gui, int_to_gui, float_to_gui, str_to_gui
37 from gui.user_functions import deselect, sequence, spin
38 from gui.wizard import Wiz_window
39
40
41 -class Rx(GuiTestCase):
42 """Class for testing various aspects specific to the R1 and R2 analyses."""
43
45 """Check the results of the curve-fitting."""
46
47
48 relax_times = [0.0176, 0.0176, 0.0352, 0.0704, 0.0704, 0.1056, 0.1584, 0.1584, 0.1936, 0.1936]
49 chi2 = [None, None, None, 2.916952651567855, 5.4916923952919632, 16.21182245065274, 4.3591263759462926, 9.8925377583244316, None, None, None, 6.0238341559877782]
50 rx = [None, None, None, 8.0814894819820662, 8.6478971039559642, 9.5710638183013845, 10.716551838066295, 11.143793935455122, None, None, None, 12.82875370075309]
51 i0 = [None, None, None, 1996050.9679875025, 2068490.9458927638, 1611556.5194095275, 1362887.2331948928, 1877670.5623875158, None, None, None, 897044.17382064369]
52
53
54 self.assertEqual(cdp.curve_type, 'exp')
55 self.assertEqual(cdp.int_method, 'height')
56 self.assertEqual(len(cdp.relax_times), 10)
57 cdp_relax_times = sorted(cdp.relax_times.values())
58 for i in range(10):
59 self.assertEqual(cdp_relax_times[i], relax_times[i])
60
61
62 for key in cdp.sigma_I:
63 self.assertEqual(cdp.sigma_I[key], 10578.03948242143)
64 self.assertEqual(cdp.var_I[key], 111894919.29166666)
65
66
67 i = 0
68 for spin in spin_loop():
69
70 if chi2[i] == None:
71 self.assert_(not hasattr(spin, 'chi2'))
72
73
74 else:
75 self.assertAlmostEqual(spin.chi2, chi2[i])
76 self.assertAlmostEqual(spin.rx, rx[i])
77 self.assertAlmostEqual(spin.i0/1e6, i0[i]/1e6)
78
79
80 i = i + 1
81 if i >= 12:
82 break
83
84
86 """Test the r1 analysis."""
87
88
89 data_path = status.install_path + sep + 'test_suite' + sep + 'shared_data' + sep + 'curve_fitting' + sep
90
91
92 self.app.gui.analysis.menu_new(None)
93 page = self.app.gui.analysis.new_wizard.wizard.get_page(0)
94 page.select_r1(None)
95 self.app.gui.analysis.new_wizard.wizard._go_next(None)
96 page = self.app.gui.analysis.new_wizard.wizard.get_page(1)
97 self.app.gui.analysis.new_wizard.wizard._go_next(None)
98
99
100 analysis_type, analysis_name, pipe_name = self.app.gui.analysis.new_wizard.get_data()
101
102
103 self.app.gui.analysis.new_analysis(analysis_type=analysis_type, analysis_name=analysis_name, pipe_name=pipe_name)
104
105
106 analysis = self.app.gui.analysis.get_page_from_name("R1 relaxation")
107
108
109 analysis.field_nmr_frq.SetValue(str_to_gui('600'))
110
111
112 analysis.field_results_dir.SetValue(str_to_gui(ds.tmpdir))
113
114
115 wizard = Wiz_window(self.app.gui)
116 seq_read = sequence.Read_page(wizard)
117 file = status.install_path + sep + 'test_suite' + sep + 'shared_data' + sep + 'Ap4Aase.seq'
118 seq_read.file.SetValue(str_to_gui(file))
119 seq_read.mol_name_col.SetValue(int_to_gui(None))
120 seq_read.res_name_col.SetValue(int_to_gui(2))
121 seq_read.res_num_col.SetValue(int_to_gui(1))
122 seq_read.spin_name_col.SetValue(int_to_gui(None))
123 seq_read.spin_num_col.SetValue(int_to_gui(None))
124 seq_read.on_execute()
125
126
127 deselect_read = deselect.Read_page(wizard)
128 deselect_read.file.SetValue(str_to_gui(data_path + 'unresolved'))
129 deselect_read.mol_name_col.SetValue(int_to_gui(None))
130 deselect_read.res_name_col.SetValue(int_to_gui(None))
131 deselect_read.res_num_col.SetValue(int_to_gui(1))
132 deselect_read.spin_name_col.SetValue(int_to_gui(None))
133 deselect_read.spin_num_col.SetValue(int_to_gui(None))
134 deselect_read.change_all.SetValue(bool_to_gui(True))
135 deselect_read.on_execute()
136
137
138 page = spin.Name_page(wizard)
139 page.name.SetValue(str_to_gui('N'))
140 page.on_execute()
141
142
143 interpreter.flush()
144
145
146 names = [
147 'T2_ncyc1_ave',
148 'T2_ncyc1b_ave',
149 'T2_ncyc2_ave',
150 'T2_ncyc4_ave',
151 'T2_ncyc4b_ave',
152 'T2_ncyc6_ave',
153 'T2_ncyc9_ave',
154 'T2_ncyc9b_ave',
155 'T2_ncyc11_ave',
156 'T2_ncyc11b_ave'
157 ]
158
159
160 replicated = {
161 'T2_ncyc1b_ave': 'T2_ncyc1_ave',
162 'T2_ncyc4b_ave': 'T2_ncyc4_ave',
163 'T2_ncyc9b_ave': 'T2_ncyc9_ave',
164 'T2_ncyc11b_ave': 'T2_ncyc11_ave'
165 }
166
167
168 ncyc = [1,
169 1,
170 2,
171 4,
172 4,
173 6,
174 9,
175 9,
176 11,
177 11
178 ]
179
180
181 time = 0.0176
182
183
184 for i in range(len(names)):
185
186 analysis.peak_wizard(None)
187
188
189 page = analysis.wizard.get_page(analysis.page_indices['read'])
190 page.file.SetValue(str_to_gui("%s%s.list" % (data_path, names[i])))
191 page.spectrum_id.SetValue(str_to_gui(names[i]))
192 page.proton.SetValue(str_to_gui('HN'))
193
194
195 analysis.wizard._go_next(None)
196
197
198 page = analysis.wizard.get_page(analysis.page_indices['err_type'])
199 page.selection = 'repl'
200
201
202 analysis.wizard._go_next(None)
203
204
205 if names[i] in replicated.keys():
206 page = analysis.wizard.get_page(analysis.page_indices['repl'])
207 page.spectrum_id_boxes[1].SetStringSelection(str_to_gui(replicated[names[i]]))
208
209
210 analysis.wizard._go_next(None)
211
212
213 page = analysis.wizard.get_page(analysis.page_indices['relax_time'])
214 page.time.SetValue(float_to_gui(ncyc[i]*time))
215
216
217 analysis.wizard._go_next(None)
218
219
220 analysis.mc_sim_num.SetValue(3)
221
222
223 analysis.execute(wx.CommandEvent(wx.wxEVT_COMMAND_BUTTON_CLICKED, analysis.button_exec_relax.GetId()))
224
225
226 analysis.thread.join()
227
228
229 wx.Yield()
230
231
232 self.check_exceptions()
233
234
235 if status.relax_mode != 'gui':
236 self.assertEqual(self.app.gui.controller.mc_gauge_rx.GetValue(), 100)
237 self.assertEqual(self.app.gui.controller.main_gauge.GetValue(), 100)
238
239
240 self.assertEqual(cdp_name(), ds.relax_gui.analyses[0].pipe_name)
241
242
243 self.check_curve_fitting()
244
245
246 self.assert_(access(ds.tmpdir+sep+'r1.600.out', F_OK))
247 self.assert_(access(ds.tmpdir+sep+'results.bz2', F_OK))
248 self.assert_(access(ds.tmpdir+sep+'r1.600.save.bz2', F_OK))
249 self.assert_(access(ds.tmpdir+sep+'grace'+sep+'r1.600.agr', F_OK))
250 self.assert_(access(ds.tmpdir+sep+'grace'+sep+'chi2.agr', F_OK))
251 self.assert_(access(ds.tmpdir+sep+'grace'+sep+'i0.agr', F_OK))
252 self.assert_(access(ds.tmpdir+sep+'grace'+sep+'intensities.agr', F_OK))
253 self.assert_(access(ds.tmpdir+sep+'grace'+sep+'intensities_norm.agr', F_OK))
254