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

Source Code for Module test_suite.gui_tests.noe

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2006-2012 Edward d'Auvergne                                   # 
  4  #                                                                             # 
  5  # This file is part of the program relax.                                     # 
  6  #                                                                             # 
  7  # relax is free software; you can redistribute it and/or modify               # 
  8  # it under the terms of the GNU General Public License as published by        # 
  9  # the Free Software Foundation; either version 2 of the License, or           # 
 10  # (at your option) any later version.                                         # 
 11  #                                                                             # 
 12  # relax is distributed in the hope that it will be useful,                    # 
 13  # but WITHOUT ANY WARRANTY; without even the implied warranty of              # 
 14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               # 
 15  # GNU General Public License for more details.                                # 
 16  #                                                                             # 
 17  # You should have received a copy of the GNU General Public License           # 
 18  # along with relax; if not, write to the Free Software                        # 
 19  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   # 
 20  #                                                                             # 
 21  ############################################################################### 
 22   
 23  # Python module imports. 
 24  from os import F_OK, access, sep 
 25  import wx 
 26   
 27  # relax module imports. 
 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  # relax GUI imports. 
 35  from gui.interpreter import Interpreter; interpreter = Interpreter() 
 36  from gui.misc import int_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 Noe(GuiTestCase):
42 """Class for testing various aspects specific to the NOE analysis.""" 43
44 - def test_noe_analysis(self):
45 """Test the NOE analysis.""" 46 47 # Initialise all the special windows (to sometimes catch rare race conditions). 48 self.app.gui.show_prompt(None) 49 self.app.gui.show_tree(None) 50 self.app.gui.show_pipe_editor(None) 51 52 # Simulate the new analysis wizard. 53 self.app.gui.analysis.menu_new(None) 54 page = self.app.gui.analysis.new_wizard.wizard.get_page(0) 55 page.select_noe(None) 56 self.app.gui.analysis.new_wizard.wizard._go_next(None) 57 page = self.app.gui.analysis.new_wizard.wizard.get_page(1) 58 self.app.gui.analysis.new_wizard.wizard._go_next(None) 59 60 # Get the data. 61 analysis_type, analysis_name, pipe_name = self.app.gui.analysis.new_wizard.get_data() 62 63 # Set up the analysis. 64 self.app.gui.analysis.new_analysis(analysis_type=analysis_type, analysis_name=analysis_name, pipe_name=pipe_name) 65 66 # Alias the analysis. 67 analysis = self.app.gui.analysis.get_page_from_name("Steady-state NOE") 68 69 # The frequency label. 70 analysis.field_nmr_frq.SetValue(str_to_gui('500')) 71 72 # Change the results directory. 73 analysis.field_results_dir.SetValue(str_to_gui(ds.tmpdir)) 74 75 # Load the sequence. 76 wizard = Wiz_window(self.app.gui) 77 seq_read = sequence.Read_page(wizard) 78 file = status.install_path + sep + 'test_suite' + sep + 'shared_data' + sep + 'Ap4Aase.seq' 79 seq_read.file.SetValue(str_to_gui(file)) 80 seq_read.mol_name_col.SetValue(int_to_gui(None)) 81 seq_read.res_name_col.SetValue(int_to_gui(2)) 82 seq_read.res_num_col.SetValue(int_to_gui(1)) 83 seq_read.spin_name_col.SetValue(int_to_gui(None)) 84 seq_read.spin_num_col.SetValue(int_to_gui(None)) 85 seq_read.on_execute() 86 87 # Unresolved spins. 88 deselect_spin = deselect.Spin_page(wizard) 89 deselect_spin.spin_id.SetValue(str_to_gui(":3")) 90 deselect_spin.on_execute() 91 92 # Name the spins. 93 page = spin.Name_page(wizard) 94 page.name.SetValue(str_to_gui('N')) 95 page.on_execute() 96 97 # Flush the interpreter in preparation for the synchronous user functions of the peak list wizard. 98 interpreter.flush() 99 100 # The intensity data. 101 ids = ['ref', 'sat'] 102 files = [ 103 status.install_path + sep + 'test_suite' + sep + 'shared_data' + sep + 'peak_lists' + sep + 'ref_ave.list', 104 status.install_path + sep + 'test_suite' + sep + 'shared_data' + sep + 'peak_lists' + sep + 'sat_ave.list' 105 ] 106 errors = [3600, 3000] 107 types = [1, 0] 108 109 # Loop over the 2 spectra. 110 for i in range(2): 111 # Set up the peak intensity wizard. 112 analysis.peak_wizard(None) 113 114 # The spectrum. 115 page = analysis.wizard.get_page(analysis.page_indices['read']) 116 page.file.SetValue(str_to_gui(files[i])) 117 page.spectrum_id.SetValue(str_to_gui(ids[i])) 118 page.proton.SetValue(str_to_gui('HN')) 119 120 # Move down 2 pages. 121 analysis.wizard._go_next(None) 122 analysis.wizard._go_next(None) 123 124 # Set the errors. 125 page = analysis.wizard.get_page(analysis.page_indices['rmsd']) 126 page.error.SetValue(int_to_gui(errors[i])) 127 128 # Go to the next page. 129 analysis.wizard._go_next(None) 130 131 # Set the type. 132 page = analysis.wizard.get_page(analysis.page_indices['spectrum_type']) 133 page.spectrum_type.SetSelection(types[i]) 134 135 # Go to the next page (i.e. finish). 136 analysis.wizard._go_next(None) 137 138 # Execute relax. 139 analysis.execute(wx.CommandEvent(wx.wxEVT_COMMAND_BUTTON_CLICKED, analysis.button_exec_relax.GetId())) 140 141 # Wait for execution to complete. 142 analysis.thread.join() 143 144 # Flush all wx events. 145 wx.Yield() 146 147 # Exceptions in the thread. 148 self.check_exceptions() 149 150 # Check the relax controller. 151 if status.relax_mode != 'gui': 152 self.assertEqual(self.app.gui.controller.main_gauge.GetValue(), 100) 153 154 # The real data. 155 res_nums = [4, 5, 6] 156 sat = [5050.0, 51643.0, 53663.0] 157 ref = [148614.0, 166842.0, 128690.0] 158 noe = [0.033980647852826784, 0.30953237194471417, 0.4169943274535706] 159 noe_err = [0.02020329903276632, 0.019181416098790607, 0.026067523940084526] 160 161 # Check the data pipe. 162 self.assertEqual(cdp_name(), ds.relax_gui.analyses[0].pipe_name) 163 164 # Check the data. 165 i = 0 166 for spin_cont, mol_name, res_num, res_name in spin_loop(full_info=True): 167 # Skip deselected spins. 168 if not spin_cont.select: 169 continue 170 171 # Spin info. 172 self.assertEqual(res_nums[i], res_num) 173 174 # Check the intensity data. 175 self.assertEqual(sat[i], spin_cont.intensities['sat']) 176 self.assertEqual(ref[i], spin_cont.intensities['ref']) 177 178 # Check the NOE data. 179 self.assertEqual(noe[i], spin_cont.noe) 180 self.assertEqual(noe_err[i], spin_cont.noe_err) 181 182 # Increment the spin index. 183 i += 1 184 185 # Check the created files. 186 self.assert_(access(ds.tmpdir+sep+'grace'+sep+'noe.agr', F_OK))
187