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.                                     # 
  7  #                                                                             # 
  8  # relax 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 2 of the License, or           # 
 11  # (at your option) any later version.                                         # 
 12  #                                                                             # 
 13  # relax 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 relax; if not, write to the Free Software                        # 
 20  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   # 
 21  #                                                                             # 
 22  ############################################################################### 
 23   
 24  # Python module imports. 
 25  from math import pi 
 26  from os import sep 
 27  from tempfile import mkdtemp 
 28   
 29  # relax module imports. 
 30  from base_classes import SystemTestCase 
 31  from data import Relax_data_store; ds = Relax_data_store() 
 32  from generic_fns import pipes 
 33  from generic_fns.mol_res_spin import return_spin 
 34  from relax_errors import RelaxError 
 35  from relax_io import test_binary 
 36  from status import Status; status = Status() 
 37   
 38   
39 -class Palmer(SystemTestCase):
40 """Class for testing various aspects specific to model-free analysis using the program 'Modelfree4'.""" 41
42 - def setUp(self):
43 """Set up for all the functional tests.""" 44 45 # Create a temporary directory for ModelFree4 outputs. 46 ds.tmpdir = mkdtemp()
47 48
49 - def test_palmer(self):
50 """Test a complete model-free analysis using the program 'Modelfree4'.""" 51 52 # Test for the presence of the Modelfree4 binary (skip the test if not present). 53 try: 54 test_binary('modelfree4') 55 except: 56 return 57 58 # Execute the script. 59 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'palmer.py') 60 61 # Determine if the Gnu gcc or Portland C compiler version is being used. 62 spin = return_spin(':0', pipe='m2') 63 if spin.te == 1.951*1e-12: 64 compiler = 'gcc' # Gnu gcc modelfree4 version. 65 else: 66 compiler = 'pgf' # Portland C compiler modelfree4 version. 67 68 # Checks for model m1, m2, and m3 mfout file reading. 69 models = ['m1', 'm2', 'm3'] 70 params = [['s2'], ['s2', 'te'], ['s2', 'rex']] 71 spin_names = [':-2&:Gly', ':-1&:Gly', ':0&:Gly'] 72 if compiler == 'gcc': 73 s2 = [[0.869, 0.732, None], [0.869, 0.730, None], [0.715, 0.643, None]] 74 te = [[None, None, None], [0.0, 1.951, None], [None, None, None]] # Gnu gcc modelfree4 version. 75 rex = [[None, None, None], [None, None, None], [4.308, 4.278, None]] 76 else: 77 s2 = [[0.869, 0.732, None], [0.869, 0.730, None], [0.715, 0.643, None]] 78 te = [[None, None, None], [0.0, 1.952, None], [None, None, None]] # Portland C compiler modelfree4 version. 79 rex = [[None, None, None], [None, None, None], [4.308, 4.278, None]] 80 chi2 = [[36.6223, 20.3954, None], [36.6223, 20.3299, None], [1.9763, 0.6307, None]] 81 for model_index in xrange(3): 82 print(("Model " + repr(models[model_index]))) 83 for spin_index in xrange(3): 84 print(("Spin " + repr(spin_names[spin_index]))) 85 86 # Get the spin. 87 spin = return_spin(spin_names[spin_index], pipe=models[model_index]) 88 89 # Conversions. 90 if te[model_index][spin_index]: 91 te[model_index][spin_index] = te[model_index][spin_index] * 1e-12 92 if rex[model_index][spin_index]: 93 rex[model_index][spin_index] = rex[model_index][spin_index] / (2.0 * pi * cdp.frq[cdp.ri_ids[0]])**2 94 95 # Checks. 96 self.assertEqual(spin.model, models[model_index]) 97 self.assertEqual(spin.params, params[model_index]) 98 self.assertEqual(spin.s2, s2[model_index][spin_index]) 99 self.assertEqual(spin.s2f, None) 100 self.assertEqual(spin.s2s, None) 101 if te[model_index][spin_index] == None: 102 self.assertEqual(spin.te, te[model_index][spin_index]) 103 else: 104 self.assertAlmostEqual(spin.te, te[model_index][spin_index]) 105 self.assertEqual(spin.tf, None) 106 self.assertEqual(spin.ts, None) 107 self.assertEqual(spin.rex, rex[model_index][spin_index]) 108 self.assertEqual(spin.chi2, chi2[model_index][spin_index]) 109 110 # Checks for the final mfout file reading. 111 models = ['m3', 'm3'] 112 params = [['s2', 'rex'], ['s2', 'rex']] 113 s2 = [0.844, 0.760] 114 te = [None, None] 115 rex = [0.005, 0.404] 116 chi2 = [1.7966, 0.7389] 117 for spin_index in xrange(3): 118 # Get the spin. 119 spin = return_spin(spin_names[spin_index], pipe='aic') 120 121 # Deselected spin. 122 if not spin.select: 123 continue 124 125 # Conversions. 126 if te[spin_index]: 127 te[spin_index] = te[spin_index] * 1e-12 128 if rex[spin_index]: 129 rex[spin_index] = rex[spin_index] / (2.0 * pi * cdp.frq[cdp.ri_ids[0]])**2 130 131 # Checks. 132 self.assertEqual(spin.model, models[spin_index]) 133 self.assertEqual(spin.params, params[spin_index]) 134 self.assertEqual(spin.s2, s2[spin_index]) 135 self.assertEqual(spin.s2f, None) 136 self.assertEqual(spin.s2s, None) 137 self.assertEqual(spin.te, te[spin_index]) 138 self.assertEqual(spin.tf, None) 139 self.assertEqual(spin.ts, None) 140 self.assertEqual(spin.rex, rex[spin_index]) 141 self.assertEqual(spin.chi2, chi2[spin_index]) 142 143 # Final global values. 144 final_pipe = pipes.get_pipe('aic') 145 self.assertEqual(final_pipe.chi2, 2.5356) 146 self.assertEqual(final_pipe.diff_tensor.tm, 12.045)
147 148
149 - def test_palmer_omp(self):
150 """Test a complete model-free analysis using 'Modelfree4' with the OMP relaxation data, a PDB file, and a spheroid tensor.""" 151 152 # Test for the presence of the Modelfree4 binary (skip the test if not present). 153 try: 154 test_binary('modelfree4') 155 except: 156 return 157 158 # Execute the script. 159 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'palmer_omp.py') 160 161 # Catch a the old, buggy modelfree4 versions and complain loudly! 162 spin = return_spin(':9', pipe='m2') 163 if spin.s2 == 0.855: 164 raise RelaxError("You are using an old, buggy Modelfree4 version! You must upgrade to version 4.20 or later.") 165 166 # Determine if the Gnu gcc or Portland C compiler version is being used. 167 if spin.te == 20.043*1e-12: 168 compiler = 'gcc' # Gnu gcc modelfree4 version. 169 else: 170 compiler = 'pgf' # Portland C compiler modelfree4 version. 171 172 # Model m1, m2, and m3 mfout file data. 173 models = ['m1', 'm2', 'm3'] 174 params = [['s2'], ['s2', 'te'], ['s2', 'rex']] 175 spin_names = [':9', ':10', ':11'] 176 s2 = [[0.822, 0.799, 0.823], [0.788, 0.777, 0.812], [0.822, 0.799, 0.823]] 177 if compiler == 'gcc': 178 te = [[None, None, None], [61.506, 36.084, 20.043], [None, None, None]] 179 else: 180 te = [[None, None, None], [61.506, 36.087, 20.039], [None, None, None]] 181 rex = [[None, None, None], [None, None, None], [0.0, 0.0, 0.0]] 182 chi2 = [[143.6773, 105.1767, 61.6684], [40.9055, 57.1562, 48.4927], [143.6773, 105.1767, 61.6684]] 183 184 # Checks for model m1, m2, and m3 mfout file reading. 185 for model_index in xrange(3): 186 print(("Model " + repr(models[model_index]))) 187 for spin_index in xrange(3): 188 print(("Spin " + repr(spin_names[spin_index]))) 189 190 # Get the spin. 191 spin = return_spin(spin_names[spin_index], pipe=models[model_index]) 192 193 # Conversions. 194 if te[model_index][spin_index]: 195 te[model_index][spin_index] = te[model_index][spin_index] * 1e-12 196 if rex[model_index][spin_index]: 197 rex[model_index][spin_index] = rex[model_index][spin_index] / (2.0 * pi * cdp.frq[cdp.ri_ids[0]])**2 198 199 # Checks. 200 self.assertEqual(spin.model, models[model_index]) 201 self.assertEqual(spin.params, params[model_index]) 202 self.assertEqual(spin.s2, s2[model_index][spin_index]) 203 self.assertEqual(spin.s2f, None) 204 self.assertEqual(spin.s2s, None) 205 self.assertEqual(spin.te, te[model_index][spin_index]) 206 self.assertEqual(spin.tf, None) 207 self.assertEqual(spin.ts, None) 208 self.assertEqual(spin.rex, rex[model_index][spin_index]) 209 self.assertEqual(spin.chi2, chi2[model_index][spin_index]) 210 211 # Final mfout file data. 212 models = ['m2', 'm2', 'm2'] 213 params = [['s2', 'te'], ['s2', 'te'], ['s2', 'te']] 214 if compiler == 'gcc': 215 s2 = [0.782, 0.760, 0.785] 216 te = [60.009, 29.134, 12.590] 217 chi2 = [24.0495, 8.1168, 0.5332] 218 else: 219 s2 = [0.755, 0.761, 0.787] 220 te = [52.197, 29.361, 12.677] 221 chi2 = [7.254, 8.0437, 0.5327] 222 223 # Checks for the final mfout file reading. 224 for spin_index in xrange(3): 225 # Get the spin. 226 spin = return_spin(spin_names[spin_index], pipe='aic') 227 228 # Conversions. 229 if te[spin_index]: 230 te[spin_index] = te[spin_index] * 1e-12 231 232 # Checks. 233 self.assertEqual(spin.model, models[spin_index]) 234 self.assertEqual(spin.params, params[spin_index]) 235 self.assertEqual(spin.s2, s2[spin_index]) 236 self.assertEqual(spin.s2f, None) 237 self.assertEqual(spin.s2s, None) 238 self.assertAlmostEqual(spin.te, te[spin_index]) 239 self.assertEqual(spin.tf, None) 240 self.assertEqual(spin.ts, None) 241 self.assertEqual(spin.rex, None) 242 self.assertEqual(spin.chi2, chi2[spin_index]) 243 244 # Final global values. 245 final_pipe = pipes.get_pipe('aic') 246 if compiler == 'gcc': 247 self.assertEqual(final_pipe.chi2, 32.6995) 248 self.assertEqual(final_pipe.diff_tensor.tm, 8.964) 249 self.assertEqual(final_pipe.diff_tensor.Dratio, 1.324) 250 self.assertEqual(final_pipe.diff_tensor.theta, (-52.070 / 360.0) * 2.0 * pi + pi) 251 self.assertEqual(final_pipe.diff_tensor.phi, (2.377 / 360.0) * 2.0 * pi) 252 else: 253 self.assertEqual(final_pipe.chi2, 15.8304) 254 self.assertEqual(final_pipe.diff_tensor.tm, 8.443) 255 self.assertEqual(final_pipe.diff_tensor.Dratio, 1.053) 256 self.assertEqual(final_pipe.diff_tensor.theta, (68.864 / 360.0) * 2.0 * pi) 257 self.assertEqual(final_pipe.diff_tensor.phi, (73.913 / 360.0) * 2.0 * pi)
258