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-2008,2011-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 __init__(self, methodName=None):
40 """Set up the test case class for the system tests.""" 41 42 # Execute the base __init__ methods. 43 super(Noe, self).__init__(methodName) 44 45 # Tests to skip. 46 blacklist = [ 47 'test_noe_analysis_memory_leaks' 48 ] 49 50 # Skip the blacklisted tests. 51 if methodName in blacklist: 52 status.skipped_tests.append([methodName, None, self._skip_type])
53 54
55 - def test_noe_analysis(self):
56 """Test the NOE analysis.""" 57 58 # Initialise all the special windows (to sometimes catch rare race conditions). 59 self.app.gui.show_prompt(None) 60 self.app.gui.show_tree(None) 61 self.app.gui.show_pipe_editor(None) 62 63 # Simulate the new analysis wizard. 64 analysis = self.new_analysis_wizard(analysis_type='noe') 65 66 # The frequency label. 67 analysis.field_nmr_frq.SetValue(str_to_gui('500')) 68 69 # Change the results directory. 70 analysis.field_results_dir.SetValue(str_to_gui(ds.tmpdir)) 71 72 # Load the sequence. 73 file = status.install_path + sep + 'test_suite' + sep + 'shared_data' + sep + 'Ap4Aase.seq' 74 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) 75 76 # Unresolved spins. 77 self._execute_uf(uf_name='deselect.spin', spin_id=":3") 78 79 # Name the spins. 80 self._execute_uf(uf_name='spin.name', name="N") 81 82 # Create a Trp indole N spin. 83 self._execute_uf(uf_name='spin.create', res_num=40, spin_name="NE1") 84 85 # Flush the interpreter in preparation for the synchronous user functions of the peak list wizard. 86 interpreter.flush() 87 88 # The intensity data. 89 ids = ['ref', 'sat'] 90 files = [ 91 status.install_path + sep + 'test_suite' + sep + 'shared_data' + sep + 'peak_lists' + sep + 'ref_ave.list', 92 status.install_path + sep + 'test_suite' + sep + 'shared_data' + sep + 'peak_lists' + sep + 'sat_ave.list' 93 ] 94 errors = [3600, 3000] 95 errors_5 = [122000, 8500] 96 types = ['ref', 'sat'] 97 98 # Loop over the 2 spectra. 99 for i in range(2): 100 # Set up the peak intensity wizard. 101 analysis.peak_wizard_launch(None) 102 wizard = analysis.peak_wizard 103 104 # The spectrum. 105 wizard.setup_page(page='read', file=files[i], spectrum_id=ids[i]) 106 wizard._go_next(None) 107 108 # Move down one pages. 109 wizard._go_next(None) 110 111 # Set the errors. 112 wizard.setup_page(page='rmsd', error=errors[i]) 113 wizard._apply(None) 114 wizard.setup_page(page='rmsd', error=errors_5[i], spin_id=':5') 115 wizard._go_next(None) 116 117 # Set the type and finish. 118 wizard.setup_page(page='spectrum_type', spectrum_type=types[i]) 119 wizard._go_next(None) 120 121 # Execute relax. 122 analysis.execute(wx.CommandEvent(wx.wxEVT_COMMAND_BUTTON_CLICKED, analysis.button_exec_relax.GetId())) 123 124 # Wait for execution to complete. 125 analysis.thread.join() 126 127 # Flush all wx events. 128 wx.Yield() 129 130 # Exceptions in the thread. 131 self.check_exceptions() 132 133 # Check the relax controller. 134 # FIXME: skipping the checks for certain wxPython bugs. 135 if status.relax_mode != 'gui' and wx.version() != '2.9.4.1 gtk2 (classic)': 136 self.assertEqual(self.app.gui.controller.main_gauge.GetValue(), 100) 137 138 # The real data. 139 res_nums = [4, 5, 6, 40, 40, 55] 140 sat = [5050.0, 51643.0, 53663.0, -65111.0, -181131.0, -105322.0] 141 ref = [148614.0, 166842.0, 128690.0, 99566.0, 270047.0, 130959.0] 142 noe = [0.033980647852826784, 0.30953237194471417, 0.4169943274535706, -0.6539481349054899, -0.6707387973204665, -0.8042364404126482] 143 noe_err = [0.02020329903276632, 0.2320024671657343, 0.026067523940084526, 0.038300618865378507, 0.014260663438353431, 0.03183614777183591] 144 145 # Check the data pipe. 146 self.assertEqual(cdp_name(), ds.relax_gui.analyses[0].pipe_name) 147 148 # Check the data. 149 i = 0 150 for spin_cont, mol_name, res_num, res_name in spin_loop(full_info=True): 151 # Skip deselected spins. 152 if not spin_cont.select: 153 continue 154 155 # Spin info. 156 self.assertEqual(res_nums[i], res_num) 157 158 # Check the intensity data. 159 self.assertEqual(sat[i], spin_cont.peak_intensity['sat']) 160 self.assertEqual(ref[i], spin_cont.peak_intensity['ref']) 161 162 # Check the NOE data. 163 self.assertEqual(noe[i], spin_cont.noe) 164 self.assertAlmostEqual(noe_err[i], spin_cont.noe_err) 165 166 # Increment the spin index. 167 i += 1 168 169 # Check the created files. 170 self.assert_(access(ds.tmpdir+sep+'grace'+sep+'noe.agr', F_OK))
171 172
174 """Test for memory leaks in the NOE analysis. 175 176 This can be monitored using the MS Windows task manager, once the 'USER Objects' column is shown. 177 """ 178 179 # A large loop (to try to reach the USER Object limit in MS Windows). 180 for i in range(1000): 181 # Printout for debugging. 182 print("\n\n\nCreating the analysis number %i." % (i+1)) 183 184 # Simulate the new analysis wizard. 185 analysis = self.new_analysis_wizard(analysis_type='noe') 186 187 # Close the analysis. 188 self.app.gui.analysis.delete_analysis(0) 189 190 # Printout for debugging. 191 print("\n\nClosing the analysis number %i.\n\n\n" % (i+1))
192