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-2013 Edward d'Auvergne                                   # 
  4  #                                                                             # 
  5  # This file is part of the program relax (http://www.nmr-relax.com).          # 
  6  #                                                                             # 
  7  # This program 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 3 of the License, or           # 
 10  # (at your option) any later version.                                         # 
 11  #                                                                             # 
 12  # This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.       # 
 19  #                                                                             # 
 20  ############################################################################### 
 21   
 22  # Python module imports. 
 23  from os import F_OK, access, sep 
 24  import wx 
 25   
 26  # relax module imports. 
 27  from data import Relax_data_store; ds = Relax_data_store() 
 28  from generic_fns.mol_res_spin import spin_loop 
 29  from generic_fns.pipes import cdp_name 
 30  from status import Status; status = Status() 
 31  from test_suite.gui_tests.base_classes import GuiTestCase 
 32   
 33  # relax GUI imports. 
 34  from gui.interpreter import Interpreter; interpreter = Interpreter() 
 35  from gui.string_conv import int_to_gui, str_to_gui 
 36  from gui.wizard import Wiz_window 
 37   
 38   
39 -class Noe(GuiTestCase):
40 """Class for testing various aspects specific to the NOE analysis.""" 41
42 - def test_noe_analysis(self):
43 """Test the NOE analysis.""" 44 45 # Initialise all the special windows (to sometimes catch rare race conditions). 46 self.app.gui.show_prompt(None) 47 self.app.gui.show_tree(None) 48 self.app.gui.show_pipe_editor(None) 49 50 # Simulate the new analysis wizard. 51 self.app.gui.analysis.menu_new(None) 52 page = self.app.gui.analysis.new_wizard.wizard.get_page(0) 53 page.select_noe(None) 54 self.app.gui.analysis.new_wizard.wizard._go_next(None) 55 page = self.app.gui.analysis.new_wizard.wizard.get_page(1) 56 self.app.gui.analysis.new_wizard.wizard._go_next(None) 57 58 # Get the data. 59 analysis_type, analysis_name, pipe_name, pipe_bundle = self.app.gui.analysis.new_wizard.get_data() 60 61 # Set up the analysis. 62 self.app.gui.analysis.new_analysis(analysis_type=analysis_type, analysis_name=analysis_name, pipe_name=pipe_name, pipe_bundle=pipe_bundle) 63 64 # Alias the analysis. 65 analysis = self.app.gui.analysis.get_page_from_name("Steady-state NOE") 66 67 # The frequency label. 68 analysis.field_nmr_frq.SetValue(str_to_gui('500')) 69 70 # Change the results directory. 71 analysis.field_results_dir.SetValue(str_to_gui(ds.tmpdir)) 72 73 # Load the sequence. 74 file = status.install_path + sep + 'test_suite' + sep + 'shared_data' + sep + 'Ap4Aase.seq' 75 self._execute_uf(uf_name='sequence.read', file=file, mol_name_col=None, res_name_col=2, res_num_col=1, spin_name_col=None, spin_num_col=None) 76 77 # Unresolved spins. 78 self._execute_uf(uf_name='deselect.spin', spin_id=":3") 79 80 # Name the spins. 81 self._execute_uf(uf_name='spin.name', name="N") 82 83 # Create a Trp indole N spin. 84 self._execute_uf(uf_name='spin.create', res_num=40, spin_name="NE1") 85 86 # Flush the interpreter in preparation for the synchronous user functions of the peak list wizard. 87 interpreter.flush() 88 89 # The intensity data. 90 ids = ['ref', 'sat'] 91 files = [ 92 status.install_path + sep + 'test_suite' + sep + 'shared_data' + sep + 'peak_lists' + sep + 'ref_ave.list', 93 status.install_path + sep + 'test_suite' + sep + 'shared_data' + sep + 'peak_lists' + sep + 'sat_ave.list' 94 ] 95 errors = [3600, 3000] 96 errors_5 = [122000, 8500] 97 types = ['ref', 'sat'] 98 99 # Loop over the 2 spectra. 100 for i in range(2): 101 # Set up the peak intensity wizard. 102 analysis.peak_wizard(None) 103 104 # The spectrum. 105 page = analysis.wizard.get_page(analysis.page_indices['read']) 106 page.uf_args['file'].SetValue(str_to_gui(files[i])) 107 page.uf_args['spectrum_id'].SetValue(str_to_gui(ids[i])) 108 page.uf_args['proton'].SetValue(str_to_gui('HN')) 109 110 # Apply to load the backbone NH, then set up for the Trp indoles. 111 analysis.wizard._apply(None) 112 interpreter.flush() 113 page.uf_args['heteronuc'].SetValue(str_to_gui('NE1')) 114 page.uf_args['proton'].SetValue(str_to_gui('HE1')) 115 116 # Move down 2 pages. 117 analysis.wizard._go_next(None) 118 analysis.wizard._go_next(None) 119 120 # Set the errors. 121 page = analysis.wizard.get_page(analysis.page_indices['rmsd']) 122 page.uf_args['error'].SetValue(int_to_gui(errors[i])) 123 124 # Apply, then set the individual spin errors. 125 analysis.wizard._apply(None) 126 interpreter.flush() 127 page.uf_args['error'].SetValue(int_to_gui(errors_5[i])) 128 page.uf_args['spin_id'].SetValue(str_to_gui(':5')) 129 130 # Go to the next page. 131 analysis.wizard._go_next(None) 132 133 # Set the type. 134 page = analysis.wizard.get_page(analysis.page_indices['spectrum_type']) 135 page.uf_args['spectrum_type'].SetValue(types[i]) 136 137 # Go to the next page (i.e. finish). 138 analysis.wizard._go_next(None) 139 140 # Execute relax. 141 analysis.execute(wx.CommandEvent(wx.wxEVT_COMMAND_BUTTON_CLICKED, analysis.button_exec_relax.GetId())) 142 143 # Wait for execution to complete. 144 analysis.thread.join() 145 146 # Flush all wx events. 147 wx.Yield() 148 149 # Exceptions in the thread. 150 self.check_exceptions() 151 152 # Check the relax controller. 153 # FIXME: skipping the checks for certain wxPython bugs. 154 if status.relax_mode != 'gui' and wx.version() != '2.9.4.1 gtk2 (classic)': 155 self.assertEqual(self.app.gui.controller.main_gauge.GetValue(), 100) 156 157 # The real data. 158 res_nums = [4, 5, 6, 40, 40, 55] 159 sat = [5050.0, 51643.0, 53663.0, -65111.0, -181131.0, -105322.0] 160 ref = [148614.0, 166842.0, 128690.0, 99566.0, 270047.0, 130959.0] 161 noe = [0.033980647852826784, 0.30953237194471417, 0.4169943274535706, -0.6539481349054899, -0.6707387973204665, -0.8042364404126482] 162 noe_err = [0.02020329903276632, 0.2320024671657343, 0.026067523940084526, 0.038300618865378507, 0.014260663438353431, 0.03183614777183591] 163 164 # Check the data pipe. 165 self.assertEqual(cdp_name(), ds.relax_gui.analyses[0].pipe_name) 166 167 # Check the data. 168 i = 0 169 for spin_cont, mol_name, res_num, res_name in spin_loop(full_info=True): 170 # Skip deselected spins. 171 if not spin_cont.select: 172 continue 173 174 # Spin info. 175 self.assertEqual(res_nums[i], res_num) 176 177 # Check the intensity data. 178 self.assertEqual(sat[i], spin_cont.intensities['sat']) 179 self.assertEqual(ref[i], spin_cont.intensities['ref']) 180 181 # Check the NOE data. 182 self.assertEqual(noe[i], spin_cont.noe) 183 self.assertAlmostEqual(noe_err[i], spin_cont.noe_err) 184 185 # Increment the spin index. 186 i += 1 187 188 # Check the created files. 189 self.assert_(access(ds.tmpdir+sep+'grace'+sep+'noe.agr', F_OK))
190