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

Source Code for Module test_suite.system_tests.palmer

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2008 Sebastien Morin                                          # 
  4  # Copyright (C) 2010-2012 Edward d'Auvergne                                   # 
  5  #                                                                             # 
  6  # This file is part of the program relax (http://www.nmr-relax.com).          # 
  7  #                                                                             # 
  8  # This program is free software: you can redistribute it and/or modify        # 
  9  # it under the terms of the GNU General Public License as published by        # 
 10  # the Free Software Foundation, either version 3 of the License, or           # 
 11  # (at your option) any later version.                                         # 
 12  #                                                                             # 
 13  # This program is distributed in the hope that it will be useful,             # 
 14  # but WITHOUT ANY WARRANTY; without even the implied warranty of              # 
 15  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               # 
 16  # GNU General Public License for more details.                                # 
 17  #                                                                             # 
 18  # You should have received a copy of the GNU General Public License           # 
 19  # along with this program.  If not, see <http://www.gnu.org/licenses/>.       # 
 20  #                                                                             # 
 21  ############################################################################### 
 22   
 23  # Python module imports. 
 24  from math import pi 
 25  from os import sep 
 26  from tempfile import mkdtemp 
 27   
 28  # relax module imports. 
 29  from data import Relax_data_store; ds = Relax_data_store() 
 30  import dep_check 
 31  from generic_fns import pipes 
 32  from generic_fns.mol_res_spin import return_spin 
 33  from relax_errors import RelaxError 
 34  from relax_io import test_binary 
 35  from status import Status; status = Status() 
 36  from test_suite.system_tests.base_classes import SystemTestCase 
 37   
 38   
