Package test_suite :: Package gui_tests :: Module relax_disp
[hide private]
[frames] | no frames]

Source Code for Module test_suite.gui_tests.relax_disp

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2013-2014 Edward d'Auvergne                                   # 
  4  # Copyright (C) 2013-2014 Troels E. Linnet                                    # 
  5  #                                                                             # 
  6  # This file is part of the program relax (http://www.nmr-relax.com).          # 
  7  #                                                                             # 
  8  # This program is free software: you can redistribute it and/or modify        # 
  9  # it under the terms of the GNU General Public License as published by        # 
 10  # the Free Software Foundation, either version 3 of the License, or           # 
 11  # (at your option) any later version.                                         # 
 12  #                                                                             # 
 13  # This program is distributed in the hope that it will be useful,             # 
 14  # but WITHOUT ANY WARRANTY; without even the implied warranty of              # 
 15  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               # 
 16  # GNU General Public License for more details.                                # 
 17  #                                                                             # 
 18  # You should have received a copy of the GNU General Public License           # 
 19  # along with this program.  If not, see <http://www.gnu.org/licenses/>.       # 
 20  #                                                                             # 
 21  ############################################################################### 
 22   
 23  # Module docstring. 
 24  """GUI tests for the relaxation dispersion analyses.""" 
 25   
 26  # Python module imports. 
 27  from os import sep 
 28  import wx 
 29   
 30  # relax module imports. 
 31  from data_store import Relax_data_store; ds = Relax_data_store() 
 32  import dep_check 
 33  from gui.interpreter import Interpreter; interpreter = Interpreter() 
 34  from gui.string_conv import float_to_gui, str_to_gui 
 35  from gui.uf_objects import Uf_storage; uf_store = Uf_storage() 
 36  from pipe_control.mol_res_spin import spin_loop 
 37  from pipe_control.pipes import switch 
 38  from specific_analyses.relax_disp.disp_data import generate_r20_key 
 39  from specific_analyses.relax_disp.variables import EXP_TYPE_R1RHO, MODEL_CR72, MODEL_IT99, MODEL_LM63, MODEL_NOREX, MODEL_NS_CPMG_2SITE_EXPANDED, MODEL_R2EFF, MODEL_TP02 
 40  from status import Status; status = Status() 
 41  from test_suite.gui_tests.base_classes import GuiTestCase 
 42   
 43   
