Package test_suite :: Package system_tests :: Module model_selection
[hide private]
[frames] | no frames]

Source Code for Module test_suite.system_tests.model_selection

 1  ############################################################################### 
 2  #                                                                             # 
 3  # Copyright (C) 2006-2011 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 sep 
25   
26  # relax module imports. 
27  from base_classes import SystemTestCase 
28  from data import Relax_data_store; ds = Relax_data_store() 
29  from generic_fns import pipes 
30  from status import Status; status = Status() 
31   
32   
33 -class Modsel(SystemTestCase):
34 """Class for testing model selection.""" 35
37 """AIC model selection between two diffusion tensors.""" 38 39 # Init. 40 pipe_list = ['sphere', 'spheroid'] 41 tensors = [1e-9, (1e-9, 0, 0, 0)] 42 43 # Path of the files. 44 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'model_free'+sep+'S2_0.970_te_2048_Rex_0.149' 45 46 # Loop over the data pipes. 47 for i in xrange(2): 48 # Create the data pipe. 49 self.interpreter.pipe.create(pipe_list[i], 'mf') 50 51 # Read the sequence. 52 self.interpreter.sequence.read(file='r1.600.out', dir=path, res_num_col=1, res_name_col=2) 53 54 # Select the model. 55 self.interpreter.model_free.select_model(model='m4') 56 57 # Read the relaxation data. 58 self.interpreter.relax_data.read(ri_id='R1_600', ri_type='R1', frq=600.0*1e6, file='r1.600.out', dir=path, res_num_col=1, res_name_col=2, data_col=3, error_col=4) 59 self.interpreter.relax_data.read(ri_id='R2_600', ri_type='R2', frq=600.0*1e6, file='r2.600.out', dir=path, res_num_col=1, res_name_col=2, data_col=3, error_col=4) 60 self.interpreter.relax_data.read(ri_id='NOE_600', ri_type='NOE', frq=600.0*1e6, file='noe.600.out', dir=path, res_num_col=1, res_name_col=2, data_col=3, error_col=4) 61 self.interpreter.relax_data.read(ri_id='R1_500', ri_type='R1', frq=500.0*1e6, file='r1.500.out', dir=path, res_num_col=1, res_name_col=2, data_col=3, error_col=4) 62 self.interpreter.relax_data.read(ri_id='R2_500', ri_type='R2', frq=500.0*1e6, file='r2.500.out', dir=path, res_num_col=1, res_name_col=2, data_col=3, error_col=4) 63 self.interpreter.relax_data.read(ri_id='NOE_500', ri_type='NOE', frq=500.0*1e6, file='noe.500.out', dir=path, res_num_col=1, res_name_col=2, data_col=3, error_col=4) 64 65 # Set the diffusion tensors. 66 self.interpreter.diffusion_tensor.init(tensors[i], fixed=False) 67 68 # Get the data pipes. 69 dp_sphere = pipes.get_pipe('sphere') 70 dp_spheroid = pipes.get_pipe('spheroid') 71 72 # Set some global stats. 73 dp_sphere.chi2 = 200 74 dp_spheroid.chi2 = 0 75 76 # Model selection. 77 self.interpreter.model_selection(method='AIC', modsel_pipe='aic') 78 79 # Get the AIC data pipe. 80 dp_aic = pipes.get_pipe('aic') 81 82 # Test if the spheroid has been selected. 83 self.assert_(hasattr(dp_aic, 'diff_tensor')) 84 self.assertEqual(dp_aic.diff_tensor.type, 'spheroid')
85