1   
  2   
  3   
  4   
  5   
  6   
  7   
  8   
  9   
 10   
 11   
 12   
 13   
 14   
 15   
 16   
 17   
 18   
 19   
 20   
 21   
 22   
 23  from os import F_OK, access, sep 
 24  import wx 
 25   
 26   
 27  from data_store import Relax_data_store; ds = Relax_data_store() 
 28  import dep_check 
 29  from gui.interpreter import Interpreter; interpreter = Interpreter() 
 30  from gui.string_conv import float_to_gui, float_to_gui, str_to_gui 
 31  from gui.uf_objects import Uf_storage; uf_store = Uf_storage() 
 32  from pipe_control.mol_res_spin import spin_loop 
 33  from pipe_control.pipes import cdp_name 
 34  from status import Status; status = Status() 
 35  from test_suite.gui_tests.base_classes import GuiTestCase 
 36   
 37   
 38 -class Rx(GuiTestCase): 
  39      """Class for testing various aspects specific to the R1 and R2 analyses.""" 
 40   
 41 -    def __init__(self, methodName='runTest'): 
  42          """Skip the tests if the C modules are non-functional or for wxPython bugs. 
 43   
 44          @keyword methodName:    The name of the test. 
 45          @type methodName:       str 
 46          """ 
 47   
 48           
 49          super(Rx, self).__init__(methodName) 
 50   
 51           
 52          if not dep_check.C_module_exp_fn: 
 53               
 54              status.skipped_tests.append([methodName, 'Relax curve-fitting C module', self._skip_type]) 
  55   
 56   
 58          """Check the results of the curve-fitting.""" 
 59   
 60           
 61          relax_times = [0.0176, 0.0176, 0.0352, 0.0704, 0.0704, 0.1056, 0.1584, 0.1584, 0.1936, 0.1936] 
 62          chi2 = [None, None, None, 2.916952651567855, 5.4916923952919632, 16.21182245065274, 4.3591263759462926, 9.8925377583244316, None, None, None, 6.0238341559877782] 
 63          rx = [None, None, None, 8.0814894819820662, 8.6478971039559642, 9.5710638183013845, 10.716551838066295, 11.143793935455122, None, None, None, 12.82875370075309] 
 64          i0 = [None, None, None, 1996050.9679875025, 2068490.9458927638, 1611556.5194095275, 1362887.2331948928, 1877670.5623875158, None, None, None, 897044.17382064369] 
 65   
 66           
 67          self.assertEqual(cdp.curve_type, 'exp') 
 68          self.assertEqual(cdp.int_method, 'height') 
 69          self.assertEqual(len(cdp.relax_times), 10) 
 70          cdp_relax_times = sorted(cdp.relax_times.values()) 
 71          for i in range(10): 
 72              self.assertEqual(cdp_relax_times[i], relax_times[i]) 
 73   
 74           
 75          for key in cdp.sigma_I: 
 76              self.assertEqual(cdp.sigma_I[key], 10578.039482421433) 
 77              self.assertEqual(cdp.var_I[key], 111894919.29166669) 
 78   
 79           
 80          i = 0 
 81          for spin in spin_loop(): 
 82               
 83              if chi2[i] == None: 
 84                  self.assert_(not hasattr(spin, 'chi2')) 
 85   
 86               
 87              else: 
 88                  self.assertAlmostEqual(spin.chi2, chi2[i]) 
 89                  self.assertAlmostEqual(spin.rx, rx[i]) 
 90                  self.assertAlmostEqual(spin.i0/1e6, i0[i]/1e6) 
 91   
 92               
 93              i = i + 1 
 94              if i >= 12: 
 95                  break 
  96   
 97   
 99          """Test the r1 analysis.""" 