44 -class Relax_disp(GuiTestCase):
45 """GUI test case class for testing various aspects of the relaxation dispersion analyses.""" 46
47 - def __init__(self, methodName='runTest'):
48 """Skip the tests if the C modules are non-functional or for wxPython bugs. 49 50 @keyword methodName: The name of the test. 51 @type methodName: str 52 """ 53 54 # Execute the base class method. 55 super(Relax_disp, self).__init__(methodName) 56 57 # Missing module. 58 if not dep_check.C_module_exp_fn: 59 # Store in the status object. 60 status.skipped_tests.append([methodName, 'Relax curve-fitting C module', self._skip_type])
61 62
64 """Test catching U{bug #20889<https://web.archive.org/web/https://gna.org/bugs/?20889>}, the custom peak intensity reading with a list of spectrum_ids submitted by Troels E. Linnet.""" 65 66 # The path to the files. 67 path = status.install_path + sep + 'test_suite' + sep + 'shared_data' + sep + 'peak_lists' + sep 68 69 # Simulate the new analysis wizard, selecting the fixed time CPMG experiment. 70 self.app.gui.analysis.menu_new(None) 71 page = self.app.gui.analysis.new_wizard.wizard.get_page(0) 72 page.select_disp(None) 73 self.app.gui.analysis.new_wizard.wizard._go_next(None) 74 self.app.gui.analysis.new_wizard.wizard._go_next(None) 75 76 # Get the data. 77 analysis_type, analysis_name, pipe_name, pipe_bundle, uf_exec = self.app.gui.analysis.new_wizard.get_data() 78 79 # Set up the analysis. 80 self.app.gui.analysis.new_analysis(analysis_type=analysis_type, analysis_name=analysis_name, pipe_name=pipe_name, pipe_bundle=pipe_bundle, uf_exec=uf_exec) 81 82 # Alias the analysis. 83 analysis = self.app.gui.analysis.get_page_from_name("Relaxation dispersion") 84 85 # Change the results directory. 86 analysis.field_results_dir.SetValue(str_to_gui(ds.tmpdir)) 87 88 # Load the sequence. 89 file = path + 'test.seq' 90 self._execute_uf(uf_name='sequence.read', file=file, mol_name_col=1, res_name_col=3, res_num_col=2, spin_name_col=5, spin_num_col=4) 91 92 # Flush the interpreter in preparation for the synchronous user functions of the peak list wizard. 93 interpreter.flush() 94 95 # Set up the nuclear isotopes. 96 analysis.spin_isotope() 97 uf_store['spin.isotope'].page.SetValue('spin_id', '') 98 uf_store['spin.isotope'].wizard._go_next() 99 interpreter.flush() # Required because of the asynchronous uf call. 100 101 # Set up the peak intensity wizard. 102 analysis.peak_wizard_launch(None) 103 wizard = analysis.peak_wizard 104 105 # The spectrum. 106 page = wizard.get_page(wizard.page_indices['read']) 107 page.uf_args['file'].SetValue(str_to_gui("%stest.seq" % path)) 108 page.uf_args['spectrum_id'].SetValue(['0_2', '1_0']) 109 page.uf_args['int_col'].SetValue([6, 7]) 110 wizard._go_next(None) 111 112 # The error type. 113 page = wizard.get_page(wizard.page_indices['err_type']) 114 page.selection = 'rmsd' 115 wizard._go_next(None) 116 117 # Set the RMSD. 118 page = wizard.get_page(wizard.page_indices['rmsd']) 119 page.uf_args['error'].SetValue(float_to_gui(3000.0)) 120 wizard._ok(None) 121 122 # The peak intensities. 123 data_2 = [337765.90000000002, 1697771.0, 867389.80000000005, 2339480.0, 2574062.0, 1609356.0, 2179341.0, 1563795.0, 1535896.0, 3578841.0] 124 data_0 = [636244.59999999998, 3015788.0, 1726064.0, 4039142.0, 4313824.0, 2927111.0, 4067343.0, 2921316.0, 3005234.0, 6352595.0] 125 126 # Data checks. 127 for i in range(len(cdp.mol[0].res)): 128 # Alias the spin. 129 spin = cdp.mol[0].res[i].spin[0] 130 131 # The intensities. 132 self.assertEqual(spin.intensities['1_0'], data_0[i]) 133 self.assertEqual(spin.intensities['0_2'], data_2[i]) 134 135 # The errors. 136 self.assert_(hasattr(spin, 'baseplane_rmsd')) 137 self.assertEqual(spin.baseplane_rmsd['0_2'], 3000.0)
138 139
141 """Test catching U{bug #21076<https://web.archive.org/web/https://gna.org/bugs/?21076>}, loading a multi-spectra NMRPipe seriesTab file through the GUI, Error messages occur.""" 142 143 # The paths to the data files. 144 data_path = status.install_path + sep + 'test_suite' + sep + 'shared_data' + sep + 'dispersion' + sep + 'KTeilum_FMPoulsen_MAkke_2006' + sep + 'acbp_cpmg_disp_101MGuHCl_40C_041223' + sep 145 146 # Simulate the new analysis wizard, selecting the fixed time CPMG experiment. 147 self.app.gui.analysis.menu_new(None) 148 page = self.app.gui.analysis.new_wizard.wizard.get_page(0) 149 page.select_disp(None) 150 self.app.gui.analysis.new_wizard.wizard._go_next(None) 151 self.app.gui.analysis.new_wizard.wizard._go_next(None) 152 153 # Get the data. 154 analysis_type, analysis_name, pipe_name, pipe_bundle, uf_exec = self.app.gui.analysis.new_wizard.get_data() 155 156 # Set up the analysis. 157 self.app.gui.analysis.new_analysis(analysis_type=analysis_type, analysis_name=analysis_name, pipe_name=pipe_name, pipe_bundle=pipe_bundle, uf_exec=uf_exec) 158 159 # Alias the analysis. 160 analysis = self.app.gui.analysis.get_page_from_name("Relaxation dispersion") 161 162 # Change the results directory. 163 analysis.field_results_dir.SetValue(str_to_gui(ds.tmpdir)) 164 165 # Load the sequence. 166 file = data_path + 'relax_2_spins_trunc.py' 167 self._execute_uf(uf_name='script', file=file, dir=None) 168 169 # Flush the interpreter in preparation for the synchronous user functions of the peak list wizard. 170 interpreter.flush() 171 172 # Set up the nuclear isotopes. 173 analysis.spin_isotope() 174 uf_store['spin.isotope'].page.SetValue('spin_id', '') 175 uf_store['spin.isotope'].wizard._go_next() 176 interpreter.flush() # Required because of the asynchronous uf call. 177 178 # Set up the peak intensity wizard. 179 analysis.peak_wizard_launch(None) 180 wizard = analysis.peak_wizard 181 182 # The spectrum, where the use of Keyword auto will auto-assign spectra Z_A{i}. 183 page = wizard.get_page(wizard.page_indices['read']) 184 page.uf_args['file'].SetValue(str_to_gui("%sfolded_sparky_corr_final_max_standard_trunc.ser" % data_path)) 185 page.uf_args['spectrum_id'].SetValue('auto') 186 wizard._go_next(None) 187 188 # The error type window. 189 page = wizard.get_page(wizard.page_indices['err_type']) 190 page.selection = 'rmsd' 191 wizard._go_next(None) 192 193 # Get ID from RMSD window. 194 page = wizard.get_page(wizard.page_indices['rmsd']) 195 196 # Flush all wx events (to allow the spectrum list GUI element to populate all its rows). 197 wx.Yield() 198 199 # Get the first ID from list. 200 cur_id = page.uf_args['spectrum_id'].GetValue() 201 202 # Now check that the first is set to 'Z_A0', since the keyword 'auto' was used for spectrum_id. 203 self.assertEqual(cur_id, 'Z_A0') 204 205 # Finally close the wizard to allow subsequent tests to be able to operate cleanly. 206 wizard.Close()
207 208
209 - def test_hansen_trunc_data(self):
210 """Test the GUI analysis with Flemming Hansen's CPMG data truncated to residues 70 and 71.""" 211 212 # The paths to the data files. 213 data_path = status.install_path + sep + 'test_suite' + sep + 'shared_data' + sep + 'dispersion' + sep + 'Hansen' + sep 214 data_path_500 = data_path + sep + '500_MHz' + sep 215 data_path_800 = data_path + sep + '800_MHz' + sep 216 217 # Simulate the new analysis wizard, selecting the fixed time CPMG experiment. 218 self.app.gui.analysis.menu_new(None) 219 page = self.app.gui.analysis.new_wizard.wizard.get_page(0) 220 page.select_disp(None) 221 self.app.gui.analysis.new_wizard.wizard._go_next(None) 222 self.app.gui.analysis.new_wizard.wizard._go_next(None) 223 224 # Get the data. 225 analysis_type, analysis_name, pipe_name, pipe_bundle, uf_exec = self.app.gui.analysis.new_wizard.get_data() 226 227 # Set up the analysis. 228 self.app.gui.analysis.new_analysis(analysis_type=analysis_type, analysis_name=analysis_name, pipe_name=pipe_name, pipe_bundle=pipe_bundle, uf_exec=uf_exec) 229 230 # Alias the analysis. 231 analysis = self.app.gui.analysis.get_page_from_name("Relaxation dispersion") 232 233 # Change the results directory. 234 analysis.field_results_dir.SetValue(str_to_gui(ds.tmpdir)) 235 236 # Load the sequence. 237 file = data_path + 'fake_sequence.in' 238 self._execute_uf(uf_name='sequence.read', file=file, mol_name_col=None, res_num_col=1, res_name_col=2, spin_name_col=None, spin_num_col=None) 239 240 # Flush the interpreter in preparation for the synchronous user functions of the peak list wizard. 241 interpreter.flush() 242 243 # Set up the nuclear isotopes. 244 analysis.spin_isotope() 245 uf_store['spin.isotope'].page.SetValue('spin_id', '') 246 uf_store['spin.isotope'].wizard._go_next() 247 interpreter.flush() # Required because of the asynchronous uf call. 248 249 # The spectral data - spectrum ID, peak list file name, CPMG frequency (Hz), spectrometer frequency in Hertz. 250 data = [ 251 ['500_reference.in', '500_MHz'+sep+'reference.in', None, 500e6], 252 ['500_66.667.in', '500_MHz'+sep+'66.667.in', 66.6666, 500e6], 253 ['500_133.33.in', '500_MHz'+sep+'133.33.in', 133.3333, 500e6], 254 ['500_133.33.in.bis', '500_MHz'+sep+'133.33.in.bis', 133.3333, 500e6], 255 ['500_200.in', '500_MHz'+sep+'200.in', 200.0000, 500e6], 256 ['500_266.67.in', '500_MHz'+sep+'266.67.in', 266.6666, 500e6], 257 ['500_333.33.in', '500_MHz'+sep+'333.33.in', 333.3333, 500e6], 258 ['500_400.in', '500_MHz'+sep+'400.in', 400.0000, 500e6], 259 ['500_466.67.in', '500_MHz'+sep+'466.67.in', 466.6666, 500e6], 260 ['500_533.33.in', '500_MHz'+sep+'533.33.in', 533.3333, 500e6], 261 ['500_533.33.in.bis', '500_MHz'+sep+'533.33.in.bis', 533.3333, 500e6], 262 ['500_600.in', '500_MHz'+sep+'600.in', 600.0000, 500e6], 263 ['500_666.67.in', '500_MHz'+sep+'666.67.in', 666.6666, 500e6], 264 ['500_733.33.in', '500_MHz'+sep+'733.33.in', 733.3333, 500e6], 265 ['500_800.in', '500_MHz'+sep+'800.in', 800.0000, 500e6], 266 ['500_866.67.in', '500_MHz'+sep+'866.67.in', 866.6666, 500e6], 267 ['500_933.33.in', '500_MHz'+sep+'933.33.in', 933.3333, 500e6], 268 ['500_933.33.in.bis', '500_MHz'+sep+'933.33.in.bis', 933.3333, 500e6], 269 ['500_1000.in', '500_MHz'+sep+'1000.in', 1000.0000, 500e6], 270 ['800_reference.in', '800_MHz'+sep+'reference.in', None, 800e6], 271 ['800_66.667.in', '800_MHz'+sep+'66.667.in', 66.6666, 800e6], 272 ['800_133.33.in', '800_MHz'+sep+'133.33.in', 133.3333, 800e6], 273 ['800_133.33.in.bis', '800_MHz'+sep+'133.33.in.bis', 133.3333, 800e6], 274 ['800_200.in', '800_MHz'+sep+'200.in', 200.0000, 800e6], 275 ['800_266.67.in', '800_MHz'+sep+'266.67.in', 266.6666, 800e6], 276 ['800_333.33.in', '800_MHz'+sep+'333.33.in', 333.3333, 800e6], 277 ['800_400.in', '800_MHz'+sep+'400.in', 400.0000, 800e6], 278 ['800_466.67.in', '800_MHz'+sep+'466.67.in', 466.6666, 800e6], 279 ['800_533.33.in', '800_MHz'+sep+'533.33.in', 533.3333, 800e6], 280 ['800_533.33.in.bis', '800_MHz'+sep+'533.33.in.bis', 533.3333, 800e6], 281 ['800_600.in', '800_MHz'+sep+'600.in', 600.0000, 800e6], 282 ['800_666.67.in', '800_MHz'+sep+'666.67.in', 666.6666, 800e6], 283 ['800_733.33.in', '800_MHz'+sep+'733.33.in', 733.3333, 800e6], 284 ['800_800.in', '800_MHz'+sep+'800.in', 800.0000, 800e6], 285 ['800_866.67.in', '800_MHz'+sep+'866.67.in', 866.6666, 800e6], 286 ['800_933.33.in', '800_MHz'+sep+'933.33.in', 933.3333, 800e6], 287 ['800_933.33.in.bis', '800_MHz'+sep+'933.33.in.bis', 933.3333, 800e6], 288 ['800_1000.in', '800_MHz'+sep+'1000.in', 1000.0000, 800e6] 289 ] 290 291 # Replicated spectra. 292 replicated = [ 293 ['500_133.33.in', '500_133.33.in.bis'], 294 ['500_533.33.in', '500_533.33.in.bis'], 295 ['500_933.33.in', '500_933.33.in.bis'], 296 ['800_133.33.in', '800_133.33.in.bis'], 297 ['800_533.33.in', '800_533.33.in.bis'], 298 ['800_933.33.in', '800_933.33.in.bis'] 299 ] 300 301 # Set up the peak intensity wizard. 302 analysis.peak_wizard_launch(None) 303 wizard = analysis.peak_wizard 304 305 # Spin naming. 306 wizard.setup_page(page='name', name="N", force=True) 307 wizard._go_next(None) 308 309 # The spectrum. 310 for id, file, cpmg_frq, H_frq in data: 311 wizard.setup_page(page='read', file=data_path+file, spectrum_id=id, int_method='height', int_col=2, mol_name_col=None, res_num_col=1, res_name_col=None, spin_num_col=None, spin_name_col=None) 312 wizard._apply(None) 313 wizard._skip(None) 314 315 # The error type. 316 page = wizard.get_page(wizard.page_indices['err_type']) 317 page.selection = 'repl' 318 wizard._go_next(None) 319 320 # Replicated spectra: 321 for id1, id2 in replicated: 322 wizard.setup_page(page='repl', spectrum_ids=[id1, id2]) 323 wizard._apply(None) 324 wizard._skip(None) 325 326 # Set the experiment types. 327 for id, file, cpmg_frq, H_frq in data: 328 wizard.setup_page(page='exp_type', spectrum_id=id, exp_type='SQ CPMG') 329 wizard._apply(None) 330 wizard._skip(None) 331 332 # Set the spectrometer frequencies. 333 for id, file, cpmg_frq, H_frq in data: 334 wizard.setup_page(page='spectrometer_frequency', id=id, frq=H_frq) 335 wizard._apply(None) 336 wizard._skip(None) 337 338 # Set the relaxation time. 339 for id, file, cpmg_frq, H_frq in data: 340 wizard.setup_page(page='relax_time', spectrum_id=id, time=0.03) 341 wizard._apply(None) 342 wizard._skip(None) 343 344 # Set the CPMG frequencies. 345 for id, file, cpmg_frq, H_frq in data: 346 wizard.setup_page(page='cpmg_frq', spectrum_id=id, cpmg_frq=cpmg_frq) 347 wizard._apply(None) 348 wizard._skip(None) 349 350 # Flush all wx events (to allow the spectrum list GUI element to populate all its rows). 351 wx.Yield() 352 353 # Simulate right clicking in the spectrum list element to test the popup menu. 354 analysis.peak_intensity.on_right_click(Fake_right_click()) 355 356 # Simulate the popup menu entries to catch bugs there (just apply the user functions with the currently set values). 357 # FIXME: skipping the checks for certain wxPython bugs. 358 if status.relax_mode != 'gui' and wx.version() != '2.9.4.1 gtk2 (classic)': 359 analysis.peak_intensity.action_relax_disp_cpmg_frq(item=4) 360 uf_store['relax_disp.cpmg_frq'].wizard._go_next() 361 interpreter.flush() 362 analysis.peak_intensity.action_relax_disp_exp_type(item=5) 363 uf_store['relax_disp.exp_type'].wizard._go_next() 364 interpreter.flush() 365 analysis.peak_intensity.action_relax_disp_relax_time(item=0) 366 uf_store['relax_disp.relax_time'].wizard._go_next() 367 interpreter.flush() 368 analysis.peak_intensity.action_spectrometer_frq(item=10) 369 uf_store['spectrometer.frequency'].wizard._go_next() 370 interpreter.flush() 371 372 # Set up the models to use. 373 models = [MODEL_R2EFF, MODEL_NOREX, MODEL_LM63, MODEL_CR72, MODEL_IT99, MODEL_NS_CPMG_2SITE_EXPANDED] 374 for i in range(len(analysis.model_field.models_stripped)): 375 if analysis.model_field.models_stripped[i] in models: 376 analysis.model_field.select[i] = True 377 else: 378 analysis.model_field.select[i] = False 379 analysis.model_field.modify() 380 381 # Set the grid search size and number of MC sims. 382 analysis.grid_inc.SetValue(4) 383 analysis.mc_sim_num.SetValue(3) 384 385 # Optimisation speedups. 386 analysis.opt_func_tol = 1e-5 387 analysis.opt_max_iterations = 1000 388 389 # Perform the error analysis. 390 self._execute_uf(uf_name='spectrum.error_analysis', subset=['500_reference.in', '500_66.667.in', '500_133.33.in', '500_133.33.in.bis', '500_200.in', '500_266.67.in', '500_333.33.in', '500_400.in', '500_466.67.in', '500_533.33.in', '500_533.33.in.bis', '500_600.in', '500_666.67.in', '500_733.33.in', '500_800.in', '500_866.67.in', '500_933.33.in', '500_933.33.in.bis', '500_1000.in']) 391 self._execute_uf(uf_name='spectrum.error_analysis', subset=['800_reference.in', '800_66.667.in', '800_133.33.in', '800_133.33.in.bis', '800_200.in', '800_266.67.in', '800_333.33.in', '800_400.in', '800_466.67.in', '800_533.33.in', '800_533.33.in.bis', '800_600.in', '800_666.67.in', '800_733.33.in', '800_800.in', '800_866.67.in', '800_933.33.in', '800_933.33.in.bis', '800_1000.in']) 392 393 # Delete all residues but :4, :70 and :71. 394 for i in range(1, 100): 395 if i in [4, 70, 71]: 396 continue 397 self._execute_uf(uf_name='residue.delete', res_id=":%s" % i) 398 399 # Execute relax. 400 analysis.execute(wx.CommandEvent(wx.wxEVT_COMMAND_BUTTON_CLICKED, analysis.button_exec_relax.GetId())) 401 402 # Wait for execution to complete. 403 analysis.thread.join() 404 405 # Flush all wx events. 406 wx.Yield() 407 408 # Exceptions in the thread. 409 self.check_exceptions() 410 411 # Check the relax controller. 412 # FIXME: skipping the checks for certain wxPython bugs. 413 if status.relax_mode != 'gui' and wx.version() != '2.9.4.1 gtk2 (classic)': 414 self.assertEqual(self.app.gui.controller.mc_gauge_rx.GetValue(), 100) 415 self.assertEqual(self.app.gui.controller.main_gauge.GetValue(), 100)
416 417
419 """Test the GUI load spins from a spectrum formatted file.""" 420 421 # The path to the files. 422 path = status.install_path + sep + 'test_suite' + sep + 'shared_data' + sep + 'peak_lists' + sep 423 424 # Simulate the dispersion analysis wizard. 425 self.app.gui.analysis.menu_new(None) 426 page = self.app.gui.analysis.new_wizard.wizard.get_page(0) 427 page.select_disp(None) 428 self.app.gui.analysis.new_wizard.wizard._go_next(None) 429 self.app.gui.analysis.new_wizard.wizard._go_next(None) 430 431 # Get the data. 432 analysis_type, analysis_name, pipe_name, pipe_bundle, uf_exec = self.app.gui.analysis.new_wizard.get_data() 433 434 # Set up the analysis. 435 self.app.gui.analysis.new_analysis(analysis_type=analysis_type, analysis_name=analysis_name, pipe_name=pipe_name, pipe_bundle=pipe_bundle, uf_exec=uf_exec) 436 437 # Alias the analysis. 438 analysis = self.app.gui.analysis.get_page_from_name("Relaxation dispersion") 439 440 # Change the results directory. 441 analysis.field_results_dir.SetValue(str_to_gui(ds.tmpdir)) 442 443 # Launch the spin viewer window. 444 self.app.gui.show_tree() 445 446 # Spin loading wizard: Initialisation. 447 self.app.gui.spin_viewer.load_spins_wizard() 448 449 # Spin loading wizard: The spectrum.read_spins page. 450 page = self.app.gui.spin_viewer.wizard.get_page(0) 451 page.selection = 'new spectrum' 452 self.app.gui.spin_viewer.wizard._go_next() 453 page = self.app.gui.spin_viewer.wizard.get_page(self.app.gui.spin_viewer.wizard._current_page) 454 page.uf_args['file'].SetValue(str_to_gui(path + 'seriesTab.ser')) 455 self.app.gui.spin_viewer.wizard._go_next() 456 interpreter.flush() # Required because of the asynchronous uf call. 457 458 # Spin loading wizard: The spin loading. 459 self.app.gui.spin_viewer.wizard._go_next() 460 interpreter.flush() # Required because of the asynchronous uf call. 461 462 # Close the spin viewer window. 463 self.app.gui.spin_viewer.handler_close() 464 465 # Flush the interpreter in preparation for the synchronous user functions of the peak list wizard. 466 interpreter.flush() 467 468 # Test some of the sequence. 469 self.assertEqual(len(cdp.mol), 1) 470 self.assertEqual(cdp.mol[0].name, None) 471 self.assertEqual(len(cdp.mol[0].res), 3) 472 473 # 1st residue. 474 self.assertEqual(cdp.mol[0].res[0].num, 62) 475 self.assertEqual(cdp.mol[0].res[0].name, 'W') 476 self.assertEqual(len(cdp.mol[0].res[0].spin), 1) 477 self.assertEqual(cdp.mol[0].res[0].spin[0].num, None) 478 self.assertEqual(cdp.mol[0].res[0].spin[0].name, 'NE1') 479 480 # 2nd residue. 481 self.assertEqual(cdp.mol[0].res[1].num, 10) 482 self.assertEqual(cdp.mol[0].res[1].name, 'L') 483 self.assertEqual(len(cdp.mol[0].res[1].spin), 1) 484 self.assertEqual(cdp.mol[0].res[1].spin[0].num, None) 485 self.assertEqual(cdp.mol[0].res[1].spin[0].name, 'N') 486 487 # 3rd residue. 488 self.assertEqual(cdp.mol[0].res[2].num, 6) 489 self.assertEqual(cdp.mol[0].res[2].name, 'V') 490 self.assertEqual(len(cdp.mol[0].res[2].spin), 1) 491 self.assertEqual(cdp.mol[0].res[2].spin[0].num, None) 492 self.assertEqual(cdp.mol[0].res[2].spin[0].name, 'N')
493 494
495 - def test_tp02_data_to_tp02(self):
496 """Test the GUI analysis with the relaxation dispersion 'TP02' model fitting to the 'TP02' synthetic data.""" 497 498 # The paths to the data files. 499 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'r1rho_off_res_tp02'+sep 500 501 # Simulate the new analysis wizard, selecting the fixed time CPMG experiment. 502 self.app.gui.analysis.menu_new(None) 503 page = self.app.gui.analysis.new_wizard.wizard.get_page(0) 504 page.select_disp(None) 505 self.app.gui.analysis.new_wizard.wizard._go_next(None) 506 self.app.gui.analysis.new_wizard.wizard._go_next(None) 507 508 # Get the data. 509 analysis_type, analysis_name, pipe_name, pipe_bundle, uf_exec = self.app.gui.analysis.new_wizard.get_data() 510 511 # Set up the analysis. 512 self.app.gui.analysis.new_analysis(analysis_type=analysis_type, analysis_name=analysis_name, pipe_name=pipe_name, pipe_bundle=pipe_bundle, uf_exec=uf_exec) 513 514 # Alias the analysis. 515 analysis = self.app.gui.analysis.get_page_from_name("Relaxation dispersion") 516 517 # Change the results directory. 518 analysis.field_results_dir.SetValue(str_to_gui(ds.tmpdir)) 519 520 # Create the sequence data. 521 self._execute_uf(uf_name='spin.create', res_name='Trp', res_num=1, spin_name='N') 522 interpreter.flush() 523 self._execute_uf(uf_name='spin.create', res_name='Trp', res_num=2, spin_name='N') 524 interpreter.flush() 525 self._execute_uf(uf_name='sequence.display') 526 interpreter.flush() 527 528 # Set up the nuclear isotopes. 529 analysis.spin_isotope() 530 uf_store['spin.isotope'].page.SetValue('spin_id', '') 531 uf_store['spin.isotope'].wizard._go_next() 532 interpreter.flush() # Required because of the asynchronous uf call. 533 534 # Load the chemical shift data. 535 self._execute_uf(uf_name='chemical_shift.read', file='ref_500MHz.list', dir=data_path) 536 interpreter.flush() 537 538 # The spectral data. 539 frq = [500, 800] 540 frq_label = ['500MHz', '800MHz'] 541 error = 200000.0 542 data = [] 543 spin_lock = [None, 1000.0, 1500.0, 2000.0, 2500.0, 3000.0, 3500.0, 4000.0, 4500.0, 5000.0, 5500.0, 6000.0] 544 for frq_index in range(len(frq)): 545 for spin_lock_index in range(len(spin_lock)): 546 # The reference. 547 if spin_lock[spin_lock_index] == None: 548 id = 'ref_%s' % frq_label[frq_index] 549 file = "ref_%s.list" % frq_label[frq_index] 550 551 # Normal data. 552 else: 553 id = "nu_%s_%s" % (spin_lock[spin_lock_index], frq_label[frq_index]) 554 file = "nu_%s_%s.list" % (spin_lock[spin_lock_index], frq_label[frq_index]) 555 556 # Append the data. 557 data.append([id, file, spin_lock[spin_lock_index], frq[frq_index]]) 558 559 # Load the R1 data. 560 for frq_index in range(len(frq)): 561 label = 'R1_%s' % frq_label[frq_index] 562 self._execute_uf(uf_name='relax_data.read', ri_id=label, ri_type='R1', frq=frq[frq_index]*1e6, file='%s.out'%label, dir=data_path, mol_name_col=1, res_num_col=2, res_name_col=3, spin_num_col=4, spin_name_col=5, data_col=6, error_col=7) 563 interpreter.flush() 564 565 # Set up the peak intensity wizard. 566 analysis.peak_wizard_launch(None) 567 wizard = analysis.peak_wizard 568 569 # The spectra. 570 for id, file, field, H_frq in data: 571 wizard.setup_page(page='read', file=data_path+file, spectrum_id=id, int_method='height', dim=1) 572 wizard._apply(None) 573 wizard._skip(None) 574 575 # The error type. 576 page = wizard.get_page(wizard.page_indices['err_type']) 577 page.selection = 'rmsd' 578 wizard._go_next(None) 579 580 # Baseplane RMSD. 581 for id, file, field, H_frq in data: 582 wizard.setup_page(page='rmsd', spectrum_id=id, error=error) 583 wizard._apply(None) 584 wizard._skip(None) 585 586 # The experiment type. 587 for id, file, field, H_frq in data: 588 wizard.setup_page(page='exp_type', spectrum_id=id, exp_type='R1rho') 589 wizard._apply(None) 590 wizard._skip(None) 591 592 # Set the spectrometer frequency. 593 for id, file, field, H_frq in data: 594 wizard.setup_page(page='spectrometer_frequency', id=id, frq=H_frq, units='MHz') 595 wizard._apply(None) 596 wizard._skip(None) 597 598 # Set the relaxation times. 599 for id, file, field, H_frq in data: 600 wizard.setup_page(page='relax_time', spectrum_id=id, time=0.1) 601 wizard._apply(None) 602 wizard._skip(None) 603 604 # Set the relaxation dispersion spin-lock field strength (nu1). 605 for id, file, field, H_frq in data: 606 wizard.setup_page(page='spin_lock_field', spectrum_id=id, field=field) 607 wizard._apply(None) 608 wizard._skip(None) 609 610 # Set the spin-lock offset. 611 for id, file, field, H_frq in data: 612 wizard.setup_page(page='spin_lock_offset', spectrum_id=id, offset=110.0) 613 wizard._apply(None) 614 wizard._skip(None) 615 616 # Flush all wx events (to allow the spectrum list GUI element to populate all its rows). 617 wx.Yield() 618 619 # Simulate right clicking in the spectrum list element to test the popup menu. 620 analysis.peak_intensity.on_right_click(Fake_right_click()) 621 622 # Simulate the popup menu entries to catch bugs there (just apply the user functions with the currently set values). 623 # FIXME: skipping the checks for certain wxPython bugs. 624 if status.relax_mode != 'gui' and wx.version() != '2.9.4.1 gtk2 (classic)': 625 analysis.peak_intensity.action_relax_disp_spin_lock_field(item=4) 626 uf_store['relax_disp.spin_lock_field'].wizard._go_next() 627 interpreter.flush() 628 analysis.peak_intensity.action_relax_disp_exp_type(item=5) 629 uf_store['relax_disp.exp_type'].wizard._go_next() 630 interpreter.flush() 631 analysis.peak_intensity.action_relax_disp_relax_time(item=0) 632 uf_store['relax_disp.relax_time'].wizard._go_next() 633 interpreter.flush() 634 analysis.peak_intensity.action_spectrometer_frq(item=10) 635 uf_store['spectrometer.frequency'].wizard._go_next() 636 interpreter.flush() 637 638 # Deselect all but the 'TP02' model. 639 models = [MODEL_R2EFF, MODEL_NOREX, MODEL_TP02] 640 for i in range(len(analysis.model_field.models_stripped)): 641 if analysis.model_field.models_stripped[i] in models: 642 analysis.model_field.select[i] = True 643 else: 644 analysis.model_field.select[i] = False 645 analysis.model_field.modify() 646 647 # Set the grid search size and number of MC sims. 648 analysis.grid_inc.SetValue(4) 649 analysis.mc_sim_num.SetValue(3) 650 651 # Optimisation speedups. 652 analysis.opt_func_tol = 1e-10 653 analysis.opt_max_iterations = 10000 654 655 # Execute relax. 656 analysis.execute(wx.CommandEvent(wx.wxEVT_COMMAND_BUTTON_CLICKED, analysis.button_exec_relax.GetId())) 657 658 # Wait for execution to complete. 659 analysis.thread.join() 660 661 # Flush all wx events. 662 wx.Yield() 663 664 # Exceptions in the thread. 665 self.check_exceptions() 666 667 # Check the relax controller. 668 # FIXME: skipping the checks for certain wxPython bugs. 669 if status.relax_mode != 'gui' and wx.version() != '2.9.4.1 gtk2 (classic)': 670 self.assertEqual(self.app.gui.controller.mc_gauge_rx.GetValue(), 100) 671 self.assertEqual(self.app.gui.controller.main_gauge.GetValue(), 100) 672 673 # The original parameters. 674 r1rho_prime = [[10.0, 15.0], [12.0, 18.0]] 675 pA = 0.7654321 676 kex = 1234.56789 677 delta_omega = [7.0, 9.0] 678 679 # The R20 keys. 680 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_R1RHO, frq=500e6) 681 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_R1RHO, frq=800e6) 682 683 # Switch to the 'TP02' model data pipe, then check for each spin. 684 switch("%s - %s" % ('TP02', pipe_bundle)) 685 spin_index = 0 686 for spin, spin_id in spin_loop(return_id=True): 687 # Printout. 688 print("\nSpin %s." % spin_id) 689 690 # Check the fitted parameters. 691 self.assertAlmostEqual(spin.r2[r20_key1]/10, r1rho_prime[spin_index][0]/10, 4) 692 self.assertAlmostEqual(spin.r2[r20_key2]/10, r1rho_prime[spin_index][1]/10, 4) 693 self.assertAlmostEqual(spin.dw, delta_omega[spin_index], 3) 694 self.assertAlmostEqual(spin.kex/1000.0, kex/1000.0, 3) 695 696 # Increment the spin index. 697 spin_index += 1
698 699 700
701 -class Fake_right_click:
702 """Simulate a grid_cell_right_click event .""" 703
704 - def GetPosition(self):
705 """Overwrite the GetPosition() method.""" 706 707 # Return roughly the position of the forth row. 708 return wx.Point(10, 65)
709