39 -class Palmer(SystemTestCase):
40 """Class for testing various aspects specific to model-free analysis using the program 'Modelfree4'.""" 41
42 - def __init__(self, methodName='runTest'):
43 """Skip the tests if the subprocess module is not available (Python 2.3 and earlier). 44 45 @keyword methodName: The name of the test. 46 @type methodName: str 47 """ 48 49 # Execute the base class method. 50 super(Palmer, self).__init__(methodName) 51 52 # Missing module. 53 if not dep_check.subprocess_module: 54 # Store in the status object. 55 status.skipped_tests.append([methodName, 'subprocess', self._skip_type])
56 57
58 - def setUp(self):
59 """Set up for all the functional tests.""" 60 61 # Create a temporary directory for ModelFree4 outputs. 62 ds.tmpdir = mkdtemp()
63 64
65 - def test_palmer(self):
66 """Test a complete model-free analysis using the program 'Modelfree4'.""" 67 68 # Test for the presence of the Modelfree4 binary (skip the test if not present). 69 try: 70 test_binary('modelfree4') 71 except: 72 return 73 74 # Execute the script. 75 self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'palmer.py') 76 77 # Determine if the Gnu gcc or Portland C compiler version is being used. 78 spin = return_spin(':0@N', pipe='m2') 79 if spin.te == 1.951*1e-12: 80 compiler = 'gcc' # Gnu gcc modelfree4 version. 81 else: 82 compiler = 'pgf' # Portland C compiler modelfree4 version. 83 84 # Checks for model m1, m2, and m3 mfout file reading. 85 models = ['m1', 'm2', 'm3'] 86 params = [['s2'], ['s2', 'te'], ['s2', 'rex']] 87 spin_names = [':-2@N', ':-1@N', ':0@N'] 88 if compiler == 'gcc': 89 s2 = [[0.869, 0.732, None], [0.869, 0.730, None], [0.715, 0.643, None]] 90 te = [[None, None, None], [0.0, 1.951, None], [None, None, None]] # Gnu gcc modelfree4 version. 91 rex = [[None, None, None], [None, None, None], [4.308, 4.278, None]] 92 else: 93 s2 = [[0.869, 0.732, None], [0.869, 0.730, None], [0.715, 0.643, None]] 94 te = [[None, None, None], [0.0, 1.952, None], [None, None, None]] # Portland C compiler modelfree4 version. 95 rex = [[None, None, None], [None, None, None], [4.308, 4.278, None]] 96 chi2 = [[36.6223, 20.3954, None], [36.6223, 20.3299, None], [1.9763, 0.6307, None]] 97 for model_index in range(3): 98 print("Model " + repr(models[model_index])) 99 for spin_index in range(3): 100 print("Spin " + repr(spin_names[spin_index])) 101 102 # Get the spin. 103 spin = return_spin(spin_names[spin_index], pipe=models[model_index]) 104 105 # Conversions. 106 if te[model_index][spin_index]: 107 te[model_index][spin_index] = te[model_index][spin_index] * 1e-12 108 if rex[model_index][spin_index]: 109 rex[model_index][spin_index] = rex[model_index][spin_index] / (2.0 * pi * cdp.frq[cdp.ri_ids[0]])**2 110 111 # Checks. 112 self.assertEqual(spin.model, models[model_index]) 113 self.assertEqual(spin.params, params[model_index]) 114 self.assertEqual(spin.s2, s2[model_index][spin_index]) 115 self.assertEqual(spin.s2f, None) 116 self.assertEqual(spin.s2s, None) 117 if te[model_index][spin_index] == None: 118 self.assertEqual(spin.te, te[model_index][spin_index]) 119 else: 120 self.assertAlmostEqual(spin.te, te[model_index][spin_index]) 121 self.assertEqual(spin.tf, None) 122 self.assertEqual(spin.ts, None) 123 self.assertEqual(spin.rex, rex[model_index][spin_index]) 124 self.assertEqual(spin.chi2, chi2[model_index][spin_index]) 125 126 # Checks for the final mfout file reading. 127 models = ['m3', 'm3'] 128 params = [['s2', 'rex'], ['s2', 'rex']] 129 s2 = [0.844, 0.760] 130 te = [None, None] 131 rex = [0.005, 0.404] 132 chi2 = [1.7966, 0.7389] 133 for spin_index in range(3): 134 # Get the spin. 135 spin = return_spin(spin_names[spin_index], pipe='aic') 136 137 # Deselected spin. 138 if not spin.select: 139 continue 140 141 # Conversions. 142 if te[spin_index]: 143 te[spin_index] = te[spin_index] * 1e-12 144 if rex[spin_index]: 145 rex[spin_index] = rex[spin_index] / (2.0 * pi * cdp.frq[cdp.ri_ids[0]])**2 146 147 # Checks. 148 self.assertEqual(spin.model, models[spin_index]) 149 self.assertEqual(spin.params, params[spin_index]) 150 self.assertEqual(spin.s2, s2[spin_index]) 151 self.assertEqual(spin.s2f, None) 152 self.assertEqual(spin.s2s, None) 153 self.assertEqual(spin.te, te[spin_index]) 154 self.assertEqual(spin.tf, None) 155 self.assertEqual(spin.ts, None) 156 self.assertEqual(spin.rex, rex[spin_index]) 157 self.assertEqual(spin.chi2, chi2[spin_index]) 158 159 # Final global values. 160 final_pipe = pipes.get_pipe('aic') 161 self.assertEqual(final_pipe.chi2, 2.5356) 162 self.assertEqual(final_pipe.diff_tensor.tm, 12.045)
163 164
165 - def test_palmer_omp(self):
166 """Test a complete model-free analysis using 'Modelfree4' with the OMP relaxation data, a PDB file, and a spheroid tensor.""" 167 168 # Test for the presence of the Modelfree4 binary (skip the test if not present). 169 try: 170 test_binary('modelfree4') 171 except: 172 return 173 174 # Execute the script. 175 self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'palmer_omp.py') 176 177 # Catch a the old, buggy modelfree4 versions and complain loudly! 178 spin = return_spin(':9@N', pipe='m2') 179 if spin.s2 == 0.855: 180 raise RelaxError("You are using an old, buggy Modelfree4 version! You must upgrade to version 4.20 or later.") 181 182 # Determine if the Gnu gcc or Portland C compiler version is being used. 183 if spin.te == 20.043*1e-12: 184 compiler = 'gcc' # Gnu gcc modelfree4 version. 185 else: 186 compiler = 'pgf' # Portland C compiler modelfree4 version. 187 188 # Model m1, m2, and m3 mfout file data. 189 models = ['m1', 'm2', 'm3'] 190 params = [['s2'], ['s2', 'te'], ['s2', 'rex']] 191 spin_names = [':9@N', ':10@N', ':11@N'] 192 s2 = [[0.822, 0.799, 0.823], [0.788, 0.777, 0.812], [0.822, 0.799, 0.823]] 193 if compiler == 'gcc': 194 te = [[None, None, None], [61.506, 36.084, 20.043], [None, None, None]] 195 else: 196 te = [[None, None, None], [61.506, 36.087, 20.039], [None, None, None]] 197 rex = [[None, None, None], [None, None, None], [0.0, 0.0, 0.0]] 198 chi2 = [[143.6773, 105.1767, 61.6684], [40.9055, 57.1562, 48.4927], [143.6773, 105.1767, 61.6684]] 199 200 # Checks for model m1, m2, and m3 mfout file reading. 201 for model_index in range(3): 202 print("Model " + repr(models[model_index])) 203 for spin_index in range(3): 204 print("Spin " + repr(spin_names[spin_index])) 205 206 # Get the spin. 207 spin = return_spin(spin_names[spin_index], pipe=models[model_index]) 208 209 # Conversions. 210 if te[model_index][spin_index]: 211 te[model_index][spin_index] = te[model_index][spin_index] * 1e-12 212 if rex[model_index][spin_index]: 213 rex[model_index][spin_index] = rex[model_index][spin_index] / (2.0 * pi * cdp.frq[cdp.ri_ids[0]])**2 214 215 # Checks. 216 self.assertEqual(spin.model, models[model_index]) 217 self.assertEqual(spin.params, params[model_index]) 218 self.assertEqual(spin.s2, s2[model_index][spin_index]) 219 self.assertEqual(spin.s2f, None) 220 self.assertEqual(spin.s2s, None) 221 self.assertEqual(spin.te, te[model_index][spin_index]) 222 self.assertEqual(spin.tf, None) 223 self.assertEqual(spin.ts, None) 224 self.assertEqual(spin.rex, rex[model_index][spin_index]) 225 self.assertEqual(spin.chi2, chi2[model_index][spin_index]) 226 227 # Final mfout file data. 228 models = ['m2', 'm2', 'm2'] 229 params = [['s2', 'te'], ['s2', 'te'], ['s2', 'te']] 230 if compiler == 'gcc': 231 s2 = [0.782, 0.760, 0.785] 232 te = [60.009, 29.134, 12.590] 233 chi2 = [24.0495, 8.1168, 0.5332] 234 else: 235 s2 = [0.755, 0.761, 0.787] 236 te = [52.197, 29.361, 12.677] 237 chi2 = [7.254, 8.0437, 0.5327] 238 239 # Checks for the final mfout file reading. 240 for spin_index in range(3): 241 # Get the spin. 242 spin = return_spin(spin_names[spin_index], pipe='aic') 243 244 # Conversions. 245 if te[spin_index]: 246 te[spin_index] = te[spin_index] * 1e-12 247 248 # Checks. 249 self.assertEqual(spin.model, models[spin_index]) 250 self.assertEqual(spin.params, params[spin_index]) 251 self.assertEqual(spin.s2, s2[spin_index]) 252 self.assertEqual(spin.s2f, None) 253 self.assertEqual(spin.s2s, None) 254 self.assertAlmostEqual(spin.te, te[spin_index]) 255 self.assertEqual(spin.tf, None) 256 self.assertEqual(spin.ts, None) 257 self.assertEqual(spin.rex, None) 258 self.assertEqual(spin.chi2, chi2[spin_index]) 259 260 # Final global values. 261 final_pipe = pipes.get_pipe('aic') 262 if compiler == 'gcc': 263 self.assertEqual(final_pipe.chi2, 32.6995) 264 self.assertEqual(final_pipe.diff_tensor.tm, 8.964) 265 self.assertEqual(final_pipe.diff_tensor.Dratio, 1.324) 266 self.assertEqual(final_pipe.diff_tensor.theta, (-52.070 / 360.0) * 2.0 * pi + pi) 267 self.assertEqual(final_pipe.diff_tensor.phi, (2.377 / 360.0) * 2.0 * pi) 268 else: 269 self.assertEqual(final_pipe.chi2, 15.8304) 270 self.assertEqual(final_pipe.diff_tensor.tm, 8.443) 271 self.assertEqual(final_pipe.diff_tensor.Dratio, 1.053) 272 self.assertEqual(final_pipe.diff_tensor.theta, (68.864 / 360.0) * 2.0 * pi) 273 self.assertEqual(final_pipe.diff_tensor.phi, (73.913 / 360.0) * 2.0 * pi)
274