100   
101           
102          data_path = status.install_path + sep + 'test_suite' + sep + 'shared_data' + sep + 'curve_fitting' + sep 
103   
104           
105          analysis = self.new_analysis_wizard(analysis_type='r1') 
106   
107           
108          analysis.field_nmr_frq.SetValue(str_to_gui('600')) 
109   
110           
111          analysis.field_results_dir.SetValue(str_to_gui(ds.tmpdir)) 
112   
113           
114          file = status.install_path + sep + 'test_suite' + sep + 'shared_data' + sep + 'Ap4Aase.seq' 
115          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) 
116   
117           
118          self._execute_uf(uf_name='deselect.read', file=data_path+'unresolved', mol_name_col=None, res_name_col=None, res_num_col=1, spin_name_col=None, spin_num_col=None, change_all=True) 
119   
120           
121          self._execute_uf(uf_name='spin.name', name='N') 
122   
123           
124          interpreter.flush() 
125   
126           
127          names = [ 
128              'T2_ncyc1_ave', 
129              'T2_ncyc1b_ave', 
130              'T2_ncyc2_ave', 
131              'T2_ncyc4_ave', 
132              'T2_ncyc4b_ave', 
133              'T2_ncyc6_ave', 
134              'T2_ncyc9_ave', 
135              'T2_ncyc9b_ave', 
136              'T2_ncyc11_ave', 
137              'T2_ncyc11b_ave' 
138          ] 
139   
140           
141          replicated = { 
142              'T2_ncyc1b_ave': 'T2_ncyc1_ave', 
143              'T2_ncyc4b_ave': 'T2_ncyc4_ave', 
144              'T2_ncyc9b_ave': 'T2_ncyc9_ave', 
145              'T2_ncyc11b_ave': 'T2_ncyc11_ave' 
146          } 
147   
148           
149          ncyc = [1, 
150                  1, 
151                  2, 
152                  4, 
153                  4, 
154                  6, 
155                  9, 
156                  9, 
157                  11, 
158                  11 
159          ] 
160   
161           
162          time = 0.0176 
163   
164           
165          for i in range(len(names)): 
166               
167              analysis.peak_wizard_launch(None) 
168              wizard = analysis.peak_wizard 
169   
170               
171              page = wizard.get_page(wizard.page_indices['read']) 
172              page.uf_args['file'].SetValue(str_to_gui("%s%s.list" % (data_path, names[i]))) 
173              page.uf_args['spectrum_id'].SetValue(str_to_gui(names[i])) 
174   
175               
176              wizard._go_next(None) 
177   
178               
179              page = wizard.get_page(wizard.page_indices['err_type']) 
180              page.selection = 'repl' 
181   
182               
183              wizard._go_next(None) 
184   
185               
186              if names[i] in replicated: 
187                  page = wizard.get_page(wizard.page_indices['repl']) 
188                  page.uf_args['spectrum_ids'].SetValue(value=replicated[names[i]], index=1) 
189   
190               
191              wizard._go_next(None) 
192   
193               
194              page = wizard.get_page(wizard.page_indices['relax_time']) 
195              page.uf_args['time'].SetValue(float_to_gui(ncyc[i]*time)) 
196   
197               
198              wizard._go_next(None) 
199   
200           
201          analysis.select_model() 
202          uf_store['relax_fit.select_model'].wizard._go_next() 
203          interpreter.flush()     
204   
205           
206          analysis.mc_sim_num.SetValue(3) 
207   
208           
209          analysis.execute(wx.CommandEvent(wx.wxEVT_COMMAND_BUTTON_CLICKED, analysis.button_exec_relax.GetId())) 
210   
211           
212          analysis.thread.join() 
213   
214           
215          wx.Yield() 
216   
217           
218          self.check_exceptions() 
219   
220           
221           
222          if status.relax_mode != 'gui' and wx.version() != '2.9.4.1 gtk2 (classic)': 
223              self.assertEqual(self.app.gui.controller.mc_gauge_rx.GetValue(), 100) 
224              self.assertEqual(self.app.gui.controller.main_gauge.GetValue(), 100) 
225   
226           
227          self.assertEqual(cdp_name(), ds.relax_gui.analyses[0].pipe_name) 
228   
229           
230          self.check_curve_fitting() 
231   
232           
233          self.assert_(access(ds.tmpdir+sep+'r1.600.out', F_OK)) 
234          self.assert_(access(ds.tmpdir+sep+'results.bz2', F_OK)) 
235          self.assert_(access(ds.tmpdir+sep+'r1.600.save.bz2', F_OK)) 
236          self.assert_(access(ds.tmpdir+sep+'grace'+sep+'r1.600.agr', F_OK)) 
237          self.assert_(access(ds.tmpdir+sep+'grace'+sep+'chi2.agr', F_OK)) 
238          self.assert_(access(ds.tmpdir+sep+'grace'+sep+'i0.agr', F_OK)) 
239          self.assert_(access(ds.tmpdir+sep+'grace'+sep+'intensities.agr', F_OK)) 
240          self.assert_(access(ds.tmpdir+sep+'grace'+sep+'intensities_norm.agr', F_OK)) 
  241