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-2014 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_store import Relax_data_store; ds = Relax_data_store() 
 28  from gui.interpreter import Interpreter; interpreter = Interpreter() 
 29  from gui.string_conv import str_to_gui 
 30  from pipe_control.mol_res_spin import spin_loop 
 31  from pipe_control.pipes import cdp_name 
 32  from status import Status; status = Status() 
 33  from test_suite.gui_tests.base_classes import GuiTestCase 
 34   
 35   
36 -class Noe(GuiTestCase):
37 """Class for testing various aspects specific to the NOE analysis.""" 38
39 - def test_noe_analysis(self):
40 """Test the NOE analysis.""" 41 42 # Initialise all the special windows (to sometimes catch rare race conditions). 43 self.app.gui.show_prompt(None) 44 self.app.gui.show_tree(None) 45 self.app.gui.show_pipe_editor(None) 46 47 # Simulate the new analysis wizard. 48 self.app.gui.analysis.menu_new(None) 49 page = self.app.gui.analysis.new_wizard.wizard.get_page(0) 50 page.select_noe(None) 51 self.app.gui.analysis.new_wizard.wizard._go_next(None) 52 page = self.app.gui.analysis.new_wizard.wizard.get_page(1) 53 self.app.gui.analysis.new_wizard.wizard._go_next(None) 54 55 # Get the data. 56 analysis_type, analysis_name, pipe_name, pipe_bundle, uf_exec = self.app.gui.analysis.new_wizard.get_data() 57 58 # Set up the analysis. 59 self.app.gui.analysis.new_analysis(analysis_type=analysis_type, analysis_name=analysis_name, pipe_name=pipe_name, pipe_bundle=pipe_bundle) 60 61 # Alias the analysis. 62 analysis = self.app.gui.analysis.get_page_from_name("Steady-state NOE") 63 64 # The frequency label. 65 analysis.field_nmr_frq.SetValue(str_to_gui('500')) 66 67 # Change the results directory. 68 analysis.field_results_dir.SetValue(str_to_gui(ds.tmpdir)) 69 70 # Load the sequence. 71 file = status.install_path + sep + 'test_suite' + sep + 'shared_data' + sep + 'Ap4Aase.seq' 72 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) 73 74 # Unresolved spins. 75 self._execute_uf(uf_name='deselect.spin', spin_id=":3") 76 77 # Name the spins. 78 self._execute_uf(uf_name='spin.name', name="N") 79 80 # Create a Trp indole N spin. 81 self._execute_uf(uf_name='spin.create', res_num=40, spin_name="NE1") 82 83 # Flush the interpreter in preparation for the synchronous user functions of the peak list wizard. 84 interpreter.flush() 85 86 # The intensity data. 87 ids = ['ref', 'sat'] 88 files = [ 89 status.install_path + sep + 'test_suite' + sep + 'shared_data' + sep + 'peak_lists' + sep + 'ref_ave.list', 90 status.install_path + sep + 'test_suite' + sep + 'shared_data' + sep + 'peak_lists' + sep + 'sat_ave.list' 91 ] 92 errors = [3600, 3000] 93 errors_5 = [122000, 8500] 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_launch(None) 100 wizard = analysis.peak_wizard 101 102 # The spectrum. 103 wizard.setup_page(page='read', file=files[i], spectrum_id=ids[i]) 104 wizard._go_next(None) 105 106 # Move down one pages. 107 wizard._go_next(None) 108 109 # Set the errors. 110 wizard.setup_page(page='rmsd', error=errors[i]) 111 wizard._apply(None) 112 wizard.setup_page(page='rmsd', error=errors_5[i], spin_id=':5') 113 wizard._go_next(None) 114 115 # Set the type and finish. 116 wizard.setup_page(page='spectrum_type', spectrum_type=types[i]) 117 wizard._go_next(None) 118 119 # Execute relax. 120 analysis.execute(wx.CommandEvent(wx.wxEVT_COMMAND_BUTTON_CLICKED, analysis.button_exec_relax.GetId())) 121 122 # Wait for execution to complete. 123 analysis.thread.join() 124 125 # Flush all wx events. 126 wx.Yield() 127 128 # Exceptions in the thread. 129 self.check_exceptions() 130 131 # Check the relax controller. 132 # FIXME: skipping the checks for certain wxPython bugs. 133 if status.relax_mode != 'gui' and wx.version() != '2.9.4.1 gtk2 (classic)': 134 self.assertEqual(self.app.gui.controller.main_gauge.GetValue(), 100) 135 136 # The real data. 137 res_nums = [4, 5, 6, 40, 40, 55] 138 sat = [5050.0, 51643.0, 53663.0, -65111.0, -181131.0, -105322.0] 139 ref = [148614.0, 166842.0, 128690.0, 99566.0, 270047.0, 130959.0] 140 noe = [0.033980647852826784, 0.30953237194471417, 0.4169943274535706, -0.6539481349054899, -0.6707387973204665, -0.8042364404126482] 141 noe_err = [0.02020329903276632, 0.2320024671657343, 0.026067523940084526, 0.038300618865378507, 0.014260663438353431, 0.03183614777183591] 142 143 # Check the data pipe. 144 self.assertEqual(cdp_name(), ds.relax_gui.analyses[0].pipe_name) 145 146 # Check the data. 147 i = 0 148 for spin_cont, mol_name, res_num, res_name in spin_loop(full_info=True): 149 # Skip deselected spins. 150 if not spin_cont.select: 151 continue 152 153 # Spin info. 154 self.assertEqual(res_nums[i], res_num) 155 156 # Check the intensity data. 157 self.assertEqual(sat[i], spin_cont.peak_intensity['sat']) 158 self.assertEqual(ref[i], spin_cont.peak_intensity['ref']) 159 160 # Check the NOE data. 161 self.assertEqual(noe[i], spin_cont.noe) 162 self.assertAlmostEqual(noe_err[i], spin_cont.noe_err) 163 164 # Increment the spin index. 165 i += 1 166 167 # Check the created files. 168 self.assert_(access(ds.tmpdir+sep+'grace'+sep+'noe.agr', F_OK))
169