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-2013 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 sep 
24   
25  # relax module imports. 
26  from data_store import Relax_data_store; ds = Relax_data_store() 
27  from pipe_control import pipes 
28  from status import Status; status = Status() 
29  from test_suite.system_tests.base_classes import SystemTestCase 
30   
31   
32 -class Modsel(SystemTestCase):
33 """Class for testing model selection.""" 34
36 """AIC model selection between two diffusion tensors.""" 37 38 # Init. 39 pipe_list = ['sphere', 'spheroid'] 40 tensors = [1e-9, (1e-9, 0, 0, 0)] 41 42 # Path of the files. 43 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'model_free'+sep+'S2_0.970_te_2048_Rex_0.149' 44 45 # Loop over the data pipes. 46 for i in range(2): 47 # Create the data pipe. 48 self.interpreter.pipe.create(pipe_list[i], 'mf') 49 50 # Read the sequence. 51 self.interpreter.sequence.read(file='r1.600.out', dir=path, res_num_col=1, res_name_col=2) 52 53 # Select the model. 54 self.interpreter.model_free.select_model(model='m4') 55 56 # Read the relaxation data. 57 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) 58 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) 59 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) 60 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) 61 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) 62 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) 63 64 # Name the spins, then create all attached protons. 65 self.interpreter.spin.name('N') 66 self.interpreter.sequence.attach_protons() 67 68 # Set the diffusion tensors. 69 self.interpreter.diffusion_tensor.init(tensors[i], fixed=False) 70 71 # Get the data pipes. 72 dp_sphere = pipes.get_pipe('sphere') 73 dp_spheroid = pipes.get_pipe('spheroid') 74 75 # Set some global stats. 76 dp_sphere.chi2 = 200 77 dp_spheroid.chi2 = 0 78 79 # Model selection. 80 self.interpreter.model_selection(method='AIC', modsel_pipe='aic') 81 82 # Get the AIC data pipe. 83 dp_aic = pipes.get_pipe('aic') 84 85 # Test if the spheroid has been selected. 86 self.assert_(hasattr(dp_aic, 'diff_tensor')) 87 self.assertEqual(dp_aic.diff_tensor.type, 'spheroid')
88