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

Source Code for Module test_suite.model_selection

 1  ############################################################################### 
 2  #                                                                             # 
 3  # Copyright (C) 2006 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  import sys 
24   
25   
26 -class Modsel:
27 - def __init__(self, relax, test_name):
28 """Class for testing model selection.""" 29 30 self.relax = relax 31 32 # Diffusion tensor selection. 33 if test_name == 'diff tensor': 34 # The name of the test. 35 self.name = "AIC model selection between two diffusion tensors" 36 37 # The test. 38 self.test = self.diff
39 40
41 - def diff(self, run):
42 """The test of selecting between diffusion tensors using AIC.""" 43 44 # Create the three runs. 45 self.relax.generic.runs.create('sphere', 'mf') 46 self.relax.generic.runs.create('spheroid', 'mf') 47 self.relax.generic.runs.create('aic', 'mf') 48 49 # Path of the files. 50 path = sys.path[-1] + '/test_suite/data/model_free/S2_0.970_te_2048_Rex_0.149' 51 52 # Read the sequence. 53 self.relax.interpreter._Sequence.read('sphere', file='r1.600.out', dir=path) 54 self.relax.interpreter._Sequence.read('spheroid', file='r1.600.out', dir=path) 55 56 # Select the model. 57 self.relax.interpreter._Model_free.select_model('sphere', model='m4') 58 self.relax.interpreter._Model_free.select_model('spheroid', model='m4') 59 60 # Read the relaxation data. 61 self.relax.interpreter._Relax_data.read('sphere', 'R1', '600', 600.0 * 1e6, 'r1.600.out', dir=path) 62 self.relax.interpreter._Relax_data.read('sphere', 'R2', '600', 600.0 * 1e6, 'r2.600.out', dir=path) 63 self.relax.interpreter._Relax_data.read('sphere', 'NOE', '600', 600.0 * 1e6, 'noe.600.out', dir=path) 64 self.relax.interpreter._Relax_data.read('sphere', 'R1', '500', 500.0 * 1e6, 'r1.500.out', dir=path) 65 self.relax.interpreter._Relax_data.read('sphere', 'R2', '500', 500.0 * 1e6, 'r2.500.out', dir=path) 66 self.relax.interpreter._Relax_data.read('sphere', 'NOE', '500', 500.0 * 1e6, 'noe.500.out', dir=path) 67 self.relax.interpreter._Relax_data.copy('sphere', 'spheroid') 68 69 # Set the diffusion tensors. 70 self.relax.interpreter._Diffusion_tensor.init('sphere', 1e-9, fixed=0) 71 self.relax.interpreter._Diffusion_tensor.init('spheroid', (1e-9, 0, 0, 0), fixed=0) 72 73 # Set some global stats. 74 self.relax.data.chi2['sphere'] = 200 75 self.relax.data.chi2['spheroid'] = 0 76 77 # Model selection. 78 self.relax.interpreter._Modsel.model_selection(method='AIC', modsel_run='aic') 79 80 # Test if the spheroid has been selected. 81 if not self.relax.data.diff.has_key('aic') or not self.relax.data.diff['aic'].type == 'spheroid': 82 print "\nThe spheroid diffusion tensor has not been selected." 83 return 84 85 # Success. 86 return 1
87