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.string_conv import int_to_gui, str_to_gui 
 37  from gui.wizard import Wiz_window 
 38   
 39   
40 -class Noe(GuiTestCase):
41 """Class for testing various aspects specific to the NOE analysis.""" 42
43 - def test_noe_analysis(self):
44 """Test the NOE analysis.""" 45 46 # Initialise all the special windows (to sometimes catch rare race conditions). 47 self.app.gui.show_prompt(None) 48 self.app.gui.show_tree(None) 49 self.app.gui.show_pipe_editor(None) 50 51 # Simulate the new analysis wizard. 52 self.app.gui.analysis.menu_new(None) 53 page = self.app.gui.analysis.new_wizard.wizard.get_page(0) 54 page.select_noe(None) 55 self.app.gui.analysis.new_wizard.wizard._go_next(None) 56 page = self.app.gui.analysis.new_wizard.wizard.get_page(1) 57 self.app.gui.analysis.new_wizard.wizard._go_next(None) 58 59 # Get the data. 60 analysis_type, analysis_name, pipe_name, pipe_bundle = self.app.gui.analysis.new_wizard.get_data() 61 62 # Set up the analysis. 63 self.app.gui.analysis.new_analysis(analysis_type=analysis_type, analysis_name=analysis_name, pipe_name=pipe_name, pipe_bundle=pipe_bundle) 64 65 # Alias the analysis. 66 analysis = self.app.gui.analysis.get_page_from_name("Steady-state NOE") 67 68 # The frequency label. 69 analysis.field_nmr_frq.SetValue(str_to_gui('500')) 70 71 # Change the results directory. 72 analysis.field_results_dir.SetValue(str_to_gui(ds.tmpdir)) 73 74 # Load the sequence. 75 file = status.install_path + sep + 'test_suite' + sep + 'shared_data' + sep + 'Ap4Aase.seq' 76 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) 77 78 # Unresolved spins. 79 self._execute_uf(uf_name='deselect.spin', spin_id=":3") 80 81 # Name the spins. 82 self._execute_uf(uf_name='spin.name', name="N") 83 84 # Flush the interpreter in preparation for the synchronous user functions of the peak list wizard. 85 interpreter.flush() 86 87 # The intensity data. 88 ids = ['ref', 'sat'] 89 files = [ 90 status.install_path + sep + 'test_suite' + sep + 'shared_data' + sep + 'peak_lists' + sep + 'ref_ave.list', 91 status.install_path + sep + 'test_suite' + sep + 'shared_data' + sep + 'peak_lists' + sep + 'sat_ave.list' 92 ] 93 errors = [3600, 3000] 94 types = ['ref', 'sat'] 95 96 # Loop over the 2 spectra. 97 for i in range(2): 98 # Set up the peak intensity wizard. 99 analysis.peak_wizard(None) 100 101 # The spectrum. 102 page = analysis.wizard.get_page(analysis.page_indices['read']) 103 page.uf_args['file'].SetValue(str_to_gui(files[i])) 104 page.uf_args['spectrum_id'].SetValue(str_to_gui(ids[i])) 105 page.uf_args['proton'].SetValue(str_to_gui('HN')) 106 107 # Move down 2 pages. 108 analysis.wizard._go_next(None) 109 analysis.wizard._go_next(None) 110 111 # Set the errors. 112 page = analysis.wizard.get_page(analysis.page_indices['rmsd']) 113 page.uf_args['error'].SetValue(int_to_gui(errors[i])) 114 115 # Go to the next page. 116 analysis.wizard._go_next(None) 117 118 # Set the type. 119 page = analysis.wizard.get_page(analysis.page_indices['spectrum_type']) 120 page.uf_args['spectrum_type'].SetValue(types[i]) 121 122 # Go to the next page (i.e. finish). 123 analysis.wizard._go_next(None) 124 125 # Execute relax. 126 analysis.execute(wx.CommandEvent(wx.wxEVT_COMMAND_BUTTON_CLICKED, analysis.button_exec_relax.GetId())) 127 128 # Wait for execution to complete. 129 analysis.thread.join() 130 131 # Flush all wx events. 132 wx.Yield() 133 134 # Exceptions in the thread. 135 self.check_exceptions() 136 137 # Check the relax controller. 138 if status.relax_mode != 'gui': 139 self.assertEqual(self.app.gui.controller.main_gauge.GetValue(), 100) 140 141 # The real data. 142 res_nums = [4, 5, 6] 143 sat = [5050.0, 51643.0, 53663.0] 144 ref = [148614.0, 166842.0, 128690.0] 145 noe = [0.033980647852826784, 0.30953237194471417, 0.4169943274535706] 146 noe_err = [0.02020329903276632, 0.019181416098790607, 0.026067523940084526] 147 148 # Check the data pipe. 149 self.assertEqual(cdp_name(), ds.relax_gui.analyses[0].pipe_name) 150 151 # Check the data. 152 i = 0 153 for spin_cont, mol_name, res_num, res_name in spin_loop(full_info=True): 154 # Skip deselected spins. 155 if not spin_cont.select: 156 continue 157 158 # Spin info. 159 self.assertEqual(res_nums[i], res_num) 160 161 # Check the intensity data. 162 self.assertEqual(sat[i], spin_cont.intensities['sat']) 163 self.assertEqual(ref[i], spin_cont.intensities['ref']) 164 165 # Check the NOE data. 166 self.assertEqual(noe[i], spin_cont.noe) 167 self.assertEqual(noe_err[i], spin_cont.noe_err) 168 169 # Increment the spin index. 170 i += 1 171 172 # Check the created files. 173 self.assert_(access(ds.tmpdir+sep+'grace'+sep+'noe.agr', F_OK))
174