1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 from os import F_OK, access, getcwd, path, sep
26 import copy
27 from numpy import array, asarray, average, exp, median, inf, isnan, linspace, log, std, sum, zeros
28 from minfx.generic import generic_minimise
29 from random import gauss
30 import re, math
31 from tempfile import mkdtemp, NamedTemporaryFile
32
33
34
35 from auto_analyses import relax_disp
36 from auto_analyses.relax_disp_repeat_cpmg import DIC_KEY_FORMAT, Relax_disp_rep
37 from data_store import Relax_data_store; ds = Relax_data_store()
38 import dep_check
39 from lib.dispersion.variables import EXP_TYPE_CPMG_DQ, EXP_TYPE_CPMG_MQ, EXP_TYPE_CPMG_PROTON_MQ, EXP_TYPE_CPMG_PROTON_SQ, EXP_TYPE_CPMG_SQ, EXP_TYPE_CPMG_ZQ, EXP_TYPE_LIST, EXP_TYPE_R1RHO, MODEL_B14_FULL, MODEL_CR72, MODEL_CR72_FULL, MODEL_DPL94, MODEL_IT99, MODEL_LIST_FULL, MODEL_LM63, MODEL_M61, MODEL_M61B, MODEL_MP05, MODEL_NOREX, MODEL_NS_CPMG_2SITE_3D_FULL, MODEL_NS_CPMG_2SITE_EXPANDED, MODEL_NS_CPMG_2SITE_STAR_FULL, MODEL_NS_R1RHO_2SITE, MODEL_PARAMS, MODEL_R2EFF, MODEL_TP02, MODEL_TAP03
40 from lib.errors import RelaxError
41 from lib.io import extract_data, get_file_path
42 from lib.spectrum.nmrpipe import show_apod_extract, show_apod_rmsd, show_apod_rmsd_dir_to_files, show_apod_rmsd_to_file
43 from pipe_control.mol_res_spin import generate_spin_string, return_spin, spin_loop
44 from pipe_control.minimise import assemble_scaling_matrix
45 from specific_analyses.relax_disp.checks import check_missing_r1
46 from specific_analyses.relax_disp.estimate_r2eff import estimate_r2eff
47 from specific_analyses.relax_disp.data import average_intensity, check_intensity_errors, generate_r20_key, get_curve_type, has_exponential_exp_type, loop_exp_frq, loop_exp_frq_offset_point, loop_time, return_grace_file_name_ini, return_param_key_from_data, spin_ids_to_containers
48 from specific_analyses.relax_disp.data import INTERPOLATE_DISP, INTERPOLATE_OFFSET, X_AXIS_DISP, X_AXIS_W_EFF, X_AXIS_THETA, Y_AXIS_R2_R1RHO, Y_AXIS_R2_EFF
49 from specific_analyses.relax_disp.model import models_info, nesting_param
50 from specific_analyses.relax_disp.parameters import linear_constraints
51 from status import Status; status = Status()
52 from target_functions.relax_fit_wrapper import Relax_fit_opt
53 from test_suite.system_tests.base_classes import SystemTestCase
54
55
57 """Class for testing various aspects specific to relaxation dispersion curve-fitting."""
58
59 - def __init__(self, methodName='runTest'):
60 """Skip certain tests if the C modules are non-functional.
61
62 @keyword methodName: The name of the test.
63 @type methodName: str
64 """
65
66
67 super(Relax_disp, self).__init__(methodName)
68
69
70 blacklist = [
71 'test_m61b_data_to_m61b'
72 ]
73 if methodName in blacklist:
74 status.skipped_tests.append([methodName, None, self._skip_type])
75
76
77 if not dep_check.C_module_exp_fn:
78
79 to_skip = [
80 "test_bug_atul_srivastava",
81 "test_bug_21344_sparse_time_spinlock_acquired_r1rho_fail_relax_disp",
82 "test_bug_9999_slow_r1rho_r2eff_error_with_mc",
83 "test_estimate_r2eff_err",
84 "test_estimate_r2eff_err_auto",
85 "test_estimate_r2eff_err_methods",
86 "test_finite_value",
87 "test_exp_fit",
88 "test_m61_exp_data_to_m61",
89 "test_r1rho_kjaergaard_auto",
90 "test_r1rho_kjaergaard_auto_check_graphs",
91 "test_r1rho_kjaergaard_man",
92 "test_r1rho_kjaergaard_missing_r1",
93 "test_value_write_calc_rotating_frame_params_auto_analysis"
94 ]
95
96
97 if methodName in to_skip:
98 status.skipped_tests.append([methodName, 'Relax curve-fitting C module', self._skip_type])
99
100
101 if not dep_check.scipy_module:
102
103 to_skip = [
104 "test_estimate_r2eff_err_methods"
105 ]
106
107
108 if methodName in to_skip:
109 status.skipped_tests.append([methodName, 'scipy.optimize.leastsq module', self._skip_type])
110
111
112 if not dep_check.showApod_software:
113
114 to_skip = [
115 "test_show_apod_extract",
116 "test_show_apod_rmsd",
117 "test_show_apod_rmsd_to_file",
118 "test_show_apod_rmsd_dir_to_files"
119 ]
120
121
122 if methodName in to_skip:
123 status.skipped_tests.append([methodName, 'NMRPipe showApod program', self._skip_type])
124
125
126 if not dep_check.matplotlib_module:
127
128 to_skip = [
129 "test_repeat_cpmg"
130 ]
131
132
133 if methodName in to_skip:
134 status.skipped_tests.append([methodName, 'matplotlib module', self._skip_type])
135
136
138 """Set up for all the functional tests."""
139
140
141 self.interpreter.pipe.create('relax_disp', 'relax_disp')
142
143
144 ds.tmpdir = mkdtemp()
145 self.tmpdir = ds.tmpdir
146
147
149 """Setup data for the catch of U{bug #22146<https://web.archive.org/web/https://gna.org/bugs/?22146>}, the failure of unpacking R2A and R2B, when performing a clustered full dispersion models.
150
151 @keyword folder: The name of the folder for the test data.
152 @type folder: str
153 @keyword model_analyse: The name of the model which will be tested.
154 @type model_analyse: str
155 """
156
157 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'Hansen'
158
159
160 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_22146_unpacking_r2a_r2b_cluster'+sep+folder
161
162
163
164 sfrq_1 = 500.0*1E6
165 r20_key_1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=sfrq_1)
166 time_T2_1 = 0.05
167 ncycs_1 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 40, 50]
168
169
170 r2eff_errs_1 = [0.0] * len(ncycs_1)
171 exp_1 = [sfrq_1, time_T2_1, ncycs_1, r2eff_errs_1]
172
173 sfrq_2 = 600.0*1E6
174 r20_key_2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=sfrq_2)
175 time_T2_2 = 0.06
176 ncycs_2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 40, 60]
177
178
179 r2eff_errs_2 = [0.0] * len(ncycs_2)
180 exp_2 = [sfrq_2, time_T2_2, ncycs_2, r2eff_errs_2]
181
182 sfrq_3 = 700.0*1E6
183 r20_key_3 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=sfrq_3)
184 time_T2_3 = 0.07
185 ncycs_3 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 50, 70]
186
187
188 r2eff_errs_3 = [0.0] * len(ncycs_3)
189 exp_3 = [sfrq_3, time_T2_3, ncycs_3, r2eff_errs_3]
190
191
192 exps = [exp_1, exp_2, exp_3]
193
194 R20 = [5.1, 5.2, 5.3, 10.1, 10.2, 10.3, 6.1, 6.2, 6.3, 11.1, 11.2, 11.3, 7.1, 7.2, 7.3, 12.1, 12.2, 12.3, 8.1, 8.2, 8.3, 13.1, 13.2, 13.3]
195 dw_arr = [1.0, 2.0, 3.0, 4.0]
196 pA_arr = [0.9]
197 kex_arr = [1000.]
198
199 spins = [
200 ['Ala', 1, 'N', {'r2a': {r20_key_1: R20[0], r20_key_2: R20[1], r20_key_3: R20[2]}, 'r2b': {r20_key_1: R20[3], r20_key_2: R20[4], r20_key_3: R20[5]}, 'kex': kex_arr[0], 'pA': pA_arr[0], 'dw': dw_arr[0]}],
201 ['Ala', 2, 'N', {'r2a': {r20_key_1: R20[6], r20_key_2: R20[7], r20_key_3: R20[8]}, 'r2b': {r20_key_1: R20[9], r20_key_2: R20[10], r20_key_3: R20[11]}, 'kex': kex_arr[0], 'pA': pA_arr[0], 'dw': dw_arr[1]}],
202 ['Ala', 3, 'N', {'r2a': {r20_key_1: R20[12], r20_key_2: R20[13], r20_key_3: R20[14]}, 'r2b': {r20_key_1: R20[15], r20_key_2: R20[16], r20_key_3: R20[17]}, 'kex': kex_arr[0], 'pA': pA_arr[0], 'dw': dw_arr[2]}],
203 ['Ala', 4, 'N', {'r2a': {r20_key_1: R20[18], r20_key_2: R20[19], r20_key_3: R20[20]}, 'r2b': {r20_key_1: R20[21], r20_key_2: R20[22], r20_key_3: R20[23]}, 'kex': kex_arr[0], 'pA': pA_arr[0], 'dw': dw_arr[3]}],
204 ]
205
206
207 pipe_name = 'base pipe'
208 pipe_type = 'relax_disp'
209 pipe_bundle = 'relax_disp'
210 self.interpreter.pipe.create(pipe_name=pipe_name, pipe_type=pipe_type, bundle = pipe_bundle)
211
212
213 for res_name, res_num, spin_name, params in spins:
214 self.interpreter.spin.create(res_name=res_name, res_num=res_num, spin_name=spin_name)
215
216
217 self.interpreter.spin.isotope('15N', spin_id='@N')
218
219
220 exp_ids = []
221 for exp_i in exps:
222 sfrq, time_T2, ncycs, r2eff_errs = exp_i
223 exp_id = 'CPMG_%3.1f' % (sfrq/1E6)
224 exp_ids.append(exp_id)
225
226 ids = []
227 for ncyc in ncycs:
228 nu_cpmg = ncyc / time_T2
229 cur_id = '%s_%.1f' % (exp_id, nu_cpmg)
230 ids.append(cur_id)
231
232
233 self.interpreter.spectrometer.frequency(id=cur_id, frq=sfrq)
234
235
236 self.interpreter.relax_disp.exp_type(spectrum_id=cur_id, exp_type=EXP_TYPE_CPMG_SQ)
237
238
239 self.interpreter.relax_disp.relax_time(spectrum_id=cur_id, time=time_T2)
240
241
242 self.interpreter.relax_disp.cpmg_setup(spectrum_id=cur_id, cpmg_frq=nu_cpmg)
243
244 print("\n\nThe experiment IDs are %s." % cdp.spectrum_ids)
245
246
247
248
249 pipe_name_MODEL = "%s_%s"%(pipe_name, model_analyse)
250 self.interpreter.pipe.copy(pipe_from=pipe_name, pipe_to=pipe_name_MODEL, bundle_to = pipe_bundle)
251 self.interpreter.pipe.switch(pipe_name=pipe_name_MODEL)
252
253
254 for exp_type, frq, ei, mi in loop_exp_frq(return_indices=True):
255 exp_id = exp_ids[mi]
256 exp_i = exps[mi]
257 sfrq, time_T2, ncycs, r2eff_errs = exp_i
258
259
260 for res_name, res_num, spin_name, params in spins:
261 cur_spin_id = ":%i@%s"%(res_num, spin_name)
262
263
264 file_name = "%s%s.txt" % (exp_id, cur_spin_id .replace('#', '_').replace(':', '_').replace('@', '_'))
265
266
267 self.interpreter.relax_disp.r2eff_read_spin(id=exp_id, spin_id=cur_spin_id, file=file_name, dir=data_path, disp_point_col=1, data_col=2, error_col=3)
268
269
270 self.interpreter.relax_disp.select_model(model=model_analyse)
271
272
273 self.interpreter.relax_disp.cluster('model_cluster', ":1-100")
274
275
276 low_arr = R20 + dw_arr + pA_arr + kex_arr
277 self.interpreter.minimise.grid_search(lower=low_arr, upper=low_arr, inc=1, constraints=True, verbosity=1)
278
279
280 for i in range(len(spins)):
281 res_name, res_num, spin_name, params = spins[i]
282 cur_spin_id = ":%i@%s"%(res_num, spin_name)
283 cur_spin = return_spin(cur_spin_id)
284
285 for mo_param in cur_spin.params:
286 print(mo_param)
287
288 if isinstance(getattr(cur_spin, mo_param), dict):
289 for key, val in list(getattr(cur_spin, mo_param).items()):
290 should_be = params[mo_param][key]
291 print(cur_spin.model, res_name, cur_spin_id, mo_param, key, float(val), should_be)
292 self.assertAlmostEqual(val, should_be)
293 else:
294 should_be = float(params[mo_param])
295 val = getattr(cur_spin, mo_param)
296 print(cur_spin.model, res_name, cur_spin_id, mo_param, val, should_be)
297 self.assertAlmostEqual(val, should_be)
298
299
300
301 self.assertAlmostEqual(cur_spin.chi2, 0.0, places = places)
302
303
305 """Set up the data for the test_r1rho_kjaergaard_*() system tests."""
306
307
308 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'Kjaergaard_et_al_2013'
309
310
311 ds.pipe_name = 'base pipe'
312 ds.pipe_bundle = 'relax_disp'
313 ds.pipe_type = 'relax_disp'
314
315
316 self.interpreter.pipe.create(pipe_name=ds.pipe_name, bundle=ds.pipe_bundle, pipe_type=ds.pipe_type)
317
318
319 self.interpreter.spectrum.read_spins(file='1_0_46_0_max_standard.ser', dir=data_path+sep+'peak_lists')
320
321
322 self.interpreter.spin.isotope(isotope='15N')
323
324
325 NR_exp = 70
326
327
328 expfile = open(data_path+sep+'exp_parameters_sort.txt', 'r')
329 expfileslines = expfile.readlines()[:NR_exp]
330 expfile.close()
331
332
333 yOBS = 81.050
334
335 yCAR = 118.078
336 centerPPM_N15 = yCAR
337
338
339 self.interpreter.chemical_shift.read(file='1_0_46_0_max_standard.ser', dir=data_path+sep+'peak_lists')
340
341
342 spin_lock_field_strengths_Hz = {'35': 431.0, '39': 651.2, '41': 800.5, '43': 984.0, '46': 1341.11, '48': 1648.5}
343
344
345
346 j = 0
347 for i in range(len(expfileslines)):
348 line = expfileslines[i]
349 if line[0] == "#":
350 continue
351 else:
352
353 DIRN = line.split()[0]
354 I = int(line.split()[1])
355 deltadof2 = line.split()[2]
356 dpwr2slock = line.split()[3]
357 ncyc = int(line.split()[4])
358 trim = float(line.split()[5])
359 ss = int(line.split()[6])
360 set_sfrq = float(line.split()[7])
361 apod_rmsd = float(line.split()[8])
362 spin_lock_field_strength = spin_lock_field_strengths_Hz[dpwr2slock]
363
364
365 time_sl = 2*ncyc*trim
366
367
368 FNAME = "%s_%s_%s_%s_max_standard.ser"%(I, deltadof2, dpwr2slock, ncyc)
369 sp_id = "%s_%s_%s_%s"%(I, deltadof2, dpwr2slock, ncyc)
370
371
372 self.interpreter.spectrum.read_intensities(file=FNAME, dir=data_path+sep+'peak_lists', spectrum_id=sp_id, int_method='height')
373
374
375 self.interpreter.spectrum.baseplane_rmsd(error=apod_rmsd, spectrum_id=sp_id)
376
377
378 self.interpreter.relax_disp.exp_type(spectrum_id=sp_id, exp_type='R1rho')
379
380
381 self.interpreter.relax_disp.spin_lock_field(spectrum_id=sp_id, field=spin_lock_field_strength)
382
383
384 frq_N15_Hz = yOBS * 1E6
385 offset_ppm_N15 = float(deltadof2) / frq_N15_Hz * 1E6
386 omega_rf_ppm = centerPPM_N15 + offset_ppm_N15
387
388
389 self.interpreter.relax_disp.spin_lock_offset(spectrum_id=sp_id, offset=omega_rf_ppm)
390
391
392 self.interpreter.relax_disp.relax_time(spectrum_id=sp_id, time=time_sl)
393
394
395 self.interpreter.spectrometer.frequency(id=sp_id, frq=set_sfrq, units='MHz')
396
397
398 j += 1
399
400
401 print("Testing the number of settings")
402 print("Number of settings iterations is: %s. Number of cdp.exp_type is: %s"%(i, len(cdp.exp_type)))
403 self.assertEqual(70, len(expfileslines))
404 self.assertEqual(69, j)
405 self.assertEqual(69, len(cdp.exp_type))
406
407
408 for curspin in cluster_ids:
409 print("Adding spin %s to cluster"%curspin)
410 self.interpreter.relax_disp.cluster('model_cluster', curspin)
411
412
413 for free_spin in cdp.clustering['free spins']:
414 print("Deselecting free spin %s"%free_spin)
415 self.interpreter.deselect.spin(spin_id=free_spin, change_all=False)
416
417
418
419
420
421 ds.ref = dict()
422 ds.ref[':13@N'] = [13, 'L13N-HN', 1.32394, 0.14687, 8.16007, 1.01237, 13193.82986, 2307.09152, 58703.06446, 22413.09854, 0.2261054135, 0.0863280812]
423 ds.ref[':15@N'] = [15, 'R15N-HN', 1.34428, 0.14056, 7.83256, 0.67559, 13193.82986, 2307.09152, 28688.33492, 13480.72253, 0.110498283, 0.051923428]
424 ds.ref[':16@N'] = [16, 'T16N-HN', 1.71514, 0.13651, 17.44216, 0.98583, 13193.82986, 2307.09152, 57356.77617, 21892.44205, 0.220919942, 0.084322679]
425 ds.ref[':25@N'] = [25, 'Q25N-HN', 1.82412, 0.15809, 9.09447, 2.09215, 13193.82986, 2307.09152, 143111.13431, 49535.80302, 0.5512182797, 0.1907960569]
426 ds.ref[':26@N'] = [26, 'Q26N-HN', 1.45746, 0.14127, 10.22801, 0.67116, 13193.82986, 2307.09152, 28187.06876, 13359.01615, 0.1085675662, 0.051454654]
427 ds.ref[':28@N'] = [28, 'Q28N-HN', 1.48095, 0.14231, 10.33552, 0.691, 13193.82986, 2307.09152, 30088.0686, 13920.25654, 0.1158896091, 0.0536163723]
428 ds.ref[':39@N'] = [39, 'L39N-HN', 1.46094, 0.14514, 8.02194, 0.84649, 13193.82986, 2307.09152, 44130.18538, 18104.55064, 0.1699753481, 0.0697329338]
429 ds.ref[':40@N'] = [40, 'M40N-HN', 1.21381, 0.14035, 12.19112, 0.81418, 13193.82986, 2307.09152, 41834.90493, 17319.92156, 0.1611346625, 0.0667107938]
430 ds.ref[':41@N'] = [41, 'A41N-HN', 1.29296, 0.14286, 9.29941, 0.66246, 13193.82986, 2307.09152, 26694.8921, 13080.66782, 0.1028201794, 0.0503825453]
431 ds.ref[':43@N'] = [43, 'F43N-HN', 1.33626, 0.14352, 12.73816, 1.17386, 13193.82986, 2307.09152, 70347.63797, 26648.30524, 0.2709565833, 0.1026407417]
432 ds.ref[':44@N'] = [44, 'I44N-HN', 1.28487, 0.1462, 12.70158, 1.52079, 13193.82986, 2307.09152, 95616.20461, 35307.79817, 0.3682830136, 0.1359943366]
433 ds.ref[':45@N'] = [45, 'K45N-HN', 1.59227, 0.14591, 9.54457, 0.95596, 13193.82986, 2307.09152, 53849.7826, 21009.89973, 0.2074121253, 0.0809234085]
434 ds.ref[':49@N'] = [49, 'A49N-HN', 1.38521, 0.14148, 4.44842, 0.88647, 13193.82986, 2307.09152, 40686.65286, 18501.20774, 0.1567119631, 0.07126073]
435 ds.ref[':52@N'] = [52, 'V52N-HN', 1.57531, 0.15042, 6.51945, 1.43418, 13193.82986, 2307.09152, 93499.92172, 33233.23039, 0.3601317693, 0.1280037656]
436 ds.ref[':53@N'] = [53, 'A53N-HN', 1.27214, 0.13823, 4.0705, 0.85485, 13193.82986, 2307.09152, 34856.18636, 17505.02393, 0.1342548725, 0.0674237488]
437
438 ds.guess = dict()
439 ds.guess[':13@N'] = [13, 'L13N-HN', 1.32394, 0.14687, 8.16007, 1.01237, 13193.82986, 2307.09152, 58703.06446, 22413.09854, 0.2261054135, 0.0863280812]
440 ds.guess[':15@N'] = [15, 'R15N-HN', 1.34428, 0.14056, 7.83256, 0.67559, 13193.82986, 2307.09152, 28688.33492, 13480.72253, 0.110498283, 0.051923428]
441 ds.guess[':16@N'] = [16, 'T16N-HN', 1.71514, 0.13651, 17.44216, 0.98583, 13193.82986, 2307.09152, 57356.77617, 21892.44205, 0.220919942, 0.084322679]
442 ds.guess[':25@N'] = [25, 'Q25N-HN', 1.82412, 0.15809, 9.09447, 2.09215, 13193.82986, 2307.09152, 143111.13431, 49535.80302, 0.5512182797, 0.1907960569]
443 ds.guess[':26@N'] = [26, 'Q26N-HN', 1.45746, 0.14127, 10.22801, 0.67116, 13193.82986, 2307.09152, 28187.06876, 13359.01615, 0.1085675662, 0.051454654]
444 ds.guess[':28@N'] = [28, 'Q28N-HN', 1.48095, 0.14231, 10.33552, 0.691, 13193.82986, 2307.09152, 30088.0686, 13920.25654, 0.1158896091, 0.0536163723]
445 ds.guess[':39@N'] = [39, 'L39N-HN', 1.46094, 0.14514, 8.02194, 0.84649, 13193.82986, 2307.09152, 44130.18538, 18104.55064, 0.1699753481, 0.0697329338]
446 ds.guess[':40@N'] = [40, 'M40N-HN', 1.21381, 0.14035, 12.19112, 0.81418, 13193.82986, 2307.09152, 41834.90493, 17319.92156, 0.1611346625, 0.0667107938]
447 ds.guess[':41@N'] = [41, 'A41N-HN', 1.29296, 0.14286, 9.29941, 0.66246, 13193.82986, 2307.09152, 26694.8921, 13080.66782, 0.1028201794, 0.0503825453]
448 ds.guess[':43@N'] = [43, 'F43N-HN', 1.33626, 0.14352, 12.73816, 1.17386, 13193.82986, 2307.09152, 70347.63797, 26648.30524, 0.2709565833, 0.1026407417]
449 ds.guess[':44@N'] = [44, 'I44N-HN', 1.28487, 0.1462, 12.70158, 1.52079, 13193.82986, 2307.09152, 95616.20461, 35307.79817, 0.3682830136, 0.1359943366]
450 ds.guess[':45@N'] = [45, 'K45N-HN', 1.59227, 0.14591, 9.54457, 0.95596, 13193.82986, 2307.09152, 53849.7826, 21009.89973, 0.2074121253, 0.0809234085]
451 ds.guess[':49@N'] = [49, 'A49N-HN', 1.38521, 0.14148, 4.44842, 0.88647, 13193.82986, 2307.09152, 40686.65286, 18501.20774, 0.1567119631, 0.07126073]
452 ds.guess[':52@N'] = [52, 'V52N-HN', 1.57531, 0.15042, 6.51945, 1.43418, 13193.82986, 2307.09152, 93499.92172, 33233.23039, 0.3601317693, 0.1280037656]
453 ds.guess[':53@N'] = [53, 'A53N-HN', 1.27214, 0.13823, 4.0705, 0.85485, 13193.82986, 2307.09152, 34856.18636, 17505.02393, 0.1342548725, 0.0674237488]
454
455
456 for spin, spin_id in spin_loop(return_id=True):
457 if spin_id in cluster_ids:
458 print("spin_id %s in cluster ids"%(spin_id))
459 spin.kex = ds.guess[spin_id][6]
460 spin.phi_ex = ds.guess[spin_id][10]
461 else:
462 print("spin_id %s NOT in cluster ids"%(spin_id))
463
464 if read_R1:
465
466 self.interpreter.relax_data.read(ri_id='R1', ri_type='R1', frq=cdp.spectrometer_frq_list[0], file='R1_fitted_values.txt', dir=data_path, mol_name_col=1, res_num_col=2, res_name_col=3, spin_num_col=4, spin_name_col=5, data_col=6, error_col=7)
467
468
501
502
530
531
533 """Set up the data for the test_korzhnev_2005_data_*() system tests using the 'NS MMQ 2-site' model.
534
535 This loads the proton-heteronuclear SQ, ZQ, DQ, and MQ (MMQ) data from:
536
537 - Dmitry M. Korzhnev, Philipp Neudecker, Anthony Mittermaier, Vladislav Yu. Orekhov, and Lewis E. Kay (2005) Multiple-site exchange in proteins studied with a suite of six NMR relaxation dispersion experiments: An application to the folding of a Fyn SH3 domain mutant. 127, 15602-15611 (U{DOI: 10.1021/ja054550e<http://dx.doi.org/10.1021/ja054550e>}).
538
539 It consists of the 1H SQ, 15N SQ, ZQ, DQ, 1H MQ and 15N MQ data for residue Asp 9 of the Fyn SH3 domain mutant.
540
541
542 @keyword data_list: The list of data to load. It can contain 'SQ', '1H SQ', 'ZQ', 'DQ', 'MQ', and '1H MQ'.
543 @type data_list: list of str
544 """
545
546
547 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'Korzhnev_et_al_2005'
548 self.interpreter.pipe.create(pipe_name='Korzhnev et al., 2005', pipe_type='relax_disp')
549
550
551 self.interpreter.spin.create(res_name='Asp', res_num=9, spin_name='H')
552 self.interpreter.spin.create(res_name='Asp', res_num=9, spin_name='N')
553 self.interpreter.spin.element('H', spin_id='@H')
554 self.interpreter.spin.element('N', spin_id='@N')
555 self.interpreter.spin.isotope('1H', spin_id='@H')
556 self.interpreter.spin.isotope('15N', spin_id='@N')
557
558
559 self.interpreter.interatom.define(spin_id1=':9@N', spin_id2=':9@H', direct_bond=True)
560
561
562 data = [
563 ['1H SQ', '1H_SQ_CPMG_500_MHz', 'hs_500.res', EXP_TYPE_CPMG_PROTON_SQ, ':9@H', 500e6, 0.03],
564 ['1H SQ', '1H_SQ_CPMG_600_MHz', 'hs_600.res', EXP_TYPE_CPMG_PROTON_SQ, ':9@H', 600e6, 0.03],
565 ['1H SQ', '1H_SQ_CPMG_800_MHz', 'hs_800.res', EXP_TYPE_CPMG_PROTON_SQ, ':9@H', 800e6, 0.03],
566 ['SQ', '15N_SQ_CPMG_500_MHz', 'ns_500.res', EXP_TYPE_CPMG_SQ, ':9@N', 500e6, 0.04],
567 ['SQ', '15N_SQ_CPMG_600_MHz', 'ns_600.res', EXP_TYPE_CPMG_SQ, ':9@N', 600e6, 0.04],
568 ['SQ', '15N_SQ_CPMG_800_MHz', 'ns_800.res', EXP_TYPE_CPMG_SQ, ':9@N', 800e6, 0.04],
569 ['DQ', '15N_DQ_CPMG_500_MHz', 'dq_500.res', EXP_TYPE_CPMG_DQ, ':9@N', 500e6, 0.03],
570 ['DQ', '15N_DQ_CPMG_600_MHz', 'dq_600.res', EXP_TYPE_CPMG_DQ, ':9@N', 600e6, 0.03],
571 ['DQ', '15N_DQ_CPMG_800_MHz', 'dq_800.res', EXP_TYPE_CPMG_DQ, ':9@N', 800e6, 0.03],
572 ['ZQ', '15N_ZQ_CPMG_500_MHz', 'zq_500.res', EXP_TYPE_CPMG_ZQ, ':9@N', 500e6, 0.03],
573 ['ZQ', '15N_ZQ_CPMG_600_MHz', 'zq_600.res', EXP_TYPE_CPMG_ZQ, ':9@N', 600e6, 0.03],
574 ['ZQ', '15N_ZQ_CPMG_800_MHz', 'zq_800.res', EXP_TYPE_CPMG_ZQ, ':9@N', 800e6, 0.03],
575 ['1H MQ', '1H_MQ_CPMG_500_MHz', 'hm_500.res', EXP_TYPE_CPMG_PROTON_MQ, ':9@H', 500e6, 0.02],
576 ['1H MQ', '1H_MQ_CPMG_600_MHz', 'hm_600.res', EXP_TYPE_CPMG_PROTON_MQ, ':9@H', 600e6, 0.02],
577 ['1H MQ', '1H_MQ_CPMG_800_MHz', 'hm_800.res', EXP_TYPE_CPMG_PROTON_MQ, ':9@H', 800e6, 0.02],
578 ['MQ', '15N_MQ_CPMG_500_MHz', 'nm_500.res', EXP_TYPE_CPMG_MQ, ':9@N', 500e6, 0.02],
579 ['MQ', '15N_MQ_CPMG_600_MHz', 'nm_600.res', EXP_TYPE_CPMG_MQ, ':9@N', 600e6, 0.02],
580 ['MQ', '15N_MQ_CPMG_800_MHz', 'nm_800.res', EXP_TYPE_CPMG_MQ, ':9@N', 800e6, 0.02]
581 ]
582 cpmg_frqs_1h_sq = [67.0, 133.0, 267.0, 400.0, 533.0, 667.0, 800.0, 933.0, 1067.0, 1600.0, 2133.0, 2667.0]
583 cpmg_frqs_sq = [50.0, 100.0, 150.0, 200.0, 250.0, 300.0, 350.0, 400.0, 450.0, 500.0, 600.0, 700.0, 800.0, 900.0, 1000.0]
584 cpmg_frqs_dq = [33.0, 67.0, 133.0, 200.0, 267.0, 333.0, 400.0, 467.0, 533.0, 667.0, 800.0, 933.0, 1067.0]
585 cpmg_frqs_zq = [33.0, 67.0, 133.0, 200.0, 267.0, 333.0, 400.0, 467.0, 533.0, 667.0, 800.0, 933.0, 1067.0]
586 cpmg_frqs_1h_mq = [50.0, 100.0, 150.0, 200.0, 250.0, 300.0, 400.0, 500.0, 600.0, 700.0, 800.0, 1000.0, 1500.0, 2000.0, 2500.0]
587 cpmg_frqs_mq = [50.0, 100.0, 150.0, 200.0, 250.0, 300.0, 350.0, 400.0, 500.0, 600.0, 700.0, 800.0, 900.0, 1000.0]
588
589
590 for data_type, id, file, exp_type, spin_id, H_frq, relax_time in data:
591
592 if data_type not in data_list:
593 continue
594
595
596 if data_type == 'SQ':
597 cpmg_frqs = cpmg_frqs_sq
598 elif data_type == '1H SQ':
599 cpmg_frqs = cpmg_frqs_1h_sq
600 elif data_type == 'DQ':
601 cpmg_frqs = cpmg_frqs_dq
602 elif data_type == 'ZQ':
603 cpmg_frqs = cpmg_frqs_zq
604 elif data_type == '1H MQ':
605 cpmg_frqs = cpmg_frqs_1h_mq
606 elif data_type == 'MQ':
607 cpmg_frqs = cpmg_frqs_mq
608
609
610 for cpmg_frq in cpmg_frqs:
611
612 new_id = "%s_%s" % (id, cpmg_frq)
613
614
615 self.interpreter.spectrometer.frequency(id=new_id, frq=H_frq)
616
617
618 self.interpreter.relax_disp.exp_type(spectrum_id=new_id, exp_type=exp_type)
619
620
621 self.interpreter.relax_disp.relax_time(spectrum_id=new_id, time=relax_time)
622
623
624 self.interpreter.relax_disp.cpmg_setup(spectrum_id=new_id, cpmg_frq=cpmg_frq)
625
626
627 self.interpreter.relax_disp.r2eff_read_spin(id=id, file=file, dir=data_path, spin_id=spin_id, disp_point_col=1, data_col=2, error_col=3)
628
629
630 self.interpreter.relax_disp.select_model('NS MMQ 2-site')
631
632
633 - def setup_sod1wt_t25(self, pipe_name, pipe_type, pipe_name_r2eff, select_spin_index):
634 """Setup of data SOD1-WT CPMG. From paper at U{http://dx.doi.org/10.1073/pnas.0907387106}.
635
636 Optimisation of Kaare Teilum, Melanie H. Smith, Eike Schulz, Lea C. Christensen, Gleb Solomentseva, Mikael Oliveberg, and Mikael Akkea 2009
637 'SOD1-WT' CPMG data to the CR72 dispersion model.
638
639 This uses the data from paper at U{http://dx.doi.org/10.1073/pnas.0907387106}. This is CPMG data with a fixed relaxation time period recorded at fields of 500 and 600MHz.
640 Data is for experiment at 25 degree Celcius.
641 """
642
643
644 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'sod1wt_t25'
645
646
647 Exps = [
648 ["600MHz", "Z_A", 599.8908617*1E6, 0.06, [28, 0, 4, 32, 60, 2, 10, 16, 8, 20, 50, 18, 40, 6, 12, 0, 24], ["Z_A1", "Z_A15"] ],
649 ["500MHz", "Z_B", 499.862139*1E6, 0.04, [20, 0, 16, 10, 36, 2, 12, 4, 22, 18, 40, 14, 26, 8, 32, 24, 6, 28, 0], ["Z_B1", "Z_B18"] ] ]
650
651
652 self.interpreter.pipe.create(pipe_name=pipe_name, pipe_type=pipe_type)
653
654
655 id_lists = []
656 for folder, key, sfrq, time_T2, ncycs, rep_ncyss in Exps:
657
658 self.interpreter.spectrum.read_spins(file="128_FT.ser", dir=data_path+sep+folder)
659 self.interpreter.spectrum.read_spins(file="128_FT.ser", dir=data_path+sep+folder)
660
661
662 id_list = list(key+str(i) for i in range(len(ncycs)))
663 id_lists.append(id_list)
664
665
666 self.interpreter.spectrum.read_intensities(file="128_FT.ser", dir=data_path+sep+folder, int_method='height', spectrum_id=id_list, int_col=list(range(len(id_list))) )
667
668
669 for i in range(len(ncycs)):
670 ncyc = ncycs[i]
671 vcpmg = ncyc/time_T2
672
673
674 if float(vcpmg) == 0.0:
675 vcpmg = None
676 else:
677 vcpmg = round(float(vcpmg), 3)
678
679
680 current_id = id_list[i]
681
682
683 self.interpreter.relax_disp.exp_type(spectrum_id=current_id, exp_type='SQ CPMG')
684
685
686 self.interpreter.spectrometer.frequency(id=current_id, frq=sfrq, units='Hz')
687
688
689 self.interpreter.relax_disp.relax_time(spectrum_id=current_id, time=time_T2)
690
691
692 self.interpreter.relax_disp.cpmg_setup(spectrum_id=current_id, cpmg_frq=vcpmg)
693
694
695 self.interpreter.spectrum.replicated(spectrum_ids=Exps[0][5])
696 self.interpreter.spectrum.replicated(spectrum_ids=Exps[1][5])
697
698
699 self.interpreter.spectrum.error_analysis(subset=id_lists[0])
700 self.interpreter.spectrum.error_analysis(subset=id_lists[1])
701
702
703 self.interpreter.spin.isotope(isotope='15N')
704
705
706
707
708 glob_assn = ["G10N-H", "D11N-H", "Q15N-H", "G16N-H", "G37N-H", "G41N-H", "L42N-H", "H43N-H", "H46N-H", "V47N-H", "E49N-H",
709 "E50N-H", "E51N-H", "N53N-H", "T54N-H", "G56N-H", "C57N-H", "T58N-H", "G61N-H", "H63aN-H", "F64aN-H", "N65aN-H",
710 "L67N-H", "S68N-H", "K70N-H", "G72N-H", "G73N-H", "K75N-H", "E78N-H", "R79N-H", "H80N-H", "V81N-H", "G82N-H",
711 "G85N-H", "N86N-H", "V87N-H", "S102N-H", "V103N-H", "I104N-H", "S105N-H", "A111N-H", "I112N-H", "R115N-H",
712 "V118N-H", "E121N-H", "A123N-H", "L126N-H", "G127N-H", "K128N-H", "G129N-H", "G130N-H", "N131N-H", "E133N-H",
713 "S134N-H", "T135N-H", "T137N-H", "G138N-H", "N139N-H", "A140N-H", "G141N-H", "S142N-H", "R143N-H", "C146N-H", "G147N-H"]
714
715
716 self.assertEqual(64, len(glob_assn ))
717
718
719
720 r = re.compile("([a-zA-Z]+)([0-9]+)([a-zA-Z]+)")
721
722
723 relax_glob_ids = []
724
725
726 for assn in glob_assn:
727
728 m = r.match(assn)
729
730 relax_string = ":%s@%s"%(m.group(2), m.group(3))
731
732
733 relax_glob_ids.append([m.group(0), m.group(1), m.group(2), m.group(3), relax_string])
734
735
736
737
738 self.interpreter.deselect.all()
739
740
741 for i in select_spin_index:
742 self.interpreter.select.spin(spin_id=relax_glob_ids[i][4], change_all=False)
743
744
745
746
747 self.interpreter.pipe.copy(pipe_from=pipe_name, pipe_to=pipe_name_r2eff)
748 self.interpreter.pipe.switch(pipe_name=pipe_name_r2eff)
749
750
751 MODEL = "R2eff"
752 self.interpreter.relax_disp.select_model(model=MODEL)
753
754 self.interpreter.minimise.calculate(verbosity=1)
755
756
758 """Function for setting up a few spins for the given pipe."""
759
760
761 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'Kjaergaard_et_al_2013'
762
763
764 file = open(data_path+sep+'R1_fitted_values.txt')
765 lines = file.readlines()
766 file.close()
767
768 for i, line in enumerate(lines):
769
770 line_split = line.split()
771
772 if line_split[0] == "#":
773 continue
774
775 mol_name = line_split[0]
776 mol_name = None
777 res_num = int(line_split[1])
778 res_name = line_split[2]
779 spin_num = line_split[3]
780 spin_num = None
781 spin_name = line_split[4]
782
783
784 self.interpreter.spin.create(spin_name=spin_name, spin_num=spin_num, res_name=res_name, res_num=res_num, mol_name=mol_name)
785
786
788 """This setup the truncated private data which was provided by Paul Schanda."""
789
790
791 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'Paul_Schanda_2015_Nov'
792 file = data_path + sep + '1_prepare_data.py'
793
794
795 status.outdir = outdir
796
797
798 self.interpreter.script(file=file, dir=None)
799
800
802 """Setup data for the test of relaxation dispersion 'NS R1rho 2-site' model fitting against the 'TP02' test data."""
803
804
805 self.interpreter.reset()
806
807
808 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'r1rho_off_res_tp02'
809 self.interpreter.state.load(data_path+sep+'r2eff_values')
810
811
812 model = 'NS R1rho 2-site'
813 pipe_name = "%s - relax_disp" % model
814 self.interpreter.pipe.copy(pipe_from='base pipe', pipe_to=pipe_name, bundle_to='relax_disp')
815 self.interpreter.pipe.switch(pipe_name=pipe_name)
816
817
818 self.interpreter.relax_disp.select_model(model=model)
819
820
821 self.interpreter.value.copy(pipe_from='R2eff', pipe_to=pipe_name, param='r2eff')
822
823
824 spin1 = cdp.mol[0].res[0].spin[0]
825 spin2 = cdp.mol[0].res[1].spin[0]
826
827
828 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_R1RHO, frq=500e6)
829 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_R1RHO, frq=800e6)
830
831
832 spin1.r2 = {r20_key1: 9.9963793866185, r20_key2: 15.0056724422684}
833 spin1.pA = 0.779782428085762
834 spin1.dw = 7.57855284496424
835 spin1.kex = 1116.7911285203
836 spin2.r2 = {r20_key1: 11.9983346935434, r20_key2: 18.0076097513337}
837 spin2.pA = 0.826666229688602
838 spin2.dw = 9.5732624231366
839 spin2.kex = 1380.46162655657
840
841
842 if clustering:
843 self.interpreter.relax_disp.cluster(cluster_id='all', spin_id=":1-100")
844
845
846 self.interpreter.minimise.execute(min_algor='simplex', line_search=None, hessian_mod=None, hessian_type=None, func_tol=1e-05, grad_tol=None, max_iter=1000, constraints=True, scaling=True, verbosity=1)
847
848
849 print("\n\nOptimised parameters:\n")
850 print("%-20s %-20s %-20s" % ("Parameter", "Value (:1)", "Value (:2)"))
851 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin1.r2[r20_key1], spin2.r2[r20_key1]))
852 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin1.r2[r20_key2], spin2.r2[r20_key2]))
853 print("%-20s %20.15g %20.15g" % ("pA", spin1.pA, spin2.pA))
854 print("%-20s %20.15g %20.15g" % ("dw", spin1.dw, spin2.dw))
855 print("%-20s %20.15g %20.15g" % ("kex", spin1.kex, spin2.kex))
856 print("%-20s %20.15g %20.15g\n" % ("chi2", spin1.chi2, spin2.chi2))
857
858
860 """Test synthetic data of Andrew J. Baldwin B14 model whereby the simplification R20A = R20B is assumed.
861
862 Support requst sr #3154 U{https://web.archive.org/web/https://gna.org/support/index.php?3154}.
863
864 This uses the synthetic data from paper U{DOI: 10.1016/j.jmr.2014.02.023 <http://dx.doi.org/10.1016/j.jmr.2014.02.023>} with R20A, R20B = 2. rad/s.
865 """
866
867
868 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'Baldwin_2014'
869
870
871 pipe_name = 'base pipe'
872 pipe_type = 'relax_disp'
873 pipe_name_r2eff = "%s_R2eff"%(pipe_name)
874
875
876 self.interpreter.pipe.create(pipe_name=pipe_name, pipe_type=pipe_type)
877
878
879 self.interpreter.spin.create(res_name='Ala', res_num=1, spin_name='H')
880
881
882 self.interpreter.spin.isotope('1H', spin_id='@H')
883
884
885
886 ncycs = [2, 4, 8, 10, 20, 40, 500]
887 ids = []
888 for ncyc in ncycs:
889 ids.append('CPMG_%s' % ncyc)
890
891 print("\n\nThe experiment IDs are %s." % ids)
892
893
894
895 sfrq = 200. * 1E6
896
897
898 Trelax = 0.04
899
900
901 for i in range(len(ids)):
902 id = ids[i]
903
904 self.interpreter.spectrometer.frequency(id=id, frq=sfrq)
905
906
907 self.interpreter.relax_disp.exp_type(spectrum_id=id, exp_type='SQ CPMG')
908
909
910 self.interpreter.relax_disp.relax_time(spectrum_id=id, time=Trelax)
911
912
913 ncyc = ncycs[i]
914 nu_cpmg = ncyc / Trelax
915 self.interpreter.relax_disp.cpmg_setup(spectrum_id=id, cpmg_frq=nu_cpmg)
916
917
918 self.interpreter.pipe.copy(pipe_from=pipe_name, pipe_to=pipe_name_r2eff)
919 self.interpreter.pipe.switch(pipe_name=pipe_name_r2eff)
920
921
922 self.interpreter.relax_disp.r2eff_read_spin(id="CPMG", file="test_r2a_eq_r2b_w_error.out", dir=data_path, spin_id=':1@H', disp_point_col=1, data_col=2, error_col=3)
923
924
925 data = [
926 ['cpmg_frqs', {'CPMG_20': 500.0, 'CPMG_10': 250.0, 'CPMG_40': 1000.0, 'CPMG_4': 100.0, 'CPMG_2': 50.0, 'CPMG_500': 12500.0, 'CPMG_8': 200.0}],
927 ['cpmg_frqs_list', list(array(ncycs)/Trelax) ],
928 ['dispersion_points', len(ncycs)],
929 ['exp_type', {'CPMG_20': 'SQ CPMG', 'CPMG_10': 'SQ CPMG', 'CPMG_40': 'SQ CPMG', 'CPMG_4': 'SQ CPMG', 'CPMG_2': 'SQ CPMG', 'CPMG_500': 'SQ CPMG', 'CPMG_8': 'SQ CPMG'}],
930 ['exp_type_list', ['SQ CPMG']],
931 ['spectrometer_frq', {'CPMG_20': 200000000.0, 'CPMG_10': 200000000.0, 'CPMG_40': 200000000.0, 'CPMG_4': 200000000.0, 'CPMG_2': 200000000.0, 'CPMG_500': 200000000.0, 'CPMG_8': 200000000.0}],
932 ['spectrometer_frq_count', 1],
933 ['spectrometer_frq_list', [sfrq]],
934 ['spectrum_ids', ['CPMG_2', 'CPMG_4', 'CPMG_8', 'CPMG_10', 'CPMG_20', 'CPMG_40', 'CPMG_500']]
935 ]
936 for name, value in data:
937
938 self.assert_(hasattr(cdp, name))
939
940
941 obj = getattr(cdp, name)
942 if not isinstance(data, dict):
943 self.assertEqual(obj, value)
944
945
946 else:
947 for id in ids:
948 self.assertEqual(obj[id], value[id])
949
950
951 n_data = [
952 [ 50.000000, 10.367900, 0.1],
953 [ 100.000000, 10.146849, 0.1],
954 [ 200.000000, 9.765987, 0.1],
955 [ 250.000000, 9.409789, 0.1],
956 [ 500.000000, 5.829819, 0.1],
957 [ 1000.000000, 3.191928, 0.1],
958 [ 12500.000000, 2.008231, 0.1]
959 ]
960 for disp_point, value, error in n_data:
961 id = 'sq_cpmg_200.00000000_0.000_%.3f' % disp_point
962 self.assertEqual(cdp.mol[0].res[0].spin[0].r2eff[id], value)
963 self.assertEqual(cdp.mol[0].res[0].spin[0].r2eff_err[id], error)
964
965
966 r20_key = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=sfrq)
967
968
969 MODEL = "B14"
970
971
972 pipe_name_MODEL = "%s_%s"%(pipe_name, MODEL)
973 self.interpreter.pipe.copy(pipe_from=pipe_name_r2eff, pipe_to=pipe_name_MODEL)
974 self.interpreter.pipe.switch(pipe_name=pipe_name_MODEL)
975
976
977 self.interpreter.relax_disp.select_model(model=MODEL)
978
979
980 grid_results = []
981 mini_results = []
982
983
984
985
986 GRID = 13
987
988 if GRID:
989
990
991 self.interpreter.relax_disp.r20_from_min_r2eff(force=False)
992
993
994 self.interpreter.minimise.grid_search(lower=None, upper=None, inc=GRID, constraints=True, verbosity=1)
995
996
997 else:
998 for param in MODEL_PARAMS[MODEL]:
999 self.interpreter.value.set(param=param, index=None)
1000
1001 self.interpreter.minimise.grid_search(lower=None, upper=None, inc=1, constraints=True, verbosity=1)
1002
1003
1004 for spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
1005 grid_results.append([spin.r2[r20_key], spin.dw, spin.pA, spin.kex, spin.chi2, spin_id, resi, resn])
1006
1007
1008
1009 set_func_tol = 1e-10
1010 set_max_iter = 1000
1011 self.interpreter.minimise.execute(min_algor='simplex', func_tol=set_func_tol, max_iter=set_max_iter, constraints=True, scaling=True, verbosity=1)
1012
1013
1014 for spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
1015 mini_results.append([spin.r2[r20_key], spin.dw, spin.pA, spin.kex, spin.chi2, spin_id, resi, resn])
1016
1017
1018 for i in range(len(grid_results)):
1019 g_r2, g_dw, g_pA, g_kex, g_chi2, g_spin_id, g_resi, g_resn = grid_results[i]
1020 m_r2, m_dw, m_pA, m_kex, m_chi2, m_spin_id, m_resi, m_resn = mini_results[i]
1021 print("GRID %s r2=%2.4f dw=%1.4f pA=%1.4f kex=%3.4f chi2=%3.4f spin_id=%s resi=%i resn=%s"%(g_spin_id, g_r2, g_dw, g_pA, g_kex, g_chi2, g_spin_id, g_resi, g_resn))
1022 print("MIN %s r2=%2.4f dw=%1.4f pA=%1.4f kex=%3.4f chi2=%3.4f spin_id=%s resi=%i resn=%s"%(m_spin_id, m_r2, m_dw, m_pA, m_kex, m_chi2, m_spin_id, m_resi, m_resn))
1023
1024
1025
1026 kex = 1000.
1027
1028 pb = 0.01
1029
1030 dw_ppm = 2.
1031
1032 R2g = 2.
1033
1034 R2e = 2.
1035
1036
1037
1038 self.assertAlmostEqual(cdp.mol[0].res[0].spin[0].r2[r20_key], R2g, 6)
1039
1040 self.assertAlmostEqual(cdp.mol[0].res[0].spin[0].dw, dw_ppm, 6)
1041 self.assertAlmostEqual(cdp.mol[0].res[0].spin[0].pA, 1-pb, 8)
1042 self.assertAlmostEqual(cdp.mol[0].res[0].spin[0].kex, kex, 3)
1043
1044
1046 """Test synthetic data of Andrew J. Baldwin B14 model. Support requst sr #3154 U{https://web.archive.org/web/https://gna.org/support/index.php?3154}.
1047
1048 This uses the synthetic data from paper U{DOI: 10.1016/j.jmr.2014.02.023 <http://dx.doi.org/10.1016/j.jmr.2014.02.023>}.
1049 """
1050
1051
1052 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'Baldwin_2014'
1053
1054
1055 pipe_name = 'base pipe'
1056 pipe_type = 'relax_disp'
1057 pipe_name_r2eff = "%s_R2eff"%(pipe_name)
1058
1059
1060 self.interpreter.pipe.create(pipe_name=pipe_name, pipe_type=pipe_type)
1061
1062
1063
1064 self.interpreter.spin.create(res_name='Ala', res_num=1, spin_name='H')
1065
1066
1067 self.interpreter.spin.isotope('1H', spin_id='@H')
1068
1069
1070
1071 ncycs = [2, 4, 8, 10, 20, 40, 500]
1072 ids = []
1073 for ncyc in ncycs:
1074 ids.append('CPMG_%s' % ncyc)
1075
1076 print("\n\nThe experiment IDs are %s." % ids)
1077
1078
1079
1080 sfrq = 200. * 1E6
1081
1082
1083 Trelax = 0.04
1084
1085
1086 for i in range(len(ids)):
1087 id = ids[i]
1088
1089 self.interpreter.spectrometer.frequency(id=id, frq=sfrq)
1090
1091
1092 self.interpreter.relax_disp.exp_type(spectrum_id=id, exp_type='SQ CPMG')
1093
1094
1095 self.interpreter.relax_disp.relax_time(spectrum_id=id, time=Trelax)
1096
1097
1098 ncyc = ncycs[i]
1099 nu_cpmg = ncyc / Trelax
1100 self.interpreter.relax_disp.cpmg_setup(spectrum_id=id, cpmg_frq=nu_cpmg)
1101
1102
1103 self.interpreter.pipe.copy(pipe_from=pipe_name, pipe_to=pipe_name_r2eff)
1104 self.interpreter.pipe.switch(pipe_name=pipe_name_r2eff)
1105
1106
1107 self.interpreter.relax_disp.r2eff_read_spin(id="CPMG", file="test_w_error.out", dir=data_path, spin_id=':1@H', disp_point_col=1, data_col=2, error_col=3)
1108
1109
1110 data = [
1111 ['cpmg_frqs', {'CPMG_20': 500.0, 'CPMG_10': 250.0, 'CPMG_40': 1000.0, 'CPMG_4': 100.0, 'CPMG_2': 50.0, 'CPMG_500': 12500.0, 'CPMG_8': 200.0}],
1112 ['cpmg_frqs_list', list(array(ncycs)/Trelax) ],
1113 ['dispersion_points', len(ncycs)],
1114 ['exp_type', {'CPMG_20': 'SQ CPMG', 'CPMG_10': 'SQ CPMG', 'CPMG_40': 'SQ CPMG', 'CPMG_4': 'SQ CPMG', 'CPMG_2': 'SQ CPMG', 'CPMG_500': 'SQ CPMG', 'CPMG_8': 'SQ CPMG'}],
1115 ['exp_type_list', ['SQ CPMG']],
1116 ['spectrometer_frq', {'CPMG_20': 200000000.0, 'CPMG_10': 200000000.0, 'CPMG_40': 200000000.0, 'CPMG_4': 200000000.0, 'CPMG_2': 200000000.0, 'CPMG_500': 200000000.0, 'CPMG_8': 200000000.0}],
1117 ['spectrometer_frq_count', 1],
1118 ['spectrometer_frq_list', [sfrq]],
1119 ['spectrum_ids', ['CPMG_2', 'CPMG_4', 'CPMG_8', 'CPMG_10', 'CPMG_20', 'CPMG_40', 'CPMG_500']]
1120 ]
1121 for name, value in data:
1122
1123 self.assert_(hasattr(cdp, name))
1124
1125
1126 obj = getattr(cdp, name)
1127 if not isinstance(data, dict):
1128 self.assertEqual(obj, value)
1129
1130
1131 else:
1132 for id in ids:
1133 self.assertEqual(obj[id], value[id])
1134
1135
1136 n_data = [
1137 [ 50.000000, 10.286255, 0.1],
1138 [ 100.000000, 10.073083, 0.1],
1139 [ 200.000000, 9.692746, 0.1],
1140 [ 250.000000, 9.382441, 0.1],
1141 [ 500.000000, 6.312396, 0.1],
1142 [ 1000.000000, 3.957029, 0.1],
1143 [ 12500.000000, 2.880420, 0.1]
1144 ]
1145 for disp_point, value, error in n_data:
1146 id = 'sq_cpmg_200.00000000_0.000_%.3f' % disp_point
1147 self.assertEqual(cdp.mol[0].res[0].spin[0].r2eff[id], value)
1148 self.assertEqual(cdp.mol[0].res[0].spin[0].r2eff_err[id], error)
1149
1150
1151 r20_key = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=sfrq)
1152
1153
1154 MODEL = "B14 full"
1155
1156
1157 pipe_name_MODEL = "%s_%s"%(pipe_name, MODEL)
1158 self.interpreter.pipe.copy(pipe_from=pipe_name_r2eff, pipe_to=pipe_name_MODEL)
1159 self.interpreter.pipe.switch(pipe_name=pipe_name_MODEL)
1160
1161
1162 self.interpreter.relax_disp.select_model(model=MODEL)
1163
1164
1165 grid_results = []
1166 mini_results = []
1167 clust_results = []
1168
1169
1170
1171
1172 GRID = 13
1173
1174 if GRID:
1175
1176
1177 self.interpreter.relax_disp.r20_from_min_r2eff(force=False)
1178
1179
1180 self.interpreter.minimise.grid_search(lower=None, upper=None, inc=GRID, constraints=True, verbosity=1)
1181
1182
1183 else:
1184 for param in MODEL_PARAMS[MODEL]:
1185 self.interpreter.value.set(param=param, index=None)
1186
1187 self.interpreter.minimise.grid_search(lower=None, upper=None, inc=1, constraints=True, verbosity=1)
1188
1189
1190 for spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
1191 grid_results.append([spin.r2a[r20_key], spin.r2b[r20_key], spin.dw, spin.pA, spin.kex, spin.chi2, spin_id, resi, resn])
1192
1193
1194
1195 set_func_tol = 1e-11
1196 set_max_iter = 10000
1197 self.interpreter.minimise.execute(min_algor='simplex', func_tol=set_func_tol, max_iter=set_max_iter, constraints=True, scaling=True, verbosity=1)
1198
1199
1200 for spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
1201 mini_results.append([spin.r2a[r20_key], spin.r2b[r20_key], spin.dw, spin.pA, spin.kex, spin.chi2, spin_id, resi, resn])
1202
1203 print("\n# Now print before and after minimisation-\n")
1204
1205
1206 for i in range(len(grid_results)):
1207 g_r2a, g_r2b, g_dw, g_pA, g_kex, g_chi2, g_spin_id, g_resi, g_resn = grid_results[i]
1208 m_r2a, m_r2b, m_dw, m_pA, m_kex, m_chi2, m_spin_id, m_resi, m_resn = mini_results[i]
1209 print("GRID %s r2a=%2.4f r2b=%2.4f dw=%1.4f pA=%1.4f kex=%3.4f chi2=%3.4f spin_id=%s resi=%i resn=%s"%(g_spin_id, g_r2a, g_r2b, g_dw, g_pA, g_kex, g_chi2, g_spin_id, g_resi, g_resn))
1210 print("MIN %s r2b=%2.4f r2b=%2.4f dw=%1.4f pA=%1.4f kex=%3.4f chi2=%3.4f spin_id=%s resi=%i resn=%s"%(m_spin_id, m_r2a, m_r2b, m_dw, m_pA, m_kex, m_chi2, m_spin_id, m_resi, m_resn))
1211
1212
1213
1214 kex = 1000.
1215
1216 pb = 0.01
1217
1218 dw_ppm = 2.
1219
1220 R2g = 2.
1221
1222 R2e = 100.
1223
1224
1225
1226 self.assertAlmostEqual(cdp.mol[0].res[0].spin[0].r2a[r20_key], R2g, 3)
1227 self.assertAlmostEqual(cdp.mol[0].res[0].spin[0].r2b[r20_key]/100, R2e/100, 3)
1228
1229 self.assertAlmostEqual(cdp.mol[0].res[0].spin[0].dw, dw_ppm, 6)
1230 self.assertAlmostEqual(cdp.mol[0].res[0].spin[0].pA, 1-pb, 6)
1231 self.assertAlmostEqual(cdp.mol[0].res[0].spin[0].kex/1000, kex/1000, 2)
1232
1233
1235 """U{Task #7858: <https://web.archive.org/web/https://gna.org/task/?7858>} Make it possible to submit CPMG experiments for BMRB.
1236 This uses CPMG data from:
1237 - Webb H, Tynan-Connolly BM, Lee GM, Farrell D, O'Meara F, Soendergaard CR, Teilum K, Hewage C, McIntosh LP, Nielsen JE.
1238 Remeasuring HEWL pK(a) values by NMR spectroscopy: methods, analysis, accuracy, and implications for theoretical pK(a) calculations.
1239 (2011), Proteins: Struct, Funct, Bioinf 79(3):685-702, DOI 10.1002/prot.22886
1240 """
1241
1242
1243 prev_data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'HWebb_KTeilum_Proteins_Struct_Funct_Bioinf_2011'
1244
1245
1246 self.interpreter.results.read(prev_data_path + sep + 'FT_-_CR72_-_min_-_128_-_free_spins')
1247
1248
1249 self.interpreter.spin.element(element='N', spin_id=':*@N', force=False)
1250
1251
1252 self.interpreter.molecule.name(mol_id=None, name='HEWL', force=True)
1253 self.interpreter.molecule.type(mol_id='#HEWL', type='protein', force=False)
1254
1255 for cur_spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
1256 print(spin_id)
1257 if resn == 'C':
1258 print(resi, resn)
1259
1260
1261
1262 self.interpreter.bmrb.thiol_state(state='not reported')
1263
1264
1265
1266
1267 self.interpreter.bmrb.display()
1268
1269
1271 """U{Bug #21081<https://web.archive.org/web/https://gna.org/bugs/?21081>} catch, the failure of a cluster analysis when spins are deselected."""
1272
1273
1274 self.interpreter.reset()
1275
1276
1277 state = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'saved_states'+sep+'bug_21081_disp_cluster_fail.bz2'
1278 self.interpreter.state.load(state, force=True)
1279
1280
1281 self.interpreter.model_selection(method='AIC', modsel_pipe='final', bundle='relax_disp', pipes=['No Rex', 'CR72'])
1282
1283
1285 """U{Bug #21460<https://web.archive.org/web/https://gna.org/bugs/?21460>} catch, the failure due to a spectrometer frequency having no relaxation data."""
1286
1287
1288 self.interpreter.reset()
1289
1290
1291 state = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'saved_states'+sep+'bug_21460_bad_fields.bz2'
1292 self.interpreter.state.load(state, force=True)
1293
1294
1295 relax_disp.Relax_disp.opt_func_tol = 1e-5
1296 relax_disp.Relax_disp.opt_max_iterations = 1000
1297 relax_disp.Relax_disp(pipe_name="origin - relax_disp (Thu Jan 2 13:46:44 2014)", pipe_bundle="relax_disp (Thu Jan 2 13:46:44 2014)", results_dir=self.tmpdir, models=['R2eff', 'No Rex', 'CR72', 'NS CPMG 2-site expanded'], grid_inc=3, mc_sim_num=5, modsel='AIC', pre_run_dir=None, insignificance=1.0, numeric_only=False, mc_sim_all_models=False, eliminate=True)
1298
1299
1301 """U{Bug #21665<https://web.archive.org/web/https://gna.org/bugs/?21344>} catch, the failure of an analysis of a sparse acquired R1rho dataset with missing combinations of time and spin-lock field strengths using auto_analysis."""
1302
1303
1304 self.interpreter.reset()
1305
1306
1307 state = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21344_trunc.bz2'
1308 self.interpreter.state.load(state, force=True)
1309
1310
1311 relax_disp.Relax_disp.opt_func_tol = 1e-5
1312 relax_disp.Relax_disp.opt_max_iterations = 1000
1313 relax_disp.Relax_disp(pipe_name='base pipe', pipe_bundle='relax_disp', results_dir=self.tmpdir, models=['R2eff'], grid_inc=3, mc_sim_num=5, modsel='AIC', pre_run_dir=None, insignificance=1.0, numeric_only=False, mc_sim_all_models=False, eliminate=True)
1314
1315
1317 """U{Bug #21665<https://web.archive.org/web/https://gna.org/bugs/?21665>} catch, the failure due to a a CPMG analysis recorded at two fields at two delay times, using minimise.calculate()."""
1318
1319
1320 self.interpreter.reset()
1321
1322
1323 state = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21665.bz2'
1324 self.interpreter.state.load(state, force=True)
1325
1326
1327 self.interpreter.minimise.calculate(verbosity=1)
1328
1329
1331 """U{Bug #21665<https://web.archive.org/web/https://gna.org/bugs/?21665>} catch, the failure due to a a CPMG analysis recorded at two fields at two delay times using auto_analysis."""
1332
1333
1334 self.interpreter.reset()
1335
1336
1337 state = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21665.bz2'
1338 self.interpreter.state.load(state, force=True)
1339
1340
1341 relax_disp.Relax_disp.opt_func_tol = 1e-5
1342 relax_disp.Relax_disp.opt_max_iterations = 1000
1343 relax_disp.Relax_disp(pipe_name="compare_128_FT_R2eff", pipe_bundle="cpmg_disp_sod1d90a", results_dir=self.tmpdir, models=['R2eff'], grid_inc=3, mc_sim_num=5, modsel='AIC', pre_run_dir=None, insignificance=1.0, numeric_only=False, mc_sim_all_models=False, eliminate=True)
1344
1345
1347 """Catch U{bug #21715<https://web.archive.org/web/https://gna.org/bugs/?21715>}, the failure of a clustered auto-analysis due to an IndexError."""
1348
1349
1350 self.interpreter.reset()
1351
1352
1353 state = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21715_clustered_indexerror'+sep+'state.bz2'
1354 self.interpreter.state.load(state, force=True)
1355
1356
1357 pre_run_dir = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21715_clustered_indexerror'+sep+'non_clustered'
1358 relax_disp.Relax_disp.opt_func_tol = 1e-5
1359 relax_disp.Relax_disp.opt_max_iterations = 1000
1360 relax_disp.Relax_disp(pipe_name='origin - relax_disp (Sun Feb 23 19:36:51 2014)', pipe_bundle='relax_disp (Sun Feb 23 19:36:51 2014)', results_dir=self.tmpdir, models=['R2eff', 'No Rex'], grid_inc=11, mc_sim_num=3, modsel='AIC', pre_run_dir=pre_run_dir, insignificance=1.0, numeric_only=True, mc_sim_all_models=False, eliminate=True)
1361
1362
1364 """Catch U{bug #22146<https://web.archive.org/web/https://gna.org/bugs/?22146>}, the failure of unpacking R2A and R2B, when performing a clustered B14 full analysis."""
1365
1366
1367 self.setup_bug_22146_unpacking_r2a_r2b_cluster(folder='B14_full', model_analyse = MODEL_B14_FULL)
1368
1369
1371 """Catch U{bug #22146<https://web.archive.org/web/https://gna.org/bugs/?22146>}, the failure of unpacking R2A and R2B, when performing a clustered CR72 full analysis."""
1372
1373
1374 self.setup_bug_22146_unpacking_r2a_r2b_cluster(folder='CR72_full', model_analyse = MODEL_CR72_FULL)
1375
1376
1382
1383
1389
1390
1392 """Catch U{bug #22146<https://web.archive.org/web/https://gna.org/bugs/?22477>}, the failure of issuing: grace.write(x_data_type='res_num', y_data_type=param) for a mixed CPMG analysis."""
1393
1394
1395 self.interpreter.reset()
1396
1397
1398 state = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_22477_grace_write_k_AB_mixed_analysis'+sep+'bug_22477_results.bz2'
1399 self.interpreter.state.load(state, force=True)
1400
1401 param = 'k_AB'
1402
1403 for spin, spin_id in spin_loop(return_id=True, skip_desel=True):
1404 print(spin_id, spin.params)
1405 if param in spin.params:
1406 print(spin_id, spin.k_AB, spin.k_AB_err)
1407
1408
1409 self.interpreter.grace.write(x_data_type='res_num', y_data_type=param, file='%s.agr'%param, dir=self.tmpdir, force=True)
1410
1411
1412
1413 param = 'r2'
1414 self.interpreter.value.write(param=param, file='%s.out'%param, dir=self.tmpdir, force=True)
1415
1416 file = open(self.tmpdir+sep+'%s.out'%param)
1417 lines = file.readlines()
1418 file.close()
1419
1420 for i, line in enumerate(lines):
1421
1422 line_split = line.split()
1423 print(line_split)
1424
1425 if len(line_split) > 1:
1426
1427 if line_split[0] == "#" and line_split[1] == 'mol_name':
1428 nr_split_header = len(line_split)
1429 nr_split_header_i = i
1430 break
1431
1432
1433 line_split_val = lines[nr_split_header_i + 1].split()
1434 print(line_split_val)
1435
1436
1437 self.assertEqual(nr_split_header, len(line_split_val) + 1)
1438
1439
1440 param = 'r2eff'
1441 self.interpreter.value.write(param=param, file='%s.out'%param, dir=self.tmpdir, force=True)
1442
1443 file = open(self.tmpdir+sep+'%s.out'%param)
1444 lines = file.readlines()
1445 file.close()
1446
1447 for i, line in enumerate(lines):
1448
1449 line_split = line.split()
1450 print(line_split)
1451
1452 if len(line_split) > 1:
1453
1454 if line_split[0] == "#" and line_split[1] == 'mol_name':
1455 nr_split_header = len(line_split)
1456 nr_split_header_i = i
1457 break
1458
1459
1460 line_split_val = lines[nr_split_header_i + 1].split()
1461 print(line_split_val)
1462
1463
1464 self.assertEqual(nr_split_header, len(line_split_val) + 1)
1465
1466
1468 """Catch U{bug #23186<https://web.archive.org/web/https://gna.org/bugs/?23186>}: Error calculation of individual parameter "dw" from Monte-Carlo, is based on first spin."""
1469
1470
1471 self.interpreter.reset()
1472
1473
1474 state = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_23186.bz2'
1475 self.interpreter.state.load(state, force=True)
1476
1477
1478 dickey = 'SQ CPMG - 599.89086220 MHz'
1479
1480
1481 resi_0_r2a = []
1482
1483
1484 res0 = cdp.mol[0].res[0].spin[0]
1485 res1 = cdp.mol[0].res[1].spin[0]
1486
1487 print("Chi2 before call to minimise: %3.3f"%res0.chi2)
1488 self.interpreter.minimise.execute(min_algor='simplex', max_iter=100000, verbosity=0)
1489 print("Chi2 after call to minimise: %3.3f"%res0.chi2)
1490
1491
1492 for cdic in res0.r2a_sim:
1493 resi_0_r2a.append(cdic[dickey])
1494
1495
1496 resi_0_r2a_std = std(asarray(resi_0_r2a), ddof=1)
1497
1498
1499 resi_86_r2a = []
1500
1501
1502 for cdic in res1.r2a_sim:
1503 resi_86_r2a.append(cdic[dickey])
1504
1505
1506 resi_86_r2a_std = std(asarray(resi_86_r2a), ddof=1)
1507
1508
1509
1510
1511 resi_0_dw = res0.dw_sim
1512 resi_86_dw = res1.dw_sim
1513
1514
1515 resi_0_dw_std = std(asarray(resi_0_dw), ddof=1)
1516 resi_86_dw_std = std(asarray(resi_86_dw), ddof=1)
1517
1518
1519
1520
1521 resi_0_kAB = res0.k_AB_sim
1522 resi_86_kAB = res1.k_AB_sim
1523
1524
1525 resi_0_kAB_std = std(asarray(resi_0_kAB), ddof=1)
1526 resi_86_kAB_std = std(asarray(resi_0_kAB), ddof=1)
1527
1528
1529 self.assertEqual(resi_0_kAB_std, resi_86_kAB_std)
1530
1531
1532 self.interpreter.monte_carlo.error_analysis()
1533
1534
1535 self.assertAlmostEqual(resi_0_kAB_std, res0.k_AB_err)
1536 self.assertAlmostEqual(resi_86_kAB_std, res1.k_AB_err)
1537
1538
1539 self.assertAlmostEqual(resi_0_r2a_std, res0.r2a_err[dickey])
1540 self.assertAlmostEqual(resi_86_r2a_std, res1.r2a_err[dickey])
1541
1542
1543 self.assertAlmostEqual(resi_0_dw_std, res0.dw_err)
1544 self.assertAlmostEqual(resi_86_dw_std, res1.dw_err)
1545
1546
1547
1548
1549
1550 self.interpreter.monte_carlo.setup(number=3)
1551 self.interpreter.monte_carlo.create_data(method='back_calc')
1552 self.interpreter.monte_carlo.initial_values()
1553
1554
1555 res0.r2eff_sim[0] = copy.copy(res0.r2eff)
1556 res0.r2eff_sim[1] = copy.copy(res0.r2eff)
1557 res0.r2eff_sim[2] = copy.copy(res0.r2eff)
1558 res1.r2eff_sim[0] = copy.copy(res1.r2eff)
1559 res1.r2eff_sim[1] = copy.copy(res1.r2eff)
1560 res1.r2eff_sim[2] = copy.copy(res1.r2eff)
1561
1562 self.interpreter.minimise.execute(min_algor='simplex', max_iter=100000)
1563 self.interpreter.monte_carlo.error_analysis()
1564
1565
1566 spin_chi2_mc = res0.chi2
1567 spin_chi2_mc_sim = res0.chi2_sim
1568 spin_chi2_mc_sim_ave = average(spin_chi2_mc_sim)
1569
1570 print("The chi2 from calculation is: %3.3f"%spin_chi2_mc)
1571 print("The array with monte-carlo chi2 values is: %s"%spin_chi2_mc_sim)
1572 print("The average of this array is: %3.3f"%spin_chi2_mc_sim_ave)
1573
1574 self.assertAlmostEqual(spin_chi2_mc, spin_chi2_mc_sim_ave, 7)
1575
1576
1578 """Catch U{bug #24601<https://web.archive.org/web/https://gna.org/bugs/?24601>}, the failure of optimisation of the 'R2eff' model with missing data."""
1579
1580
1581 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'r2eff_missing_data.py')
1582
1583
1585 """Catch U{bug #9999<https://web.archive.org/web/https://gna.org/bugs/?9999>}, The slow optimisation of R1rho R2eff error estimation with Monte Carlo simulations."""
1586
1587
1588 prev_data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'Kjaergaard_et_al_2013' +sep+ "check_graphs" +sep+ "mc_2000" +sep+ "R2eff"
1589
1590
1591 self.interpreter.results.read(prev_data_path + sep + 'results')
1592
1593
1594 graph_nr = 1
1595 for exp_type, frq, offset, point in loop_exp_frq_offset_point(return_indices=False):
1596 print("\nGraph nr %i" % graph_nr)
1597 for time in loop_time(exp_type=exp_type, frq=frq, offset=offset, point=point):
1598 print(exp_type, frq, offset, point, time)
1599 graph_nr += 1
1600
1601
1602
1603
1604 precalc = True
1605 for spin in spin_loop(skip_desel=True):
1606
1607 if not hasattr(spin, 'peak_intensity_err'):
1608 precalc = False
1609 break
1610
1611
1612 for id in cdp.spectrum_ids:
1613 if id not in spin.peak_intensity_err:
1614 precalc = False
1615 break
1616
1617
1618 if precalc:
1619 print("Skipping the error analysis as it has already been performed.")
1620
1621 else:
1622
1623 for frq in loop_frq():
1624
1625 ids = []
1626 for id in cdp.spectrum_ids:
1627
1628 match_frq = True
1629 if frq != None and cdp.spectrometer_frq[id] != frq:
1630 match_frq = False
1631
1632
1633 if match_frq:
1634 ids.append(id)
1635
1636
1637 self.interpreter.spectrum.error_analysis(subset=ids)
1638
1639 print("has_exponential_exp_type:", has_exponential_exp_type())
1640
1641 model = 'R2eff'
1642 self.interpreter.relax_disp.select_model(model)
1643
1644 for spin, spin_id in spin_loop(return_id=True, skip_desel=True):
1645
1646
1647
1648
1649 setattr(spin, 'r2eff', {})
1650 setattr(spin, 'r2eff_err', {})
1651 setattr(spin, 'i0', {})
1652 setattr(spin, 'i0_err', {})
1653
1654
1655 self.interpreter.minimise.grid_search(lower=None, upper=None, inc=21, constraints=True, verbosity=1)
1656
1657
1658 my_dic = {}
1659
1660
1661 NE = 0
1662 NS = 1
1663 NM = 0
1664 NO = 0
1665 ND = 0
1666 NT = 0
1667
1668 for exp_type, frq, offset, point, ei, mi, oi, di in loop_exp_frq_offset_point(return_indices=True):
1669
1670 if ei > NE:
1671 NE = ei
1672 if mi > NM:
1673 NM = mi
1674 if oi > NO:
1675 NO = oi
1676 if di > ND:
1677 ND = di
1678
1679 for time, ti in loop_time(exp_type=exp_type, frq=frq, offset=offset, point=point, return_indices=True):
1680
1681 if ti > NT:
1682 NT = ti
1683
1684
1685 NE = NE + 1
1686 NM = NM + 1
1687 NO = NO + 1
1688 ND = ND + 1
1689 NT = NT + 1
1690
1691
1692 values_arr = zeros([NE, NS, NM, NO, ND, NT])
1693 errors_arr = zeros([NE, NS, NM, NO, ND, NT])
1694 times_arr = zeros([NE, NS, NM, NO, ND, NT])
1695 struct_arr = zeros([NE, NS, NM, NO, ND, NT])
1696 param_key_list = []
1697
1698
1699
1700 for cur_spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
1701
1702 my_dic[spin_id] = {}
1703
1704
1705 spin_string = generate_spin_string(spin=cur_spin, mol_name=mol_name, res_num=resi, res_name=resn)
1706
1707
1708
1709
1710 for exp_type, frq, offset, point, ei, mi, oi, di in loop_exp_frq_offset_point(return_indices=True):
1711
1712 param_key = return_param_key_from_data(exp_type=exp_type, frq=frq, offset=offset, point=point)
1713
1714
1715 param_key_list.append(param_key)
1716
1717
1718 my_dic[spin_id][param_key] = {}
1719
1720
1721 R2eff_value = getattr(cur_spin, 'r2eff')[param_key]
1722 i0_value = getattr(cur_spin, 'i0')[param_key]
1723
1724
1725 my_dic[spin_id][param_key]['R2eff_value_grid'] = R2eff_value
1726 my_dic[spin_id][param_key]['i0_value_grid'] = i0_value
1727
1728
1729
1730 values = []
1731 errors = []
1732 times = []
1733 for time, ti in loop_time(exp_type=exp_type, frq=frq, offset=offset, point=point, return_indices=True):
1734 value = average_intensity(spin=cur_spin, exp_type=exp_type, frq=frq, offset=offset, point=point, time=time, sim_index=None)
1735 values.append(value)
1736
1737 error = average_intensity(spin=cur_spin, exp_type=exp_type, frq=frq, offset=offset, point=point, time=time, error=True)
1738 errors.append(error)
1739 times.append(time)
1740
1741
1742 values_arr[ei, 0, mi, oi, di, ti] = value
1743 errors_arr[ei, 0, mi, oi, di, ti] = error
1744 times_arr[ei, 0, mi, oi, di, ti] = time
1745 struct_arr[ei, 0, mi, oi, di, ti] = 1.0
1746
1747
1748
1749
1750 w = log(array(values))
1751 x = - array(times)
1752 n = len(times)
1753
1754 b = (sum(x*w) - 1./n * sum(x) * sum(w) ) / ( sum(x**2) - 1./n * (sum(x))**2 )
1755 a = 1./n * sum(w) - b * 1./n * sum(x)
1756 R2eff_est = b
1757 i0_est = exp(a)
1758
1759 my_dic[spin_id][param_key]['R2eff_est'] = R2eff_est
1760 my_dic[spin_id][param_key]['i0_est'] = i0_est
1761
1762
1763
1764
1765
1766
1767
1768 set_func_tol = 1e-25
1769 set_max_iter = int(1e7)
1770 self.interpreter.minimise.execute(min_algor='simplex', func_tol=set_func_tol, max_iter=set_max_iter, constraints=True, scaling=True, verbosity=1)
1771
1772
1773 for cur_spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
1774
1775 spin_string = generate_spin_string(spin=cur_spin, mol_name=mol_name, res_num=resi, res_name=resn)
1776
1777
1778 print("Optimised parameters for spin: %s" % (spin_string))
1779
1780 for exp_type, frq, offset, point in loop_exp_frq_offset_point():
1781
1782 param_key = return_param_key_from_data(exp_type=exp_type, frq=frq, offset=offset, point=point)
1783
1784
1785 R2eff_value = getattr(cur_spin, 'r2eff')[param_key]
1786 i0_value = getattr(cur_spin, 'i0')[param_key]
1787
1788
1789 R2eff_value_grid = my_dic[spin_id][param_key]['R2eff_value_grid']
1790 i0_value_grid = my_dic[spin_id][param_key]['i0_value_grid']
1791 R2eff_est = my_dic[spin_id][param_key]['R2eff_est']
1792 i0_est = my_dic[spin_id][param_key]['i0_est']
1793
1794
1795
1796
1797
1798 print("%-10s %-6s %-6s %3.1f : %3.1f: %3.1f" % ("Parameter:", 'R2eff', "Grid : Min : Estimated:", R2eff_value_grid, R2eff_value, R2eff_est))
1799 print("%-10s %-6s %-6s %3.1f : %3.1f: %3.1f" % ("Parameter:", 'i0', "Grid : Min : Estimated:", i0_value_grid, i0_value, i0_est))
1800
1801 print(NE, NS, NM, NO, ND, NT)
1802 for param_key in param_key_list:
1803 print(" '%s'," % param_key)
1804 print(values_arr.shape)
1805
1806
1807 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'curve_fitting'+sep+'profiling'+sep
1808
1809
1810
1811
1812
1813
1815 """Test data from Atul Srivastava. This is a bug missing raising a Relax Error, since the setup points to a situation where the data
1816 shows it is exponential fitting, but only one time point is added per file.
1817
1818 This follows: U{Thread <http://thread.gmane.org/gmane.science.nmr.relax.user/1718>}:
1819 This follows: U{Thread <http://thread.gmane.org/gmane.science.nmr.relax.user/1735>}:
1820 This follows: U{Thread <http://thread.gmane.org/gmane.science.nmr.relax.user/1735/focus=1736>}:
1821
1822 """
1823
1824
1825 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_Atul_Srivastava'
1826 file = data_path + sep + 'bug_script.py'
1827
1828
1829 self.interpreter.script(file=file, dir=None)
1830
1831
1832 GRID_INC = 11
1833
1834
1835
1836
1837
1838 for cur_spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
1839 print(mol_name, resi, resn, spin_id)
1840
1841
1842 for id in cdp.exp_type:
1843 print(id, cdp.exp_type[id], cdp.spectrometer_frq[id], cdp.spin_lock_offset[id], cdp.spin_lock_nu1[id])
1844
1845
1846
1847
1848 if True:
1849
1850 self.interpreter.relax_disp.select_model(MODEL_R2EFF)
1851
1852
1853 check_intensity_errors()
1854
1855
1856 if cdp.model_type == MODEL_R2EFF and not has_exponential_exp_type():
1857 self.interpreter.minimise.calculate()
1858
1859
1860 else:
1861 constraints = False
1862 min_algor = 'Newton'
1863 self.assertRaises(RelaxError, self.interpreter.minimise.grid_search, inc=GRID_INC)
1864 self.assertRaises(RelaxError, self.interpreter.minimise.execute, min_algor=min_algor, constraints=constraints)
1865
1866
1867 if False:
1868
1869 par_attr_list = ['r2eff', 'i0']
1870
1871
1872 my_dic = {}
1873 param_key_list = []
1874 est_keys = []
1875 est_key = 'grid'
1876 est_keys.append(est_key)
1877 spin_id_list = []
1878
1879 for cur_spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
1880
1881 my_dic[spin_id] = {}
1882
1883
1884 my_dic[spin_id][est_key] = {}
1885
1886
1887 spin_id_list.append(spin_id)
1888
1889
1890 spin_string = generate_spin_string(spin=cur_spin, mol_name=mol_name, res_num=resi, res_name=resn)
1891
1892 for exp_type, frq, offset, point, ei, mi, oi, di in loop_exp_frq_offset_point(return_indices=True):
1893
1894 param_key = return_param_key_from_data(exp_type=exp_type, frq=frq, offset=offset, point=point)
1895
1896
1897
1898 param_key_list.append(param_key)
1899
1900
1901 my_dic[spin_id][est_key][param_key] = {}
1902
1903
1904
1905 for par_attr in par_attr_list:
1906 if hasattr(cur_spin, par_attr):
1907 get_par_attr = getattr(cur_spin, par_attr)[param_key]
1908 else:
1909 get_par_attr = 0.0
1910
1911
1912 my_dic[spin_id][est_key][param_key][par_attr] = get_par_attr
1913
1914
1915 values = []
1916 errors = []
1917 times = []
1918 for time, ti in loop_time(exp_type=exp_type, frq=frq, offset=offset, point=point, return_indices=True):
1919 value = average_intensity(spin=cur_spin, exp_type=exp_type, frq=frq, offset=offset, point=point, time=time, sim_index=None)
1920 values.append(value)
1921
1922 error = average_intensity(spin=cur_spin, exp_type=exp_type, frq=frq, offset=offset, point=point, time=time, error=True)
1923 errors.append(error)
1924 times.append(time)
1925
1926
1927 my_dic[spin_id][est_key][param_key]['values'] = values
1928 my_dic[spin_id][est_key][param_key]['errors'] = errors
1929 my_dic[spin_id][est_key][param_key]['times'] = times
1930
1931
1932
1933
1934
1935 MODELS = ['R2eff', 'No Rex']
1936
1937
1938 MC_NUM = 10
1939
1940
1941 MC_SIM_ALL_MODELS = False
1942
1943
1944 RESULTS_DIR = ds.tmpdir
1945
1946
1947 PRE_RUN_DIR = None
1948
1949
1950 MODSEL = 'AIC'
1951
1952
1953 NUMERIC_ONLY = False
1954
1955
1956 INSIGNIFICANCE = 1.0
1957
1958
1959 self.assertRaises(RelaxError, relax_disp.Relax_disp, pipe_name='relax_disp', results_dir=RESULTS_DIR, models=MODELS, grid_inc=GRID_INC, mc_sim_num=MC_NUM, modsel=MODSEL, insignificance=INSIGNIFICANCE, numeric_only=NUMERIC_ONLY)
1960
1961
1963 """Test data, where peak intensities are negative in CPMG
1964
1965 This uses the data from paper at U{http://dx.doi.org/10.1073/pnas.0509100103}. This is CPMG data with a fixed relaxation time period. Experiment in 0.48 M GuHCl (guanidine hydrochloride).
1966 """
1967
1968 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'KTeilum_FMPoulsen_MAkke_2006'+sep+'bug_neg_int_acbp_cpmg_disp_048MGuHCl_40C_041223'
1969
1970
1971 self.interpreter.spectrum.read_spins(file="peaks_list_max_standard.ser", dir=data_path)
1972
1973
1974 self.interpreter.spin.isotope(isotope='15N')
1975
1976
1977 self.interpreter.spectrum.read_intensities(file="peaks_list_max_standard.ser", dir=data_path, spectrum_id='auto', int_method='height')
1978
1979
1980 ncycfile=open(data_path + sep + 'ncyc.txt', 'r')
1981
1982
1983 ncyclist = []
1984
1985 i = 0
1986 for line in ncycfile:
1987 ncyc = line.split()[0]
1988 time_T2 = float(line.split()[1])
1989 vcpmg = line.split()[2]
1990 set_sfrq = float(line.split()[3])
1991 rmsd_err = float(line.split()[4])
1992
1993
1994 if float(vcpmg) == 0.0:
1995 vcpmg = None
1996 else:
1997 vcpmg = round(float(vcpmg), 3)
1998
1999
2000 ncyclist.append(int(ncyc))
2001
2002
2003 current_id = "Z_A%s"%(i)
2004
2005
2006 self.interpreter.relax_disp.exp_type(spectrum_id=current_id, exp_type='SQ CPMG')
2007
2008
2009 self.interpreter.spectrum.baseplane_rmsd(error=rmsd_err, spectrum_id=current_id)
2010
2011
2012 self.interpreter.spectrometer.frequency(id=current_id, frq=set_sfrq, units='MHz')
2013
2014
2015 self.interpreter.relax_disp.relax_time(spectrum_id=current_id, time=time_T2)
2016
2017
2018 self.interpreter.relax_disp.cpmg_setup(spectrum_id=current_id, cpmg_frq=vcpmg)
2019
2020 i += 1
2021
2022
2023 self.interpreter.spectrum.replicated(spectrum_ids=['Z_A1', 'Z_A15'])
2024
2025
2026
2027
2028 MODELS = [MODEL_R2EFF, MODEL_NOREX]
2029 GRID_INC = 5; MC_NUM = 3; MODSEL = 'AIC'
2030
2031 results_dir = ds.tmpdir
2032
2033
2034 relax_disp.Relax_disp(pipe_name='relax_disp', results_dir=results_dir, models=MODELS, grid_inc=GRID_INC, mc_sim_num=MC_NUM, modsel=MODSEL)
2035
2036
2037 for cur_spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=False):
2038
2039 if spin_id == ':4@N':
2040 self.assertEqual(len(cur_spin.r2eff), 14)
2041 else:
2042 self.assertEqual(len(cur_spin.r2eff), 15)
2043
2044
2046 """Test of the check_missing_r1() function."""
2047
2048
2049 self.setup_missing_r1_spins()
2050
2051
2052 exp_type = 'R1rho'
2053 frq = 800.1 * 1E6
2054
2055 spectrum_id='test'
2056
2057
2058 self.interpreter.relax_disp.exp_type(spectrum_id=spectrum_id, exp_type=exp_type)
2059
2060
2061 self.interpreter.spectrometer.frequency(id=spectrum_id, frq=frq, units='Hz')
2062
2063
2064 check_missing_r1_return = check_missing_r1(model=MODEL_DPL94)
2065 self.assertEqual(check_missing_r1_return, True)
2066
2067
2068 check_missing_r1_return = check_missing_r1(model=MODEL_R2EFF)
2069 self.assertEqual(check_missing_r1_return, False)
2070
2071
2072 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'Kjaergaard_et_al_2013'
2073
2074
2075 self.interpreter.relax_data.read(ri_id='R1', ri_type='R1', frq=cdp.spectrometer_frq_list[0], file='R1_fitted_values.txt', dir=data_path, mol_name_col=1, res_num_col=2, res_name_col=3, spin_num_col=4, spin_name_col=5, data_col=6, error_col=7)
2076
2077
2078 check_missing_r1_return = check_missing_r1(model=MODEL_DPL94)
2079 self.assertEqual(check_missing_r1_return, False)
2080
2081
2083 """Test synthetic cpmg data. Created with B14, analysed with NS CPMG 2site 3D, for clustered analysis.
2084
2085 This is part of: U{Task #7807 <https://web.archive.org/web/https://gna.org/task/index.php?7807>}: Speed-up of dispersion models for Clustered analysis.
2086
2087 This script will produce synthetic CPMG R2eff values according to the selected model, and the fit the selected model.
2088 """
2089
2090
2091
2092
2093
2094 model_create = 'B14'
2095
2096 model_analyse = 'NS CPMG 2-site 3D'
2097
2098
2099 sfrq_1 = 599.8908617*1E6
2100 r20_key_1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=sfrq_1)
2101 time_T2_1 = 0.06
2102 ncycs_1 = [2, 4, 8, 10, 20, 30, 40, 60]
2103
2104 r2eff_errs_1 = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
2105 exp_1 = [sfrq_1, time_T2_1, ncycs_1, r2eff_errs_1]
2106
2107 sfrq_2 = 499.8908617*1E6
2108 r20_key_2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=sfrq_2)
2109 time_T2_2 = 0.05
2110 ncycs_2 = [2, 4, 8, 10, 30, 35, 40, 50]
2111
2112 r2eff_errs_2 = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
2113 exp_2 = [sfrq_2, time_T2_2, ncycs_2, r2eff_errs_2]
2114
2115
2116 exps = [exp_1, exp_2]
2117
2118 spins = [
2119 ['Ala', 1, 'N', {'r2': {r20_key_1:10., r20_key_2:11.5}, 'r2a': {r20_key_1:10., r20_key_2:11.5}, 'r2b': {r20_key_1:10., r20_key_2:11.5}, 'kex': 1000., 'pA': 0.95, 'dw': 2.} ],
2120 ['Ala', 2, 'N', {'r2': {r20_key_1:13., r20_key_2:14.5}, 'r2a': {r20_key_1:13., r20_key_2:14.5}, 'r2b': {r20_key_1:13., r20_key_2:14.5}, 'kex': 1000., 'pA': 0.95, 'dw': 1.} ]
2121 ]
2122
2123
2124 ds.data = [model_create, model_analyse, spins, exps]
2125
2126
2127 ds.tmpdir = ds.tmpdir
2128
2129
2130
2131 ds.resdir = ds.tmpdir
2132
2133
2134 ds.r20_from_min_r2eff = True
2135
2136
2137 ds.insignificance = 0.0
2138
2139
2140 ds.GRID_INC = None
2141
2142
2143 ds.do_cluster = True
2144
2145
2146
2147 ds.set_func_tol = 1e-1
2148
2149
2150
2151 ds.set_max_iter = 1000
2152
2153
2154 ds.verbosity = 1
2155
2156
2157 ds.rel_change = 0.05
2158
2159
2160 ds.plot_curves = False
2161
2162
2163 ds.sherekhan_input = False
2164
2165
2166 ds.opendx = False
2167
2168
2169 ds.r2eff_err = 0.1
2170
2171
2172 ds.print_res = True
2173
2174
2175 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'cpmg_synthetic.py')
2176
2177 cur_spins = ds.data[2]
2178
2179 for i in range(len(cur_spins)):
2180 res_name, res_num, spin_name, params = cur_spins[i]
2181 cur_spin_id = ":%i@%s"%(res_num, spin_name)
2182 cur_spin = return_spin(cur_spin_id)
2183
2184 grid_params = ds.grid_results[i][3]
2185
2186
2187 min_params = ds.clust_results[i][3]
2188
2189 print("For spin: '%s'"%cur_spin_id)
2190 for mo_param in cur_spin.params:
2191
2192 if isinstance(getattr(cur_spin, mo_param), dict):
2193 grid_r2 = grid_params[mo_param]
2194 min_r2 = min_params[mo_param]
2195 set_r2 = params[mo_param]
2196 for key, val in list(set_r2.items()):
2197 grid_r2_frq = grid_r2[key]
2198 min_r2_frq = min_r2[key]
2199 set_r2_frq = set_r2[key]
2200 frq = float(key.split(EXP_TYPE_CPMG_SQ+' - ')[-1].split('MHz')[0])
2201 rel_change = math.sqrt( (min_r2_frq - set_r2_frq)**2/(min_r2_frq)**2 )
2202 print("%s %s %s %s %.1f GRID=%.3f MIN=%.3f SET=%.3f RELC=%.3f"%(cur_spin.model, res_name, cur_spin_id, mo_param, frq, grid_r2_frq, min_r2_frq, set_r2_frq, rel_change) )
2203 if rel_change > ds.rel_change:
2204 print("WARNING: rel change level is above %.2f, and is %.4f."%(ds.rel_change, rel_change))
2205 print("###################################")
2206
2207
2208 self.assertAlmostEqual(set_r2_frq, min_r2_frq, 1)
2209 else:
2210 grid_val = grid_params[mo_param]
2211 min_val = min_params[mo_param]
2212 set_val = params[mo_param]
2213 rel_change = math.sqrt( (min_val - set_val)**2/(min_val)**2 )
2214 print("%s %s %s %s GRID=%.3f MIN=%.3f SET=%.3f RELC=%.3f"%(cur_spin.model, res_name, cur_spin_id, mo_param, grid_val, min_val, set_val, rel_change) )
2215 if rel_change > ds.rel_change:
2216 print("WARNING: rel change level is above %.2f, and is %.4f."%(ds.rel_change, rel_change))
2217 print("###################################")
2218
2219
2220 if mo_param == 'dw':
2221 self.assertAlmostEqual(set_val/10, min_val/10, 1)
2222 elif mo_param == 'kex':
2223 self.assertAlmostEqual(set_val/1000, min_val/1000, 1)
2224 elif mo_param == 'pA':
2225 self.assertAlmostEqual(set_val, min_val, 2)
2226
2227
2229 """Test synthetic cpmg data. Created with B14, analysed with NS CPMG 2site STAR, for clustered analysis.
2230
2231 This is part of: U{Task #7807 <https://web.archive.org/web/https://gna.org/task/index.php?7807>}: Speed-up of dispersion models for Clustered analysis.
2232
2233 This script will produce synthetic CPMG R2eff values according to the selected model, and the fit the selected model.
2234 """
2235
2236
2237
2238
2239
2240 model_create = 'B14'
2241
2242 model_analyse = 'NS CPMG 2-site star'
2243
2244
2245 sfrq_1 = 599.8908617*1E6
2246 r20_key_1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=sfrq_1)
2247 time_T2_1 = 0.06
2248 ncycs_1 = [2, 4, 8, 10, 20, 30, 40, 60]
2249
2250 r2eff_errs_1 = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
2251 exp_1 = [sfrq_1, time_T2_1, ncycs_1, r2eff_errs_1]
2252
2253 sfrq_2 = 499.8908617*1E6
2254 r20_key_2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=sfrq_2)
2255 time_T2_2 = 0.05
2256 ncycs_2 = [2, 4, 8, 10, 30, 35, 40, 50]
2257
2258 r2eff_errs_2 = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
2259 exp_2 = [sfrq_2, time_T2_2, ncycs_2, r2eff_errs_2]
2260
2261
2262 exps = [exp_1, exp_2]
2263
2264 spins = [
2265 ['Ala', 1, 'N', {'r2': {r20_key_1:10., r20_key_2:11.5}, 'r2a': {r20_key_1:10., r20_key_2:11.5}, 'r2b': {r20_key_1:10., r20_key_2:11.5}, 'kex': 1000., 'pA': 0.95, 'dw': 2.} ],
2266 ['Ala', 2, 'N', {'r2': {r20_key_1:13., r20_key_2:14.5}, 'r2a': {r20_key_1:13., r20_key_2:14.5}, 'r2b': {r20_key_1:13., r20_key_2:14.5}, 'kex': 1000., 'pA': 0.95, 'dw': 1.} ]
2267 ]
2268
2269
2270 ds.data = [model_create, model_analyse, spins, exps]
2271
2272
2273 ds.tmpdir = ds.tmpdir
2274
2275
2276
2277 ds.resdir = ds.tmpdir
2278
2279
2280 ds.r20_from_min_r2eff = True
2281
2282
2283 ds.insignificance = 0.0
2284
2285
2286 ds.GRID_INC = None
2287
2288
2289 ds.do_cluster = True
2290
2291
2292
2293 ds.set_func_tol = 1e-1
2294
2295
2296
2297 ds.set_max_iter = 1000
2298
2299
2300 ds.verbosity = 1
2301
2302
2303 ds.rel_change = 0.05
2304
2305
2306 ds.plot_curves = False
2307
2308
2309 ds.sherekhan_input = False
2310
2311
2312 ds.opendx = False
2313
2314
2315 ds.r2eff_err = 0.1
2316
2317
2318 ds.print_res = True
2319
2320
2321 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'cpmg_synthetic.py')
2322
2323 cur_spins = ds.data[2]
2324
2325 for i in range(len(cur_spins)):
2326 res_name, res_num, spin_name, params = cur_spins[i]
2327 cur_spin_id = ":%i@%s"%(res_num, spin_name)
2328 cur_spin = return_spin(cur_spin_id)
2329
2330 grid_params = ds.grid_results[i][3]
2331
2332
2333 min_params = ds.clust_results[i][3]
2334
2335 print("For spin: '%s'"%cur_spin_id)
2336 for mo_param in cur_spin.params:
2337
2338 if isinstance(getattr(cur_spin, mo_param), dict):
2339 grid_r2 = grid_params[mo_param]
2340 min_r2 = min_params[mo_param]
2341 set_r2 = params[mo_param]
2342 for key, val in list(set_r2.items()):
2343 grid_r2_frq = grid_r2[key]
2344 min_r2_frq = min_r2[key]
2345 set_r2_frq = set_r2[key]
2346 frq = float(key.split(EXP_TYPE_CPMG_SQ+' - ')[-1].split('MHz')[0])
2347 rel_change = math.sqrt( (min_r2_frq - set_r2_frq)**2/(min_r2_frq)**2 )
2348 print("%s %s %s %s %.1f GRID=%.3f MIN=%.3f SET=%.3f RELC=%.3f"%(cur_spin.model, res_name, cur_spin_id, mo_param, frq, grid_r2_frq, min_r2_frq, set_r2_frq, rel_change) )
2349 if rel_change > ds.rel_change:
2350 print("WARNING: rel change level is above %.2f, and is %.4f."%(ds.rel_change, rel_change))
2351 print("###################################")
2352
2353
2354 self.assertAlmostEqual(set_r2_frq, min_r2_frq, 1)
2355 else:
2356 grid_val = grid_params[mo_param]
2357 min_val = min_params[mo_param]
2358 set_val = params[mo_param]
2359 rel_change = math.sqrt( (min_val - set_val)**2/(min_val)**2 )
2360 print("%s %s %s %s GRID=%.3f MIN=%.3f SET=%.3f RELC=%.3f"%(cur_spin.model, res_name, cur_spin_id, mo_param, grid_val, min_val, set_val, rel_change) )
2361 if rel_change > ds.rel_change:
2362 print("WARNING: rel change level is above %.2f, and is %.4f."%(ds.rel_change, rel_change))
2363 print("###################################")
2364
2365
2366 if mo_param == 'dw':
2367 self.assertAlmostEqual(set_val/10, min_val/10, 1)
2368 elif mo_param == 'kex':
2369 self.assertAlmostEqual(set_val/1000, min_val/1000, 1)
2370 elif mo_param == 'pA':
2371 self.assertAlmostEqual(set_val, min_val, 2)
2372
2373
2375 """Test synthetic cpmg data.
2376
2377 This script will produce synthetic CPMG R2eff values according to the NS CPMG 2-site 3D model, and the fit the data with CR72.
2378 """
2379
2380
2381
2382
2383
2384 model_create = 'NS CPMG 2-site 3D'
2385
2386 model_analyse = 'CR72'
2387
2388 sfrq_1 = 599.8908617*1E6
2389 r20_key_1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=sfrq_1)
2390 time_T2_1 = 0.06
2391 ncycs_1 = [2, 4, 8, 10, 20, 30, 40, 60]
2392 r2eff_err_1 = [0, 0, 0, 0, 0, 0, 0, 0]
2393 exp_1 = [sfrq_1, time_T2_1, ncycs_1, r2eff_err_1]
2394
2395 sfrq_2 = 499.8908617*1E6
2396 r20_key_2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=sfrq_2)
2397 time_T2_2 = 0.05
2398 ncycs_2 = [2, 4, 8, 10, 30, 35, 40, 50]
2399 r2eff_err_2 = [0, 0, 0, 0, 0, 0, 0, 0]
2400 exp_2 = [sfrq_2, time_T2_2, ncycs_2, r2eff_err_2]
2401
2402
2403 exps = [exp_1, exp_2]
2404
2405 spins = [
2406 ['Ala', 1, 'N', {'r2': {r20_key_1:10., r20_key_2:10.}, 'r2a': {r20_key_1:10., r20_key_2:10.}, 'r2b': {r20_key_1:10., r20_key_2:10.}, 'kex': 1000., 'pA': 0.99, 'dw': 2.} ]
2407 ]
2408
2409
2410 ds.data = [model_create, model_analyse, spins, exps]
2411
2412
2413 ds.tmpdir = ds.tmpdir
2414
2415
2416
2417 ds.resdir = ds.tmpdir
2418
2419
2420 ds.r20_from_min_r2eff = True
2421
2422
2423 ds.insignificance = 0.0
2424
2425
2426 ds.GRID_INC = 8
2427
2428
2429 ds.do_cluster = False
2430
2431
2432
2433 ds.set_func_tol = 1e-9
2434
2435
2436
2437 ds.set_max_iter = 1000
2438
2439
2440 ds.verbosity = 1
2441
2442
2443 ds.rel_change = 0.05
2444
2445
2446 ds.plot_curves = False
2447
2448
2449 ds.sherekhan_input = False
2450
2451
2452 ds.opendx = False
2453
2454
2455 ds.r2eff_err = 0.1
2456
2457
2458 ds.print_res = False
2459
2460
2461 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'cpmg_synthetic.py')
2462
2463 cur_spins = ds.data[2]
2464
2465 for i in range(len(cur_spins)):
2466 res_name, res_num, spin_name, params = cur_spins[i]
2467 cur_spin_id = ":%i@%s"%(res_num, spin_name)
2468 cur_spin = return_spin(cur_spin_id)
2469
2470 grid_params = ds.grid_results[i][3]
2471 min_params = ds.min_results[i][3]
2472
2473 print("For spin: '%s'"%cur_spin_id)
2474 for mo_param in cur_spin.params:
2475
2476 if isinstance(getattr(cur_spin, mo_param), dict):
2477 grid_r2 = grid_params[mo_param]
2478 min_r2 = min_params[mo_param]
2479 set_r2 = params[mo_param]
2480 for key, val in list(set_r2.items()):
2481 grid_r2_frq = grid_r2[key]
2482 min_r2_frq = min_r2[key]
2483 set_r2_frq = set_r2[key]
2484 frq = float(key.split(EXP_TYPE_CPMG_SQ+' - ')[-1].split('MHz')[0])
2485 rel_change = math.sqrt( (min_r2_frq - set_r2_frq)**2/(min_r2_frq)**2 )
2486 print("%s %s %s %s %.1f GRID=%.3f MIN=%.3f SET=%.3f RELC=%.3f"%(cur_spin.model, res_name, cur_spin_id, mo_param, frq, grid_r2_frq, min_r2_frq, set_r2_frq, rel_change) )
2487 if rel_change > ds.rel_change:
2488 print("WARNING: rel change level is above %.2f, and is %.4f."%(ds.rel_change, rel_change))
2489 print("###################################")
2490
2491
2492 self.assertAlmostEqual(set_r2_frq, min_r2_frq, 2)
2493 else:
2494 grid_val = grid_params[mo_param]
2495 min_val = min_params[mo_param]
2496 set_val = params[mo_param]
2497 rel_change = math.sqrt( (min_val - set_val)**2/(min_val)**2 )
2498 print("%s %s %s %s GRID=%.3f MIN=%.3f SET=%.3f RELC=%.3f"%(cur_spin.model, res_name, cur_spin_id, mo_param, grid_val, min_val, set_val, rel_change) )
2499 if rel_change > ds.rel_change:
2500 print("WARNING: rel change level is above %.2f, and is %.4f."%(ds.rel_change, rel_change))
2501 print("###################################")
2502
2503
2504 if mo_param == 'dw':
2505 self.assertAlmostEqual(set_val/10, min_val/10, 1)
2506 elif mo_param == 'kex':
2507 self.assertAlmostEqual(set_val/1000, min_val/1000, 1)
2508 elif mo_param == 'pA':
2509 self.assertAlmostEqual(set_val, min_val, 3)
2510
2511
2513 """Test synthetic cpmg data.
2514
2515 This script will produce synthetic CPMG R2eff values according to the NS CPMG 2-site 3D model, and the fit the data with B14.
2516 Try to catch bug #22021 U{https://web.archive.org/web/https://gna.org/bugs/index.php?22021}: Model B14 shows bad fitting to data.
2517 """
2518
2519
2520
2521
2522
2523 model_create = 'NS CPMG 2-site 3D'
2524
2525 model_analyse = 'B14'
2526
2527 sfrq_1 = 599.8908617*1E6
2528 r20_key_1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=sfrq_1)
2529 time_T2_1 = 0.06
2530 ncycs_1 = [2, 4, 8, 10, 20, 30, 40, 60]
2531 r2eff_err_1 = [0, 0, 0, 0, 0, 0, 0, 0]
2532 exp_1 = [sfrq_1, time_T2_1, ncycs_1, r2eff_err_1]
2533
2534 sfrq_2 = 499.8908617*1E6
2535 r20_key_2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=sfrq_2)
2536 time_T2_2 = 0.05
2537 ncycs_2 = [2, 4, 8, 10, 30, 35, 40, 50]
2538 r2eff_err_2 = [0, 0, 0, 0, 0, 0, 0, 0]
2539 exp_2 = [sfrq_2, time_T2_2, ncycs_2, r2eff_err_2]
2540
2541
2542 exps = [exp_1, exp_2]
2543
2544 spins = [
2545 ['Ala', 1, 'N', {'r2': {r20_key_1:10., r20_key_2:10.}, 'r2a': {r20_key_1:10., r20_key_2:10.}, 'r2b': {r20_key_1:10., r20_key_2:10.}, 'kex': 1000., 'pA': 0.99, 'dw': 2.} ]
2546 ]
2547
2548
2549 ds.data = [model_create, model_analyse, spins, exps]
2550
2551
2552 ds.tmpdir = ds.tmpdir
2553
2554
2555
2556 ds.resdir = ds.tmpdir
2557
2558
2559 ds.r20_from_min_r2eff = True
2560
2561
2562 ds.insignificance = 0.0
2563
2564
2565 ds.GRID_INC = 8
2566
2567
2568 ds.do_cluster = False
2569
2570
2571
2572 ds.set_func_tol = 1e-9
2573
2574
2575
2576 ds.set_max_iter = 1000
2577
2578
2579 ds.verbosity = 1
2580
2581
2582 ds.rel_change = 0.05
2583
2584
2585 ds.plot_curves = False
2586
2587
2588 ds.sherekhan_input = False
2589
2590
2591 ds.opendx = False
2592
2593
2594 ds.r2eff_err = 0.1
2595
2596
2597 ds.print_res = False
2598
2599
2600 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'cpmg_synthetic.py')
2601
2602 cur_spins = ds.data[2]
2603
2604 for i in range(len(cur_spins)):
2605 res_name, res_num, spin_name, params = cur_spins[i]
2606 cur_spin_id = ":%i@%s"%(res_num, spin_name)
2607 cur_spin = return_spin(cur_spin_id)
2608
2609 grid_params = ds.grid_results[i][3]
2610 min_params = ds.min_results[i][3]
2611
2612 print("For spin: '%s'"%cur_spin_id)
2613 for mo_param in cur_spin.params:
2614
2615 if isinstance(getattr(cur_spin, mo_param), dict):
2616 grid_r2 = grid_params[mo_param]
2617 min_r2 = min_params[mo_param]
2618 set_r2 = params[mo_param]
2619 for key, val in list(set_r2.items()):
2620 grid_r2_frq = grid_r2[key]
2621 min_r2_frq = min_r2[key]
2622 set_r2_frq = set_r2[key]
2623 frq = float(key.split(EXP_TYPE_CPMG_SQ+' - ')[-1].split('MHz')[0])
2624 rel_change = math.sqrt( (min_r2_frq - set_r2_frq)**2/(min_r2_frq)**2 )
2625 print("%s %s %s %s %.1f GRID=%.3f MIN=%.3f SET=%.3f RELC=%.3f"%(cur_spin.model, res_name, cur_spin_id, mo_param, frq, grid_r2_frq, min_r2_frq, set_r2_frq, rel_change) )
2626 if rel_change > ds.rel_change:
2627 print("WARNING: rel change level is above %.2f, and is %.4f."%(ds.rel_change, rel_change))
2628 print("###################################")
2629
2630
2631 self.assertAlmostEqual(set_r2_frq, min_r2_frq, 2)
2632 else:
2633 grid_val = grid_params[mo_param]
2634 min_val = min_params[mo_param]
2635 set_val = params[mo_param]
2636 rel_change = math.sqrt( (min_val - set_val)**2/(min_val)**2 )
2637 print("%s %s %s %s GRID=%.3f MIN=%.3f SET=%.3f RELC=%.3f"%(cur_spin.model, res_name, cur_spin_id, mo_param, grid_val, min_val, set_val, rel_change) )
2638 if rel_change > ds.rel_change:
2639 print("WARNING: rel change level is above %.2f, and is %.4f."%(ds.rel_change, rel_change))
2640 print("###################################")
2641
2642
2643 if mo_param == 'dw':
2644 self.assertAlmostEqual(set_val/10, min_val/10, 5)
2645 elif mo_param == 'kex':
2646 self.assertAlmostEqual(set_val/1000, min_val/1000, 5)
2647 elif mo_param == 'pA':
2648 self.assertAlmostEqual(set_val, min_val, 6)
2649
2650
2652 """Test synthetic cpmg data. For CR72 with small noise and cluster.
2653
2654 This script will produce synthetic CPMG R2eff values according to the selected model, and the fit the selected model.
2655 """
2656
2657
2658
2659
2660
2661 model_create = 'NS CPMG 2-site 3D'
2662
2663 model_analyse = 'CR72'
2664
2665
2666 sfrq_1 = 599.8908617*1E6
2667 r20_key_1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=sfrq_1)
2668 time_T2_1 = 0.06
2669 ncycs_1 = [2, 4, 8, 10, 20, 30, 40, 60]
2670 r2eff_errs_1 = [0.05, -0.05, 0.05, -0.05, 0.05, -0.05, 0.05, -0.05]
2671
2672 exp_1 = [sfrq_1, time_T2_1, ncycs_1, r2eff_errs_1]
2673
2674 sfrq_2 = 499.8908617*1E6
2675 r20_key_2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=sfrq_2)
2676 time_T2_2 = 0.05
2677 ncycs_2 = [2, 4, 8, 10, 30, 35, 40, 50]
2678 r2eff_errs_2 = [0.05, -0.05, 0.05, -0.05, 0.05, -0.05, 0.05, -0.05]
2679
2680 exp_2 = [sfrq_2, time_T2_2, ncycs_2, r2eff_errs_2]
2681
2682
2683 exps = [exp_1, exp_2]
2684
2685 spins = [
2686 ['Ala', 1, 'N', {'r2': {r20_key_1:10., r20_key_2:11.5}, 'r2a': {r20_key_1:10., r20_key_2:11.5}, 'r2b': {r20_key_1:10., r20_key_2:11.5}, 'kex': 1000., 'pA': 0.99, 'dw': 2.} ],
2687 ['Ala', 2, 'N', {'r2': {r20_key_1:13., r20_key_2:14.5}, 'r2a': {r20_key_1:13., r20_key_2:14.5}, 'r2b': {r20_key_1:13., r20_key_2:14.5}, 'kex': 1000., 'pA': 0.99, 'dw': 1.} ]
2688 ]
2689
2690
2691 ds.data = [model_create, model_analyse, spins, exps]
2692
2693
2694 ds.tmpdir = ds.tmpdir
2695
2696
2697
2698 ds.resdir = ds.tmpdir
2699
2700
2701 ds.r20_from_min_r2eff = True
2702
2703
2704 ds.insignificance = 0.0
2705
2706
2707 ds.GRID_INC = 13
2708
2709
2710 ds.do_cluster = True
2711
2712
2713
2714 ds.set_func_tol = 1e-8
2715
2716
2717
2718 ds.set_max_iter = 10000
2719
2720
2721 ds.verbosity = 1
2722
2723
2724 ds.rel_change = 0.05
2725
2726
2727 ds.plot_curves = False
2728
2729
2730 ds.sherekhan_input = False
2731
2732
2733 ds.opendx = False
2734
2735
2736 ds.r2eff_err = 0.1
2737
2738
2739 ds.print_res = False
2740
2741
2742 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'cpmg_synthetic.py')
2743
2744 cur_spins = ds.data[2]
2745
2746 for i in range(len(cur_spins)):
2747 res_name, res_num, spin_name, params = cur_spins[i]
2748 cur_spin_id = ":%i@%s"%(res_num, spin_name)
2749 cur_spin = return_spin(cur_spin_id)
2750
2751 grid_params = ds.grid_results[i][3]
2752
2753
2754 min_params = ds.clust_results[i][3]
2755
2756 print("For spin: '%s'"%cur_spin_id)
2757 for mo_param in cur_spin.params:
2758
2759 if isinstance(getattr(cur_spin, mo_param), dict):
2760 grid_r2 = grid_params[mo_param]
2761 min_r2 = min_params[mo_param]
2762 set_r2 = params[mo_param]
2763 for key, val in list(set_r2.items()):
2764 grid_r2_frq = grid_r2[key]
2765 min_r2_frq = min_r2[key]
2766 set_r2_frq = set_r2[key]
2767 frq = float(key.split(EXP_TYPE_CPMG_SQ+' - ')[-1].split('MHz')[0])
2768 rel_change = math.sqrt( (min_r2_frq - set_r2_frq)**2/(min_r2_frq)**2 )
2769 print("%s %s %s %s %.1f GRID=%.3f MIN=%.3f SET=%.3f RELC=%.3f"%(cur_spin.model, res_name, cur_spin_id, mo_param, frq, grid_r2_frq, min_r2_frq, set_r2_frq, rel_change) )
2770 if rel_change > ds.rel_change:
2771 print("WARNING: rel change level is above %.2f, and is %.4f."%(ds.rel_change, rel_change))
2772 print("###################################")
2773
2774
2775 self.assertAlmostEqual(set_r2_frq, min_r2_frq, 1)
2776 else:
2777 grid_val = grid_params[mo_param]
2778 min_val = min_params[mo_param]
2779 set_val = params[mo_param]
2780 rel_change = math.sqrt( (min_val - set_val)**2/(min_val)**2 )
2781 print("%s %s %s %s GRID=%.3f MIN=%.3f SET=%.3f RELC=%.3f"%(cur_spin.model, res_name, cur_spin_id, mo_param, grid_val, min_val, set_val, rel_change) )
2782 if rel_change > ds.rel_change:
2783 print("WARNING: rel change level is above %.2f, and is %.4f."%(ds.rel_change, rel_change))
2784 print("###################################")
2785
2786
2787 if mo_param == 'dw':
2788 self.assertAlmostEqual(set_val/10, min_val/10, 1)
2789 elif mo_param == 'kex':
2790 self.assertAlmostEqual(set_val/1000, min_val/1000, 1)
2791 elif mo_param == 'pA':
2792 self.assertAlmostEqual(set_val, min_val, 2)
2793
2794
2796 """Test synthetic cpmg data, calling the dx.map function with one or two points.
2797
2798 This script will produce synthetic CPMG R2eff values according to the selected model, and the fit the selected model.
2799 """
2800
2801
2802
2803
2804
2805 model_create = MODEL_NS_CPMG_2SITE_EXPANDED
2806 model_analyse = 'CR72'
2807
2808 sfrq_1 = 599.8908617*1E6
2809 r20_key_1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=sfrq_1)
2810 time_T2_1 = 0.06
2811 ncycs_1 = [2, 4, 8, 10, 20, 30, 40, 60]
2812 r2eff_err_1 = [0, 0, 0, 0, 0, 0, 0, 0]
2813 exp_1 = [sfrq_1, time_T2_1, ncycs_1, r2eff_err_1]
2814
2815 sfrq_2 = 499.8908617*1E6
2816 r20_key_2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=sfrq_2)
2817 time_T2_2 = 0.05
2818 ncycs_2 = [2, 4, 8, 10, 30, 35, 40, 50]
2819 r2eff_err_2 = [0, 0, 0, 0, 0, 0, 0, 0]
2820 exp_2 = [sfrq_2, time_T2_2, ncycs_2, r2eff_err_2]
2821
2822
2823 exps = [exp_1, exp_2]
2824
2825 spins = [
2826 ['Ala', 1, 'N', {'r2': {r20_key_1:2, r20_key_2:2}, 'r2a': {r20_key_1:2, r20_key_2:2}, 'r2b': {r20_key_1:2, r20_key_2:2}, 'kex': 1000, 'pA': 0.99, 'dw': 2} ]
2827 ]
2828
2829
2830 ds.data = [model_create, model_analyse, spins, exps]
2831
2832
2833 ds.tmpdir = ds.tmpdir
2834
2835
2836
2837 ds.resdir = ds.tmpdir
2838
2839
2840 ds.r20_from_min_r2eff = True
2841
2842
2843 ds.insignificance = 0.0
2844
2845
2846 ds.GRID_INC = None
2847
2848
2849 ds.do_cluster = False
2850
2851
2852
2853 ds.set_func_tol = 1e-9
2854
2855
2856
2857 ds.set_max_iter = 1000
2858
2859
2860 ds.verbosity = 1
2861
2862
2863 ds.rel_change = 0.05
2864
2865
2866 ds.plot_curves = False
2867
2868
2869 ds.sherekhan_input = False
2870
2871
2872 ds.opendx = False
2873
2874
2875 ds.r2eff_err = 0.1
2876
2877
2878 ds.print_res = False
2879
2880
2881 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'cpmg_synthetic.py')
2882
2883
2884 cur_spins = ds.data[2]
2885
2886
2887 ds.pipe_name_MODEL_MAP = "%s_%s_map"%(ds.pipe_name, model_analyse)
2888 self.interpreter.pipe.copy(pipe_from=ds.pipe_name, pipe_to=ds.pipe_name_MODEL_MAP, bundle_to = ds.pipe_bundle)
2889 self.interpreter.pipe.switch(pipe_name=ds.pipe_name_MODEL_MAP)
2890
2891
2892 self.interpreter.value.copy(pipe_from=ds.pipe_name_r2eff, pipe_to=ds.pipe_name_MODEL_MAP, param='r2eff')
2893
2894
2895 self.interpreter.relax_disp.select_model(model=model_analyse)
2896
2897
2898 ds.dx_inc = 4
2899 ds.dx_params = ['dw', 'pA', 'kex']
2900
2901 res_name, res_num, spin_name, params = cur_spins[0]
2902 cur_spin_id = ":%i@%s"%(res_num, spin_name)
2903 cur_spin = return_spin(cur_spin_id)
2904
2905 print("Params for dx map is")
2906 print(ds.dx_params)
2907 print("Point param for dx map is")
2908 print(ds.dx_set_val)
2909 cur_model = model_analyse.replace(' ', '_')
2910 file_name_map = "%s_map%s" % (cur_model, cur_spin_id.replace('#', '_').replace(':', '_').replace('@', '_'))
2911 file_name_point = "%s_point%s" % (cur_model, cur_spin_id .replace('#', '_').replace(':', '_').replace('@', '_'))
2912 self.interpreter.dx.map(params=ds.dx_params, map_type='Iso3D', spin_id=cur_spin_id, inc=ds.dx_inc, lower=None, upper=None, axis_incs=10, file_prefix=file_name_map, dir=ds.resdir, point=[ds.dx_set_val, ds.dx_clust_val], point_file=file_name_point, create_par_file=True)
2913
2914
2915
2916 map_cfg = ds.tmpdir+sep+file_name_map+".cfg"
2917 map_net = ds.tmpdir+sep+file_name_map+".net"
2918 map_general = ds.tmpdir+sep+file_name_map+".general"
2919 map_par = get_file_path(file_name=file_name_map+".par", dir=ds.tmpdir)
2920 map_plot = get_file_path(file_name=file_name_map+".py", dir=ds.tmpdir)
2921
2922 point_general = ds.tmpdir+sep+file_name_point+".general"
2923 point_point = ds.tmpdir+sep+file_name_point
2924 point_par = get_file_path(file_name=file_name_point+".par", dir=ds.tmpdir)
2925
2926
2927 self.assert_(access(map_cfg, F_OK))
2928 self.assert_(access(map_net, F_OK))
2929 self.assert_(access(map_general, F_OK))
2930 self.assert_(access(map_par, F_OK))
2931 self.assert_(access(map_plot, F_OK))
2932 self.assert_(access(point_general, F_OK))
2933 self.assert_(access(point_point, F_OK))
2934 self.assert_(access(point_par, F_OK))
2935
2936
2937
2938 print("\nChecking the dx map .cfg file.")
2939 res_file = [
2940 '//'+"\n",
2941 '//'+"\n",
2942 '// time: Thu May 8 18:55:31 2014'+"\n",
2943 '//'+"\n",
2944 '// version: 3.2.0 (format), 4.3.2 (DX)'+"\n",
2945 '//'+"\n",
2946 '//'+"\n",
2947 '// panel[0]: position = (0.0164,0.0000), size = 0.2521x0.1933, startup = 1, devstyle = 1'+"\n",
2948 '// title: value = Control Panel'+"\n",
2949 '//'+"\n",
2950 '// workspace: width = 251, height = 142'+"\n",
2951 '// layout: snap = 0, width = 50, height = 50, align = NN'+"\n",
2952 '//'+"\n",
2953 '// interactor Selector[1]: num_components = 1, value = 1 '+"\n",
2954 '// selections: maximum = 2, current = 0 '+"\n",
2955 '// option[0]: name = "Colour", value = 1'+"\n",
2956 '// option[1]: name = "Grey", value = 2'+"\n",
2957 '// instance: panel = 0, x = 81, y = 6, style = Scrolled List, vertical = 1, size = 170x136'+"\n",
2958 '// label: value = Colour Selector'+"\n",
2959 '//'+"\n",
2960 '// node Image[3]:'+"\n",
2961 '// title: value = Surface'+"\n",
2962 '// depth: value = 24'+"\n",
2963 '// window: position = (0.0000,0.0400), size = 0.9929x0.9276'+"\n",
2964 ]
2965 file = open(map_cfg, 'r')
2966 lines = file.readlines()
2967 file.close()
2968 for i in range(len(res_file)):
2969
2970 if i == 2:
2971 continue
2972 self.assertEqual(res_file[i], lines[i])
2973
2974 print("\nChecking the dx map .general file.")
2975 res_file = [
2976 'file = CR72_map_1_N'+"\n",
2977 'grid = 5 x 5 x 5'+"\n",
2978 'format = ascii'+"\n",
2979 'interleaving = field'+"\n",
2980 'majority = row'+"\n",
2981 'field = data'+"\n",
2982 'structure = scalar'+"\n",
2983 'type = float'+"\n",
2984 'dependency = positions'+"\n",
2985 'positions = regular, regular, regular, 0, 1, 0, 1, 0, 1'+"\n",
2986 ''+"\n",
2987 'end'+"\n",
2988 ]
2989 file = open(map_general, 'r')
2990 lines = file.readlines()
2991 file.close()
2992 for i in range(len(res_file)):
2993
2994
2995
2996 self.assertEqual(res_file[i], lines[i])
2997
2998 print("\nChecking the dx point .general file.")
2999 res_file = [
3000 'file = CR72_point_1_N'+"\n",
3001 'points = 2'+"\n",
3002 'format = ascii'+"\n",
3003 'interleaving = field'+"\n",
3004 'field = locations, field0'+"\n",
3005 'structure = 3-vector, scalar'+"\n",
3006 'type = float, float'+"\n",
3007 ''+"\n",
3008 'end'+"\n",
3009 ]
3010 file = open(point_general, 'r')
3011 lines = file.readlines()
3012 file.close()
3013 for i in range(len(res_file)):
3014
3015
3016
3017 self.assertEqual(res_file[i], lines[i])
3018
3019 print("\nChecking the dx point point file.")
3020 res_file = [
3021 '0.8 3.92 0.39964 1'+"\n",
3022 '0.76981 3.9169 0.41353 1'+"\n",
3023 ]
3024 file = open(point_point, 'r')
3025 lines = file.readlines()
3026 file.close()
3027 for i in range(len(res_file)):
3028
3029
3030
3031 self.assertEqual(res_file[i], lines[i])
3032
3033 print("\nChecking the dx point par file.")
3034 res_file = [
3035 '# i dw pA kex chi2 i_sort dw_sort pA_sort kex_sort chi2_sort '+"\n",
3036 '0 2.00000 0.99000 1000.00000 6185.84926 0 2.00000 0.99000 1000.00000 6185.84926 '+"\n",
3037 '1 1.92453 0.98961 1034.72206 6396.02770 1 1.92453 0.98961 1034.72206 6396.02770 '+"\n",
3038 ]
3039 res_file2 = [
3040 '# i dw pA kex chi2 i_sort dw_sort pA_sort kex_sort chi2_sort '+"\n",
3041 '0 2.00000 0.99000 1000.00000 6185.84926 0 2.00000 0.99000 1000.00000 6185.84926 '+"\n",
3042 '1 1.92452 0.98961 1034.72424 6396.02439 1 1.92452 0.98961 1034.72424 6396.02439 '+"\n",
3043 ]
3044 file = open(point_par, 'r')
3045 lines = file.readlines()
3046 file.close()
3047 for i in range(len(res_file)):
3048 if lines[i] != res_file[i] and lines[i] != res_file2[i]:
3049 self.assertEqual(res_file[i], lines[i])
3050
3051 print("\nChecking the matplotlib surface plot file.")
3052 res_file = [
3053 'from copy import deepcopy'+"\n",
3054 'import numpy as np'+"\n",
3055 'import scipy.interpolate'+"\n",
3056 'from numpy.ma import masked_where'+"\n",
3057 ''+"\n",
3058 'from mpl_toolkits.mplot3d import axes3d'+"\n",
3059 'import matplotlib.pyplot as plt'+"\n",
3060 'from matplotlib import cm'+"\n",
3061 ''+"\n",
3062 '# Open file and get header.'+"\n",
3063 'mapfile_name = "%s.par"'%file_name_map+"\n",
3064 'pointfile_name = "%s.par"'%file_name_point+"\n",
3065 ''+"\n",
3066 ]
3067 file = open(map_plot, 'r')
3068 lines = file.readlines()
3069 file.close()
3070 for i in range(len(res_file)):
3071 self.assertEqual(res_file[i], lines[i])
3072
3073
3075 """Test the curve type detection using the Dr. Flemming Hansen's CPMG fixed time test data."""
3076
3077
3078 self.interpreter.reset()
3079
3080
3081 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'Hansen'
3082 self.interpreter.state.load(data_path+sep+'r2eff_values')
3083
3084
3085 curve_type = get_curve_type(id='500_133.33.in')
3086 self.assertEqual(curve_type, 'fixed time')
3087
3088
3090 """Test the curve type detection using the 'M61' exponential test data."""
3091
3092
3093 self.interpreter.reset()
3094
3095
3096 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'r1rho_on_res_m61'
3097 self.interpreter.state.load(data_path+sep+'r2eff_values')
3098
3099
3100 curve_type = get_curve_type(id='nu_2000_ncyc9')
3101 self.assertEqual(curve_type, 'exponential')
3102
3103
3105 """Test the curve type detection using the 'TP02' fixed time test data."""
3106
3107
3108 self.interpreter.reset()
3109
3110
3111 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'r1rho_off_res_tp02'
3112 self.interpreter.state.load(data_path+sep+'r2eff_values')
3113
3114
3115 curve_type = get_curve_type(id='nu_1000.0_500MHz')
3116 self.assertEqual(curve_type, 'fixed time')
3117
3118
3120 """Test the relaxation dispersion 'DPL94' model curve fitting to fixed time synthetic data."""
3121
3122
3123 ds.fixed = True
3124
3125
3126 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'r1rho_on_res_dpl94.py')
3127
3128
3129 i0 = [100000.0, 20000.0]
3130 r1rho_prime = [2.25, 24.0]
3131 pA = 0.7
3132 kex = 1000.0
3133 delta_omega = [1.0, 2.0]
3134 phi_ex = []
3135 for i in range(2):
3136 phi_ex.append(pA * (1.0 - pA) * delta_omega[i]**2)
3137
3138
3139 self.interpreter.pipe.switch('DPL94 - relax_disp')
3140 spin_index = 0
3141 for spin, spin_id in spin_loop(return_id=True):
3142
3143 print("\nSpin %s." % spin_id)
3144
3145
3146 self.assertAlmostEqual(spin.r2['R1rho - 800.00000000 MHz']/10, r1rho_prime[spin_index]/10, 2)
3147 self.assertAlmostEqual(spin.phi_ex, phi_ex[spin_index], 2)
3148 self.assertAlmostEqual(spin.kex/1000.0, kex/1000.0, 2)
3149
3150
3151 spin_index += 1
3152
3153
3155 """Test making dx_map for residues under clustered calculation.
3156
3157 This uses CPMG data from:
3158 - Webb H, Tynan-Connolly BM, Lee GM, Farrell D, O'Meara F, Soendergaard CR, Teilum K, Hewage C, McIntosh LP, Nielsen JE
3159 Remeasuring HEWL pK(a) values by NMR spectroscopy: methods, analysis, accuracy, and implications for theoretical pK(a) calculations.
3160 (2011), Proteins: Struct, Funct, Bioinf 79(3):685-702, U{DOI 10.1002/prot.22886<http://dx.doi.org/10.1002/prot.22886>}
3161 """
3162
3163
3164 prev_data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'HWebb_KTeilum_Proteins_Struct_Funct_Bioinf_2011'
3165
3166
3167 self.interpreter.results.read(prev_data_path + sep + 'FT_-_CR72_-_min_-_128_-_free_spins')
3168
3169
3170 cur_spin_id = ":%i@%s"%(52, 'N')
3171 cur_spin_id_str = cur_spin_id .replace('#', '_').replace(':', '_').replace('@', '_')
3172
3173
3174 cur_spin = return_spin(cur_spin_id)
3175
3176
3177 pre_chi2 = cur_spin.chi2
3178
3179
3180
3181 self.interpreter.minimise.calculate()
3182
3183
3184 calc_chi2 = cur_spin.chi2
3185
3186
3187 self.assertAlmostEqual(pre_chi2, calc_chi2)
3188
3189
3190 dx_inc = 2
3191 dx_inc_sides = dx_inc / 2
3192
3193 dx_params = ['dw', 'pA', 'kex']
3194 dx_point_clustered_min = [cur_spin.dw, cur_spin.pA, cur_spin.kex]
3195
3196 print("Params for dx map is")
3197 print(dx_params)
3198 print("Point param for dx map is, with chi2=%3.3f"%pre_chi2)
3199 print(dx_point_clustered_min)
3200
3201
3202 cur_model = 'CR72'
3203 file_name_map = "%s_map%s" % (cur_model, cur_spin_id_str)
3204 file_name_point = "%s_point%s" % (cur_model, cur_spin_id_str)
3205
3206
3207 param_delta = 0.1
3208
3209
3210 lower = []
3211 upper = []
3212 for i, param_val in enumerate(dx_point_clustered_min):
3213 param = dx_params[i]
3214 step_val = param_delta * param_val
3215 step_length = step_val * dx_inc_sides
3216
3217
3218 low_val = param_val - step_length
3219 lower.append(low_val)
3220
3221 upp_val = param_val + step_length
3222 upper.append(upp_val)
3223
3224 print("For param %s, lower=%3.3f, upper=%3.3f, step_value=%3.3f, steps=%i, centered at=%3.3f"% (param, low_val, upp_val, step_val, dx_inc, param_val))
3225
3226
3227
3228 dx_param_indexes = dx_inc + 1
3229 dx_point_index = dx_inc_sides + 1
3230
3231
3232 line = 1
3233 for i in range(1, dx_param_indexes + 1):
3234 for j in range(1, dx_param_indexes + 1):
3235 for k in range(1, dx_param_indexes + 1):
3236 if i == dx_point_index and j == dx_point_index and k == dx_point_index:
3237 line_chi2 = line
3238
3239 line += 1
3240
3241
3242 result_dir = self.tmpdir
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252 self.interpreter.dx.map(params=dx_params, map_type='Iso3D', spin_id=cur_spin_id, inc=dx_inc, lower=lower, upper=upper, axis_incs=10, file_prefix=file_name_map, dir=result_dir, point=dx_point_clustered_min, point_file=file_name_point)
3253
3254
3255 nr_chi2_val = dx_param_indexes**3
3256 print("Nr of chi2 calculations are=%i"%nr_chi2_val)
3257 print("Global chi2=%3.3f, Calc_chi=%3.3f, map_line_chi2=%i" % (pre_chi2, calc_chi2, line_chi2) )
3258
3259
3260
3261 map_name = get_file_path(file_name=file_name_map, dir=result_dir)
3262 map_cfg = get_file_path(file_name=file_name_map+".cfg", dir=result_dir)
3263 map_net = get_file_path(file_name=file_name_map+".net", dir=result_dir)
3264 map_general = get_file_path(file_name=file_name_map+".general", dir=result_dir)
3265
3266 point_general = get_file_path(file_name=file_name_point+".general", dir=result_dir)
3267 point_point = get_file_path(file_name=file_name_point, dir=result_dir)
3268
3269
3270 self.assert_(access(map_cfg, F_OK))
3271 self.assert_(access(map_net, F_OK))
3272 self.assert_(access(map_general, F_OK))
3273 self.assert_(access(point_general, F_OK))
3274 self.assert_(access(point_point, F_OK))
3275
3276
3277 get_data = extract_data(file=map_name)
3278
3279
3280 test = float(get_data[line_chi2-1][0])
3281
3282
3283 self.assertAlmostEqual(test, pre_chi2, 6)
3284
3285
3287 """Test making dx_map for residues under clustered calculation, and the creation of the parameter file.
3288
3289 U{Task #7860<https://web.archive.org/web/https://gna.org/task/index.php?7860>} : When dx_map is issued, create a parameter file which maps parameters to chi2 value.
3290
3291 This uses the data from paper at U{http://dx.doi.org/10.1073/pnas.0509100103}. This is CPMG data with a fixed relaxation time period. Experiment in 0.48 M GuHCl (guanidine hydrochloride).
3292 """
3293
3294
3295 prev_data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'KTeilum_FMPoulsen_MAkke_2006'+sep+'surface_chi2_clustered_fitting'
3296
3297
3298 self.interpreter.results.read(prev_data_path + sep + 'coMDD_-_TSMFK01_-_min_-_32_-_free_spins.bz2')
3299
3300
3301 cur_spin_id = ":%i@%s"%(65, 'N')
3302 cur_spin_id_str = cur_spin_id .replace('#', '_').replace(':', '_').replace('@', '_')
3303
3304
3305 cur_spin = return_spin(cur_spin_id)
3306
3307
3308 pre_chi2 = cur_spin.chi2
3309
3310
3311
3312 self.interpreter.minimise.calculate()
3313
3314
3315 calc_chi2 = cur_spin.chi2
3316
3317
3318 self.assertAlmostEqual(pre_chi2, calc_chi2)
3319
3320
3321 dx_inc = 2
3322 dx_params = ['dw', 'k_AB', 'r2a']
3323 dx_point_clustered_min = [cur_spin.dw, cur_spin.k_AB, cur_spin.r2a['SQ CPMG - 499.86214000 MHz']]
3324
3325 print("Params for dx map is")
3326 print(dx_params)
3327 print("Point param for dx map is, with chi2=%3.3f"%pre_chi2)
3328 print(dx_point_clustered_min)
3329
3330
3331 cur_model = 'TSMFK01'
3332 file_name_map = "%s_map%s" % (cur_model, cur_spin_id_str)
3333 file_name_point = "%s_point%s" % (cur_model, cur_spin_id_str)
3334
3335
3336 lower = [dx_point_clustered_min[0], dx_point_clustered_min[1], dx_point_clustered_min[2]]
3337 upper = [19.0, 2.4, 9.5]
3338
3339
3340 result_dir = self.tmpdir
3341
3342
3343
3344
3345
3346
3347 self.interpreter.dx.map(params=dx_params, map_type='Iso3D', spin_id=cur_spin_id, inc=dx_inc, lower=lower, upper=upper, axis_incs=10, file_prefix=file_name_map, dir=result_dir, point=dx_point_clustered_min, point_file=file_name_point, create_par_file=True)
3348
3349
3350 nr_chi2_val = (dx_inc + 1)**3
3351 print("Nr of chi2 calculations are=%i"%nr_chi2_val)
3352 print("Global chi2=%3.3f, Calc_chi=%3.3f" % (pre_chi2, calc_chi2) )
3353
3354
3355
3356 map_name = get_file_path(file_name=file_name_map, dir=result_dir)
3357 map_cfg = get_file_path(file_name=file_name_map+".cfg", dir=result_dir)
3358 map_net = get_file_path(file_name=file_name_map+".net", dir=result_dir)
3359 map_general = get_file_path(file_name=file_name_map+".general", dir=result_dir)
3360 map_par = get_file_path(file_name=file_name_map+".par", dir=result_dir)
3361
3362 point_general = get_file_path(file_name=file_name_point+".general", dir=result_dir)
3363 point_point = get_file_path(file_name=file_name_point, dir=result_dir)
3364
3365
3366 self.assert_(access(map_cfg, F_OK))
3367 self.assert_(access(map_net, F_OK))
3368 self.assert_(access(map_general, F_OK))
3369 self.assert_(access(map_par, F_OK))
3370 self.assert_(access(point_general, F_OK))
3371 self.assert_(access(point_point, F_OK))
3372
3373 print("\nParams for dx map is")
3374 print(dx_params)
3375 print("Point param for dx map is, with chi2=%3.3f"%pre_chi2)
3376 print(dx_point_clustered_min, "\n")
3377
3378
3379 get_data = extract_data(file=map_par)
3380
3381
3382 test = float(get_data[1][9])
3383
3384
3385 if test < pre_chi2:
3386 print("\nInitial clustered minimised chi2 value is=%3.3f, whereby the minimum map value is=%3.3f\n" % (pre_chi2, test))
3387 for line in get_data:
3388 print(line)
3389
3390
3391
3392
3393
3394
3395
3396
3397
3399 """Test the user function for estimating R2eff errors from exponential curve fitting.
3400
3401 This follows Task 7822.
3402 U{task #7822<https://web.archive.org/web/https://gna.org/task/index.php?7822>}: Implement user function to estimate R2eff and associated errors for exponential curve fitting.
3403
3404 This uses the data from Kjaergaard's paper at U{DOI: 10.1021/bi4001062<http://dx.doi.org/10.1021/bi4001062>}.
3405 Optimisation of the Kjaergaard et al., 2013 Off-resonance R1rho relaxation dispersion experiments using the 'DPL' model.
3406 """
3407
3408
3409 cluster_ids = [
3410 ":13@N",
3411 ":15@N",
3412 ":16@N",
3413 ":25@N",
3414 ":26@N",
3415 ":28@N",
3416 ":39@N",
3417 ":40@N",
3418 ":41@N",
3419 ":43@N",
3420 ":44@N",
3421 ":45@N",
3422 ":49@N",
3423 ":52@N",
3424 ":53@N"]
3425
3426
3427 self.setup_r1rho_kjaergaard(cluster_ids=cluster_ids, read_R1=False)
3428
3429
3430 MODELS = [MODEL_NOREX, MODEL_DPL94, MODEL_TP02, MODEL_TAP03, MODEL_MP05, MODEL_NS_R1RHO_2SITE]
3431
3432
3433 GRID_INC = None
3434
3435
3436 MC_NUM = 3
3437
3438
3439 MODSEL = 'AIC'
3440
3441
3442
3443 OPT_FUNC_TOL = 1e-25
3444 relax_disp.Relax_disp.opt_func_tol = OPT_FUNC_TOL
3445 OPT_MAX_ITERATIONS = 10000000
3446 relax_disp.Relax_disp.opt_max_iterations = OPT_MAX_ITERATIONS
3447
3448 result_dir_name = ds.tmpdir
3449
3450
3451 for curspin in cluster_ids:
3452 self.interpreter.relax_disp.cluster('free spins', curspin)
3453
3454 self.interpreter.deselect.spin(spin_id=curspin, change_all=False)
3455
3456
3457
3458
3459
3460
3461
3462
3463 self.interpreter.select.spin(spin_id=':52@N', change_all=False)
3464
3465
3466
3467 self.interpreter.relax_disp.select_model(MODEL_R2EFF)
3468
3469
3470 check_intensity_errors()
3471
3472
3473 self.interpreter.minimise.grid_search(lower=None, upper=None, inc=11, constraints=True, verbosity=1)
3474
3475
3476 self.interpreter.minimise.execute(min_algor='Newton', constraints=False, verbosity=1)
3477
3478
3479 self.interpreter.relax_disp.r2eff_err_estimate()
3480
3481 r1_fit = True
3482
3483
3484 relax_disp.Relax_disp(pipe_name=ds.pipe_name, pipe_bundle=ds.pipe_bundle, results_dir=result_dir_name, models=MODELS, grid_inc=GRID_INC, mc_sim_num=MC_NUM, modsel=MODSEL, r1_fit=r1_fit)
3485
3486
3487 self.verify_r1rho_kjaergaard_missing_r1(models=MODELS, result_dir_name=result_dir_name, r2eff_estimate='direct')
3488
3489
3491 """Test the user function for estimating R2eff errors from exponential curve fitting, via the auto_analyses menu.
3492
3493 This follows Task 7822.
3494 U{task #7822<https://web.archive.org/web/https://gna.org/task/index.php?7822>}: Implement user function to estimate R2eff and associated errors for exponential curve fitting.
3495
3496 This uses the data from Kjaergaard's paper at U{DOI: 10.1021/bi4001062<http://dx.doi.org/10.1021/bi4001062>}.
3497 Optimisation of the Kjaergaard et al., 2013 Off-resonance R1rho relaxation dispersion experiments using the 'DPL' model.
3498 """
3499
3500
3501 cluster_ids = [
3502 ":13@N",
3503 ":15@N",
3504 ":16@N",
3505 ":25@N",
3506 ":26@N",
3507 ":28@N",
3508 ":39@N",
3509 ":40@N",
3510 ":41@N",
3511 ":43@N",
3512 ":44@N",
3513 ":45@N",
3514 ":49@N",
3515 ":52@N",
3516 ":53@N"]
3517
3518
3519
3520 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'Kjaergaard_et_al_2013'+sep
3521
3522
3523 pipe_name = 'base pipe'
3524 pipe_bundle = 'relax_disp'
3525 pipe_type = 'relax_disp'
3526
3527
3528 self.interpreter.pipe.create(pipe_name=pipe_name, bundle=pipe_bundle, pipe_type=pipe_type)
3529
3530 file = data_path + '1_setup_r1rho_GUI.py'
3531 self.interpreter.script(file=file, dir=None)
3532
3533
3534 MODELS = [MODEL_R2EFF, MODEL_NOREX, MODEL_DPL94, MODEL_TP02, MODEL_TAP03, MODEL_MP05, MODEL_NS_R1RHO_2SITE]
3535
3536
3537 GRID_INC = None
3538
3539
3540
3541
3542 EXP_MC_NUM = -1
3543
3544
3545 MC_NUM = 3
3546
3547
3548 MODSEL = 'AIC'
3549
3550
3551
3552 OPT_FUNC_TOL = 1e-25
3553 relax_disp.Relax_disp.opt_func_tol = OPT_FUNC_TOL
3554 OPT_MAX_ITERATIONS = 10000000
3555 relax_disp.Relax_disp.opt_max_iterations = OPT_MAX_ITERATIONS
3556
3557
3558
3559
3560
3561
3562
3563
3564 self.interpreter.deselect.spin(spin_id=':1-100', change_all=False)
3565
3566
3567
3568
3569
3570
3571
3572
3573 self.interpreter.select.spin(spin_id=':52@N', change_all=False)
3574
3575
3576 for cur_spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
3577 print(spin_id)
3578
3579 result_dir_name = self.tmpdir
3580 r1_fit = True
3581
3582
3583 relax_disp.Relax_disp(pipe_name=pipe_name, pipe_bundle=pipe_bundle, results_dir=result_dir_name, models=MODELS, grid_inc=GRID_INC, mc_sim_num=MC_NUM, exp_mc_sim_num=EXP_MC_NUM, modsel=MODSEL, r1_fit=r1_fit)
3584
3585
3586 self.verify_r1rho_kjaergaard_missing_r1(models=MODELS, result_dir_name=result_dir_name, r2eff_estimate='direct')
3587
3588
3590 """Test the user function for estimating R2eff and associated errors for exponential curve fitting with different methods.
3591 This is compared with a run where erros are estimated by 2000 Monte Carlo simulations.
3592
3593 This follows Task 7822.
3594 U{task #7822<https://web.archive.org/web/https://gna.org/task/index.php?7822>}: Implement user function to estimate R2eff and associated errors for exponential curve fitting.
3595
3596 This uses the data from Kjaergaard's paper at U{DOI: 10.1021/bi4001062<http://dx.doi.org/10.1021/bi4001062>}.
3597 Optimisation of the Kjaergaard et al., 2013 Off-resonance R1rho relaxation dispersion experiments using the 'DPL' model.
3598
3599 NOTE: The difference in the methods was due to a bug in relax!
3600 U{bug #22554<https://web.archive.org/web/https://gna.org/bugs/index.php?22554>}. The distribution of intensity with errors in Monte-Carlo simulations are markedly more narrow than expected.
3601
3602 This dataset is old, and includes 2000 Monte-Carlo simulations, which is performed wrong.
3603 """
3604
3605
3606 prev_data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'Kjaergaard_et_al_2013' +sep+ "check_graphs" +sep+ "mc_2000" +sep+ "R2eff"
3607
3608
3609 self.interpreter.pipe.create('MC_2000', 'relax_disp')
3610
3611
3612 self.interpreter.results.read(prev_data_path + sep + 'results')
3613
3614
3615 my_dic = {}
3616 param_key_list = []
3617
3618
3619 do_boot = True
3620 if do_boot:
3621 min_algor = 'Newton'
3622 min_options = ()
3623 sim_boot = 200
3624 scaling_list = [1.0, 1.0]
3625
3626
3627 for cur_spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
3628
3629 my_dic[spin_id] = {}
3630
3631
3632 for i, r2eff_sim in enumerate(cur_spin.r2eff_sim):
3633
3634 for exp_type, frq, offset, point, ei, mi, oi, di in loop_exp_frq_offset_point(return_indices=True):
3635
3636 param_key = return_param_key_from_data(exp_type=exp_type, frq=frq, offset=offset, point=point)
3637 r2eff_sim_point = r2eff_sim[param_key]
3638 i0_sim_point = cur_spin.r2eff_sim[i][param_key]
3639
3640
3641
3642
3643 self.assert_(r2eff_sim_point > 0.0)
3644 self.assert_(i0_sim_point > 0.0)
3645
3646
3647 for cur_spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
3648
3649 spin_string = generate_spin_string(spin=cur_spin, mol_name=mol_name, res_num=resi, res_name=resn)
3650
3651 for exp_type, frq, offset, point, ei, mi, oi, di in loop_exp_frq_offset_point(return_indices=True):
3652
3653 param_key = return_param_key_from_data(exp_type=exp_type, frq=frq, offset=offset, point=point)
3654
3655
3656 r2eff_sim_l = []
3657 i0_sim_l = []
3658 for i, r2eff_sim in enumerate(cur_spin.r2eff_sim):
3659 i0_sim = cur_spin.i0_sim[i]
3660
3661 r2eff_sim_i = r2eff_sim[param_key]
3662 r2eff_sim_l.append(r2eff_sim_i)
3663 i0_sim_i = i0_sim[param_key]
3664 i0_sim_l.append(i0_sim_i)
3665
3666
3667 r2eff_sim_err = std(asarray(r2eff_sim_l), ddof=1)
3668 i0_sim_err = std(asarray(i0_sim_l), ddof=1)
3669
3670
3671 param_key_list.append(param_key)
3672
3673
3674 my_dic[spin_id][param_key] = {}
3675
3676
3677 r2eff = getattr(cur_spin, 'r2eff')[param_key]
3678 r2eff_err = getattr(cur_spin, 'r2eff_err')[param_key]
3679 i0 = getattr(cur_spin, 'i0')[param_key]
3680 i0_err = getattr(cur_spin, 'i0_err')[param_key]
3681
3682
3683 my_dic[spin_id][param_key]['r2eff'] = r2eff
3684 my_dic[spin_id][param_key]['r2eff_err'] = r2eff_err
3685 my_dic[spin_id][param_key]['i0'] = i0
3686 my_dic[spin_id][param_key]['i0_err'] = i0_err
3687 my_dic[spin_id][param_key]['r2eff_err_sim'] = r2eff_sim_err
3688 my_dic[spin_id][param_key]['i0_err_sim'] = i0_sim_err
3689
3690
3691 self.assertAlmostEqual(r2eff_sim_err, r2eff_err)
3692 self.assertAlmostEqual(i0_sim_err, i0_err)
3693
3694 if do_boot:
3695 values = []
3696 errors = []
3697 times = []
3698 for time in loop_time(exp_type=exp_type, frq=frq, offset=offset, point=point):
3699 values.append(average_intensity(spin=cur_spin, exp_type=exp_type, frq=frq, offset=offset, point=point, time=time))
3700 errors.append(average_intensity(spin=cur_spin, exp_type=exp_type, frq=frq, offset=offset, point=point, time=time, error=True))
3701 times.append(time)
3702
3703
3704 values = asarray(values)
3705 errors = asarray(errors)
3706 times = asarray(times)
3707
3708 R_m_sim_l = []
3709 I0_m_sim_l = []
3710 for j in range(sim_boot):
3711 if j in range(0, 100000, 100):
3712 print("Simulation %i"%j)
3713
3714
3715
3716 I_err = []
3717 for j, error in enumerate(errors):
3718 I_error = gauss(values[j], error)
3719 I_err.append(I_error)
3720
3721 I_err = asarray(I_err)
3722
3723 x0 = [r2eff, i0]
3724 model = Relax_fit_opt(model='exp', num_params=len(x0), values=I_err, errors=errors, relax_times=times, scaling_matrix=scaling_list)
3725
3726 params_minfx_sim_j, chi2_minfx_sim_j, iter_count, f_count, g_count, h_count, warning = generic_minimise(func=model.func, dfunc=model.dfunc, d2func=model.d2func, args=(), x0=x0, min_algor=min_algor, min_options=min_options, full_output=True, print_flag=0)
3727 R_m_sim_j, I0_m_sim_j = params_minfx_sim_j
3728 R_m_sim_l.append(R_m_sim_j)
3729 I0_m_sim_l.append(I0_m_sim_j)
3730
3731
3732 sigma_R_sim = std(asarray(R_m_sim_l), ddof=1)
3733 sigma_I0_sim = std(asarray(I0_m_sim_l), ddof=1)
3734 my_dic[spin_id][param_key]['r2eff_err_boot'] = sigma_R_sim
3735 my_dic[spin_id][param_key]['i0_err_boot'] = sigma_I0_sim
3736
3737
3738
3739 self.interpreter.pipe.copy(pipe_from='MC_2000', pipe_to='r2eff_est')
3740 self.interpreter.pipe.switch(pipe_name='r2eff_est')
3741
3742
3743 for cur_spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
3744 delattr(cur_spin, 'r2eff_err')
3745 delattr(cur_spin, 'i0_err')
3746
3747
3748 self.interpreter.relax_disp.select_model(MODEL_R2EFF)
3749
3750
3751 self.interpreter.relax_disp.r2eff_err_estimate(verbosity=0)
3752
3753 for cur_spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
3754
3755 spin_string = generate_spin_string(spin=cur_spin, mol_name=mol_name, res_num=resi, res_name=resn)
3756
3757 for exp_type, frq, offset, point, ei, mi, oi, di in loop_exp_frq_offset_point(return_indices=True):
3758
3759 param_key = return_param_key_from_data(exp_type=exp_type, frq=frq, offset=offset, point=point)
3760
3761
3762 r2eff_est = getattr(cur_spin, 'r2eff')[param_key]
3763 r2eff_err_est = getattr(cur_spin, 'r2eff_err')[param_key]
3764 i0_est = getattr(cur_spin, 'i0')[param_key]
3765 i0_err_est = getattr(cur_spin, 'i0_err')[param_key]
3766
3767
3768 r2eff = my_dic[spin_id][param_key]['r2eff']
3769 r2eff_err = my_dic[spin_id][param_key]['r2eff_err']
3770 i0 = my_dic[spin_id][param_key]['i0']
3771 i0_err = my_dic[spin_id][param_key]['i0_err']
3772 r2eff_sim_err = my_dic[spin_id][param_key]['r2eff_err_sim']
3773 i0_sim_err = my_dic[spin_id][param_key]['i0_err_sim']
3774
3775 if do_boot:
3776 r2eff_boot_err = my_dic[spin_id][param_key]['r2eff_err_boot']
3777 i0_boot_err = my_dic[spin_id][param_key]['i0_err_boot']
3778 else:
3779 r2eff_boot_err = 0.0
3780 i0_boot_err = 0.0
3781
3782 print("%s at %3.1f MHz, for offset=%3.3f ppm and dispersion point %-5.1f." % (exp_type, frq/1E6, offset, point) )
3783 print("r2eff=%3.3f/%3.3f r2eff_err=%3.4f/%3.4f/%3.4f/%3.4f" % (r2eff, r2eff_est, r2eff_err, r2eff_err_est, r2eff_sim_err, r2eff_boot_err) ),
3784 print("i0=%3.3f/%3.3f i0_err=%3.4f/%3.4f/%3.4f/%3.4f\n" % (i0, i0_est, i0_err, i0_err_est, i0_sim_err, i0_boot_err) )
3785
3786
3787
3788 estimate_r2eff(method='scipy.optimize.leastsq')
3789
3790 estimate_r2eff(method='minfx', min_algor='simplex', c_code=True, constraints=False, chi2_jacobian=False)
3791 estimate_r2eff(method='minfx', min_algor='simplex', c_code=True, constraints=False, chi2_jacobian=True)
3792
3793 estimate_r2eff(method='minfx', min_algor='simplex', c_code=False, constraints=False, chi2_jacobian=False)
3794 estimate_r2eff(method='minfx', min_algor='simplex', c_code=False, constraints=False, chi2_jacobian=True)
3795
3796 estimate_r2eff(method='minfx', min_algor='BFGS', c_code=True, constraints=False, chi2_jacobian=False)
3797 estimate_r2eff(method='minfx', min_algor='BFGS', c_code=True, constraints=False, chi2_jacobian=True)
3798
3799 estimate_r2eff(method='minfx', min_algor='BFGS', c_code=False, constraints=False, chi2_jacobian=False)
3800 estimate_r2eff(method='minfx', min_algor='BFGS', c_code=False, constraints=False, chi2_jacobian=True)
3801
3802 estimate_r2eff(method='minfx', min_algor='Newton', c_code=True, constraints=False, chi2_jacobian=False)
3803 estimate_r2eff(method='minfx', min_algor='Newton', c_code=True, constraints=False, chi2_jacobian=True)
3804
3805
3806
3808 """Test the relaxation dispersion 'exp_fit' model curve fitting."""
3809
3810
3811 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'exp_fit.py')
3812
3813
3814 res_data = [
3815 [15., 10., 20000., 25000.],
3816 [12., 11., 50000., 51000.],
3817 [17., 9., 100000., 96000.]
3818 ]
3819
3820
3821 blacklist = ['cpmg_frqs', 'r2', 'rex', 'kex', 'r2a', 'k_AB', 'dw']
3822
3823
3824 for i in range(len(res_data)):
3825
3826 print("\nResidue number %s." % (i+1))
3827
3828
3829 self.assertAlmostEqual(cdp.mol[0].res[i].spin[0].r2eff['r1rho_1200.00000000_0.000_1000.000'], res_data[i][0], places=2)
3830 self.assertAlmostEqual(cdp.mol[0].res[i].spin[0].r2eff['r1rho_1200.00000000_0.000_2000.000'], res_data[i][1], places=2)
3831 self.assertAlmostEqual(cdp.mol[0].res[i].spin[0].i0['r1rho_1200.00000000_0.000_1000.000']/10000, res_data[i][2]/10000, places=3)
3832 self.assertAlmostEqual(cdp.mol[0].res[i].spin[0].i0['r1rho_1200.00000000_0.000_2000.000']/10000, res_data[i][3]/10000, places=3)
3833
3834
3835 self.assert_(cdp.mol[0].res[i].spin[0].r2eff_err['r1rho_1200.00000000_0.000_1000.000'] < 5.0)
3836 self.assert_(cdp.mol[0].res[i].spin[0].r2eff_err['r1rho_1200.00000000_0.000_2000.000'] < 5.0)
3837 self.assert_(cdp.mol[0].res[i].spin[0].i0_err['r1rho_1200.00000000_0.000_1000.000']/10000 < 5.0)
3838 self.assert_(cdp.mol[0].res[i].spin[0].i0_err['r1rho_1200.00000000_0.000_2000.000']/10000 < 5.0)
3839
3840
3841 for param in blacklist:
3842 print("\tChecking for the absence of the '%s' parameter." % param)
3843 self.assert_(not hasattr(cdp.mol[0].res[i].spin[0], param))
3844
3845
3846 self.assert_(hasattr(cdp, 'clustering'))
3847 keys = ['free spins', 'cluster']
3848 for key in keys:
3849 self.assert_(key in cdp.clustering)
3850 self.assert_('test' not in cdp.clustering)
3851 self.assertEqual(cdp.clustering['free spins'], [':2@N'])
3852 self.assertEqual(cdp.clustering['cluster'], [':1@N', ':3@N'])
3853
3854
3856 """Test return from C code, when parameters are wrong. This can happen, if minfx takes a wrong step."""
3857
3858 times = array([ 0.7, 1., 0.8, 0.4, 0.9])
3859 I = array([ 476.76174875, 372.43328777, 454.20339981, 656.87936253, 419.16726341])
3860 errors = array([ 9.48032653, 11.34093541, 9.35149017, 10.84867928, 12.17590736])
3861
3862 scaling_list = [1.0, 1.0]
3863 model = Relax_fit_opt(model='exp', num_params=2, values=I, errors=errors, relax_times=times, scaling_matrix=scaling_list)
3864
3865 R = - 500.
3866 I0 = 1000.
3867 params = [R, I0]
3868
3869 chi2 = model.func(params)
3870
3871 print("The chi2 value returned from C-code for R=%3.2f and I0=%3.2f, then chi2=%3.2f"%(R, I0, chi2))
3872 self.assertNotEqual(chi2, inf)
3873
3874
3985
3986
3988 """Test of the dispersion auto-analysis using Dr. Flemming Hansen's CPMG data.
3989
3990 This uses the data from Dr. Flemming Hansen's paper at http://dx.doi.org/10.1021/jp074793o. This is CPMG data with a fixed relaxation time period.
3991 """
3992
3993
3994 ds.models = [
3995 MODEL_NOREX,
3996 MODEL_LM63,
3997 MODEL_CR72,
3998 MODEL_IT99
3999 ]
4000
4001
4002 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'hansen_data.py')
4003 self.interpreter.state.save('analysis_heights', dir=ds.tmpdir, force=True)
4004
4005
4006 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6)
4007 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6)
4008
4009
4010 self.interpreter.pipe.switch(pipe_name='No Rex - relax_disp')
4011 spin70 = return_spin(":70")
4012 spin71 = return_spin(":71")
4013 print("\n\nOptimised parameters:\n")
4014 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)"))
4015 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin70.r2[r20_key1], spin71.r2[r20_key1]))
4016 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin70.r2[r20_key2], spin71.r2[r20_key2]))
4017 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2))
4018 self.assertAlmostEqual(spin70.r2[r20_key1], 10.5340593984683, 3)
4019 self.assertAlmostEqual(spin70.r2[r20_key2], 16.1112170102734, 3)
4020 self.assertAlmostEqual(spin70.chi2, 8973.84810025761, 3)
4021 self.assertAlmostEqual(spin71.r2[r20_key1], 5.83139953954648, 3)
4022 self.assertAlmostEqual(spin71.r2[r20_key2], 8.90856319376098, 3)
4023 self.assertAlmostEqual(spin71.chi2, 3908.00127830003, 3)
4024
4025
4026 self.interpreter.pipe.switch(pipe_name='LM63 - relax_disp')
4027 spin70 = return_spin(":70")
4028 spin71 = return_spin(":71")
4029 print("\n\nOptimised parameters:\n")
4030 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)"))
4031 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin70.r2[r20_key1], spin71.r2[r20_key1]))
4032 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin70.r2[r20_key2], spin71.r2[r20_key2]))
4033 print("%-20s %20.15g %20.15g" % ("phi_ex", spin70.phi_ex, spin71.phi_ex))
4034 print("%-20s %20.15g %20.15g" % ("kex", spin70.kex, spin71.kex))
4035 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2))
4036 self.assertAlmostEqual(spin70.r2[r20_key1], 6.74326615264889, 2)
4037 self.assertAlmostEqual(spin70.r2[r20_key2], 6.57331164382438, 2)
4038 self.assertAlmostEqual(spin70.phi_ex, 0.312767653822936, 3)
4039 self.assertAlmostEqual(spin70.kex/10000, 4723.44390412119/10000, 3)
4040 self.assertAlmostEqual(spin70.chi2, 363.534049046805, 3)
4041 self.assertAlmostEqual(spin71.r2[r20_key1], 5.00778024769786, 3)
4042 self.assertAlmostEqual(spin71.r2[r20_key2], 6.83343630016037, 3)
4043 self.assertAlmostEqual(spin71.phi_ex, 0.0553791362097596, 3)
4044 self.assertAlmostEqual(spin71.kex/10000, 2781.67925957068/10000, 3)
4045 self.assertAlmostEqual(spin71.chi2, 17.0776426190574, 3)
4046
4047
4048 self.interpreter.pipe.switch(pipe_name='CR72 - relax_disp')
4049 spin70 = return_spin(":70")
4050 spin71 = return_spin(":71")
4051 print("\n\nOptimised parameters:\n")
4052 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)"))
4053 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin70.r2[r20_key1], spin71.r2[r20_key1]))
4054 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin70.r2[r20_key2], spin71.r2[r20_key2]))
4055 print("%-20s %20.15g %20.15g" % ("pA", spin70.pA, spin71.pA))
4056 print("%-20s %20.15g %20.15g" % ("dw", spin70.dw, spin71.dw))
4057 print("%-20s %20.15g %20.15g" % ("kex", spin70.kex, spin71.kex))
4058 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2))
4059 self.assertAlmostEqual(spin70.r2[r20_key1], 6.97233943292193, 3)
4060 self.assertAlmostEqual(spin70.r2[r20_key2], 9.409506394526, 2)
4061 self.assertAlmostEqual(spin70.pA, 0.989856804525044, 3)
4062 self.assertAlmostEqual(spin70.dw, 5.60889078920945, 3)
4063 self.assertAlmostEqual(spin70.kex/10000, 1753.01607073019/10000, 3)
4064 self.assertAlmostEqual(spin70.chi2, 53.8382158551706, 3)
4065 self.assertAlmostEqual(spin71.r2[r20_key1], 5.003171547206, 3)
4066 self.assertAlmostEqual(spin71.r2[r20_key2], 6.90210797727492, 3)
4067 self.assertAlmostEqual(spin71.pA, 0.985922406455826, 3)
4068 self.assertAlmostEqual(spin71.dw, 2.00500965892672, 2)
4069 self.assertAlmostEqual(spin71.kex/10000, 2481.10839579617/10000, 3)
4070 self.assertAlmostEqual(spin71.chi2, 15.6595374286822, 3)
4071
4072
4074 """Test of the numeric model only dispersion auto-analysis using Dr. Flemming Hansen's CPMG data.
4075
4076 This uses the data from Dr. Flemming Hansen's paper at http://dx.doi.org/10.1021/jp074793o. This is CPMG data with a fixed relaxation time period.
4077 """
4078
4079
4080 ds.models = [
4081 MODEL_NOREX,
4082 MODEL_CR72,
4083 MODEL_NS_CPMG_2SITE_EXPANDED
4084 ]
4085 ds.numeric_only = True
4086
4087
4088 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'hansen_data.py')
4089
4090
4091 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6)
4092 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6)
4093
4094
4095 self.interpreter.pipe.switch(pipe_name='No Rex - relax_disp')
4096 spin70 = return_spin(":70")
4097 spin71 = return_spin(":71")
4098 print("\n\nOptimised parameters:\n")
4099 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)"))
4100 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin70.r2[r20_key1], spin71.r2[r20_key1]))
4101 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin70.r2[r20_key2], spin71.r2[r20_key2]))
4102 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2))
4103 self.assertAlmostEqual(spin70.r2[r20_key1], 10.5340593984683, 3)
4104 self.assertAlmostEqual(spin70.r2[r20_key2], 16.1112170102734, 3)
4105 self.assertAlmostEqual(spin70.chi2/10000, 8973.84810025761/10000, 3)
4106 self.assertAlmostEqual(spin71.r2[r20_key1], 5.83139953954648, 3)
4107 self.assertAlmostEqual(spin71.r2[r20_key2], 8.90856319376098, 3)
4108 self.assertAlmostEqual(spin71.chi2/10000, 3908.00127830003/10000, 3)
4109
4110
4111 self.interpreter.pipe.switch(pipe_name='CR72 - relax_disp')
4112 spin70 = return_spin(":70")
4113 spin71 = return_spin(":71")
4114 print("\n\nOptimised parameters:\n")
4115 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)"))
4116 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin70.r2[r20_key1], spin71.r2[r20_key1]))
4117 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin70.r2[r20_key2], spin71.r2[r20_key2]))
4118 print("%-20s %20.15g %20.15g" % ("pA", spin70.pA, spin71.pA))
4119 print("%-20s %20.15g %20.15g" % ("dw", spin70.dw, spin71.dw))
4120 print("%-20s %20.15g %20.15g" % ("kex", spin70.kex, spin71.kex))
4121 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2))
4122 self.assertAlmostEqual(spin70.r2[r20_key1], 6.97233943292193, 3)
4123 self.assertAlmostEqual(spin70.r2[r20_key2], 9.409506394526, 2)
4124 self.assertAlmostEqual(spin70.pA, 0.989856804525044, 3)
4125 self.assertAlmostEqual(spin70.dw, 5.60889078920945, 3)
4126 self.assertAlmostEqual(spin70.kex/10000, 1753.01607073019/10000, 3)
4127 self.assertAlmostEqual(spin70.chi2, 53.8382158551706, 3)
4128 self.assertAlmostEqual(spin71.r2[r20_key1], 5.003171547206, 3)
4129 self.assertAlmostEqual(spin71.r2[r20_key2], 6.90210797727492, 3)
4130 self.assertAlmostEqual(spin71.pA, 0.985922406455826, 3)
4131 self.assertAlmostEqual(spin71.dw, 2.00500965892672, 2)
4132 self.assertAlmostEqual(spin71.kex/10000, 2481.10839579617/10000, 3)
4133 self.assertAlmostEqual(spin71.chi2, 15.6595374286822, 3)
4134
4135
4136 self.interpreter.pipe.switch(pipe_name='NS CPMG 2-site expanded - relax_disp')
4137 spin70 = return_spin(":70")
4138 spin71 = return_spin(":71")
4139 print("\n\nOptimised parameters:\n")
4140 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)"))
4141 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin70.r2[r20_key1], spin71.r2[r20_key1]))
4142 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin70.r2[r20_key2], spin71.r2[r20_key2]))
4143 print("%-20s %20.15g %20.15g" % ("pA", spin70.pA, spin71.pA))
4144 print("%-20s %20.15g %20.15g" % ("dw", spin70.dw, spin71.dw))
4145 print("%-20s %20.15g %20.15g" % ("kex", spin70.kex, spin71.kex))
4146 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2))
4147 self.assertAlmostEqual(spin70.r2[r20_key1], 6.95815351460902, 3)
4148 self.assertAlmostEqual(spin70.r2[r20_key2], 9.39649535771294, 3)
4149 self.assertAlmostEqual(spin70.pA, 0.989701014493195, 3)
4150 self.assertAlmostEqual(spin70.dw, 5.67314464776128, 3)
4151 self.assertAlmostEqual(spin70.kex/10000, 1713.65380495429/10000, 3)
4152 self.assertAlmostEqual(spin70.chi2, 52.5106880917473, 3)
4153 self.assertAlmostEqual(spin71.r2[r20_key1], 4.99889337382435, 3)
4154 self.assertAlmostEqual(spin71.r2[r20_key2], 6.89822887466673, 3)
4155 self.assertAlmostEqual(spin71.pA, 0.986709050819695, 3)
4156 self.assertAlmostEqual(spin71.dw, 2.09238266766502, 2)
4157 self.assertAlmostEqual(spin71.kex/10000, 2438.27019901422/10000, 3)
4158 self.assertAlmostEqual(spin71.chi2, 15.1644906963987, 3)
4159
4160
4161 self.interpreter.pipe.switch(pipe_name='final - relax_disp')
4162 spin70 = return_spin(":70")
4163 spin71 = return_spin(":71")
4164 self.assertEqual(spin70.model, 'NS CPMG 2-site expanded')
4165 self.assertEqual(spin71.model, 'NS CPMG 2-site expanded')
4166
4167
4169 """Test of the dispersion auto-analysis using Dr. Flemming Hansen's CPMG data (using the R2eff data directly instead of peak intensities).
4170
4171 This uses the data from Dr. Flemming Hansen's paper at http://dx.doi.org/10.1021/jp074793o. This is CPMG data with a fixed relaxation time period.
4172 """
4173
4174
4175 ds.models = [
4176 MODEL_NOREX,
4177 MODEL_LM63,
4178 MODEL_CR72,
4179 MODEL_IT99
4180 ]
4181
4182
4183 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'hansen_r2eff_data.py')
4184 self.interpreter.state.save('analysis_r2eff', dir=ds.tmpdir, force=True)
4185
4186
4187 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6)
4188 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6)
4189
4190
4191 self.interpreter.pipe.switch(pipe_name='No Rex - relax_disp')
4192 spin70 = return_spin(":70")
4193 spin71 = return_spin(":71")
4194 print("\n\nOptimised parameters:\n")
4195 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)"))
4196 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin70.r2[r20_key1], spin71.r2[r20_key1]))
4197 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin70.r2[r20_key2], spin71.r2[r20_key2]))
4198 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2))
4199 self.assertAlmostEqual(spin70.r2[r20_key1], 10.5340593984683, 3)
4200 self.assertAlmostEqual(spin70.r2[r20_key2], 16.1112170102734, 3)
4201 self.assertAlmostEqual(spin70.chi2, 8973.84810025761, 3)
4202 self.assertAlmostEqual(spin71.r2[r20_key1], 5.83139953954648, 3)
4203 self.assertAlmostEqual(spin71.r2[r20_key2], 8.90856319376098, 3)
4204 self.assertAlmostEqual(spin71.chi2, 3908.00127830003, 3)
4205
4206
4207 self.interpreter.pipe.switch(pipe_name='LM63 - relax_disp')
4208 spin70 = return_spin(":70")
4209 spin71 = return_spin(":71")
4210 print("\n\nOptimised parameters:\n")
4211 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)"))
4212 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin70.r2[r20_key1], spin71.r2[r20_key1]))
4213 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin70.r2[r20_key2], spin71.r2[r20_key2]))
4214 print("%-20s %20.15g %20.15g" % ("phi_ex", spin70.phi_ex, spin71.phi_ex))
4215 print("%-20s %20.15g %20.15g" % ("kex", spin70.kex, spin71.kex))
4216 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2))
4217 self.assertAlmostEqual(spin70.r2[r20_key1], 6.74326615264889, 2)
4218 self.assertAlmostEqual(spin70.r2[r20_key2], 6.57331164382438, 2)
4219 self.assertAlmostEqual(spin70.phi_ex, 0.312767653822936, 3)
4220 self.assertAlmostEqual(spin70.kex/10000, 4723.44390412119/10000, 3)
4221 self.assertAlmostEqual(spin70.chi2, 363.534049046805, 3)
4222 self.assertAlmostEqual(spin71.r2[r20_key1], 5.00778024769786, 3)
4223 self.assertAlmostEqual(spin71.r2[r20_key2], 6.83343630016037, 3)
4224 self.assertAlmostEqual(spin71.phi_ex, 0.0553791362097596, 3)
4225 self.assertAlmostEqual(spin71.kex/10000, 2781.67925957068/10000, 3)
4226 self.assertAlmostEqual(spin71.chi2, 17.0776426190574, 3)
4227
4228
4229 self.interpreter.pipe.switch(pipe_name='CR72 - relax_disp')
4230 spin70 = return_spin(":70")
4231 spin71 = return_spin(":71")
4232 print("\n\nOptimised parameters:\n")
4233 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)"))
4234 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin70.r2[r20_key1], spin71.r2[r20_key1]))
4235 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin70.r2[r20_key2], spin71.r2[r20_key2]))
4236 print("%-20s %20.15g %20.15g" % ("pA", spin70.pA, spin71.pA))
4237 print("%-20s %20.15g %20.15g" % ("dw", spin70.dw, spin71.dw))
4238 print("%-20s %20.15g %20.15g" % ("kex", spin70.kex, spin71.kex))
4239 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2))
4240 self.assertAlmostEqual(spin70.r2[r20_key1], 6.97233943292193, 3)
4241 self.assertAlmostEqual(spin70.r2[r20_key2], 9.409506394526, 2)
4242 self.assertAlmostEqual(spin70.pA, 0.989856804525044, 3)
4243 self.assertAlmostEqual(spin70.dw, 5.60889078920945, 3)
4244 self.assertAlmostEqual(spin70.kex/10000, 1753.01607073019/10000, 3)
4245 self.assertAlmostEqual(spin70.chi2, 53.8382158551706, 3)
4246 self.assertAlmostEqual(spin71.r2[r20_key1], 5.00317154730225, 3)
4247 self.assertAlmostEqual(spin71.r2[r20_key2], 6.90210797713541, 3)
4248 self.assertAlmostEqual(spin71.pA, 0.985922406429147, 3)
4249 self.assertAlmostEqual(spin71.dw, 2.00500965887772, 2)
4250 self.assertAlmostEqual(spin71.kex/10000, 2481.10839579804/10000, 3)
4251 self.assertAlmostEqual(spin71.chi2, 15.6595374288635, 3)
4252
4253
4255 """Test of the dispersion auto-analysis using Dr. Flemming Hansen's CPMG data with parts missing.
4256
4257 This uses the data from Dr. Flemming Hansen's paper at http://dx.doi.org/10.1021/jp074793o. This is CPMG data with a fixed relaxation time period.
4258 """
4259
4260
4261 ds.models = [
4262 MODEL_R2EFF,
4263 MODEL_NOREX,
4264 MODEL_CR72,
4265 MODEL_NS_CPMG_2SITE_EXPANDED
4266 ]
4267
4268
4269 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'hansen_data_missing.py')
4270 self.interpreter.state.save('analysis_heights', dir=ds.tmpdir, force=True)
4271
4272
4273 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6)
4274 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6)
4275
4276
4277 self.interpreter.pipe.switch(pipe_name='No Rex - relax_disp')
4278 spin4 = return_spin(":4")
4279 spin70 = return_spin(":70")
4280 spin71 = return_spin(":71")
4281 print("\n\nOptimised parameters:\n")
4282 print("%-20s %-20s %-20s %-20s" % ("Parameter", "Value (:4)", "Value (:70)", "Value (:71)"))
4283 print("%-20s %20.15g %20.15g %20.15g" % ("R2 (500 MHz)", spin4.r2[r20_key1], spin70.r2[r20_key1], spin71.r2[r20_key1]))
4284 print("%-20s %20.15g %20.15g %20.15g" % ("R2 (800 MHz)", spin4.r2[r20_key2], spin70.r2[r20_key2], spin71.r2[r20_key2]))
4285 print("%-20s %20.15g %20.15g %20.15g\n" % ("chi2", spin4.chi2, spin70.chi2, spin71.chi2))
4286 self.assertAlmostEqual(spin4.r2[r20_key1], 1.60463084515171, 3)
4287 self.assertAlmostEqual(spin4.r2[r20_key2], 1.63220784651911, 3)
4288 self.assertAlmostEqual(spin4.chi2, 26.7356700694891, 3)
4289 self.assertAlmostEqual(spin70.r2[r20_key1], 10.534285641325, 3)
4290 self.assertAlmostEqual(spin70.r2[r20_key2], 16.1112794857068, 3)
4291 self.assertAlmostEqual(spin70.chi2, 8973.84809774722, 3)
4292 self.assertAlmostEqual(spin71.r2[r20_key1], 5.83136858890037, 3)
4293 self.assertAlmostEqual(spin71.chi2, 182.60081909193, 3)
4294
4295
4296 self.interpreter.pipe.switch(pipe_name='CR72 - relax_disp')
4297 spin4 = return_spin(":4")
4298 spin70 = return_spin(":70")
4299 spin71 = return_spin(":71")
4300 print("\n\nOptimised parameters:\n")
4301 print("%-20s %-20s %-20s %-20s" % ("Parameter", "Value (:4)", "Value (:70)", "Value (:71)"))
4302 print("%-20s %20.15g %20.15g %20.15g" % ("R2 (500 MHz)", spin4.r2[r20_key1], spin70.r2[r20_key1], spin71.r2[r20_key1]))
4303 print("%-20s %20.15g %20.15g %20.15g" % ("R2 (800 MHz)", spin4.r2[r20_key2], spin70.r2[r20_key2], spin71.r2[r20_key2]))
4304 print("%-20s %20.15g %20.15g %20.15g" % ("pA", spin4.pA, spin70.pA, spin71.pA))
4305 print("%-20s %20.15g %20.15g %20.15g" % ("dw", spin4.dw, spin70.dw, spin71.dw))
4306 print("%-20s %20.15g %20.15g %20.15g" % ("kex", spin4.kex, spin70.kex, spin71.kex))
4307 print("%-20s %20.15g %20.15g %20.15g\n" % ("chi2", spin4.chi2, spin70.chi2, spin71.chi2))
4308 self.assertAlmostEqual(spin4.r2[r20_key1], 1.60463650370664, 2)
4309 self.assertAlmostEqual(spin4.r2[r20_key2], 1.63221675941434, 3)
4310
4311 self.assertAlmostEqual(spin4.dw, 0.0, 2)
4312 self.assertAlmostEqual(spin4.kex/10000, 0.0, 3)
4313 self.assertAlmostEqual(spin4.chi2/100, 26.7356711142038/100, 3)
4314 self.assertAlmostEqual(spin70.r2[r20_key1], 6.97268077496405, 3)
4315 self.assertAlmostEqual(spin70.r2[r20_key2], 9.41028133407727, 3)
4316 self.assertAlmostEqual(spin70.pA, 0.989856641885939, 3)
4317 self.assertAlmostEqual(spin70.dw, 5.60889911049405, 3)
4318 self.assertAlmostEqual(spin70.kex/10000, 1752.62025618632/10000, 3)
4319 self.assertAlmostEqual(spin70.chi2, 53.8382196964083, 3)
4320 self.assertAlmostEqual(spin71.r2[r20_key1], 4.98123328466942, 3)
4321 self.assertAlmostEqual(spin71.pA, 0.996607425484157, 3)
4322 self.assertAlmostEqual(spin71.dw, 4.34346257383825, 2)
4323 self.assertAlmostEqual(spin71.kex/10000, 1936.73197158804/10000, 3)
4324 self.assertAlmostEqual(spin71.chi2, 5.51703791653689, 3)
4325
4326
4328 """Optimisation of Dr. Flemming Hansen's CPMG data to the CR72 dispersion model.
4329
4330 This uses the data from Dr. Flemming Hansen's paper at http://dx.doi.org/10.1021/jp074793o. This is CPMG data with a fixed relaxation time period.
4331 """
4332
4333
4334 self.setup_hansen_cpmg_data(model='CR72')
4335
4336
4337 spin70 = return_spin(":70")
4338 spin71 = return_spin(":71")
4339
4340
4341 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6)
4342 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6)
4343
4344
4345 spin70.r2 = {r20_key1: 7.0, r20_key2: 9.0}
4346 spin70.pA = 0.9
4347 spin70.dw = 6.0
4348 spin70.kex = 1500.0
4349 spin71.r2 = {r20_key1: 5, r20_key2: 9.0}
4350 spin71.pA = 0.9
4351 spin71.dw = 4.0
4352 spin71.kex = 1900.0
4353
4354
4355 self.interpreter.minimise.execute(min_algor='simplex', line_search=None, hessian_mod=None, hessian_type=None, func_tol=1e-05, grad_tol=None, max_iter=1000, constraints=True, scaling=True, verbosity=1)
4356
4357
4358 print("\n\nOptimised parameters:\n")
4359 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)"))
4360 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin70.r2[r20_key1], spin71.r2[r20_key1]))
4361 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin70.r2[r20_key2], spin71.r2[r20_key2]))
4362 print("%-20s %20.15g %20.15g" % ("pA", spin70.pA, spin71.pA))
4363 print("%-20s %20.15g %20.15g" % ("dw", spin70.dw, spin71.dw))
4364 print("%-20s %20.15g %20.15g" % ("kex", spin70.kex, spin71.kex))
4365 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2))
4366
4367
4368 self.assertAlmostEqual(spin70.r2[r20_key1], 6.9724581325007, 4)
4369 self.assertAlmostEqual(spin70.r2[r20_key2], 9.40968331038162, 2)
4370 self.assertAlmostEqual(spin70.pA, 0.989856656702431, 4)
4371 self.assertAlmostEqual(spin70.dw, 5.60885879594746, 3)
4372 self.assertAlmostEqual(spin70.kex/1000, 1752.91052702273/1000, 3)
4373 self.assertAlmostEqual(spin70.chi2, 53.8382133597495, 4)
4374
4375
4376 self.assertAlmostEqual(spin71.r2[r20_key1], 5.0030740940524, 4)
4377 self.assertAlmostEqual(spin71.pA, 0.985941082507823, 4)
4378 self.assertAlmostEqual(spin71.dw, 2.00640384113696, 4)
4379 self.assertAlmostEqual(spin71.kex/1000, 2480.79614442041/1000, 4)
4380 self.assertAlmostEqual(spin71.chi2, 15.6595388312451, 4)
4381
4382
4383 self.assertEqual(spin70.k_AB, spin70.kex * (1.0 - spin70.pA))
4384 self.assertEqual(spin71.k_AB, spin71.kex * (1.0 - spin71.pA))
4385
4386
4387 self.assertEqual(spin70.k_BA, spin70.kex * spin70.pA)
4388 self.assertEqual(spin71.k_BA, spin71.kex * spin71.pA)
4389
4390
4392 """Optimisation of Dr. Flemming Hansen's CPMG data to the CR72 full dispersion model.
4393
4394 This uses the data from Dr. Flemming Hansen's paper at http://dx.doi.org/10.1021/jp074793o. This is CPMG data with a fixed relaxation time period.
4395 """
4396
4397
4398 self.setup_hansen_cpmg_data(model='CR72 full')
4399
4400
4401 spin70 = return_spin(":70")
4402 spin71 = return_spin(":71")
4403
4404
4405 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6)
4406 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6)
4407
4408
4409 spin70.r2a = {r20_key1: 7.0, r20_key2: 9.0}
4410 spin70.r2b = {r20_key1: 7.0, r20_key2: 9.0}
4411 spin70.pA = 0.9
4412 spin70.dw = 6.0
4413 spin70.kex = 1500.0
4414 spin71.r2a = {r20_key1: 5.0, r20_key2: 9.0}
4415 spin71.r2b = {r20_key1: 5.0, r20_key2: 9.0}
4416 spin71.pA = 0.9
4417 spin71.dw = 4.0
4418 spin71.kex = 1900.0
4419
4420
4421 self.interpreter.minimise.execute(min_algor='simplex', line_search=None, hessian_mod=None, hessian_type=None, func_tol=1e-05, grad_tol=None, max_iter=1000, constraints=True, scaling=True, verbosity=1)
4422
4423
4424 print("\n\nOptimised parameters:\n")
4425 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)"))
4426 print("%-20s %20.15g %20.15g" % ("R2A (500 MHz)", spin70.r2a[r20_key1], spin71.r2a[r20_key1]))
4427 print("%-20s %20.15g %20.15g" % ("R2B (500 MHz)", spin70.r2b[r20_key1], spin71.r2b[r20_key1]))
4428 print("%-20s %20.15g %20.15g" % ("R2A (800 MHz)", spin70.r2a[r20_key2], spin71.r2a[r20_key2]))
4429 print("%-20s %20.15g %20.15g" % ("R2B (800 MHz)", spin70.r2b[r20_key2], spin71.r2b[r20_key2]))
4430 print("%-20s %20.15g %20.15g" % ("pA", spin70.pA, spin71.pA))
4431 print("%-20s %20.15g %20.15g" % ("dw", spin70.dw, spin71.dw))
4432 print("%-20s %20.15g %20.15g" % ("kex", spin70.kex, spin71.kex))
4433 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2))
4434
4435
4436 self.assertAlmostEqual(spin70.r2a[r20_key1], 6.87485258365614, 4)
4437 self.assertAlmostEqual(spin70.r2b[r20_key1], 1.26075839074614, 4)
4438 self.assertAlmostEqual(spin70.r2a[r20_key2], 8.79580446260797, 4)
4439 self.assertAlmostEqual(spin70.r2b[r20_key2], 51.188411562843, 4)
4440 self.assertAlmostEqual(spin70.pA, 0.989384178573802, 4)
4441 self.assertAlmostEqual(spin70.dw, 5.54738203723682, 4)
4442 self.assertAlmostEqual(spin70.kex/1000, 1831.4566463179/1000, 4)
4443 self.assertAlmostEqual(spin70.chi2, 50.450410782403, 4)
4444
4445
4446 self.assertAlmostEqual(spin71.r2a[r20_key1], 5.04185695754972, 4)
4447 self.assertAlmostEqual(spin71.r2b[r20_key1], 1.62857899941921, 4)
4448 self.assertAlmostEqual(spin71.pA, 0.988832866751676, 4)
4449 self.assertAlmostEqual(spin71.dw, 2.24905251856265, 4)
4450 self.assertAlmostEqual(spin71.kex/1000, 2397.64122642946/1000, 4)
4451 self.assertAlmostEqual(spin71.chi2, 15.8586492923672, 4)
4452
4453
4454 self.assertEqual(spin70.k_AB, spin70.kex * (1.0 - spin70.pA))
4455 self.assertEqual(spin71.k_AB, spin71.kex * (1.0 - spin71.pA))
4456
4457
4458 self.assertEqual(spin70.k_BA, spin70.kex * spin70.pA)
4459 self.assertEqual(spin71.k_BA, spin71.kex * spin71.pA)
4460
4461
4463 """Optimisation of Dr. Flemming Hansen's CPMG data to the IT99 dispersion model.
4464
4465 This uses the data from Dr. Flemming Hansen's paper at http://dx.doi.org/10.1021/jp074793o. This is CPMG data with a fixed relaxation time period.
4466 """
4467
4468
4469 self.setup_hansen_cpmg_data(model='IT99')
4470
4471
4472 spin70 = return_spin(":70")
4473 spin71 = return_spin(":71")
4474
4475
4476 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6)
4477 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6)
4478
4479
4480 spin70.r2 = {r20_key1: 8.8, r20_key2: 16.6}
4481 spin70.dw = 10.0
4482 spin70.pA = 0.5
4483 spin70.tex = 1000.09
4484 spin71.r2 = {r20_key1: 1.0, r20_key2: 1.0}
4485 spin71.dw = 10.0
4486 spin71.pA = 0.95
4487 spin71.tex = 0.1
4488
4489
4490 self.interpreter.minimise.execute(min_algor='simplex', line_search=None, hessian_mod=None, hessian_type=None, func_tol=1e-10, grad_tol=None, max_iter=10000, constraints=True, scaling=True, verbosity=1)
4491
4492
4493 print("\n\nOptimised parameters:\n")
4494 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)"))
4495 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin70.r2[r20_key1], spin71.r2[r20_key1]))
4496 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin70.r2[r20_key2], spin71.r2[r20_key2]))
4497 print("%-20s %20.15g %20.15g" % ("dw", spin70.dw, spin71.dw))
4498 print("%-20s %20.15g %20.15g" % ("pA", spin70.pA, spin71.pA))
4499 print("%-20s %20.15g %20.15g" % ("tex", spin70.tex, spin71.tex))
4500 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2))
4501
4502
4503 self.assertAlmostEqual(spin70.r2[r20_key1], 7.24471197811838, 4)
4504 self.assertAlmostEqual(spin70.r2[r20_key2], 10.0571040704729, 4)
4505 self.assertAlmostEqual(spin70.dw, 5.2116923222744, 4)
4506 self.assertAlmostEqual(spin70.pA, 0.990253627907212, 4)
4507 self.assertAlmostEqual(spin70.tex*1000, 0.000638394793480444*1000, 4)
4508 self.assertAlmostEqual(spin70.chi2, 93.5135798618747, 4)
4509
4510
4511 self.assertAlmostEqual(spin71.r2[r20_key1], 5.05971235970214, 4)
4512 self.assertAlmostEqual(spin71.r2[r20_key2], 6.96641194493447, 4)
4513 self.assertAlmostEqual(spin71.dw, 0.435389946897141, 4)
4514 self.assertAlmostEqual(spin71.pA, 0.500000000213519, 3)
4515 self.assertAlmostEqual(spin71.tex*1000, 0.000372436400585538*1000, 4)
4516 self.assertAlmostEqual(spin71.chi2, 23.7895798801404, 4)
4517
4518
4520 """Optimisation of Dr. Flemming Hansen's CPMG data to the LM63 dispersion model.
4521
4522 This uses the data from Dr. Flemming Hansen's paper at http://dx.doi.org/10.1021/jp074793o. This is CPMG data with a fixed relaxation time period.
4523 """
4524
4525
4526 self.setup_hansen_cpmg_data(model='LM63')
4527
4528
4529 spin70 = return_spin(":70")
4530 spin71 = return_spin(":71")
4531
4532
4533 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6)
4534 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6)
4535
4536
4537 spin70.r2 = {r20_key1: 7.0, r20_key2: 7.0}
4538 spin70.phi_ex = 0.3
4539 spin70.kex = 5000.0
4540 spin71.r2 = {r20_key1: 5.0, r20_key2: 9.0}
4541 spin71.phi_ex = 0.1
4542 spin71.kex = 2500.0
4543
4544
4545 self.interpreter.minimise.execute(min_algor='simplex', line_search=None, hessian_mod=None, hessian_type=None, func_tol=1e-25, grad_tol=None, max_iter=10000000, constraints=True, scaling=True, verbosity=1)
4546
4547
4548 print("\n\nOptimised parameters:\n")
4549 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)"))
4550 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin70.r2[r20_key1], spin71.r2[r20_key1]))
4551 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin70.r2[r20_key2], spin71.r2[r20_key2]))
4552 print("%-20s %20.15g %20.15g" % ("phi_ex", spin70.phi_ex, spin71.phi_ex))
4553 print("%-20s %20.15g %20.15g" % ("kex", spin70.kex, spin71.kex))
4554 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2))
4555
4556
4557 self.assertAlmostEqual(spin70.r2[r20_key1], 6.74362294539099)
4558 self.assertAlmostEqual(spin70.r2[r20_key2], 6.57406797067481, 6)
4559 self.assertAlmostEqual(spin70.phi_ex, 0.312733013751449)
4560 self.assertAlmostEqual(spin70.kex/1000, 4723.09897146338/1000, 6)
4561 self.assertAlmostEqual(spin70.chi2, 363.534044873483)
4562
4563
4564 self.assertAlmostEqual(spin71.r2[r20_key1], 5.00776657729728, 5)
4565 self.assertAlmostEqual(spin71.phi_ex, 0.0553787825650613, 5)
4566 self.assertAlmostEqual(spin71.kex/1000, 2781.72292994154/1000, 5)
4567 self.assertAlmostEqual(spin71.chi2, 17.0776399916287, 5)
4568
4569
4571 """Optimisation of Dr. Flemming Hansen's CPMG data to the LM63 dispersion model.
4572
4573 This uses the data from Dr. Flemming Hansen's paper at http://dx.doi.org/10.1021/jp074793o. This is CPMG data with a fixed relaxation time period.
4574 """
4575
4576
4577 self.setup_hansen_cpmg_data(model='LM63 3-site')
4578
4579
4580 spin70 = return_spin(":70")
4581 spin71 = return_spin(":71")
4582
4583
4584 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6)
4585 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6)
4586
4587
4588 spin70.r2 = {r20_key1: 7.570370921220954, r20_key2: 8.694446951909107}
4589 spin70.phi_ex_B = 0.14872003058250227
4590 spin70.phi_ex_C = 0.1319419923472704
4591 spin70.kB = 4103.672910444741
4592 spin70.kC = 7029.001690726248
4593 spin71.r2 = {r20_key1: 5.1347793381636, r20_key2: 7.156573986051575}
4594 spin71.phi_ex_B = 0.04013553485505605
4595 spin71.phi_ex_C = 0.020050748406928887
4596 spin71.kB = 4045.3007136121364
4597 spin71.kC = 3586.38798270774
4598
4599
4600
4601
4602
4603 self.interpreter.minimise.execute(min_algor='simplex', line_search=None, hessian_mod=None, hessian_type=None, func_tol=1e-25, grad_tol=None, max_iter=10000000, constraints=True, scaling=True, verbosity=1)
4604
4605
4606 print("\n\nOptimised parameters:\n")
4607 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)"))
4608 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin70.r2[r20_key1], spin71.r2[r20_key1]))
4609 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin70.r2[r20_key2], spin71.r2[r20_key2]))
4610 print("%-20s %20.15g %20.15g" % ("phi_ex_B", spin70.phi_ex_B, spin71.phi_ex_B))
4611 print("%-20s %20.15g %20.15g" % ("phi_ex_C", spin70.phi_ex_C, spin71.phi_ex_C))
4612 print("%-20s %20.15g %20.15g" % ("kB", spin70.kB, spin71.kB))
4613 print("%-20s %20.15g %20.15g" % ("kC", spin70.kC, spin71.kC))
4614 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2))
4615
4616
4617 self.assertAlmostEqual(spin70.r2[r20_key1], 6.7436230253685, 5)
4618 self.assertAlmostEqual(spin70.r2[r20_key2], 6.57406813008828, 6)
4619 self.assertAlmostEqual(spin70.phi_ex_B, 0.206304023079778, 5)
4620 self.assertAlmostEqual(spin70.phi_ex_C, 0.106428983339627, 5)
4621 self.assertAlmostEqual(spin70.kB/1000, 4723.09897652589/1000, 6)
4622 self.assertAlmostEqual(spin70.kC/1000, 4723.09876196409/1000, 6)
4623 self.assertAlmostEqual(spin70.chi2, 363.534044873483, 5)
4624
4625
4626 self.assertAlmostEqual(spin71.r2[r20_key1], 4.96612095596752, 5)
4627 self.assertAlmostEqual(spin71.phi_ex_B, 0.00398262266512895, 5)
4628 self.assertAlmostEqual(spin71.phi_ex_C, 0.0555791581291262, 5)
4629 self.assertAlmostEqual(spin71.kB/1000, 1323.33195689832/1000, 5)
4630 self.assertAlmostEqual(spin71.kC/1000, 3149.58971568059/1000, 5)
4631 self.assertAlmostEqual(spin71.chi2, 16.2620934464368)
4632
4633
4635 """Optimisation of Dr. Flemming Hansen's CPMG data to the 'NS CPMG 2-site 3D' dispersion model.
4636
4637 This uses the data from Dr. Flemming Hansen's paper at http://dx.doi.org/10.1021/jp074793o. This is CPMG data with a fixed relaxation time period.
4638 """
4639
4640
4641 self.setup_hansen_cpmg_data(model='NS CPMG 2-site 3D')
4642
4643
4644 spin70 = return_spin(":70")
4645 spin71 = return_spin(":71")
4646
4647
4648 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6)
4649 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6)
4650
4651
4652 spin70.r2 = {r20_key1: 6.994165925, r20_key2: 9.428129427}
4653 spin70.pA = 0.9897754407
4654 spin70.dw = 5.642418428
4655 spin70.kex = 1743.666375
4656 spin71.r2 = {r20_key1: 4.978654237, r20_key2: 9.276918959}
4657 spin71.pA = 0.9968032899
4658 spin71.dw = 4.577891393
4659 spin71.kex = 1830.044597
4660
4661
4662 self.interpreter.minimise.execute(min_algor='simplex', line_search=None, hessian_mod=None, hessian_type=None, func_tol=1e-05, grad_tol=None, max_iter=1000, constraints=False, scaling=True, verbosity=1)
4663
4664
4665 print("\n\nOptimised parameters:\n")
4666 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)"))
4667 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin70.r2[r20_key1], spin71.r2[r20_key1]))
4668 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin70.r2[r20_key2], spin71.r2[r20_key2]))
4669 print("%-20s %20.15g %20.15g" % ("pA", spin70.pA, spin71.pA))
4670 print("%-20s %20.15g %20.15g" % ("dw", spin70.dw, spin71.dw))
4671 print("%-20s %20.15g %20.15g" % ("kex", spin70.kex, spin71.kex))
4672 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2))
4673
4674
4675 self.assertAlmostEqual(spin70.r2[r20_key1], 6.95797760459016, 4)
4676 self.assertAlmostEqual(spin70.r2[r20_key2], 9.39628959312699, 4)
4677 self.assertAlmostEqual(spin70.pA, 0.989700985380975, 4)
4678 self.assertAlmostEqual(spin70.dw, 5.6733714171086, 4)
4679 self.assertAlmostEqual(spin70.kex/1000, 1713.63101361545/1000, 4)
4680 self.assertAlmostEqual(spin70.chi2, 52.5106928523775, 4)
4681
4682
4683 self.assertAlmostEqual(spin71.r2[r20_key1], 4.99893565849977, 4)
4684 self.assertAlmostEqual(spin71.r2[r20_key2], 6.89825625944034, 4)
4685 self.assertAlmostEqual(spin71.pA, 0.986716058519642, 4)
4686 self.assertAlmostEqual(spin71.dw, 2.09292495350993, 4)
4687 self.assertAlmostEqual(spin71.kex/1000, 2438.04423541463/1000, 4)
4688 self.assertAlmostEqual(spin71.chi2, 15.164490242352, 4)
4689
4690
4691 self.assertEqual(spin70.k_AB, spin70.kex * (1.0 - spin70.pA))
4692 self.assertEqual(spin71.k_AB, spin71.kex * (1.0 - spin71.pA))
4693
4694
4695 self.assertEqual(spin70.k_BA, spin70.kex * spin70.pA)
4696 self.assertEqual(spin71.k_BA, spin71.kex * spin71.pA)
4697
4698
4700 """Optimisation of Dr. Flemming Hansen's CPMG data to the 'NS CPMG 2-site 3D full' dispersion model.
4701
4702 This uses the data from Dr. Flemming Hansen's paper at http://dx.doi.org/10.1021/jp074793o. This is CPMG data with a fixed relaxation time period.
4703 """
4704
4705
4706 self.setup_hansen_cpmg_data(model='NS CPMG 2-site 3D full')
4707
4708
4709 spin70 = return_spin(":70")
4710 spin71 = return_spin(":71")
4711
4712
4713 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6)
4714 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6)
4715
4716
4717 spin70.r2a = {r20_key1: 6.644753428, r20_key2: 7.891776687}
4718 spin70.r2b = {r20_key1: 7.163478485, r20_key2: 138.5170395}
4719 spin70.pA = 0.9884781357
4720 spin70.dw = 5.456507396
4721 spin70.kex = 1906.521189
4722 spin71.r2a = {r20_key1: 4.99893524108981, r20_key2: 100.0}
4723 spin71.r2b = {r20_key1: 8.27456243639973, r20_key2: 100.0}
4724 spin71.pA = 0.986709616684097
4725 spin71.dw = 2.09245158280905
4726 spin71.kex = 2438.2766211401
4727
4728
4729 self.interpreter.minimise.execute(min_algor='simplex', line_search=None, hessian_mod=None, hessian_type=None, func_tol=1e-05, grad_tol=None, max_iter=1000, constraints=False, scaling=True, verbosity=1)
4730
4731
4732 print("\n\nOptimised parameters:\n")
4733 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)"))
4734 print("%-20s %20.15g %20.15g" % ("R2A (500 MHz)", spin70.r2a[r20_key1], spin71.r2a[r20_key1]))
4735 print("%-20s %20.15g %20.15g" % ("R2B (500 MHz)", spin70.r2b[r20_key1], spin71.r2b[r20_key1]))
4736 print("%-20s %20.15g %20.15g" % ("R2A (800 MHz)", spin70.r2a[r20_key2], spin71.r2a[r20_key2]))
4737 print("%-20s %20.15g %20.15g" % ("R2B (800 MHz)", spin70.r2b[r20_key2], spin71.r2b[r20_key2]))
4738 print("%-20s %20.15g %20.15g" % ("pA", spin70.pA, spin71.pA))
4739 print("%-20s %20.15g %20.15g" % ("dw", spin70.dw, spin71.dw))
4740 print("%-20s %20.15g %20.15g" % ("kex", spin70.kex, spin71.kex))
4741 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2))
4742
4743
4744 self.assertAlmostEqual(spin70.r2a[r20_key1], 6.61176004043484, 4)
4745 self.assertAlmostEqual(spin70.r2b[r20_key1], 7.4869316381241, 4)
4746 self.assertAlmostEqual(spin70.r2a[r20_key2], 7.78200386067591, 4)
4747 self.assertAlmostEqual(spin70.r2b[r20_key2], 141.703593742468, 4)
4748 self.assertAlmostEqual(spin70.pA, 0.988404987055969, 4)
4749 self.assertAlmostEqual(spin70.dw, 5.4497360203213, 4)
4750 self.assertAlmostEqual(spin70.kex/1000, 1934.09304607082/1000, 4)
4751 self.assertAlmostEqual(spin70.chi2, 44.6793752187925, 4)
4752
4753
4754 self.assertAlmostEqual(spin71.r2a[r20_key1], 4.6013095731966, 4)
4755 self.assertAlmostEqual(spin71.r2b[r20_key1], 13.3245678276332, 4)
4756 self.assertAlmostEqual(spin71.r2a[r20_key2], 2.08243621257779, 4)
4757 self.assertAlmostEqual(spin71.r2b[r20_key2], 153.355765094575, 4)
4758 self.assertAlmostEqual(spin71.pA, 0.9665748685124, 4)
4759 self.assertAlmostEqual(spin71.dw, 1.41898001408953, 4)
4760 self.assertAlmostEqual(spin71.kex/1000, 2580.65795560688/1000, 4)
4761 self.assertAlmostEqual(spin71.chi2, 13.4937006732165, 4)
4762
4763
4764 self.assertEqual(spin70.k_AB, spin70.kex * (1.0 - spin70.pA))
4765 self.assertEqual(spin71.k_AB, spin71.kex * (1.0 - spin71.pA))
4766
4767
4768 self.assertEqual(spin70.k_BA, spin70.kex * spin70.pA)
4769 self.assertEqual(spin71.k_BA, spin71.kex * spin71.pA)
4770
4771
4773 """Optimisation of Dr. Flemming Hansen's CPMG data to the 'NS CPMG 2-site expanded' dispersion model.
4774
4775 This uses the data from Dr. Flemming Hansen's paper at http://dx.doi.org/10.1021/jp074793o. This is CPMG data with a fixed relaxation time period.
4776 """
4777
4778
4779 self.setup_hansen_cpmg_data(model='NS CPMG 2-site expanded')
4780
4781
4782 spin70 = return_spin(":70")
4783 spin71 = return_spin(":71")
4784
4785
4786 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6)
4787 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6)
4788
4789
4790 spin70.r2 = {r20_key1: 7.0, r20_key2: 9.0}
4791 spin70.pA = 0.9
4792 spin70.dw = 6.0
4793 spin70.kex = 1500.0
4794 spin71.r2 = {r20_key1: 5.0, r20_key2: 9.0}
4795 spin71.pA = 0.9
4796 spin71.dw = 4.0
4797 spin71.kex = 1900.0
4798
4799
4800 self.interpreter.minimise.execute(min_algor='simplex', line_search=None, hessian_mod=None, hessian_type=None, func_tol=1e-05, grad_tol=None, max_iter=1000, constraints=True, scaling=True, verbosity=1)
4801
4802
4803 print("\n\nOptimised parameters:\n")
4804 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)"))
4805 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin70.r2[r20_key1], spin71.r2[r20_key1]))
4806 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin70.r2[r20_key2], spin71.r2[r20_key2]))
4807 print("%-20s %20.15g %20.15g" % ("pA", spin70.pA, spin71.pA))
4808 print("%-20s %20.15g %20.15g" % ("dw", spin70.dw, spin71.dw))
4809 print("%-20s %20.15g %20.15g" % ("kex", spin70.kex, spin71.kex))
4810 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2))
4811
4812
4813 self.assertAlmostEqual(spin70.r2[r20_key1], 6.95813330991529, 4)
4814 self.assertAlmostEqual(spin70.r2[r20_key2], 9.39663480561524, 4)
4815 self.assertAlmostEqual(spin70.pA, 0.989700843879574, 4)
4816 self.assertAlmostEqual(spin70.dw, 5.67315878825691, 4)
4817 self.assertAlmostEqual(spin70.kex/1000, 1713.56110716632/1000, 4)
4818 self.assertAlmostEqual(spin70.chi2, 52.5106879242812, 4)
4819
4820
4821 self.assertAlmostEqual(spin71.r2[r20_key1], 4.99881666793312, 4)
4822 self.assertAlmostEqual(spin71.r2[r20_key2], 6.89817482453042, 4)
4823 self.assertAlmostEqual(spin71.pA, 0.986712911453639, 4)
4824 self.assertAlmostEqual(spin71.dw, 2.09273069372236, 4)
4825 self.assertAlmostEqual(spin71.kex/1000, 2438.20525930405/1000, 4)
4826 self.assertAlmostEqual(spin71.chi2, 15.1644913030633, 4)
4827
4828
4829 self.assertEqual(spin70.k_AB, spin70.kex * (1.0 - spin70.pA))
4830 self.assertEqual(spin71.k_AB, spin71.kex * (1.0 - spin71.pA))
4831
4832
4833 self.assertEqual(spin70.k_BA, spin70.kex * spin70.pA)
4834 self.assertEqual(spin71.k_BA, spin71.kex * spin71.pA)
4835
4836
4838 """Optimisation of Dr. Flemming Hansen's CPMG data to the 'NS CPMG 2-site star' dispersion model.
4839
4840 This uses the data from Dr. Flemming Hansen's paper at http://dx.doi.org/10.1021/jp074793o. This is CPMG data with a fixed relaxation time period.
4841 """
4842
4843
4844 self.setup_hansen_cpmg_data(model='NS CPMG 2-site star')
4845
4846
4847 spin70 = return_spin(":70")
4848 spin71 = return_spin(":71")
4849
4850
4851 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6)
4852 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6)
4853
4854
4855 spin70.r2 = {r20_key1: 6.996327746, r20_key2: 9.452051268}
4856 spin70.pA = 0.9897519798
4857 spin70.dw = 5.644862195
4858 spin70.kex = 1723.820567
4859 spin71.r2 = {r20_key1: 4.978654237, r20_key2: 9.276918959}
4860 spin71.pA = 0.9968032899
4861 spin71.dw = 4.577891393
4862 spin71.kex = 1830.044597
4863
4864
4865 self.interpreter.minimise.execute(min_algor='simplex', line_search=None, hessian_mod=None, hessian_type=None, func_tol=1e-05, grad_tol=None, max_iter=1000, constraints=False, scaling=True, verbosity=1)
4866
4867
4868 print("\n\nOptimised parameters:\n")
4869 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)"))
4870 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin70.r2[r20_key1], spin71.r2[r20_key1]))
4871 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin70.r2[r20_key2], spin71.r2[r20_key2]))
4872 print("%-20s %20.15g %20.15g" % ("pA", spin70.pA, spin71.pA))
4873 print("%-20s %20.15g %20.15g" % ("dw", spin70.dw, spin71.dw))
4874 print("%-20s %20.15g %20.15g" % ("kex", spin70.kex, spin71.kex))
4875 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2))
4876
4877
4878 self.assertAlmostEqual(spin70.r2[r20_key1], 6.95543947938561, 1)
4879 self.assertAlmostEqual(spin70.r2[r20_key2], 9.38991914134929, 1)
4880 self.assertAlmostEqual(spin70.pA, 0.989702750971153, 3)
4881 self.assertAlmostEqual(spin70.dw, 5.67527122494516, 1)
4882 self.assertAlmostEqual(spin70.kex/1000, 1715.72032391817/1000, 1)
4883 self.assertAlmostEqual(spin70.chi2, 52.5011991483842, 1)
4884
4885
4886 self.assertAlmostEqual(spin71.r2[r20_key1], 4.992594256544, 1)
4887 self.assertAlmostEqual(spin71.pA, 0.986716058519642, 2)
4888 self.assertAlmostEqual(spin71.dw/100, 2.09292495350993/100, 2)
4889 self.assertAlmostEqual(spin71.kex/100000, 2438.04423541463/100000, 2)
4890 self.assertAlmostEqual(spin71.chi2/100, 15.1644902423334/100, 1)
4891
4892
4893 self.assertEqual(spin70.k_AB, spin70.kex * (1.0 - spin70.pA))
4894 self.assertEqual(spin71.k_AB, spin71.kex * (1.0 - spin71.pA))
4895
4896
4897 self.assertEqual(spin70.k_BA, spin70.kex * spin70.pA)
4898 self.assertEqual(spin71.k_BA, spin71.kex * spin71.pA)
4899
4900
4902 """Optimisation of Dr. Flemming Hansen's CPMG data to the 'NS CPMG 2-site star full' dispersion model.
4903
4904 This uses the data from Dr. Flemming Hansen's paper at http://dx.doi.org/10.1021/jp074793o. This is CPMG data with a fixed relaxation time period.
4905 """
4906
4907
4908 self.setup_hansen_cpmg_data(model='NS CPMG 2-site star full')
4909
4910
4911 spin70 = return_spin(":70")
4912 spin71 = return_spin(":71")
4913
4914
4915 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6)
4916 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6)
4917
4918
4919 spin70.r2a = {r20_key1: 6.44836878645126, r20_key2: 7.00382877393494}
4920 spin70.r2b = {r20_key1: 12.2083127421994, r20_key2: 199.862962628402}
4921 spin70.pA = 0.987648082613451
4922 spin70.dw = 5.30679853807572
4923 spin70.kex = 2033.25380420666
4924 spin71.r2a = {r20_key1: 4.992594256544, r20_key2: 6.98674718938435}
4925 spin71.r2b = {r20_key1: 4.992594256544, r20_key2: 6.98674718938435}
4926 spin71.pA = 0.992258541625787
4927 spin71.dw = 2.75140650899058
4928 spin71.kex = 2106.60885247431
4929
4930
4931 self.interpreter.minimise.calculate()
4932
4933
4934 self.assertAlmostEqual(spin70.chi2/10, 45.773987568491123/10, 2)
4935 self.assertAlmostEqual(spin71.chi2/10, 17.329385665659192/10, 2)
4936
4937
5079
5080
5082 """Optimisation of the Korzhnev et al., 2005 15N DQ CPMG data using the 'NS MMQ 2-site' model.
5083
5084 This uses the data from Dmitry Korzhnev's paper at U{DOI: 10.1021/ja054550e<http://dx.doi.org/10.1021/ja054550e>}. This is the 1H SQ, 15N SQ, ZQ, DQ, 1H MQ and 15N MQ data for residue Asp 9 of the Fyn SH3 domain mutant.
5085
5086 Here only the 15N DQ data will be optimised. The values found by cpmg_fit using just this data are:
5087
5088 - r2 = {'500': 9.487269007171426, '600': 11.718267257562591, '800': 13.624551743116887},
5089 - pA = 0.965402506690231,
5090 - dw = 0.805197170133360,
5091 - dwH = -0.595536627771890,
5092 - kex = 569.003663067619868,
5093 - chi2 = 9.297671357952812.
5094 """
5095
5096
5097 self.setup_korzhnev_2005_data(data_list=['DQ'])
5098
5099
5100 spin = return_spin(":9@N")
5101
5102
5103 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_DQ, frq=500e6)
5104 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_DQ, frq=600e6)
5105 r20_key3 = generate_r20_key(exp_type=EXP_TYPE_CPMG_DQ, frq=800e6)
5106
5107
5108 spin.r2 = {r20_key1: 9.48527908326952, r20_key2: 11.7135951595536, r20_key3: 13.6153887849344}
5109 spin.pA = 0.965638501551899
5110 spin.dw = 2.8537583461577
5111 spin.dwH = -0.387633062766635
5112 spin.kex = 573.704033851592
5113
5114
5115 self.interpreter.minimise.execute(min_algor='simplex', func_tol=1e-05, max_iter=1000)
5116
5117
5118 self.interpreter.monte_carlo.setup(number=3)
5119 self.interpreter.monte_carlo.create_data(method='back_calc')
5120 self.interpreter.monte_carlo.initial_values()
5121 self.interpreter.minimise.execute(min_algor='simplex', max_iter=10)
5122 self.interpreter.monte_carlo.error_analysis()
5123
5124
5125 self.interpreter.relax_disp.plot_disp_curves(dir=ds.tmpdir, force=True)
5126
5127
5128 self.interpreter.state.save('state', dir=ds.tmpdir, compress_type=1, force=True)
5129
5130
5131 print("\n\nOptimised parameters:\n")
5132 print("%-20s %-20s" % ("Parameter", "Value (:9)"))
5133 print("%-20s %20.15g" % ("R2 (500 MHz)", spin.r2[r20_key1]))
5134 print("%-20s %20.15g" % ("R2 (600 MHz)", spin.r2[r20_key2]))
5135 print("%-20s %20.15g" % ("R2 (800 MHz)", spin.r2[r20_key3]))
5136 print("%-20s %20.15g" % ("pA", spin.pA))
5137 print("%-20s %20.15g" % ("dw", spin.dw))
5138 print("%-20s %20.15g" % ("dwH", spin.dwH))
5139 print("%-20s %20.15g" % ("kex", spin.kex))
5140 print("%-20s %20.15g\n" % ("chi2", spin.chi2))
5141
5142
5143 self.assertAlmostEqual(spin.r2[r20_key1], 9.4870656457415, 2)
5144 self.assertAlmostEqual(spin.r2[r20_key2], 11.7183291788929, 2)
5145 self.assertAlmostEqual(spin.r2[r20_key3], 13.6241729933153, 2)
5146 self.assertAlmostEqual(spin.pA, 0.965405468217295, 4)
5147 self.assertAlmostEqual(spin.dw, 2.76835528427355, 1)
5148 self.assertAlmostEqual(spin.dwH, -0.396489341086363, 2)
5149 self.assertAlmostEqual(spin.kex/1000, 569.06937047601/1000, 3)
5150 self.assertAlmostEqual(spin.chi2, 9.29767487125257, 2)
5151
5152
5154 """Optimisation of the Korzhnev et al., 2005 15N MQ CPMG data using the 'NS MMQ 2-site' model.
5155
5156 This uses the data from Dmitry Korzhnev's paper at U{DOI: 10.1021/ja054550e<http://dx.doi.org/10.1021/ja054550e>}. This is the 1H SQ, 15N SQ, ZQ, DQ, 1H MQ and 15N MQ data for residue Asp 9 of the Fyn SH3 domain mutant.
5157
5158 Here only the 15N MQ data will be optimised. The values found by cpmg_fit using just this data are:
5159
5160 - r2 = {'500': 5.993083514798655, '600': 6.622184438384841, '800': 8.640765919352019},
5161 - pA = 0.930027999814003,
5162 - dw = 4.338620619954370,
5163 - dwH = -0.274250775560818,
5164 - kex = 344.613362916544475,
5165 - chi2 = 10.367733168217050.
5166 """
5167
5168
5169 self.setup_korzhnev_2005_data(data_list=['MQ'])
5170
5171
5172 spin = return_spin(":9@N")
5173
5174
5175 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_MQ, frq=500e6)
5176 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_MQ, frq=600e6)
5177 r20_key3 = generate_r20_key(exp_type=EXP_TYPE_CPMG_MQ, frq=800e6)
5178
5179
5180 spin.r2 = {r20_key1: 6.02016436619016, r20_key2: 6.65421500772308, r20_key3: 8.6729591487622}
5181 spin.pA = 0.930083249288083
5182 spin.dw = 4.33890689462363
5183 spin.dwH = -0.274316585638047
5184 spin.kex = 344.329651956132
5185
5186
5187 self.interpreter.minimise.execute(min_algor='simplex', func_tol=1e-05, max_iter=1000)
5188
5189
5190 self.interpreter.monte_carlo.setup(number=3)
5191 self.interpreter.monte_carlo.create_data(method='back_calc')
5192 self.interpreter.monte_carlo.initial_values()
5193 self.interpreter.minimise.execute(min_algor='simplex', max_iter=10)
5194 self.interpreter.monte_carlo.error_analysis()
5195
5196
5197 self.interpreter.relax_disp.plot_disp_curves(dir=ds.tmpdir, force=True)
5198
5199
5200 self.interpreter.state.save('state', dir=ds.tmpdir, compress_type=1, force=True)
5201
5202
5203 print("\n\nOptimised parameters:\n")
5204 print("%-20s %-20s" % ("Parameter", "Value (:9)"))
5205 print("%-20s %20.15g" % ("R2 (500 MHz)", spin.r2[r20_key1]))
5206 print("%-20s %20.15g" % ("R2 (600 MHz)", spin.r2[r20_key2]))
5207 print("%-20s %20.15g" % ("R2 (800 MHz)", spin.r2[r20_key3]))
5208 print("%-20s %20.15g" % ("pA", spin.pA))
5209 print("%-20s %20.15g" % ("dw", spin.dw))
5210 print("%-20s %20.15g" % ("dwH", spin.dwH))
5211 print("%-20s %20.15g" % ("kex", spin.kex))
5212 print("%-20s %20.15g\n" % ("chi2", spin.chi2))
5213
5214
5215 self.assertAlmostEqual(spin.r2[r20_key1], 5.99503641023038, 1)
5216 self.assertAlmostEqual(spin.r2[r20_key2], 6.62432897608527, 1)
5217 self.assertAlmostEqual(spin.r2[r20_key3], 8.64278915809492, 1)
5218 self.assertAlmostEqual(spin.pA, 0.930036474040713, 3)
5219 self.assertAlmostEqual(spin.dw, 4.33848403058432, 2)
5220 self.assertAlmostEqual(spin.dwH, -0.274246558825267, 3)
5221 self.assertAlmostEqual(spin.kex/1000, 344.626563267384/1000, 3)
5222 self.assertAlmostEqual(spin.chi2, 10.3677362372789, 2)
5223
5224
5226 """Optimisation of the Korzhnev et al., 2005 15N SQ CPMG data using the 'NS MMQ 2-site' model.
5227
5228 This uses the data from Dmitry Korzhnev's paper at U{DOI: 10.1021/ja054550e<http://dx.doi.org/10.1021/ja054550e>}. This is the 1H SQ, 15N SQ, ZQ, DQ, 1H MQ and 15N MQ data for residue Asp 9 of the Fyn SH3 domain mutant.
5229
5230 Here only the 15N SQ data will be optimised. The values found by cpmg_fit using just this data are:
5231
5232 - r2 = {'500': 8.335037972570017, '600': 8.761366016417508, '800': 10.225001019091822},
5233 - pA = 0.950003458294991,
5234 - dw = 4.358402855315123,
5235 - kex = 429.906473361926999,
5236 - chi2 = 17.393331915567252.
5237 """
5238
5239
5240 self.setup_korzhnev_2005_data(data_list=['SQ'])
5241
5242
5243 spin = return_spin(":9@N")
5244
5245
5246 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6)
5247 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=600e6)
5248 r20_key3 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6)
5249
5250
5251 spin.r2 = {r20_key1: 8.334232330326190, r20_key2: 8.756773997879968, r20_key3: 10.219320492033058}
5252 spin.pA = 0.950310172115387
5253 spin.dw = 4.356737157889636
5254 spin.kex = 433.176323890829849
5255
5256
5257 self.interpreter.minimise.execute(min_algor='simplex', func_tol=1e-05, max_iter=1000)
5258
5259
5260 self.interpreter.monte_carlo.setup(number=3)
5261 self.interpreter.monte_carlo.create_data(method='back_calc')
5262 self.interpreter.monte_carlo.initial_values()
5263 self.interpreter.minimise.execute(min_algor='simplex', max_iter=10)
5264 self.interpreter.monte_carlo.error_analysis()
5265
5266
5267 self.interpreter.relax_disp.plot_disp_curves(dir=ds.tmpdir, force=True)
5268
5269
5270 self.interpreter.state.save('state', dir=ds.tmpdir, compress_type=1, force=True)
5271
5272
5273 print("\n\nOptimised parameters:\n")
5274 print("%-20s %-20s" % ("Parameter", "Value (:9)"))
5275 print("%-20s %20.15g" % ("R2 (500 MHz)", spin.r2[r20_key1]))
5276 print("%-20s %20.15g" % ("R2 (600 MHz)", spin.r2[r20_key2]))
5277 print("%-20s %20.15g" % ("R2 (800 MHz)", spin.r2[r20_key3]))
5278 print("%-20s %20.15g" % ("pA", spin.pA))
5279 print("%-20s %20.15g" % ("dw", spin.dw))
5280 print("%-20s %20.15g" % ("kex", spin.kex))
5281 print("%-20s %20.15g\n" % ("chi2", spin.chi2))
5282
5283
5284 self.assertAlmostEqual(spin.r2[r20_key1], 8.33499994313902, 2)
5285 self.assertAlmostEqual(spin.r2[r20_key2], 8.76118738798082, 2)
5286 self.assertAlmostEqual(spin.r2[r20_key3], 10.2250821829928, 1)
5287 self.assertAlmostEqual(spin.pA, 0.950000281516303, 3)
5288 self.assertAlmostEqual(spin.dw, 4.35845318983581, 2)
5289 self.assertAlmostEqual(spin.kex/1000, 429.874510184149/1000, 2)
5290 self.assertAlmostEqual(spin.chi2, 17.3933357984425, 1)
5291
5292
5294 """Optimisation of the Korzhnev et al., 2005 15N ZQ CPMG data using the 'NS MMQ 2-site' model.
5295
5296 This uses the data from Dmitry Korzhnev's paper at U{DOI: 10.1021/ja054550e<http://dx.doi.org/10.1021/ja054550e>}. This is the 1H SQ, 15N SQ, ZQ, DQ, 1H MQ and 15N MQ data for residue Asp 9 of the Fyn SH3 domain mutant.
5297
5298 Here only the 15N ZQ data will be optimised. The values found by cpmg_fit using just this data are:
5299
5300 - r2 = {'500': 5.909812628572937, '600': 6.663690132557320, '800': 6.787171647689906},
5301 - pA = 0.942452612380140,
5302 - dw = 0.858972784230892,
5303 - dwH = 0.087155962730608,
5304 - kex = 373.219151384798920,
5305 - chi2 = 23.863208106025152.
5306 """
5307
5308
5309 self.setup_korzhnev_2005_data(data_list=['ZQ'])
5310
5311
5312 spin = return_spin(":9@N")
5313
5314
5315 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_ZQ, frq=500e6)
5316 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_ZQ, frq=600e6)
5317 r20_key3 = generate_r20_key(exp_type=EXP_TYPE_CPMG_ZQ, frq=800e6)
5318
5319
5320 spin.r2 = {r20_key1: 5.91033272691614, r20_key2: 6.66368695342258, r20_key3: 6.78922219135537}
5321 spin.pA = 0.942457332074014
5322 spin.dw = 0.850592422908884
5323 spin.dwH = 0.0881272284455416
5324 spin.kex = 372.745483351305
5325
5326
5327 self.interpreter.minimise.execute(min_algor='simplex', func_tol=1e-05, max_iter=1000)
5328
5329
5330 self.interpreter.monte_carlo.setup(number=3)
5331 self.interpreter.monte_carlo.create_data(method='back_calc')
5332 self.interpreter.monte_carlo.initial_values()
5333 self.interpreter.minimise.execute(min_algor='simplex', max_iter=10)
5334 self.interpreter.monte_carlo.error_analysis()
5335
5336
5337 self.interpreter.relax_disp.plot_disp_curves(dir=ds.tmpdir, force=True)
5338
5339
5340 self.interpreter.state.save('state', dir=ds.tmpdir, compress_type=1, force=True)
5341
5342
5343 print("\n\nOptimised parameters:\n")
5344 print("%-20s %-20s" % ("Parameter", "Value (:9)"))
5345 print("%-20s %20.15g" % ("R2 (500 MHz)", spin.r2[r20_key1]))
5346 print("%-20s %20.15g" % ("R2 (600 MHz)", spin.r2[r20_key2]))
5347 print("%-20s %20.15g" % ("R2 (800 MHz)", spin.r2[r20_key3]))
5348 print("%-20s %20.15g" % ("pA", spin.pA))
5349 print("%-20s %20.15g" % ("dw", spin.dw))
5350 print("%-20s %20.15g" % ("dwH", spin.dwH))
5351 print("%-20s %20.15g" % ("kex", spin.kex))
5352 print("%-20s %20.15g\n" % ("chi2", spin.chi2))
5353
5354
5355 self.assertAlmostEqual(spin.r2[r20_key1], 5.9098385837035, 2)
5356 self.assertAlmostEqual(spin.r2[r20_key2], 6.66377885876553, 2)
5357 self.assertAlmostEqual(spin.r2[r20_key3], 6.78717432941353, 2)
5358 self.assertAlmostEqual(spin.pA, 0.942457141344462, 4)
5359 self.assertAlmostEqual(spin.dw, 0.84442055695814, 1)
5360 self.assertAlmostEqual(spin.dwH, 0.0886367674566058, 2)
5361 self.assertAlmostEqual(spin.kex/1000, 373.243053643367/1000, 3)
5362 self.assertAlmostEqual(spin.chi2, 23.863211604121, 1)
5363
5364
5366 """Optimisation of the Korzhnev et al., 2005 1H MQ CPMG data using the 'NS MMQ 2-site' model.
5367
5368 This uses the data from Dmitry Korzhnev's paper at U{DOI: 10.1021/ja054550e<http://dx.doi.org/10.1021/ja054550e>}. This is the 1H SQ, 15N SQ, ZQ, DQ, 1H MQ and 15N MQ data for residue Asp 9 of the Fyn SH3 domain mutant.
5369
5370 Here only the 1H MQ data will be optimised. The values found by cpmg_fit using just this data are:
5371
5372 - r2 = {'500': -0.000016676911302, '600': 0.036594127620440, '800': 2.131014839635728},
5373 - pA = 0.936911090448340,
5374 - dw = 4.325314846914845,
5375 - dwH = -0.213870168665628,
5376 - kex = 487.361914835074117,
5377 - chi2 = 14.870371897291138.
5378 """
5379
5380
5381 self.setup_korzhnev_2005_data(data_list=['1H MQ'])
5382
5383
5384 spin = return_spin(":9@N")
5385
5386
5387 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_MQ, frq=500e6)
5388 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_MQ, frq=600e6)
5389 r20_key3 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_MQ, frq=800e6)
5390
5391
5392 spin.r2 = {r20_key1: 0.000022585022901, r20_key2: 0.039223196112941, r20_key3: 2.136576686700357}
5393 spin.pA = 0.936884348941701
5394 spin.dw = 4.326454531583964
5395 spin.dwH = -0.214026093221782
5396 spin.kex = 487.043592705469223
5397
5398
5399 self.interpreter.minimise.execute(min_algor='simplex', func_tol=1e-05, max_iter=100)
5400
5401
5402 self.interpreter.monte_carlo.setup(number=3)
5403 self.interpreter.monte_carlo.create_data(method='back_calc')
5404 self.interpreter.monte_carlo.initial_values()
5405 self.interpreter.minimise.execute(min_algor='simplex', max_iter=10)
5406 self.interpreter.monte_carlo.error_analysis()
5407
5408
5409 self.interpreter.relax_disp.plot_disp_curves(dir=ds.tmpdir, force=True)
5410
5411
5412 self.interpreter.state.save('state', dir=ds.tmpdir, compress_type=1, force=True)
5413
5414
5415 print("\n\nOptimised parameters:\n")
5416 print("%-20s %-20s" % ("Parameter", "Value (:9)"))
5417 print("%-20s %20.15g" % ("R2 (500 MHz)", spin.r2[r20_key1]))
5418 print("%-20s %20.15g" % ("R2 (600 MHz)", spin.r2[r20_key2]))
5419 print("%-20s %20.15g" % ("R2 (800 MHz)", spin.r2[r20_key3]))
5420 print("%-20s %20.15g" % ("pA", spin.pA))
5421 print("%-20s %20.15g" % ("dw", spin.dw))
5422 print("%-20s %20.15g" % ("dwH", spin.dwH))
5423 print("%-20s %20.15g" % ("kex", spin.kex))
5424 print("%-20s %20.15g\n" % ("chi2", spin.chi2))
5425
5426
5427 self.assertAlmostEqual(spin.r2[r20_key1], 2.48493199969936e-05, 4)
5428 self.assertAlmostEqual(spin.r2[r20_key2], 0.0382382195911849, 2)
5429 self.assertAlmostEqual(spin.r2[r20_key3], 2.13397221524655, 2)
5430 self.assertAlmostEqual(spin.pA, 0.936879359956996, 4)
5431 self.assertAlmostEqual(spin.dw, 4.32573362253701, 2)
5432 self.assertAlmostEqual(spin.dwH, -0.213951762275293, 2)
5433 self.assertAlmostEqual(spin.kex/1000, 487.021196851596/1000, 4)
5434 self.assertAlmostEqual(spin.chi2, 14.8704048958378, 2)
5435
5436
5438 """Optimisation of the Korzhnev et al., 2005 1H SQ CPMG data using the 'NS MMQ 2-site' model.
5439
5440 This uses the data from Dmitry Korzhnev's paper at U{DOI: 10.1021/ja054550e<http://dx.doi.org/10.1021/ja054550e>}. This is the 1H SQ, 15N SQ, ZQ, DQ, 1H MQ and 15N MQ data for residue Asp 9 of the Fyn SH3 domain mutant.
5441
5442 Here only the 1H SQ data will be optimised. The values found by cpmg_fit using just this data are:
5443
5444 - r2 = {'500': 6.691697587650816, '600': 6.998915158708793, '800': 5.519267837559072},
5445 - pA = 0.946949480545876,
5446 - dwH = -0.265279672133308,
5447 - kex = 406.548178869750700,
5448 - chi2 = 50.400680290545026.
5449 """
5450
5451
5452 self.setup_korzhnev_2005_data(data_list=['1H SQ'])
5453
5454
5455 spin = return_spin(":9@N")
5456
5457
5458 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_SQ, frq=500e6)
5459 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_SQ, frq=600e6)
5460 r20_key3 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_SQ, frq=800e6)
5461
5462
5463 spin.r2 = {r20_key1: 6.69107911078939, r20_key2: 6.99888898689085, r20_key3: 5.52012880268077}
5464 spin.pA = 0.946990967372467
5465 spin.dwH = -0.265308128403529
5466 spin.kex = 406.843250675648
5467
5468
5469 self.interpreter.minimise.execute(min_algor='simplex', func_tol=1e-05, max_iter=1000)
5470
5471
5472 self.interpreter.monte_carlo.setup(number=3)
5473 self.interpreter.monte_carlo.create_data(method='back_calc')
5474 self.interpreter.monte_carlo.initial_values()
5475 self.interpreter.minimise.execute(min_algor='simplex', max_iter=10)
5476 self.interpreter.monte_carlo.error_analysis()
5477
5478
5479 self.interpreter.relax_disp.plot_disp_curves(dir=ds.tmpdir, force=True)
5480
5481
5482 self.interpreter.state.save('state', dir=ds.tmpdir, compress_type=1, force=True)
5483
5484
5485 print("\n\nOptimised parameters:\n")
5486 print("%-20s %-20s" % ("Parameter", "Value (:9)"))
5487 print("%-20s %20.15g" % ("R2 (500 MHz)", spin.r2[r20_key1]))
5488 print("%-20s %20.15g" % ("R2 (600 MHz)", spin.r2[r20_key2]))
5489 print("%-20s %20.15g" % ("R2 (800 MHz)", spin.r2[r20_key3]))
5490 print("%-20s %20.15g" % ("pA", spin.pA))
5491 print("%-20s %20.15g" % ("dwH", spin.dwH))
5492 print("%-20s %20.15g" % ("kex", spin.kex))
5493 print("%-20s %20.15g\n" % ("chi2", spin.chi2))
5494
5495
5496 self.assertAlmostEqual(spin.r2[r20_key1], 6.69168251154302, 2)
5497 self.assertAlmostEqual(spin.r2[r20_key2], 6.99900388754043, 2)
5498 self.assertAlmostEqual(spin.r2[r20_key3], 5.51921590064843, 2)
5499 self.assertAlmostEqual(spin.pA, 0.946951877648819, 4)
5500 self.assertAlmostEqual(spin.dwH, -0.265280175525516, 3)
5501 self.assertAlmostEqual(spin.kex/1000, 406.566453278183/1000, 2)
5502 self.assertAlmostEqual(spin.chi2, 50.4006836222044, 1)
5503
5504
5506 """Optimisation of all the Korzhnev et al., 2005 CPMG data using the 'NS MMQ 2-site' model.
5507
5508 This uses the data from Dmitry Korzhnev's paper at U{DOI: 10.1021/ja054550e<http://dx.doi.org/10.1021/ja054550e>}. This is the 1H SQ, 15N SQ, ZQ, DQ, 1H MQ and 15N MQ data for residue Asp 9 of the Fyn SH3 domain mutant.
5509
5510 Here all data will be optimised. The values found by cpmg_fit using just this data are:
5511
5512 - r2 = {'H-S 500': 6.671649051677150, 'H-S 600': 6.988634195648529, 'H-S 800': 5.527971316790596,
5513 'N-S 500': 8.394988400015988, 'N-S 600': 8.891359568401835, 'N-S 800': 10.405356669006709,
5514 'NHZ 500': 5.936446687394352, 'NHZ 600': 6.717058062814535, 'NHZ 800': 6.838733853403030,
5515 'NHD 500': 8.593136215779710, 'NHD 600': 10.651511259239674, 'NHD 800': 12.567902357560627,
5516 'HNM 500': 7.851325614877817, 'HNM 600': 8.408803624020202, 'HNM 800': 11.227489645758979,
5517 'NHM 500': 9.189159145380575, 'NHM 600': 9.856814478405868, 'NHM 800': 11.967910041807118},
5518 - pA = 0.943125351763911,
5519 - dw = 4.421827493809807,
5520 - dwH = -0.272637034755752,
5521 - kex = 360.609744568697238,
5522 - chi2 = 162.589570340050813.
5523 """
5524
5525
5526 self.setup_korzhnev_2005_data(data_list=['SQ', '1H SQ', 'DQ', 'ZQ', 'MQ', '1H MQ'])
5527
5528
5529 spin = return_spin(":9@N")
5530
5531
5532 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_SQ, frq=500e6)
5533 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_SQ, frq=600e6)
5534 r20_key3 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_SQ, frq=800e6)
5535 r20_key4 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6)
5536 r20_key5 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=600e6)
5537 r20_key6 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6)
5538 r20_key7 = generate_r20_key(exp_type=EXP_TYPE_CPMG_ZQ, frq=500e6)
5539 r20_key8 = generate_r20_key(exp_type=EXP_TYPE_CPMG_ZQ, frq=600e6)
5540 r20_key9 = generate_r20_key(exp_type=EXP_TYPE_CPMG_ZQ, frq=800e6)
5541 r20_key10 = generate_r20_key(exp_type=EXP_TYPE_CPMG_DQ, frq=500e6)
5542 r20_key11 = generate_r20_key(exp_type=EXP_TYPE_CPMG_DQ, frq=600e6)
5543 r20_key12 = generate_r20_key(exp_type=EXP_TYPE_CPMG_DQ, frq=800e6)
5544 r20_key13 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_MQ, frq=500e6)
5545 r20_key14 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_MQ, frq=600e6)
5546 r20_key15 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_MQ, frq=800e6)
5547 r20_key16 = generate_r20_key(exp_type=EXP_TYPE_CPMG_MQ, frq=500e6)
5548 r20_key17 = generate_r20_key(exp_type=EXP_TYPE_CPMG_MQ, frq=600e6)
5549 r20_key18 = generate_r20_key(exp_type=EXP_TYPE_CPMG_MQ, frq=800e6)
5550
5551
5552 spin.r2 = {
5553 r20_key1: 6.67288025927458, r20_key2: 6.98951408255098, r20_key3: 5.52959273852704,
5554 r20_key4: 8.39471048876782, r20_key5: 8.89290699178799, r20_key6: 10.40770687236930,
5555 r20_key7: 5.93611174376373, r20_key8: 6.71735669582514, r20_key9: 6.83835225518265,
5556 r20_key10: 8.59615074668922, r20_key11: 10.65121378892910, r20_key12: 12.57108229191090,
5557 r20_key13: 7.85956711501608, r20_key14: 8.41891642907918, r20_key15: 11.23620892230380,
5558 r20_key16: 9.19654863789350, r20_key17: 9.86031627358462, r20_key18: 11.97523755925750
5559 }
5560 spin.pA = 0.943129019477673
5561 spin.dw = 4.42209952545181
5562 spin.dwH = -0.27258970590969
5563 spin.kex = 360.516132791038
5564
5565
5566 self.interpreter.minimise.execute(min_algor='simplex', func_tol=1e-05, max_iter=10)
5567
5568
5569 self.interpreter.monte_carlo.setup(number=3)
5570 self.interpreter.monte_carlo.create_data(method='back_calc')
5571 self.interpreter.monte_carlo.initial_values()
5572 self.interpreter.minimise.execute(min_algor='simplex', max_iter=10)
5573 self.interpreter.monte_carlo.error_analysis()
5574
5575
5576 self.interpreter.relax_disp.plot_disp_curves(dir=ds.tmpdir, force=True)
5577
5578
5579 self.interpreter.state.save('state', dir=ds.tmpdir, compress_type=1, force=True)
5580
5581
5582 print("\n\nOptimised parameters:\n")
5583 print("%-20s %-20s" % ("Parameter", "Value (:9)"))
5584 print("%-20s %20.15g" % ("R2 (1H SQ - 500 MHz)", spin.r2[r20_key1]))
5585 print("%-20s %20.15g" % ("R2 (1H SQ - 600 MHz)", spin.r2[r20_key2]))
5586 print("%-20s %20.15g" % ("R2 (1H SQ - 800 MHz)", spin.r2[r20_key3]))
5587 print("%-20s %20.15g" % ("R2 (SQ - 500 MHz)", spin.r2[r20_key4]))
5588 print("%-20s %20.15g" % ("R2 (SQ - 600 MHz)", spin.r2[r20_key5]))
5589 print("%-20s %20.15g" % ("R2 (SQ - 800 MHz)", spin.r2[r20_key6]))
5590 print("%-20s %20.15g" % ("R2 (ZQ - 500 MHz)", spin.r2[r20_key7]))
5591 print("%-20s %20.15g" % ("R2 (ZQ - 600 MHz)", spin.r2[r20_key8]))
5592 print("%-20s %20.15g" % ("R2 (ZQ - 800 MHz)", spin.r2[r20_key9]))
5593 print("%-20s %20.15g" % ("R2 (DQ - 500 MHz)", spin.r2[r20_key10]))
5594 print("%-20s %20.15g" % ("R2 (DQ - 600 MHz)", spin.r2[r20_key11]))
5595 print("%-20s %20.15g" % ("R2 (DQ - 800 MHz)", spin.r2[r20_key12]))
5596 print("%-20s %20.15g" % ("R2 (1H MQ - 500 MHz)", spin.r2[r20_key13]))
5597 print("%-20s %20.15g" % ("R2 (1H MQ - 600 MHz)", spin.r2[r20_key14]))
5598 print("%-20s %20.15g" % ("R2 (1H MQ - 800 MHz)", spin.r2[r20_key15]))
5599 print("%-20s %20.15g" % ("R2 (MQ - 500 MHz)", spin.r2[r20_key16]))
5600 print("%-20s %20.15g" % ("R2 (MQ - 600 MHz)", spin.r2[r20_key17]))
5601 print("%-20s %20.15g" % ("R2 (MQ - 800 MHz)", spin.r2[r20_key18]))
5602 print("%-20s %20.15g" % ("pA", spin.pA))
5603 print("%-20s %20.15g" % ("dw", spin.dw))
5604 print("%-20s %20.15g" % ("dwH", spin.dwH))
5605 print("%-20s %20.15g" % ("kex", spin.kex))
5606 print("%-20s %20.15g\n" % ("chi2", spin.chi2))
5607
5608
5609 self.assertAlmostEqual(spin.r2[r20_key1], 6.67288025927458, 4)
5610 self.assertAlmostEqual(spin.r2[r20_key2], 6.98951408255098, 4)
5611 self.assertAlmostEqual(spin.r2[r20_key3], 5.52959273852704, 4)
5612 self.assertAlmostEqual(spin.r2[r20_key4], 8.39471048876782, 4)
5613 self.assertAlmostEqual(spin.r2[r20_key5], 8.89290699178799, 4)
5614 self.assertAlmostEqual(spin.r2[r20_key6], 10.4077068723693, 4)
5615 self.assertAlmostEqual(spin.r2[r20_key7], 5.93611174376373, 4)
5616 self.assertAlmostEqual(spin.r2[r20_key8], 6.71735669582514, 4)
5617 self.assertAlmostEqual(spin.r2[r20_key9], 6.83835225518265, 4)
5618 self.assertAlmostEqual(spin.r2[r20_key10], 8.59615074668922, 4)
5619 self.assertAlmostEqual(spin.r2[r20_key11], 10.6512137889291, 4)
5620 self.assertAlmostEqual(spin.r2[r20_key12], 12.5710822919109, 4)
5621 self.assertAlmostEqual(spin.r2[r20_key13], 7.85956711501608, 4)
5622 self.assertAlmostEqual(spin.r2[r20_key14], 8.41891642907918, 4)
5623 self.assertAlmostEqual(spin.r2[r20_key15], 11.2362089223038, 4)
5624 self.assertAlmostEqual(spin.r2[r20_key16], 9.1965486378935, 4)
5625 self.assertAlmostEqual(spin.r2[r20_key17], 9.86031627358462, 4)
5626 self.assertAlmostEqual(spin.r2[r20_key18], 11.9752375592575, 4)
5627 self.assertAlmostEqual(spin.pA, 0.943129019477673, 4)
5628 self.assertAlmostEqual(spin.dw, 4.42209952545181, 4)
5629 self.assertAlmostEqual(spin.dwH, -0.27258970590969, 4)
5630 self.assertAlmostEqual(spin.kex/1000, 360.516132791038/1000, 4)
5631 self.assertAlmostEqual(spin.chi2/1000, 162.596331278669/1000, 3)
5632
5633
5635 """Optimisation of all the Korzhnev et al., 2005 CPMG data using the 'NS MMQ 2-site' model.
5636
5637 This uses the data from Dmitry Korzhnev's paper at U{DOI: 10.1021/ja054550e<http://dx.doi.org/10.1021/ja054550e>}. This is the 1H SQ, 15N SQ, ZQ, DQ, 1H MQ and 15N MQ data for residue Asp 9 of the Fyn SH3 domain mutant.
5638
5639 Here all data will be optimised. The values found by cpmg_fit using just this data are:
5640
5641 - r2 = {'H-S 500': 6.671649051677150, 'H-S 600': 6.988634195648529, 'H-S 800': 5.527971316790596,
5642 'N-S 500': 8.394988400015988, 'N-S 600': 8.891359568401835, 'N-S 800': 10.405356669006709,
5643 'NHZ 500': 5.936446687394352, 'NHZ 600': 6.717058062814535, 'NHZ 800': 6.838733853403030,
5644 'NHD 500': 8.593136215779710, 'NHD 600': 10.651511259239674, 'NHD 800': 12.567902357560627,
5645 'HNM 500': 7.851325614877817, 'HNM 600': 8.408803624020202, 'HNM 800': 11.227489645758979,
5646 'NHM 500': 9.189159145380575, 'NHM 600': 9.856814478405868, 'NHM 800': 11.967910041807118},
5647 - pA = 0.943125351763911,
5648 - dw = 4.421827493809807,
5649 - dwH = -0.272637034755752,
5650 - kex = 360.609744568697238,
5651 - chi2 = 162.589570340050813.
5652 """
5653
5654
5655 self.setup_korzhnev_2005_data(data_list=['SQ', '1H SQ', 'DQ', 'ZQ', 'MQ', '1H MQ'])
5656
5657
5658 spin = return_spin(":9@N")
5659
5660
5661 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_SQ, frq=500e6)
5662 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_SQ, frq=600e6)
5663 r20_key3 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_SQ, frq=800e6)
5664 r20_key4 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6)
5665 r20_key5 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=600e6)
5666 r20_key6 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6)
5667 r20_key7 = generate_r20_key(exp_type=EXP_TYPE_CPMG_ZQ, frq=500e6)
5668 r20_key8 = generate_r20_key(exp_type=EXP_TYPE_CPMG_ZQ, frq=600e6)
5669 r20_key9 = generate_r20_key(exp_type=EXP_TYPE_CPMG_ZQ, frq=800e6)
5670 r20_key10 = generate_r20_key(exp_type=EXP_TYPE_CPMG_DQ, frq=500e6)
5671 r20_key11 = generate_r20_key(exp_type=EXP_TYPE_CPMG_DQ, frq=600e6)
5672 r20_key12 = generate_r20_key(exp_type=EXP_TYPE_CPMG_DQ, frq=800e6)
5673 r20_key13 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_MQ, frq=500e6)
5674 r20_key14 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_MQ, frq=600e6)
5675 r20_key15 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_MQ, frq=800e6)
5676 r20_key16 = generate_r20_key(exp_type=EXP_TYPE_CPMG_MQ, frq=500e6)
5677 r20_key17 = generate_r20_key(exp_type=EXP_TYPE_CPMG_MQ, frq=600e6)
5678 r20_key18 = generate_r20_key(exp_type=EXP_TYPE_CPMG_MQ, frq=800e6)
5679
5680
5681 spin.r2 = {
5682 r20_key1: 6.67288025927458, r20_key2: 6.98951408255098, r20_key3: 5.52959273852704,
5683 r20_key4: 8.39471048876782, r20_key5: 8.89290699178799, r20_key6: 10.40770687236930,
5684 r20_key7: 5.93611174376373, r20_key8: 6.71735669582514, r20_key9: 6.83835225518265,
5685 r20_key10: 8.59615074668922, r20_key11: 10.65121378892910, r20_key12: 12.57108229191090,
5686 r20_key13: 7.85956711501608, r20_key14: 8.41891642907918, r20_key15: 11.23620892230380,
5687 r20_key16: 9.19654863789350, r20_key17: 9.86031627358462, r20_key18: 11.97523755925750
5688 }
5689 spin.pA = 0.943129019477673
5690 spin.dw = 4.42209952545181
5691 spin.dwH = -0.27258970590969
5692 spin.kex = 360.516132791038
5693
5694
5695 self.interpreter.minimise.calculate(verbosity=1)
5696
5697
5698 print("\n\nOptimised parameters:\n")
5699 print("%-20s %-20s" % ("Parameter", "Value (:9)"))
5700 print("%-20s %20.15g" % ("R2 (1H SQ - 500 MHz)", spin.r2[r20_key1]))
5701 print("%-20s %20.15g" % ("R2 (1H SQ - 600 MHz)", spin.r2[r20_key2]))
5702 print("%-20s %20.15g" % ("R2 (1H SQ - 800 MHz)", spin.r2[r20_key3]))
5703 print("%-20s %20.15g" % ("R2 (SQ - 500 MHz)", spin.r2[r20_key4]))
5704 print("%-20s %20.15g" % ("R2 (SQ - 600 MHz)", spin.r2[r20_key5]))
5705 print("%-20s %20.15g" % ("R2 (SQ - 800 MHz)", spin.r2[r20_key6]))
5706 print("%-20s %20.15g" % ("R2 (ZQ - 500 MHz)", spin.r2[r20_key7]))
5707 print("%-20s %20.15g" % ("R2 (ZQ - 600 MHz)", spin.r2[r20_key8]))
5708 print("%-20s %20.15g" % ("R2 (ZQ - 800 MHz)", spin.r2[r20_key9]))
5709 print("%-20s %20.15g" % ("R2 (DQ - 500 MHz)", spin.r2[r20_key10]))
5710 print("%-20s %20.15g" % ("R2 (DQ - 600 MHz)", spin.r2[r20_key11]))
5711 print("%-20s %20.15g" % ("R2 (DQ - 800 MHz)", spin.r2[r20_key12]))
5712 print("%-20s %20.15g" % ("R2 (1H MQ - 500 MHz)", spin.r2[r20_key13]))
5713 print("%-20s %20.15g" % ("R2 (1H MQ - 600 MHz)", spin.r2[r20_key14]))
5714 print("%-20s %20.15g" % ("R2 (1H MQ - 800 MHz)", spin.r2[r20_key15]))
5715 print("%-20s %20.15g" % ("R2 (MQ - 500 MHz)", spin.r2[r20_key16]))
5716 print("%-20s %20.15g" % ("R2 (MQ - 600 MHz)", spin.r2[r20_key17]))
5717 print("%-20s %20.15g" % ("R2 (MQ - 800 MHz)", spin.r2[r20_key18]))
5718 print("%-20s %20.15g" % ("pA", spin.pA))
5719 print("%-20s %20.15g" % ("dw", spin.dw))
5720 print("%-20s %20.15g" % ("dwH", spin.dwH))
5721 print("%-20s %20.15g" % ("kex", spin.kex))
5722 print("%-20s %20.15g\n" % ("chi2", spin.chi2))
5723
5724
5725 self.assertAlmostEqual(spin.chi2/1000, 162.511988511609/1000, 3)
5726
5727
5729 """Check of all possible dispersion graphs from optimisation of Kaare Teilum, Flemming M Poulsen, Mikael Akke 2006 "acyl-CoA binding protein" CPMG data to the CR72 dispersion model.
5730
5731 This uses the data from paper at U{http://dx.doi.org/10.1073/pnas.0509100103}. This is CPMG data with a fixed relaxation time period. Experiment in 0.48 M GuHCl (guanidine hydrochloride).
5732
5733 Figure 3 shows the ln( k_a [s^-1]) for different concentrations of GuHCl. The precise values are:
5734
5735 - [GuHCL][M] ln(k_a[s^-1]) k_a[s^-1]
5736 - 0.483 0.89623903 2.4503699912708878
5737 - 0.545 1.1694838
5738 - 0.545 1.1761503
5739 - 0.622 1.294
5740 - 0.669 1.5176493
5741 - 0.722 1.6238791
5742 - 0.813 1.9395758
5743 - 1.011 2.3558415 10.547000429321157
5744 """
5745
5746
5747 model = 'TSMFK01'
5748 expfolder = "acbp_cpmg_disp_048MGuHCl_40C_041223"
5749 self.setup_kteilum_fmpoulsen_makke_cpmg_data(model=model, expfolder=expfolder)
5750
5751
5752 res61L = cdp.mol[0].res[0].spin[0]
5753
5754
5755 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=599.89086220e6)
5756
5757
5758 res61L.r2a = {r20_key1: 8.0}
5759 res61L.dw = 6.5
5760 res61L.k_AB = 2.5
5761
5762
5763 self.interpreter.minimise.execute(min_algor='simplex', line_search=None, hessian_mod=None, hessian_type=None, func_tol=1e-05, grad_tol=None, max_iter=1000, constraints=True, scaling=True, verbosity=1)
5764
5765
5766 y_axis_types = [Y_AXIS_R2_EFF, Y_AXIS_R2_R1RHO]
5767 x_axis_types = [X_AXIS_DISP, X_AXIS_THETA, X_AXIS_W_EFF]
5768 interpolate_types = [INTERPOLATE_DISP]
5769
5770
5771 result_dir_name = ds.tmpdir
5772 result_folders = [model]
5773 spin_id = ":61@N"
5774
5775
5776 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'KTeilum_FMPoulsen_MAkke_2006'+sep+expfolder+sep+'check_graphs'
5777
5778 for result_folder in result_folders:
5779 for y_axis in y_axis_types:
5780 for x_axis in x_axis_types:
5781 for interpolate in interpolate_types:
5782
5783 file_name_ini = return_grace_file_name_ini(y_axis=y_axis, x_axis=x_axis, interpolate=interpolate)
5784
5785
5786 file_name = "%s%s.agr" % (file_name_ini, spin_id.replace('#', '_').replace(':', '_').replace('@', '_'))
5787
5788
5789 dir = result_dir_name+sep+result_folder
5790 print("Plotting combination of %s, %s, %s"%(y_axis, x_axis, interpolate))
5791 self.interpreter.relax_disp.plot_disp_curves(dir=dir, y_axis=y_axis, x_axis=x_axis, interpolate=interpolate, force=True)
5792
5793
5794 file_path = get_file_path(file_name, dir)
5795
5796
5797 print("Testing file access to graph: %s"%file_path)
5798 self.assert_(access(file_path, F_OK))
5799
5800
5801 file_prod = open(file_path)
5802 lines_prod = file_prod.readlines()
5803 file_prod.close()
5804
5805
5806 dir_comp = data_path+sep+result_folder
5807 file_path_comp = get_file_path(file_name, dir_comp)
5808 file_comp = open(file_path_comp)
5809 lines_comp = file_comp.readlines()
5810 file_comp.close()
5811
5812
5813 self.assertEqual(len(lines_prod), len(lines_comp))
5814 for j in range(len(lines_prod)):
5815
5816 first_char = lines_prod[j][0]
5817 if first_char in ["@", "&"]:
5818 self.assertEqual(lines_prod[j], lines_comp[j])
5819 else:
5820
5821
5822 x_prod, y_prod, y_prod_err = lines_prod[j].split()
5823 x_comp, y_comp, y_comp_err = lines_comp[j].split()
5824 self.assertAlmostEqual(float(x_prod), float(x_comp))
5825 self.assertAlmostEqual(float(y_prod), float(y_comp))
5826 self.assertAlmostEqual(float(y_prod_err), float(y_comp_err))
5827
5828
5830 """Optimisation of Kaare Teilum, Flemming M Poulsen, Mikael Akke 2006 "acyl-CoA binding protein" CPMG data to the CR72 dispersion model.
5831
5832 This uses the data from paper at U{http://dx.doi.org/10.1073/pnas.0509100103}. This is CPMG data with a fixed relaxation time period. Experiment in 0.48 M GuHCl (guanidine hydrochloride).
5833 """
5834
5835
5836 self.setup_kteilum_fmpoulsen_makke_cpmg_data(model='CR72', expfolder="acbp_cpmg_disp_048MGuHCl_40C_041223")
5837
5838
5839 res61L = cdp.mol[0].res[0].spin[0]
5840
5841
5842 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=599.89086220e6)
5843
5844
5845 res61L.r2 = {r20_key1: 8.0}
5846 res61L.pA = 0.9
5847 res61L.dw = 6.0
5848 res61L.kex = 600.0
5849
5850
5851 self.interpreter.minimise.execute(min_algor='simplex', line_search=None, hessian_mod=None, hessian_type=None, func_tol=1e-05, grad_tol=None, max_iter=1000, constraints=True, scaling=True, verbosity=1)
5852
5853
5854 print("\n\nOptimised parameters:\n")
5855 print("%-20s %-20s" % ("Parameter", "Value (:61)"))
5856 print("%-20s %20.15g" % ("R2 (600 MHz)", res61L.r2[r20_key1]))
5857 print("%-20s %20.15g" % ("pA", res61L.pA))
5858 print("%-20s %20.15g" % ("dw", res61L.dw))
5859 print("%-20s %20.15g" % ("kex", res61L.kex))
5860 print("%-20s %20.15g\n" % ("chi2", res61L.chi2))
5861
5862
5863 self.assertAlmostEqual(res61L.r2[r20_key1], 8.69277980194016, 4)
5864 self.assertAlmostEqual(res61L.pA, 0.9943781590842946, 5)
5865 self.assertAlmostEqual(res61L.dw, 6.389453131263374, 3)
5866 self.assertAlmostEqual(res61L.kex, 609.262167216419, 0)
5867 self.assertAlmostEqual(res61L.chi2, 65.99987828889657, 5)
5868
5869
5870 self.assertEqual(res61L.k_AB, res61L.kex * (1.0 - res61L.pA))
5871
5872
5873 self.assertEqual(res61L.k_BA, res61L.kex * res61L.pA)
5874
5875
5877 """Optimisation of Kaare Teilum, Flemming M Poulsen, Mikael Akke 2006 "acyl-CoA binding protein" CPMG data to the CR72 dispersion model.
5878
5879 This uses the data from paper at U{http://dx.doi.org/10.1073/pnas.0509100103}. This is CPMG data with a fixed relaxation time period. Experiment in 0.48 M GuHCl (guanidine hydrochloride).
5880 """
5881
5882
5883 self.setup_kteilum_fmpoulsen_makke_cpmg_data(model='CR72 full', expfolder="acbp_cpmg_disp_048MGuHCl_40C_041223")
5884
5885
5886 res61L = cdp.mol[0].res[0].spin[0]
5887
5888
5889 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=599.89086220e6)
5890
5891
5892 res61L.r2a = {r20_key1: 8.0}
5893 res61L.r2b = {r20_key1: 105.0}
5894 res61L.pA = 0.9
5895 res61L.dw = 6.0
5896 res61L.kex = 500.0
5897
5898
5899 self.interpreter.minimise.execute(min_algor='simplex', line_search=None, hessian_mod=None, hessian_type=None, func_tol=1e-05, grad_tol=None, max_iter=1000, constraints=True, scaling=True, verbosity=1)
5900
5901
5902 print("\n\nOptimised parameters:\n")
5903 print("%-20s %-20s" % ("Parameter", "Value (:61)"))
5904 print("%-20s %20.15g" % ("R2A (600 MHz)", res61L.r2a[r20_key1]))
5905 print("%-20s %20.15g" % ("R2B (600 MHz)", res61L.r2b[r20_key1]))
5906 print("%-20s %20.15g" % ("pA", res61L.pA))
5907 print("%-20s %20.15g" % ("dw", res61L.dw))
5908 print("%-20s %20.15g" % ("kex", res61L.kex))
5909 print("%-20s %20.15g\n" % ("chi2", res61L.chi2))
5910
5911
5912 self.assertAlmostEqual(res61L.r2a[r20_key1], 8.044428899438309, 0)
5913 self.assertAlmostEqual(res61L.r2b[r20_key1], 105.11894506392449, -2)
5914 self.assertAlmostEqual(res61L.pA, 0.992066883657578, 2)
5915 self.assertAlmostEqual(res61L.dw, 6.389453586338883, 3)
5916 self.assertAlmostEqual(res61L.kex, 513.483608742063, -2)
5917 self.assertAlmostEqual(res61L.chi2, 65.99987828890289, 5)
5918
5919
5921 """Optimisation of Kaare Teilum, Flemming M Poulsen, Mikael Akke 2006 "acyl-CoA binding protein" CPMG data to the CR72 dispersion model.
5922
5923 This uses the data from paper at U{http://dx.doi.org/10.1073/pnas.0509100103}. This is CPMG data with a fixed relaxation time period. Experiment in 0.48 M GuHCl (guanidine hydrochloride).
5924
5925 Figure 3 shows the ln( k_a [s^-1]) for different concentrations of GuHCl. The precise values are:
5926
5927 - [GuHCL][M] ln(k_a[s^-1]) k_a[s^-1]
5928 - 0.483 0.89623903 2.4503699912708878
5929 - 0.545 1.1694838
5930 - 0.545 1.1761503
5931 - 0.622 1.294
5932 - 0.669 1.5176493
5933 - 0.722 1.6238791
5934 - 0.813 1.9395758
5935 - 1.011 2.3558415 10.547000429321157
5936 """
5937
5938
5939 self.setup_kteilum_fmpoulsen_makke_cpmg_data(model='TSMFK01', expfolder="acbp_cpmg_disp_048MGuHCl_40C_041223")
5940
5941
5942 res61L = cdp.mol[0].res[0].spin[0]
5943
5944
5945 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=599.89086220e6)
5946
5947
5948 res61L.r2a = {r20_key1: 8.0}
5949 res61L.dw = 6.5
5950 res61L.k_AB = 2.5
5951
5952
5953 self.interpreter.minimise.execute(min_algor='simplex', line_search=None, hessian_mod=None, hessian_type=None, func_tol=1e-05, grad_tol=None, max_iter=1000, constraints=True, scaling=True, verbosity=1)
5954
5955
5956 print("\n\nOptimised parameters:\n")
5957 print("%-20s %-20s" % ("Parameter", "Value (:61)"))
5958 print("%-20s %20.15g" % ("R2A (600 MHz)", res61L.r2a[r20_key1]))
5959 print("%-20s %20.15g" % ("dw", res61L.dw))
5960 print("%-20s %20.15g" % ("k_AB", res61L.k_AB))
5961 print("%-20s %20.15g\n" % ("chi2", res61L.chi2))
5962
5963
5964
5965 self.assertAlmostEqual(res61L.k_AB, 2.45, 1)
5966
5967
5969 """Optimisation of Kaare Teilum, Flemming M Poulsen, Mikael Akke 2006 "acyl-CoA binding protein" CPMG data to the CR72 dispersion model.
5970
5971 This uses the data from paper at U{http://dx.doi.org/10.1073/pnas.0509100103}. This is CPMG data with a fixed relaxation time period. Experiment in 1.01 M GuHCl (guanidine hydrochloride).
5972
5973 The comparison is to Figure 2, which is for dataset with 1 M GuHCl. The reported results are expected to be in rad.s^-1. Conversion into relax stored values is preferably.
5974
5975 Representative 15N CPMG relaxation dispersion curve measured on the cross peaks from residue L61 in folded ACBP at pH 5.3, 1 M GuHCl, and 40C:
5976
5977 1. The dotted line represents a residue-specific fit of all parameters in Eq. 1:
5978 - k_AB = 11.3 +/- 0.7 s^-1,
5979 - dw = (2.45 +/- 0.09) * 10^3 s^-1,
5980 - R2 = 8.0 +/- 0.5 s^-1.
5981
5982 2. The solid line represents a global fit of k_AB to all protein residues and a residue-specific fit of dw and R2.:
5983 - k_AB = 10.55 +/- 0.08 s^-1,
5984 - dw = (2.44 +/- 0.08) * 10^3 s^-1,
5985 - R2 = 8.4 +/- 0.3 s^-1.
5986
5987 Conversion of paper results to relax results is performed by:
5988
5989 - dw(ppm) = dw(rad.s^-1) * 10^6 * 1/(2*pi) * (gyro1H/(gyro15N*spectrometer_freq)) = 2.45E3 * 1E6 / (2 * math.pi) * (26.7522212E7/(-2.7126E7 * 599.8908622E6)) = -6.41 ppm.
5990
5991 Figure 3 shows the ln( k_a [s^-1]) for different concentrations of GuHCl. The precise values are:
5992
5993 - [GuHCL][M] ln(k_a[s^-1]) k_a[s^-1]
5994 - 0.483 0.89623903 2.4503699912708878
5995 - 0.545 1.1694838
5996 - 0.545 1.1761503
5997 - 0.622 1.294
5998 - 0.669 1.5176493
5999 - 0.722 1.6238791
6000 - 0.813 1.9395758
6001 - 1.011 2.3558415 10.547000429321157
6002 """
6003
6004
6005 self.setup_kteilum_fmpoulsen_makke_cpmg_data(model='TSMFK01', expfolder="acbp_cpmg_disp_101MGuHCl_40C_041223")
6006
6007
6008 res61L = cdp.mol[0].res[0].spin[0]
6009
6010
6011 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=599.89086270e6)
6012
6013
6014 res61L.r2a = {r20_key1: 8.0}
6015 res61L.dw = 6.5
6016 res61L.k_AB = 11.0
6017
6018
6019 self.interpreter.minimise.execute(min_algor='simplex', line_search=None, hessian_mod=None, hessian_type=None, func_tol=1e-05, grad_tol=None, max_iter=1000, constraints=True, scaling=True, verbosity=1)
6020
6021
6022 print("\n\nOptimised parameters:\n")
6023 print("%-20s %-20s" % ("Parameter", "Value (:61)"))
6024 print("%-20s %20.15g" % ("R2A (600 MHz)", res61L.r2a[r20_key1]))
6025 print("%-20s %20.15g" % ("dw", res61L.dw))
6026 print("%-20s %20.15g" % ("k_AB", res61L.k_AB))
6027 print("%-20s %20.15g\n" % ("chi2", res61L.chi2))
6028
6029
6030
6031 self.assertAlmostEqual(res61L.r2a[r20_key1], 8.4, 0)
6032 self.assertAlmostEqual(res61L.dw, 6.41, 0)
6033 self.assertAlmostEqual(res61L.k_AB, 10.55, 0)
6034
6035
6037 """Test the 'LM63 3-site' dispersion model using the pure noise-free synthetic data."""
6038
6039
6040 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'lm63_3site'
6041
6042
6043 self.interpreter.reset()
6044 self.interpreter.state.load(data_path+sep+'r2eff_values')
6045
6046
6047 self.interpreter.pipe.copy(pipe_from='base pipe', pipe_to='LM63 3-site', bundle_to='relax_disp')
6048 self.interpreter.pipe.switch(pipe_name='LM63 3-site')
6049
6050
6051 self.interpreter.relax_disp.select_model(model='LM63 3-site')
6052 self.interpreter.value.copy(pipe_from='R2eff - relax_disp', pipe_to='LM63 3-site', param='r2eff')
6053 self.interpreter.spin.isotope('15N')
6054
6055
6056 spin1 = return_spin(":1")
6057 spin2 = return_spin(":2")
6058
6059
6060 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6)
6061 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6)
6062
6063
6064 spin1.r2 = {r20_key1: 12.0, r20_key2: 12.0}
6065 spin1.phi_ex_B = 0.1
6066 spin1.phi_ex_C = 0.5
6067 spin1.kB = 1500.0
6068 spin1.kC = 2500.0
6069 spin2.r2 = {r20_key1: 15.0, r20_key2: 15.0}
6070 spin2.phi_ex_B = 0.1
6071 spin2.phi_ex_C = 0.5
6072 spin2.kB = 1500.0
6073 spin2.kC = 2500.0
6074
6075
6076 self.interpreter.minimise.execute(min_algor='simplex', line_search=None, hessian_mod=None, hessian_type=None, func_tol=1e-05, grad_tol=None, max_iter=1000, constraints=True, scaling=True, verbosity=1)
6077
6078
6079 self.interpreter.monte_carlo.setup(number=3)
6080 self.interpreter.monte_carlo.create_data(method='back_calc')
6081 self.interpreter.monte_carlo.initial_values()
6082 self.interpreter.minimise.execute(min_algor='simplex', line_search=None, hessian_mod=None, hessian_type=None, func_tol=1e-2, grad_tol=None, max_iter=10, constraints=True, scaling=True, verbosity=1)
6083 self.interpreter.monte_carlo.error_analysis()
6084
6085
6086 self.interpreter.results.write(file='devnull', compress_type=1, force=True)
6087
6088
6089 print("\n\nOptimised parameters:\n")
6090 print("%-20s %-20s %-20s" % ("Parameter", "Value (:1)", "Value (:2)"))
6091 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin1.r2[r20_key1], spin2.r2[r20_key1]))
6092 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin1.r2[r20_key2], spin2.r2[r20_key2]))
6093 print("%-20s %20.15g %20.15g" % ("phi_ex_B", spin1.phi_ex_B, spin2.phi_ex_B))
6094 print("%-20s %20.15g %20.15g" % ("phi_ex_C", spin1.phi_ex_C, spin2.phi_ex_C))
6095 print("%-20s %20.15g %20.15g" % ("kB", spin1.kB, spin2.kB))
6096 print("%-20s %20.15g %20.15g" % ("kC", spin1.kC, spin2.kC))
6097 print("%-20s %20.15g %20.15g\n" % ("chi2", spin1.chi2, spin2.chi2))
6098 self.assertAlmostEqual(spin1.r2[r20_key1], 12.0, 2)
6099 self.assertAlmostEqual(spin1.r2[r20_key2], 12.0, 2)
6100 self.assertAlmostEqual(spin1.phi_ex_B, 0.1, 3)
6101 self.assertAlmostEqual(spin1.phi_ex_C, 0.5, 3)
6102 self.assertAlmostEqual(spin1.kB/1000, 1500.0/1000, 3)
6103 self.assertAlmostEqual(spin1.kC/1000, 2500.0/1000, 3)
6104 self.assertAlmostEqual(spin1.chi2, 0.0, 3)
6105 self.assertAlmostEqual(spin2.r2[r20_key1], 15.0, 3)
6106 self.assertAlmostEqual(spin2.r2[r20_key2], 15.0, 3)
6107 self.assertAlmostEqual(spin1.phi_ex_B, 0.1, 3)
6108 self.assertAlmostEqual(spin1.phi_ex_C, 0.5, 3)
6109 self.assertAlmostEqual(spin1.kB/1000, 1500.0/1000, 3)
6110 self.assertAlmostEqual(spin1.kC/1000, 2500.0/1000, 3)
6111 self.assertAlmostEqual(spin2.chi2, 0.0, 3)
6112
6113
6115 """Test the relaxation dispersion 'M61' model curve fitting to fixed time synthetic data."""
6116
6117
6118 ds.fixed = True
6119
6120
6121 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'r1rho_on_res_m61.py')
6122
6123
6124 i0 = [100000.0, 20000.0]
6125 r1rho_prime = [2.25, 24.0]
6126 pA = 0.7
6127 kex = 1000.0
6128 delta_omega = [1.0, 2.0]
6129 keys = ['r1rho_800.00000000_0.000_1000.000', 'r1rho_800.00000000_0.000_1500.000', 'r1rho_800.00000000_0.000_2000.000', 'r1rho_800.00000000_0.000_2500.000', 'r1rho_800.00000000_0.000_3000.000', 'r1rho_800.00000000_0.000_3500.000', 'r1rho_800.00000000_0.000_4000.000', 'r1rho_800.00000000_0.000_4500.000', 'r1rho_800.00000000_0.000_5000.000', 'r1rho_800.00000000_0.000_5500.000', 'r1rho_800.00000000_0.000_6000.000']
6130 phi_ex = []
6131 for i in range(2):
6132 phi_ex.append(pA * (1.0 - pA) * delta_omega[i]**2)
6133 rates = [[3.59768160399, 2.85730469783, 2.59328084312, 2.47019857325, 2.40310451058, 2.36256876552, 2.33622716364, 2.31815271355, 2.30521680479, 2.29564174079, 2.28835686631], [29.390726416, 26.4292187913, 25.3731233725, 24.880794293, 24.6124180423, 24.4502750621, 24.3449086546, 24.2726108542, 24.2208672192, 24.1825669632, 24.1534274652]]
6134
6135
6136 self.interpreter.pipe.switch('R2eff - relax_disp')
6137 spin_index = 0
6138 for spin, spin_id in spin_loop(return_id=True):
6139
6140 print("\nSpin %s." % spin_id)
6141
6142
6143 for i in range(len(keys)):
6144 self.assertAlmostEqual(spin.r2eff[keys[i]]/10.0, rates[spin_index][i]/10.0, 2)
6145
6146
6147 spin_index += 1
6148
6149
6150 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_R1RHO, frq=800e6)
6151
6152
6153 self.interpreter.pipe.switch('M61 - relax_disp')
6154 spin_index = 0
6155 for spin, spin_id in spin_loop(return_id=True):
6156
6157 print("\nSpin %s." % spin_id)
6158
6159
6160 self.assertAlmostEqual(spin.r2[r20_key1]/10, r1rho_prime[spin_index]/10, 2)
6161 self.assertAlmostEqual(spin.phi_ex, phi_ex[spin_index], 2)
6162 self.assertAlmostEqual(spin.kex/1000.0, kex/1000.0, 2)
6163
6164
6165 spin_index += 1
6166
6167
6169 """Test the relaxation dispersion 'M61' model curve fitting to the full exponential synthetic data."""
6170
6171
6172 ds.fixed = False
6173
6174
6175 ds.single = True
6176
6177
6178 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'r1rho_on_res_m61.py')
6179
6180
6181 i0 = [100000.0, 20000.0]
6182 r1rho_prime = [2.25, 24.0]
6183 pA = 0.7
6184 kex = 1000.0
6185 delta_omega = [1.0, 2.0]
6186 keys = ['r1rho_800.00000000_0.000_1000.000', 'r1rho_800.00000000_0.000_1500.000', 'r1rho_800.00000000_0.000_2000.000', 'r1rho_800.00000000_0.000_2500.000', 'r1rho_800.00000000_0.000_3000.000', 'r1rho_800.00000000_0.000_3500.000', 'r1rho_800.00000000_0.000_4000.000', 'r1rho_800.00000000_0.000_4500.000', 'r1rho_800.00000000_0.000_5000.000', 'r1rho_800.00000000_0.000_5500.000', 'r1rho_800.00000000_0.000_6000.000']
6187 phi_ex = []
6188 for i in range(2):
6189 phi_ex.append(pA * (1.0 - pA) * delta_omega[i]**2)
6190 rates = [[3.59768160399, 2.85730469783, 2.59328084312, 2.47019857325, 2.40310451058, 2.36256876552, 2.33622716364, 2.31815271355, 2.30521680479, 2.29564174079, 2.28835686631], [29.390726416, 26.4292187913, 25.3731233725, 24.880794293, 24.6124180423, 24.4502750621, 24.3449086546, 24.2726108542, 24.2208672192, 24.1825669632, 24.1534274652]]
6191
6192
6193 self.interpreter.pipe.switch('R2eff - relax_disp')
6194 spin_index = 0
6195 for spin, spin_id in spin_loop(return_id=True):
6196
6197 print("\nSpin %s." % spin_id)
6198
6199
6200 for i in range(len(keys)):
6201 self.assertAlmostEqual(spin.r2eff[keys[i]]/10.0, rates[spin_index][i]/10.0, 2)
6202
6203
6204 spin_index += 1
6205
6206
6207 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_R1RHO, frq=800e6)
6208
6209
6210 self.interpreter.pipe.switch('M61 - relax_disp')
6211 spin_index = 0
6212 for spin, spin_id in spin_loop(return_id=True):
6213
6214 print("\nSpin %s." % spin_id)
6215
6216
6217 self.assertAlmostEqual(spin.r2[r20_key1]/10, r1rho_prime[spin_index]/10, 2)
6218 self.assertAlmostEqual(spin.phi_ex, phi_ex[spin_index], 2)
6219 self.assertAlmostEqual(spin.kex/1000.0, kex/1000.0, 2)
6220
6221
6222 spin_index += 1
6223
6224
6226 """Test the relaxation dispersion 'M61 skew' model curve fitting to fixed time synthetic data."""
6227
6228
6229 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'r1rho_on_res_m61b.py')
6230
6231
6232 i0 = [100000.0, 20000.0]
6233 r1rho_prime = [10.0, 24.0]
6234 pA = 0.95
6235 kex = 2000.0
6236 delta_omega = [1.0, 2.0]
6237
6238
6239 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_R1RHO, frq=800e6)
6240
6241
6242 self.interpreter.pipe.switch("%s - relax_disp" % MODEL_M61B)
6243 spin_index = 0
6244 for spin, spin_id in spin_loop(return_id=True):
6245
6246 print("\nSpin %s." % spin_id)
6247
6248
6249 self.assertAlmostEqual(spin.r2[r20_key1]/10, r1rho_prime[spin_index]/10, 2)
6250 self.assertAlmostEqual(spin.pA, pA, 2)
6251 self.assertAlmostEqual(spin.dw, dw[spin_index], 2)
6252 self.assertAlmostEqual(spin.kex/1000.0, kex/1000.0, 2)
6253
6254
6255 spin_index += 1
6256
6257
6259 """Test that all models which can nest, have all their parameters converted."""
6260
6261
6262 cdp.exp_type_list = EXP_TYPE_LIST
6263
6264
6265 all_models_info = models_info(models=MODEL_LIST_FULL)
6266
6267
6268 print("Printing the listed of nested models for each model.")
6269 print("#########################################")
6270 for model_info in all_models_info:
6271 print("%s"%model_info.model),
6272 print("<-"),
6273 nest_list = model_info.nest_list
6274 if nest_list == None:
6275 nest_list = ["None"]
6276 print(', '.join(map(str, nest_list)))
6277
6278
6279 if nest_list == ["None"]:
6280 continue
6281
6282
6283 model_params = model_info.params
6284
6285
6286 for nested_model in nest_list:
6287
6288 nested_model_params = MODEL_PARAMS[nested_model]
6289
6290
6291 par_dic = nesting_param(model_params=model_params, nested_model_params=nested_model_params)
6292
6293
6294 self.assertEqual(len(par_dic), len(model_params))
6295
6296
6297 for param in par_dic:
6298 if param != par_dic[param]:
6299 print("Model:'%s', Nested model:'%s', Copying '%s' to '%s'." % (model_info.model, nested_model, par_dic[param], param))
6300 self.assertNotEqual(par_dic[param], None)
6301
6302
6304 """Compare the 'NS MMQ 3-site' dispersion model to synthetic data from cpmg_fit."""
6305
6306
6307 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'ns_mmq_3site.py')
6308
6309
6310 self.assertAlmostEqual(cdp.mol[0].res[0].spin[1].chi2, 0.0, 3)
6311
6312
6314 """Compare the 'NS MMQ 3-site linear' dispersion model to synthetic data from cpmg_fit."""
6315
6316
6317 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'ns_mmq_3site_linear.py')
6318
6319
6320 self.assertAlmostEqual(cdp.mol[0].res[0].spin[1].chi2, 0.0, 3)
6321
6322
6324 """Compare the 'NS R1rho 3-site' dispersion model to synthetic data from cpmg_fit."""
6325
6326
6327 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'ns_r1rho_3site.py')
6328
6329
6330 self.assertAlmostEqual(cdp.mol[0].res[0].spin[0].chi2, 136.13141468674999, 3)
6331
6332
6334 """Compare the 'NS R1rho 3-site linear' dispersion model to synthetic data from cpmg_fit."""
6335
6336
6337 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'ns_r1rho_3site_linear.py')
6338
6339
6340 self.assertAlmostEqual(cdp.mol[0].res[0].spin[0].chi2, 0.030959849811015544, 3)
6341
6342
6344 """This test truncated private data which was provided by Paul Schanda. This systemtest uncovers some unfortunate problems when
6345 running an analysis and reading points by the R2eff method.
6346 """
6347
6348
6349 outdir = ds.tmpdir
6350
6351
6352 self.setup_paul_schanda_nov_2015(outdir=outdir)
6353
6354
6355 self.interpreter.sequence.read(file='residues.txt', res_num_col=1, dir=outdir)
6356
6357
6358 set_file = open(outdir+sep+"exp_settings.txt")
6359 set_file_lines = set_file.readlines()
6360
6361
6362 for line in set_file_lines:
6363 if "#" in line[0]:
6364 continue
6365
6366
6367 field, RF_field_strength_kHz, f_name = line.split()
6368
6369
6370 spec_id = f_name
6371 self.interpreter.relax_disp.exp_type(spectrum_id=spec_id, exp_type='R1rho')
6372
6373
6374 self.interpreter.spectrometer.frequency(id=spec_id, frq=float(field), units='MHz')
6375
6376
6377 disp_frq = float(RF_field_strength_kHz)*1000
6378
6379
6380 self.interpreter.relax_disp.spin_lock_field(spectrum_id=spec_id, field=disp_frq)
6381
6382
6383 self.interpreter.relax_disp.r2eff_read(id=spec_id, file=f_name, dir=None, disp_frq=disp_frq, res_num_col=1, data_col=2, error_col=3)
6384
6385
6386
6387
6388
6389
6390 r2eff_points = []
6391 for cur_spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
6392
6393 for key in cur_spin.r2eff:
6394 value = cur_spin.r2eff[key]
6395 err = cur_spin.r2eff_err[key]
6396 r2eff_points.append(value)
6397
6398
6399 self.assert_(not isnan(value))
6400 self.assert_(not isnan(err))
6401
6402
6403
6404 self.assertEqual(len(r2eff_points), 2*(10+19)-1)
6405
6406
6407 self.assertEqual(len(cdp.mol), 1)
6408 self.assertEqual(cdp.mol[0].name, None)
6409 self.assertEqual(len(cdp.mol[0].res), 2)
6410
6411 self.assertEqual(cdp.spectrometer_frq_count, 2)
6412 self.assertEqual(cdp.spectrometer_frq_list, [600000000.0, 950000000.0])
6413 self.assertEqual(cdp.exp_type_list, ['R1rho'])
6414
6415
6416 count_600 = 0
6417 count_950 = 0
6418 for exp_type, frq, offset, point, ei, mi, oi, di in loop_exp_frq_offset_point(return_indices=True):
6419 if frq == cdp.spectrometer_frq_list[0]:
6420 count_600 += 1
6421 elif frq == cdp.spectrometer_frq_list[1]:
6422 count_950 += 1
6423
6424
6425 self.assertEqual(count_600, 10)
6426 self.assertEqual(count_950, 19)
6427
6428
6429 self.interpreter.spin.isotope(isotope='15N')
6430
6431
6432 self.assertRaises(RelaxError, self.interpreter.relax_disp.plot_disp_curves, dir=outdir, y_axis='r2_eff', x_axis='disp', num_points=1000, extend_hz=500.0, extend_ppm=500.0, interpolate='disp', force=True)
6433 self.interpreter.relax_disp.select_model(model=MODEL_R2EFF)
6434 self.interpreter.relax_disp.plot_disp_curves(dir=outdir, y_axis='r2_eff', x_axis='disp', num_points=1000, extend_hz=500.0, extend_ppm=500.0, interpolate='disp', force=True)
6435
6436
6437
6438
6439 GRID_INC = 21
6440
6441 MC_NUM = 3
6442
6443 MODSEL = 'AIC'
6444
6445 MODELS = [MODEL_NOREX, MODEL_M61]
6446
6447 r1_fit = False
6448
6449 set_grid_r20=True
6450
6451
6452
6453 OPT_FUNC_TOL = 1e-1
6454 relax_disp.Relax_disp.opt_func_tol = OPT_FUNC_TOL
6455 OPT_MAX_ITERATIONS = 1000
6456 relax_disp.Relax_disp.opt_max_iterations = OPT_MAX_ITERATIONS
6457
6458
6459 relax_disp.Relax_disp(pipe_name="relax_disp", pipe_bundle="relax_disp", results_dir=outdir, models=MODELS, grid_inc=GRID_INC, mc_sim_num=MC_NUM, exp_mc_sim_num=None, modsel=MODSEL, pre_run_dir=None, optimise_r2eff=False, insignificance=0.0, numeric_only=False, mc_sim_all_models=False, eliminate=True, set_grid_r20=set_grid_r20, r1_fit=r1_fit)
6460
6461
6462 self.interpreter.deselect.all()
6463 sel_ids = [
6464 ":12",
6465 ":51",
6466 ]
6467 for sel_spin in sel_ids:
6468 print("Selecting spin %s"%sel_spin)
6469 self.interpreter.select.spin(spin_id=sel_spin, change_all=False)
6470
6471
6472 cluster_ids = sel_ids
6473
6474
6475 for curspin in cluster_ids:
6476 print("Adding spin %s to cluster"%curspin)
6477 self.interpreter.relax_disp.cluster('model_cluster', curspin)
6478
6479
6480 print("\nPrinting all the available pipes.")
6481 self.interpreter.pipe.display()
6482
6483
6484 print("\nChecking which model is stored per spin.")
6485 for curspin, mol_name, res_num, res_name, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=False):
6486 print("For spin_id '%s the model is '%s''"%(spin_id, curspin.model))
6487
6488
6489 self.interpreter.pipe.copy(pipe_from="final - relax_disp", pipe_to="relax_disp_cluster", bundle_to="relax_disp_cluster")
6490 self.interpreter.pipe.switch(pipe_name="relax_disp_cluster")
6491 self.interpreter.pipe.display()
6492
6493
6494 relax_disp.Relax_disp(pipe_name="relax_disp_cluster", pipe_bundle="relax_disp_cluster", results_dir=outdir+sep+"cluster", models=MODELS, grid_inc=GRID_INC, mc_sim_num=MC_NUM, exp_mc_sim_num=None, modsel=MODSEL, pre_run_dir=None, optimise_r2eff=False, insignificance=0.0, numeric_only=False, mc_sim_all_models=False, eliminate=True, set_grid_r20=set_grid_r20, r1_fit=r1_fit)
6495
6496
6497 print("\nChecking which value is stored per spin.")
6498 kex = None
6499 for curspin, mol_name, res_num, res_name, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=False):
6500 if kex == None:
6501 kex = curspin.kex
6502 self.assertEqual(curspin.kex, kex)
6503 print("For spin_id %s the kex is %.3f"%(spin_id, kex))
6504
6505
6507 """Test the protocol for repeated dispersion analysis. The class: relax_disp_repeat_cpmg.
6508
6509 U{task #7826<https://web.archive.org/web/https://gna.org/task/index.php?7826>}. Write an python class for the repeated analysis of dispersion data.
6510 """
6511
6512
6513 self.interpreter.reset()
6514
6515
6516 base_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'repeated_analysis'+sep+'SOD1'
6517
6518
6519 sdic = {}
6520
6521
6522 sfrq_1 = 499.86214
6523 sfrq_2 = 599.8908587
6524 sfrqs = [sfrq_1, sfrq_2]
6525
6526
6527 sdic['sfrqs'] = sfrqs
6528
6529
6530 sdic['sfrq_unit'] = 'MHz'
6531
6532
6533 sdic['exp_type'] = 'SQ CPMG'
6534
6535
6536 sdic['isotope'] = '15N'
6537
6538
6539 sdic['int_method'] = 'height'
6540
6541
6542 sdic['time'] = '2014_09'
6543
6544
6545 for frq in sfrqs:
6546 key = DIC_KEY_FORMAT % (frq)
6547 sdic[key] = {}
6548
6549
6550 e_1 = DIC_KEY_FORMAT % (sfrq_1)
6551 e_2 = DIC_KEY_FORMAT % (sfrq_2)
6552
6553
6554 sdic[e_1]['time_T2'] = 0.04
6555 sdic[e_2]['time_T2'] = 0.06
6556
6557
6558 ncyc_1 = array([20, 0, 16, 10, 36, 2, 12, 4, 22, 18, 40, 14, 26, 8, 32, 24, 6, 28, 0])
6559 ncyc_2 = array([28, 0, 4, 32, 60, 2, 10, 16, 8, 20, 52, 18, 40, 6, 12, 0, 24, 14, 22])
6560
6561
6562 sdic[e_1]['cpmg_frqs'] = ncyc_1 / sdic[e_1]['time_T2']
6563 sdic[e_2]['cpmg_frqs'] = ncyc_2 / sdic[e_2]['time_T2']
6564
6565
6566 peaks_folder_1 = base_path +sep+ 'cpmg_disp_sod1d90a_060518' +sep+ 'cpmg_disp_sod1d90a_060518_normal.fid' +sep+ 'analysis_FT' +sep+ 'ser_files'
6567 peaks_folder_2 = base_path +sep+ 'cpmg_disp_sod1d90a_060521' +sep+ 'cpmg_disp_sod1d90a_060521_normal.fid' +sep+ 'analysis_FT' +sep+ 'ser_files'
6568 sdic[e_1]['peaks_folder'] = peaks_folder_1
6569 sdic[e_2]['peaks_folder'] = peaks_folder_2
6570
6571
6572 rmsd_folder_1 = base_path +sep+ 'cpmg_disp_sod1d90a_060518' +sep+ 'cpmg_disp_sod1d90a_060518_normal.fid' +sep+ 'ft2_data'
6573 rmsd_folder_2 = base_path +sep+ 'cpmg_disp_sod1d90a_060521' +sep+ 'cpmg_disp_sod1d90a_060521_normal.fid' +sep+ 'ft2_data'
6574 sdic[e_1]['rmsd_folder'] = rmsd_folder_1
6575 sdic[e_2]['rmsd_folder'] = rmsd_folder_2
6576
6577
6578 sdic['results_dir'] = self.tmpdir
6579
6580
6581 RDR = Relax_disp_rep(sdic)
6582
6583
6584 RDR.set_base_cpmg(method='FT', glob_ini=128)
6585
6586 methods = ['FT', 'MDD']
6587
6588
6589
6590
6591
6592
6593
6594 if True:
6595 selection = None
6596
6597
6598 int_ft_sel = RDR.col_int(method='FT', list_glob_ini=[128, 126], selection=selection)
6599
6600
6601 int_mdd_sel = RDR.col_int(method='MDD', list_glob_ini=[128, 126], selection=selection)
6602
6603
6604 fig1 = [[int_ft_sel, int_mdd_sel], ['FT', 'MDD'], [128, 128]]
6605 fig2 = [[int_ft_sel, int_mdd_sel], ['FT', 'MDD'], [128, 126]]
6606 corr_data = [fig1, fig2]
6607
6608 write_stats = True
6609 RDR.plot_int_corr(corr_data=corr_data, show=False, write_stats=write_stats)
6610
6611
6612 if write_stats:
6613 for i, corr_data_i in enumerate(corr_data):
6614 data, methods, glob_inis = corr_data[i]
6615 data_x, data_y = data
6616 method_x, method_y = methods
6617 glob_ini_x, glob_ini_y = glob_inis
6618 x = data_x[str(glob_ini_x)]['peak_intensity_arr']
6619 np = len(x)
6620
6621 file_name_ini = 'int_corr_%s_%s_%s_%s_NP_%i' % (method_x, glob_ini_x, method_y, glob_ini_y, np)
6622
6623 if selection == None:
6624 file_name = file_name_ini + '_all.txt'
6625 else:
6626 file_name = file_name_ini + '_sel.txt'
6627 path = RDR.results_dir
6628 data = extract_data(file=file_name, dir=path)
6629
6630
6631 for i, data_i in enumerate(data):
6632 print(i, data_i)
6633
6634
6635
6636 if True:
6637
6638 selections = [None, ':2,3']
6639 for selection in selections:
6640 int_ft_sel = RDR.col_int(method='FT', list_glob_ini=[128], selection=selection)
6641 int_mdd_sel = RDR.col_int(method='MDD', list_glob_ini=[128, 126], selection=selection)
6642
6643
6644 int_stat_dic = RDR.get_int_stat_dic(list_int_dics=[int_ft_sel, int_mdd_sel], list_glob_ini=[128, 126])
6645
6646
6647 write_stats = True
6648 RDR.plot_int_stat(int_stat_dic=int_stat_dic, methods=['FT', 'MDD'], list_glob_ini=[128, 126], show=False, write_stats=write_stats)
6649
6650
6651 if write_stats:
6652 if selection == None:
6653 file_name = 'int_stat_all.txt'
6654 else:
6655 file_name = 'int_stat_sel.txt'
6656 path = RDR.results_dir
6657 data = extract_data(file=file_name, dir=path)
6658
6659
6660 for i, data_i in enumerate(data):
6661 print(i, data_i)
6662
6663
6664
6665 if True:
6666 selection = None
6667
6668 r2eff_ft_all = RDR.col_r2eff(method='FT', list_glob_ini=[128, 126, 6], selection=selection)
6669
6670
6671 r2eff_mdd_all = RDR.col_r2eff(method='MDD', list_glob_ini=[128, 126], selection=selection)
6672
6673
6674 fig1 = [[r2eff_ft_all, r2eff_mdd_all], ['FT', 'MDD'], [128, 128]]
6675 fig2 = [[r2eff_ft_all, r2eff_mdd_all], ['FT', 'MDD'], [128, 126]]
6676 corr_data = [fig1, fig2]
6677
6678 write_stats = True
6679 RDR.plot_r2eff_corr(corr_data=corr_data, show=False, write_stats=write_stats)
6680
6681
6682 if write_stats:
6683 for i, corr_data_i in enumerate(corr_data):
6684 data, methods, glob_inis = corr_data[i]
6685 data_x, data_y = data
6686 method_x, method_y = methods
6687 glob_ini_x, glob_ini_y = glob_inis
6688 x = data_x[str(glob_ini_x)]['r2eff_arr']
6689 np = len(x)
6690
6691 file_name_ini = 'r2eff_corr_%s_%s_%s_%s_NP_%i' % (method_x, glob_ini_x, method_y, glob_ini_y, np)
6692
6693 if selection == None:
6694 file_name = file_name_ini + '_all.txt'
6695 else:
6696 file_name = file_name_ini + '_sel.txt'
6697 path = RDR.results_dir
6698 data = extract_data(file=file_name, dir=path)
6699
6700
6701 for i, data_i in enumerate(data):
6702 print(i, data_i)
6703
6704
6705
6706 if True:
6707
6708 selections = [None, ':2,3']
6709 for selection in selections:
6710 r2eff_ft_sel = RDR.col_r2eff(method='FT', list_glob_ini=[128, 126, 6], selection=selection)
6711 r2eff_mdd_sel = RDR.col_r2eff(method='MDD', list_glob_ini=[128, 126], selection=selection)
6712
6713
6714 r2eff_stat_dic = RDR.get_r2eff_stat_dic(list_r2eff_dics=[r2eff_ft_sel, r2eff_mdd_sel], list_glob_ini=[128, 126])
6715
6716
6717 write_stats = True
6718 RDR.plot_r2eff_stat(r2eff_stat_dic=r2eff_stat_dic, methods=['FT', 'MDD'], list_glob_ini=[128, 126, 6], show=False, write_stats=write_stats)
6719
6720
6721 if write_stats:
6722 if selection == None:
6723 file_name = 'r2eff_stat_all.txt'
6724 else:
6725 file_name = 'r2eff_stat_sel.txt'
6726 path = RDR.results_dir
6727 data = extract_data(file=file_name, dir=path)
6728
6729
6730 for i, data_i in enumerate(data):
6731 print(i, data_i)
6732
6733
6734
6735 if True:
6736 methods = ['FT', 'MDD']
6737
6738 RDR.calc_r2eff(methods=methods, list_glob_ini=[128, 126])
6739
6740 min_methods = [['FT'], ['MDD']]
6741 min_list_glob_ini = [[128], list(range(126, 130, 2))[::-1]]
6742
6743
6744
6745
6746 selection = None
6747
6748 for i, methods in enumerate(min_methods):
6749 list_glob_ini = min_list_glob_ini[i]
6750
6751 if True:
6752
6753 if True:
6754
6755 RDR.calc_r2eff(methods=methods, list_glob_ini=list_glob_ini)
6756
6757
6758 if True:
6759
6760 RDR.r20_from_min_r2eff(methods=methods, model=MODEL_CR72, model_from=MODEL_R2EFF, analysis='grid_setup_ind', analysis_from='int', list_glob_ini=list_glob_ini, force=True)
6761
6762
6763 if True:
6764
6765 method = methods[0]
6766 glob_ini = list_glob_ini[0]
6767
6768 test_pipe_name = RDR.name_pipe(method=method, model=MODEL_CR72, analysis='grid_setup_ind', glob_ini=glob_ini)
6769 RDR.spin_display_params(pipe_name=test_pipe_name)
6770
6771
6772 if True:
6773
6774 RDR.minimise_grid_search(inc=4, verbosity=1, methods=methods, model=MODEL_CR72, analysis='grid_setup_ind', list_glob_ini=list_glob_ini, force=True)
6775
6776
6777 if True:
6778
6779 RDR.opt_max_iterations = int(1e2)
6780 RDR.minimise_execute(methods=methods, model=MODEL_CR72, analysis='min_ind', analysis_from='grid_setup_ind', list_glob_ini=list_glob_ini, force=True)
6781
6782
6783
6784
6785
6786 if True:
6787 selections = [None, ':2,3']
6788 for selection in selections:
6789
6790 analysis = 'min_ind'
6791 min_ft_sel = RDR.col_min(method='FT', model=MODEL_CR72, analysis=analysis, list_glob_ini=[128], selection=selection)
6792 min_mdd_sel = RDR.col_min(method='MDD', model=MODEL_CR72, analysis=analysis, list_glob_ini=list(range(126, 130, 2))[::-1], selection=selection)
6793
6794 fig1 = [[min_ft_sel, min_mdd_sel], ['FT', 'MDD'], [128, 128]]
6795 fig2 = [[min_ft_sel, min_mdd_sel], ['FT', 'MDD'], [128, 126]]
6796 corr_data = [fig1, fig2]
6797
6798 write_stats = True
6799 RDR.plot_min_corr(corr_data=corr_data, show=False, write_stats=write_stats)
6800
6801
6802 if write_stats:
6803 for i, corr_data_i in enumerate(corr_data):
6804 data, methods, glob_inis = corr_data[i]
6805 data_x, data_y = data
6806 method_x, method_y = methods
6807 glob_ini_x, glob_ini_y = glob_inis
6808
6809 file_name_ini = '%s_%s_%s_%s_%s' % (analysis, method_x, glob_ini_x, method_y, glob_ini_y)
6810
6811 if selection == None:
6812 file_name = file_name_ini + '_all.txt'
6813 else:
6814 file_name = file_name_ini + '_sel.txt'
6815 path = RDR.results_dir
6816 data = extract_data(file=file_name, dir=path)
6817
6818
6819 for i, data_i in enumerate(data):
6820 print(i, data_i)
6821
6822
6823 if True:
6824
6825
6826 selections = [None, ':2,3']
6827 for selection in selections:
6828 analysis = 'min_ind'
6829 min_ft_sel = RDR.col_min(method='FT', model=MODEL_CR72, analysis=analysis, list_glob_ini=[128], selection=selection)
6830 min_mdd_sel = RDR.col_min(method='MDD', model=MODEL_CR72, analysis=analysis, list_glob_ini=list(range(126, 130, 2))[::-1], selection=selection)
6831
6832
6833 min_stat_dic = RDR.get_min_stat_dic(list_r2eff_dics=[min_ft_sel, min_mdd_sel], list_glob_ini=[128, 126])
6834
6835
6836 write_stats = True
6837 RDR.plot_min_stat(min_stat_dic=min_stat_dic, methods=['FT', 'MDD'], list_glob_ini=[128, 126, 6], show=False, write_stats=write_stats)
6838
6839
6840 if write_stats:
6841 if selection == None:
6842 file_name = '%s_stat_all.txt' % (analysis)
6843 else:
6844 file_name = '%s_stat_sel.txt' % (analysis)
6845 path = RDR.results_dir
6846 data = extract_data(file=file_name, dir=path)
6847
6848
6849 for i, data_i in enumerate(data):
6850 print(i, data_i)
6851
6852
6853
6854 if True:
6855 methods = ['FT', 'MDD']
6856
6857 RDR.calc_r2eff(methods=methods, list_glob_ini=[128, 126])
6858
6859 min_methods = [['FT'], ['MDD']]
6860 min_list_glob_ini = [[128], list(range(126, 130, 2))[::-1]]
6861
6862
6863
6864 selection = ':2,3'
6865
6866 for i, methods in enumerate(min_methods):
6867 list_glob_ini = min_list_glob_ini[i]
6868
6869 if True:
6870
6871 if True:
6872
6873 RDR.calc_r2eff(methods=methods, list_glob_ini=list_glob_ini)
6874
6875
6876 if True:
6877
6878 RDR.deselect_all(methods=methods, model='setup', model_from=MODEL_R2EFF, analysis='grid_setup', analysis_from='int', list_glob_ini=list_glob_ini, force=True)
6879
6880 RDR.select_spin(spin_id=selection, methods=methods, model='setup', analysis='grid_setup', list_glob_ini=list_glob_ini, force=True)
6881
6882
6883 if True:
6884
6885 RDR.value_set(methods=methods, val=1000., param='kex', model=MODEL_CR72, model_from='setup', analysis='grid_setup', list_glob_ini=list_glob_ini, force=True)
6886 RDR.value_set(methods=methods, val=0.95, param='pA', model=MODEL_CR72, model_from='setup', analysis='grid_setup', list_glob_ini=list_glob_ini, force=True)
6887
6888
6889 if True:
6890
6891 RDR.r20_from_min_r2eff(methods=methods, model=MODEL_CR72, analysis='grid_setup', list_glob_ini=list_glob_ini, force=True)
6892
6893
6894 if True:
6895
6896 method = methods[0]
6897 glob_ini = list_glob_ini[0]
6898
6899 test_pipe_name = RDR.name_pipe(method=method, model=MODEL_CR72, analysis='grid_setup', glob_ini=glob_ini)
6900 RDR.spin_display_params(pipe_name=test_pipe_name)
6901
6902
6903 if True:
6904
6905 RDR.minimise_grid_search(inc=200, verbosity=1, methods=methods, model=MODEL_CR72, analysis='grid', analysis_from='grid_setup', list_glob_ini=list_glob_ini, force=True)
6906
6907
6908 if True:
6909 RDR.cluster_spins(spin_id=selection, methods=methods, model=MODEL_CR72, analysis='grid', list_glob_ini=list_glob_ini, force=True)
6910
6911
6912 if True:
6913
6914 RDR.opt_max_iterations = int(1e2)
6915 RDR.minimise_execute(methods=methods, model=MODEL_CR72, analysis='min', analysis_from='grid', list_glob_ini=list_glob_ini, force=False)
6916
6917
6918
6919 if True:
6920 selection = ':2,3'
6921
6922 analysis = 'min'
6923 min_ft_sel = RDR.col_min(method='FT', model=MODEL_CR72, analysis=analysis, list_glob_ini=[128], selection=selection)
6924 min_mdd_sel = RDR.col_min(method='MDD', model=MODEL_CR72, analysis=analysis, list_glob_ini=list(range(126, 130, 2))[::-1], selection=selection)
6925
6926 fig1 = [[min_ft_sel, min_mdd_sel], ['FT', 'MDD'], [128, 128]]
6927 fig2 = [[min_ft_sel, min_mdd_sel], ['FT', 'MDD'], [128, 126]]
6928 corr_data = [fig1, fig2]
6929
6930 write_stats = True
6931 RDR.plot_min_corr(corr_data=corr_data, show=False, write_stats=write_stats)
6932
6933
6934 if write_stats:
6935 for i, corr_data_i in enumerate(corr_data):
6936 data, methods, glob_inis = corr_data[i]
6937 data_x, data_y = data
6938 method_x, method_y = methods
6939 glob_ini_x, glob_ini_y = glob_inis
6940
6941 file_name_ini = '%s_%s_%s_%s_%s' % (analysis, method_x, glob_ini_x, method_y, glob_ini_y)
6942
6943 if selection == None:
6944 file_name = file_name_ini + '_all.txt'
6945 else:
6946 file_name = file_name_ini + '_sel.txt'
6947 path = RDR.results_dir
6948 data = extract_data(file=file_name, dir=path)
6949
6950
6951 for i, data_i in enumerate(data):
6952 print(i, data_i)
6953
6954
6955 if True:
6956
6957 selections = [':2,3']
6958 for selection in selections:
6959 analysis = 'min'
6960 min_ft_sel = RDR.col_min(method='FT', model=MODEL_CR72, analysis=analysis, list_glob_ini=[128], selection=selection)
6961 min_mdd_sel = RDR.col_min(method='MDD', model=MODEL_CR72, analysis=analysis, list_glob_ini=list(range(126, 130, 2))[::-1], selection=selection)
6962
6963
6964 min_stat_dic = RDR.get_min_stat_dic(list_r2eff_dics=[min_ft_sel, min_mdd_sel], list_glob_ini=[128, 126])
6965
6966
6967 write_stats = True
6968 RDR.plot_min_stat(min_stat_dic=min_stat_dic, methods=['FT', 'MDD'], list_glob_ini=[128, 126, 6], show=False, write_stats=write_stats)
6969
6970
6971 if write_stats:
6972 if selection == None:
6973 file_name = '%s_stat_all.txt' % (analysis)
6974 else:
6975 file_name = '%s_stat_sel.txt' % (analysis)
6976 path = RDR.results_dir
6977 data = extract_data(file=file_name, dir=path)
6978
6979
6980 for i, data_i in enumerate(data):
6981 print(i, data_i)
6982
6983
6985 """Optimisation of the Kjaergaard et al., 2013 Off-resonance R1rho relaxation dispersion experiments using the 'DPL' model.
6986
6987 This uses the data from Kjaergaard's paper at U{DOI: 10.1021/bi4001062<http://dx.doi.org/10.1021/bi4001062>}.
6988
6989 This uses the automatic analysis.
6990
6991 """
6992
6993
6994 cluster_ids = [
6995 ":13@N",
6996 ":15@N",
6997 ":16@N",
6998 ":25@N",
6999 ":26@N",
7000 ":28@N",
7001 ":39@N",
7002 ":40@N",
7003 ":41@N",
7004 ":43@N",
7005 ":44@N",
7006 ":45@N",
7007 ":49@N",
7008 ":52@N",
7009 ":53@N"]
7010
7011
7012 self.setup_r1rho_kjaergaard(cluster_ids=cluster_ids)
7013
7014
7015 self.assertEqual(len(cdp.mol), 1)
7016 self.assertEqual(cdp.mol[0].name, None)
7017 self.assertEqual(len(cdp.mol[0].res), 48)
7018
7019
7020 cs = [122.223, 122.162, 114.250, 125.852, 118.626, 117.449, 119.999, 122.610, 118.602, 118.291, 115.393,
7021 121.288, 117.448, 116.378, 116.316, 117.263, 122.211, 118.748, 118.103, 119.421, 119.317, 119.386, 117.279,
7022 122.103, 120.038, 116.698, 111.811, 118.639, 118.285, 121.318, 117.770, 119.948, 119.759, 118.314, 118.160,
7023 121.442, 118.714, 113.080, 125.706, 119.183, 120.966, 122.361, 126.675, 117.069, 120.875, 109.372, 119.811, 126.048]
7024
7025 i = 0
7026 for spin, spin_id in spin_loop(return_id=True):
7027
7028 self.assertEqual(spin.chemical_shift, cs[i])
7029
7030
7031 i += 1
7032
7033
7034 i = 0
7035 j = 0
7036
7037 for curspin, mol_name, res_num, res_name, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=False):
7038 if curspin.select == True:
7039 i += 1
7040 if curspin.select == False:
7041 j += 1
7042
7043
7044 self.assertEqual(i, len(cluster_ids))
7045 self.assertEqual(j, 48-len(cluster_ids))
7046
7047
7048 self.assertEqual(cdp.mol[0].res[7].num, 13)
7049 self.assertEqual(cdp.mol[0].res[7].spin[0].kex, ds.guess[':13@N'][6])
7050 self.assertEqual(cdp.mol[0].res[7].spin[0].ri_data['R1'], ds.ref[':13@N'][2])
7051
7052 self.assertEqual(cdp.mol[0].res[9].num, 15)
7053 self.assertEqual(cdp.mol[0].res[9].spin[0].kex, ds.guess[':15@N'][6])
7054 self.assertEqual(cdp.mol[0].res[9].spin[0].ri_data['R1'], ds.ref[':15@N'][2])
7055
7056 self.assertEqual(cdp.mol[0].res[10].num, 16)
7057 self.assertEqual(cdp.mol[0].res[10].spin[0].kex, ds.guess[':16@N'][6])
7058 self.assert_(hasattr(cdp.mol[0].res[10].spin[0], 'ri_data'))
7059
7060 self.assertEqual(cdp.mol[0].res[16].num, 25)
7061 self.assertEqual(cdp.mol[0].res[16].spin[0].kex, ds.guess[':25@N'][6])
7062 self.assert_(hasattr(cdp.mol[0].res[16].spin[0], 'ri_data'))
7063
7064 self.assertEqual(cdp.mol[0].res[17].num, 26)
7065 self.assertEqual(cdp.mol[0].res[17].spin[0].kex, ds.guess[':26@N'][6])
7066 self.assert_(hasattr(cdp.mol[0].res[17].spin[0], 'ri_data'))
7067
7068 self.assertEqual(cdp.mol[0].res[19].num, 28)
7069 self.assertEqual(cdp.mol[0].res[19].spin[0].kex, ds.guess[':28@N'][6])
7070 self.assert_(hasattr(cdp.mol[0].res[19].spin[0], 'ri_data'))
7071
7072 self.assertEqual(cdp.mol[0].res[29].num, 39)
7073 self.assertEqual(cdp.mol[0].res[29].spin[0].kex, ds.guess[':39@N'][6])
7074 self.assert_(hasattr(cdp.mol[0].res[29].spin[0], 'ri_data'))
7075
7076 self.assertEqual(cdp.mol[0].res[30].num, 40)
7077 self.assertEqual(cdp.mol[0].res[30].spin[0].kex, ds.guess[':40@N'][6])
7078 self.assert_(hasattr(cdp.mol[0].res[30].spin[0], 'ri_data'))
7079
7080 self.assertEqual(cdp.mol[0].res[31].num, 41)
7081 self.assertEqual(cdp.mol[0].res[31].spin[0].kex, ds.guess[':41@N'][6])
7082 self.assert_(hasattr(cdp.mol[0].res[31].spin[0], 'ri_data'))
7083
7084 self.assertEqual(cdp.mol[0].res[33].num, 43)
7085 self.assertEqual(cdp.mol[0].res[33].spin[0].kex, ds.guess[':43@N'][6])
7086 self.assert_(hasattr(cdp.mol[0].res[33].spin[0], 'ri_data'))
7087
7088 self.assertEqual(cdp.mol[0].res[34].num, 44)
7089 self.assertEqual(cdp.mol[0].res[34].spin[0].kex, ds.guess[':44@N'][6])
7090 self.assert_(hasattr(cdp.mol[0].res[34].spin[0], 'ri_data'))
7091
7092 self.assertEqual(cdp.mol[0].res[35].num, 45)
7093 self.assertEqual(cdp.mol[0].res[35].spin[0].kex, ds.guess[':45@N'][6])
7094 self.assert_(hasattr(cdp.mol[0].res[35].spin[0], 'ri_data'))
7095
7096 self.assertEqual(cdp.mol[0].res[38].num, 49)
7097 self.assertEqual(cdp.mol[0].res[38].spin[0].kex, ds.guess[':49@N'][6])
7098 self.assert_(hasattr(cdp.mol[0].res[38].spin[0], 'ri_data'))
7099
7100 self.assertEqual(cdp.mol[0].res[41].num, 52)
7101 self.assertEqual(cdp.mol[0].res[41].spin[0].kex, ds.guess[':52@N'][6])
7102 self.assert_(hasattr(cdp.mol[0].res[41].spin[0], 'ri_data'))
7103
7104 self.assertEqual(cdp.mol[0].res[42].num, 53)
7105 self.assertEqual(cdp.mol[0].res[42].spin[0].kex, ds.guess[':53@N'][6])
7106 self.assert_(hasattr(cdp.mol[0].res[42].spin[0], 'ri_data'))
7107
7108
7109 MODELS = [MODEL_R2EFF, MODEL_NOREX, MODEL_DPL94, MODEL_TP02, MODEL_TAP03, MODEL_MP05, MODEL_NS_R1RHO_2SITE]
7110
7111
7112 GRID_INC = 4
7113
7114
7115 MC_NUM = 3
7116
7117
7118 MODSEL = 'AIC'
7119
7120
7121
7122 OPT_FUNC_TOL = 1e-1
7123 relax_disp.Relax_disp.opt_func_tol = OPT_FUNC_TOL
7124 OPT_MAX_ITERATIONS = 1000
7125 relax_disp.Relax_disp.opt_max_iterations = OPT_MAX_ITERATIONS
7126
7127 result_dir_name = ds.tmpdir
7128
7129
7130 for curspin in cluster_ids:
7131 self.interpreter.relax_disp.cluster('free spins', curspin)
7132
7133 self.interpreter.deselect.spin(spin_id=curspin, change_all=False)
7134
7135
7136
7137
7138
7139
7140
7141
7142 self.interpreter.select.spin(spin_id=':52@N', change_all=False)
7143
7144
7145
7146 relax_disp.Relax_disp(pipe_name=ds.pipe_name, pipe_bundle=ds.pipe_bundle, results_dir=result_dir_name, models=MODELS, grid_inc=GRID_INC, mc_sim_num=MC_NUM, modsel=MODSEL)
7147
7148
7149
7150
7151
7152 print("\n\n################")
7153 print("Printing results")
7154 print("################\n")
7155 for model in MODELS:
7156
7157 if model == MODEL_R2EFF:
7158 continue
7159
7160
7161 self.interpreter.pipe.switch(pipe_name='%s - relax_disp' % (model))
7162 print("\nModel: %s" % (model))
7163
7164
7165 for cur_spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
7166
7167 spin_string = generate_spin_string(spin=cur_spin, mol_name=mol_name, res_num=resi, res_name=resn)
7168
7169
7170 print("Optimised parameters for spin: %s" % (spin_string))
7171 for param in cur_spin.params + ['chi2']:
7172
7173 if param in ['r1', 'r2']:
7174 for exp_type, frq, ei, mi in loop_exp_frq(return_indices=True):
7175
7176 r20_key = generate_r20_key(exp_type=exp_type, frq=frq)
7177
7178
7179 value = getattr(cur_spin, param)[r20_key]
7180
7181
7182 print("%-10s %-6s %-6s %3.3f" % ("Parameter:", param, "Value:", value))
7183
7184
7185 else:
7186
7187 value = getattr(cur_spin, param)
7188
7189
7190 print("%-10s %-6s %-6s %3.3f" % ("Parameter:", param, "Value:", value))
7191
7192
7193 self.interpreter.pipe.switch(pipe_name='%s - relax_disp' % ('final'))
7194 print("\nFinal pipe")
7195
7196
7198 """Check of plot_disp_curves() function, after optimisation of the Kjaergaard et al., 2013 Off-resonance R1rho relaxation dispersion experiments using the 'R2eff' model.
7199
7200 This uses the data from Kjaergaard's paper at U{DOI: 10.1021/bi4001062<http://dx.doi.org/10.1021/bi4001062>}.
7201
7202 This uses the automatic analysis.
7203
7204 """
7205
7206
7207 cluster_ids = [
7208 ":52@N"]
7209
7210
7211 self.setup_r1rho_kjaergaard(cluster_ids=cluster_ids)
7212
7213
7214 MODELS = [MODEL_R2EFF]
7215
7216
7217 GRID_INC = 4
7218
7219
7220 MC_NUM = 3
7221
7222
7223 MODSEL = 'AIC'
7224
7225
7226
7227 OPT_FUNC_TOL = 1e-1
7228 relax_disp.Relax_disp.opt_func_tol = OPT_FUNC_TOL
7229 OPT_MAX_ITERATIONS = 1000
7230 relax_disp.Relax_disp.opt_max_iterations = OPT_MAX_ITERATIONS
7231
7232 result_dir_name = ds.tmpdir
7233
7234
7235 for curspin in cluster_ids:
7236 self.interpreter.relax_disp.cluster('free spins', curspin)
7237
7238 self.interpreter.deselect.spin(spin_id=curspin, change_all=False)
7239
7240 self.interpreter.select.spin(spin_id=':52@N', change_all=False)
7241
7242
7243 relax_disp.Relax_disp(pipe_name=ds.pipe_name, pipe_bundle=ds.pipe_bundle, results_dir=result_dir_name, models=MODELS, grid_inc=GRID_INC, mc_sim_num=MC_NUM, modsel=MODSEL)
7244
7245
7246 graph_comb = [
7247 [Y_AXIS_R2_EFF, X_AXIS_DISP, INTERPOLATE_DISP],
7248 [Y_AXIS_R2_EFF, X_AXIS_THETA, INTERPOLATE_DISP],
7249 [Y_AXIS_R2_R1RHO, X_AXIS_W_EFF, INTERPOLATE_DISP],
7250 [Y_AXIS_R2_EFF, X_AXIS_THETA, INTERPOLATE_OFFSET]
7251 ]
7252
7253
7254 result_folders = MODELS
7255
7256
7257 spin_id = ':52@N'
7258
7259
7260 for result_folder in result_folders:
7261
7262 if result_folder == MODEL_R2EFF:
7263 continue
7264
7265
7266 for y_axis, x_axis, interpolate in graph_comb:
7267
7268 file_name_ini = return_grace_file_name_ini(y_axis=y_axis, x_axis=x_axis, interpolate=interpolate)
7269
7270
7271 file_name = "%s%s.agr" % (file_name_ini, spin_id.replace('#', '_').replace(':', '_').replace('@', '_'))
7272
7273
7274 file_path = get_file_path(file_name, result_dir_name+sep+result_folder)
7275
7276 print("Testing file access to graph: %s"%file_path)
7277 self.assert_(access(file_path, F_OK))
7278
7279
7280 y_axis_types = [Y_AXIS_R2_EFF, Y_AXIS_R2_R1RHO]
7281 x_axis_types = [X_AXIS_DISP, X_AXIS_THETA, X_AXIS_W_EFF]
7282 interpolate_types = [INTERPOLATE_DISP, INTERPOLATE_OFFSET]
7283
7284 result_dir_name = ds.tmpdir
7285
7286
7287 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'Kjaergaard_et_al_2013'+sep+'check_graphs'
7288
7289 for result_folder in result_folders:
7290
7291 if result_folder == MODEL_R2EFF:
7292 continue
7293
7294 for y_axis in y_axis_types:
7295 for x_axis in x_axis_types:
7296 for interpolate in interpolate_types:
7297
7298 file_name_ini = return_grace_file_name_ini(y_axis=y_axis, x_axis=x_axis, interpolate=interpolate)
7299
7300
7301 file_name = "%s%s.agr" % (file_name_ini, spin_id.replace('#', '_').replace(':', '_').replace('@', '_'))
7302
7303
7304 dir = result_dir_name+sep+result_folder
7305 print("Plotting combination of %s, %s, %s"%(y_axis, x_axis, interpolate))
7306 self.interpreter.relax_disp.plot_disp_curves(dir=dir, y_axis=y_axis, x_axis=x_axis, interpolate=interpolate, force=True)
7307
7308
7309 file_path = get_file_path(file_name, dir)
7310
7311
7312 print("Testing file access to graph: %s"%file_path)
7313 self.assert_(access(file_path, F_OK))
7314
7315
7316 file_prod = open(file_path)
7317 lines_prod = file_prod.readlines()
7318 file_prod.close()
7319
7320
7321 dir_comp = data_path+sep+result_folder
7322 file_path_comp = get_file_path(file_name, dir_comp)
7323 file_comp = open(file_path_comp)
7324 lines_comp = file_comp.readlines()
7325 file_comp.close()
7326
7327
7328 self.assertEqual(len(lines_prod), len(lines_comp))
7329 for j in range(len(lines_prod)):
7330
7331 first_char = lines_prod[j][0]
7332 if first_char in ["@", "&"]:
7333 self.assertEqual(lines_prod[j], lines_comp[j])
7334 else:
7335
7336
7337 x_prod, y_prod, y_prod_err = lines_prod[j].split()
7338 x_comp, y_comp, y_comp_err = lines_comp[j].split()
7339 self.assertAlmostEqual(float(x_prod), float(x_comp))
7340 self.assertAlmostEqual(float(y_prod), float(y_comp))
7341
7342
7344 """Optimisation of the Kjaergaard et al., 2013 Off-resonance R1rho relaxation dispersion experiments using the 'DPL' model.
7345
7346 This uses the data from Kjaergaard's paper at U{DOI: 10.1021/bi4001062<http://dx.doi.org/10.1021/bi4001062>}.
7347
7348 This uses the automatic analysis, with missing loading R1.
7349
7350 """
7351
7352
7353 cluster_ids = [
7354 ":13@N",
7355 ":15@N",
7356 ":16@N",
7357 ":25@N",
7358 ":26@N",
7359 ":28@N",
7360 ":39@N",
7361 ":40@N",
7362 ":41@N",
7363 ":43@N",
7364 ":44@N",
7365 ":45@N",
7366 ":49@N",
7367 ":52@N",
7368 ":53@N"]
7369
7370
7371 self.setup_r1rho_kjaergaard(cluster_ids=cluster_ids, read_R1=False)
7372
7373
7374 MODELS = [MODEL_R2EFF, MODEL_NOREX, MODEL_DPL94, MODEL_TP02, MODEL_TAP03, MODEL_MP05, MODEL_NS_R1RHO_2SITE]
7375
7376
7377 GRID_INC = None
7378
7379
7380 MC_NUM = 3
7381
7382
7383 MODSEL = 'AIC'
7384
7385
7386
7387 OPT_FUNC_TOL = 1e-25
7388 relax_disp.Relax_disp.opt_func_tol = OPT_FUNC_TOL
7389 OPT_MAX_ITERATIONS = 10000000
7390 relax_disp.Relax_disp.opt_max_iterations = OPT_MAX_ITERATIONS
7391
7392 result_dir_name = ds.tmpdir
7393
7394
7395 for curspin in cluster_ids:
7396 self.interpreter.relax_disp.cluster('free spins', curspin)
7397
7398 self.interpreter.deselect.spin(spin_id=curspin, change_all=False)
7399
7400
7401
7402
7403
7404
7405
7406
7407 self.interpreter.select.spin(spin_id=':52@N', change_all=False)
7408
7409
7410
7411 prev_data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'Kjaergaard_et_al_2013' +sep+ "check_graphs" +sep+ "mc_2000"
7412
7413 r1_fit = True
7414
7415
7416 relax_disp.Relax_disp(pipe_name=ds.pipe_name, pipe_bundle=ds.pipe_bundle, results_dir=result_dir_name, models=MODELS, grid_inc=GRID_INC, mc_sim_num=MC_NUM, modsel=MODSEL, pre_run_dir=prev_data_path, r1_fit=r1_fit)
7417
7418
7419 self.verify_r1rho_kjaergaard_missing_r1(models=MODELS, result_dir_name=result_dir_name, r2eff_estimate='MC2000')
7420
7421
7423 """Test the operation of the relax_disp.r2eff_read user function."""
7424
7425
7426 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'Hansen'+sep+'800_MHz'
7427
7428
7429 self.interpreter.sequence.read(file='66.667.in', dir=data_path, res_num_col=1)
7430
7431
7432 id = 'test'
7433
7434
7435 self.interpreter.spectrometer.frequency(id=id, frq=800e6)
7436 self.interpreter.relax_disp.exp_type(spectrum_id=id, exp_type='SQ CPMG')
7437
7438
7439 self.interpreter.relax_disp.r2eff_read(id=id, file='66.667.in', dir=data_path, disp_frq=66.667, res_num_col=1, data_col=2, error_col=3)
7440
7441
7442 data = [
7443 ['cpmg_frqs', {'test': 66.667}],
7444 ['cpmg_frqs_list', [66.667]],
7445 ['dispersion_points', 1],
7446 ['exp_type', {'test': 'SQ CPMG'}],
7447 ['exp_type_list', ['SQ CPMG']],
7448 ['spectrometer_frq', {'test': 800000000.0}],
7449 ['spectrometer_frq_count', 1],
7450 ['spectrometer_frq_list', [800000000.0]],
7451 ['spectrum_ids', ['test']]
7452 ]
7453 for name, value in data:
7454
7455 self.assert_(hasattr(cdp, name))
7456
7457
7458 obj = getattr(cdp, name)
7459 self.assertEqual(obj, value)
7460
7461
7462 data = [
7463 [1, 2.3035747e+04, 8.5467725e+01],
7464 [2, 9.9629762e+04, 2.8322033e+02],
7465 [3, 9.5663137e+04, 2.8632929e+02],
7466 [4, 1.7089893e+05, 3.1089428e+02],
7467 [5, 4.7323876e+04, 1.0084269e+02],
7468 [6, 2.0199122e+04, 1.0135220e+02],
7469 [7, 1.6655488e+05, 3.1609061e+02],
7470 [8, 9.0061074e+04, 1.9176585e+02],
7471 [10, 8.4726204e+04, 2.8898155e+02],
7472 [11, 1.5050233e+05, 4.3138029e+02],
7473 [12, 9.2998531e+04, 3.0440191e+02],
7474 [13, 1.6343507e+05, 3.3144097e+02],
7475 [14, 1.0137301e+05, 3.7314642e+02],
7476 [15, 8.3407837e+04, 1.6546473e+02],
7477 [16, 1.3819126e+05, 3.3388517e+02],
7478 [17, 1.1010490e+05, 3.5639222e+02],
7479 [18, 9.4324035e+04, 3.2343585e+02],
7480 [19, 1.1135179e+05, 3.0706671e+02],
7481 [20, 7.6339410e+04, 1.7377460e+02],
7482 [21, 6.2008453e+04, 1.7327150e+02],
7483 [22, 1.0590404e+05, 2.4814635e+02],
7484 [23, 1.0630198e+05, 2.3601100e+02],
7485 [24, 7.2996320e+04, 1.4952465e+02],
7486 [25, 9.5486742e+04, 2.7080766e+02],
7487 [26, 5.8067989e+04, 1.6820462e+02],
7488 [27, -1.7168510e+04, 2.2519560e+02],
7489 [28, 1.6891473e+05, 2.3497525e+02],
7490 [29, 9.4038555e+04, 2.0357593e+02],
7491 [30, 2.1386951e+04, 2.2153532e+02],
7492 [31, 9.3982899e+04, 2.0937056e+02],
7493 [32, 8.6097484e+04, 2.3868467e+02],
7494 [33, 1.0194337e+05, 2.7370704e+02],
7495 [34, 8.5683111e+04, 2.0838076e+02],
7496 [35, 8.6985768e+04, 2.0889310e+02],
7497 [36, 8.6011237e+04, 1.7498390e+02],
7498 [37, 1.0984097e+05, 2.7622998e+02],
7499 [38, 8.7017879e+04, 2.6547994e+02],
7500 [39, 9.1682649e+04, 5.2777676e+02],
7501 [40, 7.6370440e+04, 1.9873214e+02],
7502 [41, 9.1393531e+04, 2.4483824e+02],
7503 [42, 1.1017111e+05, 2.8020699e+02],
7504 [43, 9.4552366e+04, 3.4394150e+02],
7505 [44, 1.2858281e+05, 6.8449252e+02],
7506 [45, 7.4583525e+04, 1.9544210e+02],
7507 [46, 9.2087490e+04, 2.0491066e+02],
7508 [47, 9.7507255e+04, 2.5162839e+02],
7509 [48, 1.0033842e+05, 2.7566430e+02],
7510 [49, 1.3048305e+05, 2.6797466e+02],
7511 [50, 1.0546796e+05, 1.9304384e+02],
7512 [51, 9.3099697e+04, 2.0773311e+02],
7513 [52, 4.6863758e+04, 1.3169068e+02],
7514 [53, 6.1055806e+04, 1.5448477e+02],
7515 [55, 6.8629994e+04, 1.6868673e+02],
7516 [56, 1.1005552e+05, 2.1940465e+02],
7517 [57, 1.0572760e+05, 1.9768486e+02],
7518 [58, 1.1176950e+05, 3.0009610e+02],
7519 [59, 9.8758603e+04, 3.3803895e+02],
7520 [60, 9.9517201e+04, 3.5137994e+02],
7521 [61, 5.4357946e+04, 2.5896579e+02],
7522 [62, 1.0899978e+05, 2.8720371e+02],
7523 [63, 8.4549759e+04, 4.1401837e+02],
7524 [64, 5.5014550e+04, 2.1135781e+02],
7525 [65, 8.0569666e+04, 2.3249709e+02],
7526 [66, 1.2936610e+05, 3.5218725e+02],
7527 [67, 3.6438010e+04, 8.7924003e+01],
7528 [70, 3.8763157e+04, 1.3325040e+02],
7529 [71, 8.5711411e+04, 2.9316183e+02],
7530 [72, 3.3211541e+04, 1.2182123e+02],
7531 [73, 3.2070576e+04, 1.2305430e+02]
7532 ]
7533 for res_num, value, error in data:
7534
7535 spin = return_spin(spin_id=":%s"%res_num)
7536
7537
7538 self.assertEqual(spin.r2eff['sq_cpmg_800.00000000_0.000_66.667'], value)
7539 self.assertEqual(spin.r2eff_err['sq_cpmg_800.00000000_0.000_66.667'], error)
7540
7541
7543 """Test the operation of the relax_disp.r2eff_read_spin user function."""
7544
7545
7546 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'Korzhnev_et_al_2005'
7547
7548
7549 self.interpreter.spin.create(res_name='Asp', res_num=9, spin_name='H')
7550 self.interpreter.spin.create(res_name='Asp', res_num=9, spin_name='N')
7551 self.interpreter.spin.isotope('1H', spin_id='@H')
7552 self.interpreter.spin.isotope('15N', spin_id='@N')
7553
7554
7555 H_disp_points = [67.0, 133.0, 267.0, 400.0, 533.0, 667.0, 800.0, 933.0, 1067.0, 1600.0, 2133.0, 2667.0]
7556 N_disp_points = [50.0, 100.0, 150.0, 200.0, 250.0, 300.0, 350.0, 400.0, 500.0, 600.0, 700.0, 800.0, 900.0, 1000.0]
7557 ids = []
7558 for value in H_disp_points:
7559 ids.append('1H_CPMG_%s' % value)
7560 for value in N_disp_points:
7561 ids.append('15N_CPMG_%s' % value)
7562 print("\n\nThe experiment IDs are %s." % ids)
7563
7564
7565 for id in ids:
7566 self.interpreter.spectrometer.frequency(id=id, frq=500e6)
7567 self.interpreter.relax_disp.exp_type(spectrum_id=id, exp_type='SQ CPMG')
7568 for value in H_disp_points:
7569 self.interpreter.relax_disp.cpmg_setup(spectrum_id='1H_CPMG_%s' % value, cpmg_frq=value)
7570 for value in N_disp_points:
7571 self.interpreter.relax_disp.cpmg_setup(spectrum_id='15N_CPMG_%s' % value, cpmg_frq=value)
7572
7573
7574 for id, file, spin_id in [['1H_CPMG', 'hs_500.res', ':9@H'], ['15N_CPMG', 'ns_500.res', ':9@N']]:
7575
7576 self.interpreter.relax_disp.r2eff_read_spin(id=id, file=file, dir=data_path, spin_id=spin_id, disp_point_col=1, data_col=2, error_col=3)
7577
7578
7579 data = [
7580 ['cpmg_frqs', {'1H_CPMG_667.0': 667.0, '1H_CPMG_1067.0': 1067.0, '15N_CPMG_350.0': 350.0, '1H_CPMG_933.0': 933.0, '15N_CPMG_50.0': 50.0, '15N_CPMG_100.0': 100.0, '1H_CPMG_400.0': 400.0, '1H_CPMG_533.0': 533.0, '1H_CPMG_800.0': 800.0, '15N_CPMG_900.0': 900.0, '15N_CPMG_150.0': 150.0, '15N_CPMG_800.0': 800.0, '1H_CPMG_267.0': 267.0, '1H_CPMG_2667.0': 2667.0, '15N_CPMG_300.0': 300.0, '1H_CPMG_133.0': 133.0, '15N_CPMG_700.0': 700.0, '1H_CPMG_67.0': 67.0, '15N_CPMG_400.0': 400.0, '15N_CPMG_250.0': 250.0, '1H_CPMG_2133.0': 2133.0, '1H_CPMG_1600.0': 1600.0, '15N_CPMG_200.0': 200.0, '15N_CPMG_1000.0': 1000.0, '15N_CPMG_500.0': 500.0, '15N_CPMG_600.0': 600.0}],
7581 ['cpmg_frqs_list', [50.0, 67.0, 100.0, 133.0, 150.0, 200.0, 250.0, 267.0, 300.0, 350.0, 400.0, 500.0, 533.0, 600.0, 667.0, 700.0, 800.0, 900.0, 933.0, 1000.0, 1067.0, 1600.0, 2133.0, 2667.0]],
7582 ['dispersion_points', 24],
7583 ['exp_type', {'1H_CPMG_667.0': 'SQ CPMG', '1H_CPMG_1067.0': 'SQ CPMG', '15N_CPMG_350.0': 'SQ CPMG', '1H_CPMG_933.0': 'SQ CPMG', '15N_CPMG_50.0': 'SQ CPMG', '15N_CPMG_100.0': 'SQ CPMG', '1H_CPMG_400.0': 'SQ CPMG', '1H_CPMG_533.0': 'SQ CPMG', '1H_CPMG_800.0': 'SQ CPMG', '15N_CPMG_900.0': 'SQ CPMG', '15N_CPMG_150.0': 'SQ CPMG', '15N_CPMG_800.0': 'SQ CPMG', '1H_CPMG_267.0': 'SQ CPMG', '1H_CPMG_2667.0': 'SQ CPMG', '15N_CPMG_300.0': 'SQ CPMG', '1H_CPMG_133.0': 'SQ CPMG', '15N_CPMG_700.0': 'SQ CPMG', '1H_CPMG_67.0': 'SQ CPMG', '15N_CPMG_400.0': 'SQ CPMG', '15N_CPMG_250.0': 'SQ CPMG', '1H_CPMG_2133.0': 'SQ CPMG', '1H_CPMG_1600.0': 'SQ CPMG', '15N_CPMG_200.0': 'SQ CPMG', '15N_CPMG_1000.0': 'SQ CPMG', '15N_CPMG_500.0': 'SQ CPMG', '15N_CPMG_600.0': 'SQ CPMG'}],
7584 ['exp_type_list', ['SQ CPMG']],
7585 ['spectrometer_frq', {'1H_CPMG_667.0': 500000000.0, '1H_CPMG_1067.0': 500000000.0, '15N_CPMG_350.0': 500000000.0, '1H_CPMG_933.0': 500000000.0, '15N_CPMG_50.0': 500000000.0, '15N_CPMG_100.0': 500000000.0, '1H_CPMG_400.0': 500000000.0, '1H_CPMG_533.0': 500000000.0, '1H_CPMG_800.0': 500000000.0, '15N_CPMG_900.0': 500000000.0, '15N_CPMG_150.0': 500000000.0, '15N_CPMG_800.0': 500000000.0, '1H_CPMG_267.0': 500000000.0, '1H_CPMG_2667.0': 500000000.0, '15N_CPMG_300.0': 500000000.0, '1H_CPMG_133.0': 500000000.0, '15N_CPMG_700.0': 500000000.0, '1H_CPMG_67.0': 500000000.0, '15N_CPMG_400.0': 500000000.0, '15N_CPMG_250.0': 500000000.0, '1H_CPMG_2133.0': 500000000.0, '1H_CPMG_1600.0': 500000000.0, '15N_CPMG_200.0': 500000000.0, '15N_CPMG_1000.0': 500000000.0, '15N_CPMG_500.0': 500000000.0, '15N_CPMG_600.0': 500000000.0}],
7586 ['spectrometer_frq_count', 1],
7587 ['spectrometer_frq_list', [500000000.0]],
7588 ['spectrum_ids', ['1H_CPMG_67.0', '1H_CPMG_133.0', '1H_CPMG_267.0', '1H_CPMG_400.0', '1H_CPMG_533.0', '1H_CPMG_667.0', '1H_CPMG_800.0', '1H_CPMG_933.0', '1H_CPMG_1067.0', '1H_CPMG_1600.0', '1H_CPMG_2133.0', '1H_CPMG_2667.0', '15N_CPMG_50.0', '15N_CPMG_100.0', '15N_CPMG_150.0', '15N_CPMG_200.0', '15N_CPMG_250.0', '15N_CPMG_300.0', '15N_CPMG_350.0', '15N_CPMG_400.0', '15N_CPMG_500.0', '15N_CPMG_600.0', '15N_CPMG_700.0', '15N_CPMG_800.0', '15N_CPMG_900.0', '15N_CPMG_1000.0']]
7589 ]
7590 for name, value in data:
7591
7592 self.assert_(hasattr(cdp, name))
7593
7594
7595 obj = getattr(cdp, name)
7596 if not isinstance(data, dict):
7597 self.assertEqual(obj, value)
7598
7599
7600 else:
7601 for id in ids:
7602 self.assertEqual(obj[id], value[id])
7603
7604
7605 h_data = [
7606 [ 67.0, 21.47924, 0.42958],
7607 [ 133.0, 16.73898, 0.33478],
7608 [ 267.0, 9.97357, 0.19947],
7609 [ 400.0, 8.23877, 0.24737],
7610 [ 533.0, 7.59290, 0.24263],
7611 [ 667.0, 7.45843, 0.24165],
7612 [ 800.0, 7.11222, 0.23915],
7613 [ 933.0, 7.40880, 0.24129],
7614 [1067.0, 6.55191, 0.16629],
7615 [1600.0, 6.72177, 0.23637],
7616 [2133.0, 7.09629, 0.23904],
7617 [2667.0, 7.14675, 0.23940]
7618 ]
7619 for disp_point, value, error in h_data:
7620 id = 'sq_cpmg_500.00000000_0.000_%.3f' % disp_point
7621 self.assertEqual(cdp.mol[0].res[0].spin[0].r2eff[id], value)
7622 self.assertEqual(cdp.mol[0].res[0].spin[0].r2eff_err[id], error)
7623 n_data = [
7624 [ 50.0, 27.15767, 0.54315],
7625 [ 100.0, 26.55781, 0.53116],
7626 [ 150.0, 24.73462, 0.49469],
7627 [ 200.0, 20.98617, 0.41972],
7628 [ 250.0, 17.82442, 0.35649],
7629 [ 300.0, 15.55352, 0.31107],
7630 [ 350.0, 13.78958, 0.27579],
7631 [ 400.0, 12.48334, 0.24967],
7632 [ 500.0, 11.55724, 0.23114],
7633 [ 600.0, 10.53874, 0.21077],
7634 [ 700.0, 10.07395, 0.20148],
7635 [ 800.0, 9.62952, 0.19259],
7636 [ 900.0, 9.49994, 0.19000],
7637 [1000.0, 8.71350, 0.17427]
7638 ]
7639 for disp_point, value, error in n_data:
7640 id = 'sq_cpmg_500.00000000_0.000_%.3f' % disp_point
7641 self.assertEqual(cdp.mol[0].res[0].spin[1].r2eff[id], value)
7642 self.assertEqual(cdp.mol[0].res[0].spin[1].r2eff_err[id], error)
7643
7644
7646 """Test the relaxation dispersion 'R2eff' model for fixed time data in the auto-analysis."""
7647
7648
7649 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'r2eff_calc.py')
7650
7651
7653 """Test the reading of a file containing r2eff values."""
7654
7655
7656 self.interpreter.residue.create(1, 'Gly')
7657 self.interpreter.residue.create(2, 'Gly')
7658 self.interpreter.residue.create(3, 'Gly')
7659
7660
7661 self.interpreter.relax_data.read(ri_id='R2eff.600', ri_type='R2eff', frq=600*1e6, file='r2eff.out', dir=status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'r2eff', res_num_col=1, res_name_col=2, data_col=3, error_col=4)
7662
7663
7664 self.assertEqual(cdp.mol[0].res[0].spin[0].ri_data['R2eff.600'], 15.000)
7665 self.assertEqual(cdp.mol[0].res[1].spin[0].ri_data['R2eff.600'], 4.2003)
7666 self.assertEqual(cdp.mol[0].res[2].spin[0].ri_data['R2eff.600'], 7.2385)
7667
7668
7670 """Test speeding up grid search. Support requst sr #3151 U{https://web.archive.org/web/https://gna.org/support/index.php?3151}.
7671
7672 User function to set the R20 parameters in the default grid search using the minimum R2eff value.
7673
7674 Optimisation of Kaare Teilum, Melanie H. Smith, Eike Schulz, Lea C. Christensen, Gleb Solomentseva, Mikael Oliveberg, and Mikael Akkea 2009
7675 'SOD1-WT' CPMG data to the CR72 dispersion model.
7676
7677 This uses the data from paper at U{http://dx.doi.org/10.1073/pnas.0907387106}. This is CPMG data with a fixed relaxation time period recorded at fields of 500 and 600MHz.
7678 Data is for experiment at 25 degree Celcius.
7679 """
7680
7681
7682 pipe_name = 'base pipe'
7683 pipe_type = 'relax_disp'
7684 pipe_name_r2eff = "%s_R2eff"%(pipe_name)
7685 select_spin_index = list(range(0, 1))
7686 self.setup_sod1wt_t25(pipe_name=pipe_name, pipe_type=pipe_type, pipe_name_r2eff=pipe_name_r2eff, select_spin_index=select_spin_index)
7687
7688
7689 r20_key_600 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=599.8908617*1E6)
7690 r20_key_500 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=499.862139*1E6)
7691
7692
7693 MODEL = "CR72"
7694
7695
7696 pipe_name_MODEL = "%s_%s"%(pipe_name, MODEL)
7697 self.interpreter.pipe.copy(pipe_from=pipe_name_r2eff, pipe_to=pipe_name_MODEL)
7698 self.interpreter.pipe.switch(pipe_name=pipe_name_MODEL)
7699
7700
7701 self.interpreter.relax_disp.select_model(model=MODEL)
7702
7703
7704 self.interpreter.relax_disp.r20_from_min_r2eff(force=False)
7705
7706
7707 for spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
7708
7709 spin_params = spin.params
7710
7711
7712 if spin_id == ":10@N":
7713 self.assertEqual(spin.r2[r20_key_600], 20.282732526087106)
7714 self.assertEqual(spin.r2[r20_key_500], 18.475299724356649)
7715
7716
7717 print("r2_600=%2.2f r2_500=%2.2f spin_id=%s resi=%i resn=%s"%(spin.r2[r20_key_600], spin.r2[r20_key_500], spin_id, resi, resn))
7718
7719
7720 self.assert_(spin.r2[r20_key_600] != spin.r2[r20_key_500])
7721
7722
7723 self.assert_(spin.r2[r20_key_600] > 0.0)
7724 self.assert_(spin.r2[r20_key_500] > 0.0)
7725
7726
7727 r2eff_600 = []
7728 r2eff_500 = []
7729 for exp_type, frq, offset, point, ei, mi, oi, di in loop_exp_frq_offset_point(return_indices=True):
7730
7731 data_key = return_param_key_from_data(exp_type=exp_type, frq=frq, offset=offset, point=point)
7732
7733
7734 r2eff = spin.r2eff[data_key]
7735 if frq == 599.8908617*1E6:
7736 r2eff_600.append(r2eff)
7737 elif frq == 499.862139*1E6:
7738 r2eff_500.append(r2eff)
7739
7740
7741 r2eff_600.sort()
7742 r2eff_500.sort()
7743
7744
7745 print("For r20 600MHz min r2eff=%3.3f."%(min(r2eff_600)))
7746 print(r2eff_600)
7747 self.assertEqual(spin.r2[r20_key_600], min(r2eff_600))
7748 print("")
7749
7750 print("For r20 500MHz min r2eff=%3.3f."%(min(r2eff_500)))
7751 print(r2eff_500)
7752 self.assertEqual(spin.r2[r20_key_500], min(r2eff_500))
7753 print("")
7754
7755 print("###########################################")
7756 print("Trying GRID SEARCH for minimum R2eff values")
7757
7758
7759 GRID_INC = 5
7760
7761 self.interpreter.minimise.grid_search(lower=None, upper=None, inc=GRID_INC, constraints=True, verbosity=1)
7762
7763
7764
7765 pipe_name_MODEL = "%s_%s_2"%(pipe_name, MODEL)
7766 self.interpreter.pipe.copy(pipe_from=pipe_name_r2eff, pipe_to=pipe_name_MODEL)
7767 self.interpreter.pipe.switch(pipe_name=pipe_name_MODEL)
7768
7769
7770 self.interpreter.relax_disp.select_model(model=MODEL)
7771
7772
7773 for param in spin_params:
7774 print("Setting standard parameter for param: %s"%param)
7775 self.interpreter.value.set(param=param, index=None)
7776
7777
7778 for spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
7779
7780 print("r2_600=%2.2f r2_500=%2.2f pA=%2.2f, dw=%2.2f, kex=%2.2f, spin_id=%s resi=%i resn=%s"%(spin.r2[r20_key_600], spin.r2[r20_key_500], spin.pA, spin.dw, spin.kex, spin_id, resi, resn))
7781
7782
7783 self.assertEqual(spin.r2[r20_key_600], 10.00)
7784 self.assertEqual(spin.r2[r20_key_500], 10.00)
7785 self.assertEqual(spin.pA, 0.9)
7786 self.assertEqual(spin.dw, 1.0)
7787 self.assertEqual(spin.kex, 1000.0)
7788
7789 print("###########################################")
7790 print("Trying GRID SEARCH for standard R2eff values")
7791
7792
7793 GRID_INC = 5
7794
7795 self.interpreter.minimise.grid_search(lower=None, upper=None, inc=GRID_INC, constraints=True, verbosity=1)
7796
7797
7798
7799 GRID_INC = 5
7800
7801
7802 MC_NUM = 3
7803
7804
7805 MODSEL = 'AIC'
7806
7807
7808
7809 OPT_FUNC_TOL = 1e-1
7810 relax_disp.Relax_disp.opt_func_tol = OPT_FUNC_TOL
7811 OPT_MAX_ITERATIONS = 1000
7812 relax_disp.Relax_disp.opt_max_iterations = OPT_MAX_ITERATIONS
7813
7814
7815 relax_disp.Relax_disp(pipe_name=pipe_name_r2eff, results_dir=ds.tmpdir, models=[MODEL], grid_inc=GRID_INC, mc_sim_num=MC_NUM, modsel=MODSEL, set_grid_r20=True)
7816
7817
7819 """Test getting the spectrum noise for spectrum fourier transformed with NMRPipe, and tool showApod."""
7820
7821
7822 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'repeated_analysis'+sep+'SOD1'+sep+'cpmg_disp_sod1d90a_060518'+sep+'cpmg_disp_sod1d90a_060518_normal.fid'+sep+'ft2_data'
7823
7824
7825 file_name = '128_0_FT.ft2'
7826
7827
7828 get_output = show_apod_extract(file_name=file_name, dir=data_path)
7829
7830
7831
7832
7833 show_apod_ver = [
7834 'REMARK Effect of Processing on Peak Parameters and Noise for %s'%(data_path+sep+file_name),
7835 'REMARK Automated Noise Std Dev in Processed Data: 8583.41',
7836 'REMARK Noise Std Dev Before Processing H1 and N15: 60.6558',
7837 '',
7838 'VARS AXIS LABEL TSIZE FSIZE LW_ADJ LW_FINAL HI_FACTOR VOL_FACTOR SIGMA_FACTOR',
7839 'FORMAT %s %-8s %4d %4d %7.4f %7.4f %.4e %.4e %.4e']
7840
7841
7842
7843
7844 for i, line in enumerate(show_apod_ver):
7845 line_ver = get_output[i]
7846
7847 print(line)
7848 if line[:50] == 'REMARK Noise Std Dev Before Processing H1 and N15:':
7849 continue
7850
7851 self.assertEqual(line, line_ver)
7852
7853
7855 """Test getting the spectrum noise for spectrum fourier transformed with NMRPipe, and tool showApod."""
7856
7857
7858 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'repeated_analysis'+sep+'SOD1'+sep+'cpmg_disp_sod1d90a_060518'+sep+'cpmg_disp_sod1d90a_060518_normal.fid'+sep+'ft2_data'
7859
7860
7861 file_name = '128_0_FT.ft2'
7862
7863
7864 rmsd = show_apod_rmsd(file_name=file_name, dir=data_path)
7865
7866
7867 self.assertEqual(rmsd, 8583.41)
7868
7869
7871 """Test searching for all NMRPipe spectrum files in dir, call showApod, and write to files."""
7872
7873
7874 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'repeated_analysis'+sep+'SOD1'+sep+'cpmg_disp_sod1d90a_060518'+sep+'cpmg_disp_sod1d90a_060518_normal.fid'+sep+'ft2_data'
7875
7876
7877 wfile_paths = show_apod_rmsd_dir_to_files(file_ext='.ft2', dir=data_path, outdir=self.tmpdir)
7878
7879
7880 for wfile_path in wfile_paths:
7881
7882 get_data = extract_data(file=wfile_path)
7883
7884
7885 test = float(get_data[0][0])
7886
7887
7888 self.assertEqual(test, 8583.41)
7889
7890
7892 """Test getting the spectrum noise for spectrum fourier transformed with NMRPipe, and tool showApod, and write to file."""
7893
7894
7895 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'repeated_analysis'+sep+'SOD1'+sep+'cpmg_disp_sod1d90a_060518'+sep+'cpmg_disp_sod1d90a_060518_normal.fid'+sep+'ft2_data'
7896
7897
7898 file_name = '128_0_FT.ft2'
7899
7900
7901 wfile_path = show_apod_rmsd_to_file(file_name=file_name, dir=data_path, outdir=self.tmpdir)
7902
7903
7904 get_data = extract_data(file=wfile_path)
7905
7906
7907 test = float(get_data[0][0])
7908
7909
7910 self.assertEqual(test, 8583.41)
7911
7912
7914 """Error analysis of SOD1-WT CPMG. From paper at U{http://dx.doi.org/10.1073/pnas.0907387106}.
7915
7916 Optimisation of Kaare Teilum, Melanie H. Smith, Eike Schulz, Lea C. Christensen, Gleb Solomentseva, Mikael Oliveberg, and Mikael Akkea 2009
7917 'SOD1-WT' CPMG data to the CR72 dispersion model.
7918
7919 This uses the data from paper at U{http://dx.doi.org/10.1073/pnas.0907387106}. This is CPMG data with a fixed relaxation time period recorded at fields of 500 and 600MHz.
7920 Data is for experiment at 25 degree Celcius.
7921
7922 bug #21954 U{https://web.archive.org/web/https://gna.org/bugs/index.php?21954}: Order of spectrum.error_analysis is important.
7923 """
7924
7925
7926 pipe_name = 'base pipe'
7927 pipe_type = 'relax_disp'
7928 pipe_name_r2eff = "%s_R2eff"%(pipe_name)
7929 select_spin_index = list(range(0, 1))
7930 self.setup_sod1wt_t25(pipe_name=pipe_name, pipe_type=pipe_type, pipe_name_r2eff=pipe_name_r2eff, select_spin_index=select_spin_index)
7931
7932
7933 repl_A = ['Z_A1', 'Z_A15']
7934 repl_B = ['Z_B1', 'Z_B18']
7935
7936
7937 spectrum_ids_A = []
7938 spectrum_ids_B = []
7939 for spectrum_id in cdp.spectrum_ids:
7940 if "A" in spectrum_id:
7941 spectrum_ids_A.append(spectrum_id)
7942 elif "B" in spectrum_id:
7943 spectrum_ids_B.append(spectrum_id)
7944
7945
7946 delattr(cdp, "var_I")
7947 delattr(cdp, "sigma_I")
7948
7949
7950 self.interpreter.spectrum.error_analysis(subset=spectrum_ids_A)
7951 self.interpreter.spectrum.error_analysis(subset=spectrum_ids_B)
7952
7953
7954 Errors_A_B = []
7955 for spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
7956 A_err = spin.peak_intensity_err[spectrum_ids_A[0]]
7957 B_err = spin.peak_intensity_err[spectrum_ids_B[0]]
7958 Errors_A_B.append([A_err, B_err])
7959
7960
7961 delattr(cdp, "var_I")
7962 delattr(cdp, "sigma_I")
7963
7964
7965 self.interpreter.spectrum.error_analysis(subset=spectrum_ids_B)
7966 self.interpreter.spectrum.error_analysis(subset=spectrum_ids_A)
7967
7968
7969 Errors_B_A = []
7970 for spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
7971 A_err = spin.peak_intensity_err[spectrum_ids_A[0]]
7972 B_err = spin.peak_intensity_err[spectrum_ids_B[0]]
7973 Errors_B_A.append([A_err, B_err])
7974
7975
7976 for i in range(len(Errors_A_B)):
7977 Error_A_B = Errors_A_B[i]
7978 Error_B_A = Errors_B_A[i]
7979 self.assertAlmostEqual(Error_A_B[0], Error_B_A[0], 4)
7980 self.assertAlmostEqual(Error_A_B[1], Error_B_A[1], 4)
7981
7982
7983 std_A = math.sqrt((cdp.var_I[repl_A[0]] + cdp.var_I[repl_A[1]])/2)
7984 std_A_fix = 2785.7263335738567
7985
7986 for id_A in spectrum_ids_A:
7987 self.assertEqual(cdp.sigma_I[id_A], std_A)
7988 self.assertAlmostEqual(cdp.sigma_I[id_A], std_A_fix, 7)
7989
7990 std_B = math.sqrt((cdp.var_I[repl_B[0]] + cdp.var_I[repl_B[1]])/2)
7991 std_B_fix = 4967.3772030667988
7992
7993 for id_B in spectrum_ids_B:
7994 self.assertEqual(cdp.sigma_I[id_B], std_B)
7995 self.assertAlmostEqual(cdp.sigma_I[id_B], std_B_fix, 7)
7996
7997
7999 """Optimisation of SOD1-WT CPMG. From paper at U{http://dx.doi.org/10.1073/pnas.0907387106}.
8000
8001 Optimisation of Kaare Teilum, Melanie H. Smith, Eike Schulz, Lea C. Christensen, Gleb Solomentseva, Mikael Oliveberg, and Mikael Akkea 2009
8002 'SOD1-WT' CPMG data to the CR72 dispersion model.
8003
8004 This uses the data from paper at U{http://dx.doi.org/10.1073/pnas.0907387106}. This is CPMG data with a fixed relaxation time period recorded at fields of 500 and 600MHz.
8005 Data is for experiment at 25 degree Celcius.
8006 """
8007
8008
8009 pipe_name = 'base pipe'
8010 pipe_type = 'relax_disp'
8011 pipe_name_r2eff = "%s_R2eff"%(pipe_name)
8012 select_spin_index = list(range(0, 2))
8013 self.setup_sod1wt_t25(pipe_name=pipe_name, pipe_type=pipe_type, pipe_name_r2eff=pipe_name_r2eff, select_spin_index=select_spin_index)
8014
8015
8016 r20_key_600 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=599.8908617*1E6)
8017 r20_key_500 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=499.862139*1E6)
8018
8019
8020 MODEL = "CR72"
8021
8022
8023 pipe_name_MODEL = "%s_%s"%(pipe_name, MODEL)
8024 self.interpreter.pipe.copy(pipe_from=pipe_name_r2eff, pipe_to=pipe_name_MODEL)
8025 self.interpreter.pipe.switch(pipe_name=pipe_name_MODEL)
8026
8027
8028 self.interpreter.relax_disp.select_model(model=MODEL)
8029
8030
8031 GRID_INC = 7
8032
8033
8034 grid_results = []
8035 mini_results = []
8036 clust_results = []
8037
8038
8039 self.interpreter.relax_disp.r20_from_min_r2eff(force=False)
8040
8041
8042 self.interpreter.relax_disp.insignificance(level=1.0)
8043
8044
8045 self.interpreter.minimise.grid_search(lower=None, upper=None, inc=GRID_INC, constraints=True, verbosity=1)
8046
8047
8048 for spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
8049
8050 grid_results.append([spin.r2[r20_key_600], spin.r2[r20_key_500], spin.dw, spin.pA, spin.kex, spin.chi2, spin_id, resi, resn])
8051
8052
8053
8054 set_func_tol = 1e-9
8055 set_max_iter = 100000
8056 self.interpreter.minimise.execute(min_algor='simplex', func_tol=set_func_tol, max_iter=set_max_iter, constraints=True, scaling=True, verbosity=1)
8057
8058
8059 pA_values = []
8060 kex_values = []
8061 for spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
8062
8063 mini_results.append([spin.r2[r20_key_600], spin.r2[r20_key_500], spin.dw, spin.pA, spin.kex, spin.chi2, spin_id, resi, resn])
8064
8065
8066 pA_values.append(spin.pA)
8067
8068
8069 kex_values.append(spin.kex)
8070
8071 print("\n# Now print before and after minimisation.\n")
8072
8073
8074 for i in range(len(grid_results)):
8075
8076 g_r2_600, g_r2_500, g_dw, g_pA, g_kex, g_chi2, g_spin_id, g_resi, g_resn = grid_results[i]
8077 m_r2_600, m_r2_500, m_dw, m_pA, m_kex, m_chi2, m_spin_id, m_resi, m_resn = mini_results[i]
8078
8079 print("GRID r2600=%2.2f r2500=%2.2f dw=%1.1f pA=%1.3f kex=%3.2f chi2=%3.2f spin_id=%s resi=%i resn=%s"%(g_r2_600, g_r2_500, g_dw, g_pA, g_kex, g_chi2, g_spin_id, g_resi, g_resn))
8080 print("MIN r2600=%2.2f r2500=%2.2f dw=%1.1f pA=%1.3f kex=%3.2f chi2=%3.2f spin_id=%s resi=%i resn=%s"%(m_r2_600, m_r2_500, m_dw, m_pA, m_kex, m_chi2, m_spin_id, m_resi, m_resn))
8081
8082
8083
8084 pipe_name_MODEL_CLUSTER = "%s_%s_Cluster"%(pipe_name, MODEL)
8085 self.interpreter.pipe.copy(pipe_from=pipe_name_r2eff, pipe_to=pipe_name_MODEL_CLUSTER)
8086 self.interpreter.pipe.switch(pipe_name=pipe_name_MODEL_CLUSTER)
8087
8088
8089 self.interpreter.relax_disp.select_model(model=MODEL)
8090
8091
8092 cluster_id = 'clust'
8093
8094
8095 for spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
8096 self.interpreter.relax_disp.cluster(cluster_id, spin_id)
8097
8098
8099 self.interpreter.relax_disp.parameter_copy(pipe_from=pipe_name_MODEL, pipe_to=pipe_name_MODEL_CLUSTER)
8100
8101
8102 for spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
8103 print(pA_values)
8104
8105 self.assertEqual(median(pA_values), spin.pA)
8106
8107
8108 self.assertEqual(median(kex_values), spin.kex)
8109
8110
8111 self.interpreter.minimise.execute(min_algor='simplex', func_tol=set_func_tol, max_iter=set_max_iter, constraints=True, scaling=True, verbosity=1)
8112
8113
8114 for spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
8115
8116 clust_results.append([spin.r2[r20_key_600], spin.r2[r20_key_500], spin.dw, spin.pA, spin.kex, spin.chi2, spin_id, resi, resn])
8117
8118
8119 clust_pA = spin.pA
8120 clust_kex = spin.kex
8121
8122 print("\n# Now testing.\n")
8123
8124
8125 test_res = {}
8126 test_res[':10@N'] = {}
8127 test_res[':10@N']['r2600'] = 18.429755324773360
8128 test_res[':10@N']['r2500'] = 16.981349161968630
8129 test_res[':10@N']['dw'] = 2.700755859433969
8130 test_res[':10@N']['pA'] = 0.971531659288657
8131 test_res[':10@N']['kex'] = 3831.766337047963134
8132 test_res[':11@N'] = {}
8133 test_res[':11@N']['r2600'] = 18.193409421115213
8134 test_res[':11@N']['r2500'] = 17.308838135567765
8135 test_res[':11@N']['dw'] = 2.706650302761793
8136 test_res[':11@N']['pA'] = 0.971531659288657
8137 test_res[':11@N']['kex'] = 3831.766337047963134
8138
8139
8140 for i in range(len(grid_results)):
8141
8142 g_r2_600, g_r2_500, g_dw, g_pA, g_kex, g_chi2, g_spin_id, g_resi, g_resn = grid_results[i]
8143 m_r2_600, m_r2_500, m_dw, m_pA, m_kex, m_chi2, m_spin_id, m_resi, m_resn = mini_results[i]
8144 c_r2_600, c_r2_500, c_dw, c_pA, c_kex, c_chi2, c_spin_id, c_resi, c_resn = clust_results[i]
8145
8146 print("%s GRID r2600=%2.2f r2500=%2.2f dw=%1.1f pA=%1.3f kex=%3.2f chi2=%3.2f spin_id=%s resi=%i resn=%s"%(g_spin_id, g_r2_600, g_r2_500, g_dw, g_pA, g_kex, g_chi2, g_spin_id, g_resi, g_resn))
8147 print("%s MIN r2600=%2.2f r2500=%2.2f dw=%1.1f pA=%1.3f kex=%3.2f chi2=%3.2f spin_id=%s resi=%i resn=%s"%(m_spin_id, m_r2_600, m_r2_500, m_dw, m_pA, m_kex, m_chi2, m_spin_id, m_resi, m_resn))
8148 print("%s Clust r2600=%2.2f r2500=%2.2f dw=%1.1f pA=%1.3f kex=%3.2f chi2=%3.2f spin_id=%s resi=%i resn=%s"%(m_spin_id, c_r2_600, c_r2_500, c_dw, c_pA, c_kex, c_chi2, c_spin_id, c_resi, c_resn))
8149
8150
8151 self.assertEqual(clust_pA, c_pA)
8152 self.assertEqual(clust_kex, c_kex)
8153
8154
8155 if c_spin_id in test_res:
8156 self.assertAlmostEqual(c_r2_600, test_res[c_spin_id]['r2600'], 4)
8157 self.assertAlmostEqual(c_r2_500, test_res[c_spin_id]['r2500'], 4)
8158 self.assertAlmostEqual(c_dw, test_res[c_spin_id]['dw'], 3)
8159 self.assertAlmostEqual(c_pA, test_res[c_spin_id]['pA'], 5)
8160 self.assertAlmostEqual(c_kex, test_res[c_spin_id]['kex'], 1)
8161
8162
8163
8164
8165
8332
8333
8335 """Test the 'MMQ CR72' model fitting against Remco Sprangers' ClpP data.
8336
8337 This uses the data from Remco Sprangers' paper at http://dx.doi.org/10.1073/pnas.0507370102. This is MMQ CPMG data with a fixed relaxation time period.
8338 """
8339
8340
8341 self.interpreter.reset()
8342
8343
8344 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'Sprangers_ClpP'
8345 self.interpreter.state.load(data_path+sep+'r2eff_values')
8346
8347
8348 model = 'MMQ CR72'
8349 pipe_name = "%s - relax_disp" % model
8350 self.interpreter.pipe.copy(pipe_from='base pipe', pipe_to=pipe_name, bundle_to='relax_disp')
8351 self.interpreter.pipe.switch(pipe_name=pipe_name)
8352
8353
8354 self.interpreter.relax_disp.select_model(model=model)
8355
8356
8357 self.interpreter.relax_disp.cluster(cluster_id='all', spin_id=":135-137")
8358
8359
8360 self.interpreter.value.copy(pipe_from='R2eff', pipe_to=pipe_name, param='r2eff')
8361
8362
8363 spin135S = cdp.mol[0].res[0].spin[0]
8364 spin135F = cdp.mol[0].res[0].spin[1]
8365 spin137S = cdp.mol[0].res[1].spin[0]
8366 spin137F = cdp.mol[0].res[1].spin[1]
8367
8368
8369 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_MQ, frq=600e6)
8370 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_MQ, frq=800e6)
8371
8372
8373 spin135S.pA = 0.836591763632
8374 spin135S.kex = 241.806525261
8375
8376
8377 spin135S.r2 = {r20_key1: 28.2493431552, r20_key2: 31.7517334715}
8378 spin135S.dw = 0.583003118785
8379 spin135S.dwH = 0.0361441944301
8380
8381 spin135F.r2 = {r20_key1: 42.7201839991, r20_key2: 57.3178617389}
8382 spin135F.dw = 0.805849745104
8383 spin135F.dwH = 0.0215791945715
8384
8385 spin137S.r2 = {r20_key1: 26.0134115256, r20_key2: 30.575806934}
8386 spin137S.dw = 0.688107568372
8387 spin137S.dwH = 0.0344463604043
8388
8389 spin137F.r2 = {r20_key1: 46.6969397337, r20_key2: 58.602384101}
8390 spin137F.dw = 0.94978299907
8391 spin137F.dwH = 1.4818877939e-07
8392
8393
8394 self.interpreter.minimise.execute(min_algor='simplex', func_tol=1e-10, max_iter=1000)
8395
8396
8397 print("\n\nOptimised parameters:\n")
8398 print("%-20s %-20s %-20s %-20s %-20s" % ("Parameter", "Value (:135@S)", "Value (:135@F)", "Value (:137@S)", "Value (:137@F)"))
8399 print("%-20s %20.15g %20.15g %20.15g %20.15g" % ("R2 (500 MHz)", spin135S.r2[r20_key1], spin135F.r2[r20_key1], spin137S.r2[r20_key1], spin137F.r2[r20_key1]))
8400 print("%-20s %20.15g %20.15g %20.15g %20.15g" % ("R2 (800 MHz)", spin135S.r2[r20_key2], spin135F.r2[r20_key2], spin137S.r2[r20_key2], spin137F.r2[r20_key2]))
8401 print("%-20s %20.15g %20.15g %20.15g %20.15g" % ("pA", spin135S.pA, spin135F.pA, spin137S.pA, spin137F.pA))
8402 print("%-20s %20.15g %20.15g %20.15g %20.15g" % ("dw", spin135S.dw, spin135F.dw, spin137S.dw, spin137F.dw))
8403 print("%-20s %20.15g %20.15g %20.15g %20.15g" % ("dwH", spin135S.dwH, spin135F.dwH, spin137S.dwH, spin137F.dwH))
8404 print("%-20s %20.15g %20.15g %20.15g %20.15g" % ("kex", spin135S.kex, spin135F.kex, spin137S.kex, spin137F.kex))
8405 print("%-20s %20.15g %20.15g %20.15g %20.15g\n" % ("chi2", spin135S.chi2, spin135F.chi2, spin137S.chi2, spin137F.chi2))
8406 print("\n # Set the cluster specific parameters (only for the first spin).")
8407 print(" spin135S.pA = %s" % spin135S.pA)
8408 print(" spin135S.kex = %s" % spin135S.kex)
8409 print("\n # Set the initial parameter values.")
8410 print(" spin135S.r2 = {r20_key1: %s, r20_key2: %s}" % (spin135S.r2[r20_key1], spin135S.r2[r20_key2]))
8411 print(" spin135S.dw = %s" % spin135S.dw)
8412 print(" spin135S.dwH = %s" % spin135S.dwH)
8413 print("\n spin135F.r2 = {r20_key1: %s, r20_key2: %s}" % (spin135F.r2[r20_key1], spin135F.r2[r20_key2]))
8414 print(" spin135F.dw = %s" % spin135F.dw)
8415 print(" spin135F.dwH = %s" % spin135F.dwH)
8416 print("\n spin137S.r2 = {r20_key1: %s, r20_key2: %s}" % (spin137S.r2[r20_key1], spin137S.r2[r20_key2]))
8417 print(" spin137S.dw = %s" % spin137S.dw)
8418 print(" spin137S.dwH = %s" % spin137S.dwH)
8419 print("\n spin137F.r2 = {r20_key1: %s, r20_key2: %s}" % (spin137F.r2[r20_key1], spin137F.r2[r20_key2]))
8420 print(" spin137F.dw = %s" % spin137F.dw)
8421 print(" spin137F.dwH = %s" % spin137F.dwH)
8422
8423
8424 self.assertAlmostEqual(spin135S.r2[r20_key1], 28.2493445347425, 4)
8425 self.assertAlmostEqual(spin135S.r2[r20_key2], 31.7517352342937, 4)
8426 self.assertAlmostEqual(spin135S.pA, 0.836591714049569, 4)
8427 self.assertAlmostEqual(spin135S.dw, 0.583003004605869, 4)
8428 self.assertAlmostEqual(spin135S.dwH, 0.0361441894065963, 4)
8429 self.assertAlmostEqual(spin135S.kex/100, 241.806464344233/100, 4)
8430 self.assertAlmostEqual(spin135S.chi2, 12.4224060116473, 4)
8431
8432
8433 self.assertAlmostEqual(spin135F.r2[r20_key1], 42.7201844426839, 4)
8434 self.assertAlmostEqual(spin135F.r2[r20_key2], 57.3178718548898, 4)
8435 self.assertAlmostEqual(spin135F.pA, 0.836591714049569, 4)
8436 self.assertAlmostEqual(spin135F.dw, 0.805849748711916, 4)
8437 self.assertAlmostEqual(spin135F.dwH, 0.0215791669142752, 4)
8438 self.assertAlmostEqual(spin135F.kex/100, 241.806464344233/100, 4)
8439 self.assertAlmostEqual(spin135F.chi2, 12.4224060116473, 4)
8440
8441
8442 self.assertAlmostEqual(spin137S.r2[r20_key1], 26.013412509919, 4)
8443 self.assertAlmostEqual(spin137S.r2[r20_key2], 30.5758092335097, 4)
8444 self.assertAlmostEqual(spin137S.pA, 0.836591714049569, 4)
8445 self.assertAlmostEqual(spin137S.dw, 0.688107406812537, 4)
8446 self.assertAlmostEqual(spin137S.dwH, 0.034446357344577, 4)
8447 self.assertAlmostEqual(spin137S.kex/100, 241.806464344233/100, 4)
8448 self.assertAlmostEqual(spin137S.chi2, 12.4224060116473, 4)
8449
8450
8451 self.assertAlmostEqual(spin137F.r2[r20_key1], 46.696935090697, 4)
8452 self.assertAlmostEqual(spin137F.r2[r20_key2], 58.6023842513446, 4)
8453 self.assertAlmostEqual(spin137F.pA, 0.836591714049569, 4)
8454 self.assertAlmostEqual(spin137F.dw, 0.94978325541294, 4)
8455 self.assertAlmostEqual(spin137F.dwH, 1.5189362257653e-07, 4)
8456 self.assertAlmostEqual(spin137F.kex/100, 241.806464344233/100, 4)
8457 self.assertAlmostEqual(spin137F.chi2, 12.4224060116473, 4)
8458
8459
8461 """Test the 'NS MMQ 2-site' model fitting against Remco Sprangers' ClpP data.
8462
8463 This uses the data from Remco Sprangers' paper at http://dx.doi.org/10.1073/pnas.0507370102. This is MQ CPMG data with a fixed relaxation time period.
8464 """
8465
8466
8467 self.interpreter.reset()
8468
8469
8470 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'Sprangers_ClpP'
8471 self.interpreter.state.load(data_path+sep+'r2eff_values')
8472
8473
8474 model = 'NS MMQ 2-site'
8475 pipe_name = "%s - relax_disp" % model
8476 self.interpreter.pipe.copy(pipe_from='base pipe', pipe_to=pipe_name, bundle_to='relax_disp')
8477 self.interpreter.pipe.switch(pipe_name=pipe_name)
8478
8479
8480 self.interpreter.relax_disp.select_model(model=model)
8481
8482
8483 self.interpreter.relax_disp.cluster(cluster_id='all', spin_id=":135-137")
8484
8485
8486 self.interpreter.value.copy(pipe_from='R2eff', pipe_to=pipe_name, param='r2eff')
8487
8488
8489 spin135S = cdp.mol[0].res[0].spin[0]
8490 spin135F = cdp.mol[0].res[0].spin[1]
8491 spin137S = cdp.mol[0].res[1].spin[0]
8492 spin137F = cdp.mol[0].res[1].spin[1]
8493
8494
8495 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_MQ, frq=800e6)
8496 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_MQ, frq=800e6)
8497
8498
8499 spin135S.pA = 0.847378444499757
8500 spin135S.kex = 264.055604934724329
8501
8502
8503 spin135S.r2 = {r20_key1: 30.315119723745390, r20_key2: 37.411874745645299}
8504 spin135S.dw = 0.585574008745351
8505 spin135S.dwH = 0.000000000000002
8506
8507 spin135F.r2 = {r20_key1: 41.440843383778287, r20_key2: 56.989726795397893}
8508 spin135F.dw = 0.856699277665748
8509 spin135F.dwH = 0.000000000582587
8510
8511 spin137S.r2 = {r20_key1: 23.051695938570266, r20_key2: 28.352806483953824}
8512 spin137S.dw = 0.772904450844973
8513 spin137S.dwH = 0.183351478512970
8514
8515 spin137F.r2 = {r20_key1: 44.702032074210429, r20_key2: 56.453146052685319}
8516 spin137F.dw = 0.984568590342831
8517 spin137F.dwH = 0.000000001993458
8518
8519
8520 self.interpreter.minimise.execute(min_algor='simplex', line_search=None, hessian_mod=None, hessian_type=None, func_tol=1e-5, grad_tol=None, max_iter=100, constraints=True, scaling=True, verbosity=1)
8521
8522
8523 print("\n\nOptimised parameters:\n")
8524 print("%-20s %-20s %-20s %-20s %-20s" % ("Parameter", "Value (:135@S)", "Value (:135@F)", "Value (:137@S)", "Value (:137@F)"))
8525 print("%-20s %20.15g %20.15g %20.15g %20.15g" % ("R2 (500 MHz)", spin135S.r2[r20_key1], spin135F.r2[r20_key1], spin137S.r2[r20_key1], spin137F.r2[r20_key1]))
8526 print("%-20s %20.15g %20.15g %20.15g %20.15g" % ("R2 (800 MHz)", spin135S.r2[r20_key2], spin135F.r2[r20_key2], spin137S.r2[r20_key2], spin137F.r2[r20_key2]))
8527 print("%-20s %20.15g %20.15g %20.15g %20.15g" % ("pA", spin135S.pA, spin135F.pA, spin137S.pA, spin137F.pA))
8528 print("%-20s %20.15g %20.15g %20.15g %20.15g" % ("dw", spin135S.dw, spin135F.dw, spin137S.dw, spin137F.dw))
8529 print("%-20s %20.15g %20.15g %20.15g %20.15g" % ("dwH", spin135S.dwH, spin135F.dwH, spin137S.dwH, spin137F.dwH))
8530 print("%-20s %20.15g %20.15g %20.15g %20.15g" % ("kex", spin135S.kex, spin135F.kex, spin137S.kex, spin137F.kex))
8531 print("%-20s %20.15g %20.15g %20.15g %20.15g\n" % ("chi2", spin135S.chi2, spin135F.chi2, spin137S.chi2, spin137F.chi2))
8532
8533
8534 return
8535
8536
8537 self.assertAlmostEqual(spin135S.r2[r20_key1], 30.3151197237454, 4)
8538 self.assertAlmostEqual(spin135S.r2[r20_key2], 37.4118747456453, 4)
8539 self.assertAlmostEqual(spin135S.pA, 0.847378444499757, 4)
8540 self.assertAlmostEqual(spin135S.dw, 0.585574008745351, 4)
8541 self.assertAlmostEqual(spin135S.dwH, 2e-15, 4)
8542 self.assertAlmostEqual(spin135S.kex, 264.055604934724, 4)
8543 self.assertAlmostEqual(spin135S.chi2, 13.859423588071, 1)
8544
8545
8546 self.assertAlmostEqual(spin135F.r2[r20_key1], 41.4408433837783, 4)
8547 self.assertAlmostEqual(spin135F.r2[r20_key2], 56.9897267953979, 4)
8548 self.assertAlmostEqual(spin135F.pA, 0.847378444499757, 4)
8549 self.assertAlmostEqual(spin135F.dw, 0.856699277665748, 4)
8550 self.assertAlmostEqual(spin135F.dwH, 5.82587e-10, 4)
8551 self.assertAlmostEqual(spin135F.kex, 264.055604934724, 4)
8552 self.assertAlmostEqual(spin135F.chi2, 13.859423588071, 1)
8553
8554
8555 self.assertAlmostEqual(spin137S.r2[r20_key1], 23.0516959385703, 4)
8556 self.assertAlmostEqual(spin137S.r2[r20_key2], 28.3528064839538, 4)
8557 self.assertAlmostEqual(spin137S.pA, 0.847378444499757, 4)
8558 self.assertAlmostEqual(spin137S.dw, 0.772904450844973, 4)
8559 self.assertAlmostEqual(spin137S.dwH, 0.18335147851297, 4)
8560 self.assertAlmostEqual(spin137S.kex, 264.055604934724, 4)
8561 self.assertAlmostEqual(spin137S.chi2, 13.859423588071, 1)
8562
8563
8564 self.assertAlmostEqual(spin137F.r2[r20_key1], 44.7020320742104, 4)
8565 self.assertAlmostEqual(spin137F.r2[r20_key2], 56.4531460526853, 4)
8566 self.assertAlmostEqual(spin137F.pA, 0.847378444499757, 4)
8567 self.assertAlmostEqual(spin137F.dw, 0.984568590342831, 4)
8568 self.assertAlmostEqual(spin137F.dwH, 2.0931309e-09, 4)
8569 self.assertAlmostEqual(spin137F.kex, 264.055604934724, 4)
8570 self.assertAlmostEqual(spin137F.chi2, 13.859423588071, 1)
8571
8572
8574 """Test the relaxation dispersion 'NS R1rho 2-site' model fitting against the 'TP02' test data."""
8575
8576
8577 self.setup_tp02_data_to_ns_r1rho_2site()
8578
8579
8580 spin1 = cdp.mol[0].res[0].spin[0]
8581 spin2 = cdp.mol[0].res[1].spin[0]
8582
8583
8584 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_R1RHO, frq=500e6)
8585 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_R1RHO, frq=800e6)
8586
8587
8588 self.assertAlmostEqual(spin1.r2[r20_key1], 8.50207717367548, 4)
8589 self.assertAlmostEqual(spin1.r2[r20_key2], 13.4680429589972, 4)
8590 self.assertAlmostEqual(spin1.pA, 0.864523128842393, 4)
8591 self.assertAlmostEqual(spin1.dw, 8.85204828994151, 4)
8592 self.assertAlmostEqual(spin1.kex/1000, 1199.56359549637/1000, 4)
8593 self.assertAlmostEqual(spin1.chi2, 2.99182130153514, 4)
8594
8595
8596 self.assertAlmostEqual(spin2.r2[r20_key1], 10.2099357790203, 4)
8597 self.assertAlmostEqual(spin2.r2[r20_key2], 16.2137648697873, 4)
8598 self.assertAlmostEqual(spin2.pA, 0.836488681031685, 4)
8599 self.assertAlmostEqual(spin2.dw, 9.5505714779503, 4)
8600 self.assertAlmostEqual(spin2.kex/1000, 1454.45726998929/1000, 4)
8601 self.assertAlmostEqual(spin2.chi2, 0.000402231563481261, 4)
8602
8603
8605 """Test the relaxation dispersion 'NS R1rho 2-site' model fitting against the 'TP02' test data, when performing clustering."""
8606
8607
8608 self.setup_tp02_data_to_ns_r1rho_2site(clustering=True)
8609
8610
8611 spin1 = cdp.mol[0].res[0].spin[0]
8612 spin2 = cdp.mol[0].res[1].spin[0]
8613
8614
8615 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_R1RHO, frq=500e6)
8616 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_R1RHO, frq=800e6)
8617
8618
8619 self.assertAlmostEqual(spin1.r2[r20_key1], 8.48607207881462, 4)
8620 self.assertAlmostEqual(spin1.r2[r20_key2], 13.4527609061722, 4)
8621 self.assertAlmostEqual(spin1.pA, 0.863093838784425, 4)
8622 self.assertAlmostEqual(spin1.dw, 8.86218096536618, 4)
8623 self.assertAlmostEqual(spin1.kex/1000, 1186.22749648299/1000, 4)
8624 self.assertAlmostEqual(spin1.chi2, 3.09500996065247, 4)
8625
8626
8627 self.assertAlmostEqual(spin2.r2[r20_key1], 10.4577906018883, 4)
8628 self.assertAlmostEqual(spin2.r2[r20_key2], 16.4455550953792, 4)
8629 self.assertAlmostEqual(spin2.pA, 0.863093838784425, 4)
8630 self.assertAlmostEqual(spin2.dw, 11.5841168862587, 4)
8631 self.assertAlmostEqual(spin2.kex/1000, 1186.22749648299/1000, 4)
8632 self.assertAlmostEqual(spin2.chi2, 3.09500996065247, 4)
8633
8634
8636 """Test the dispersion 'MP05' model fitting against the 'TP02' test data."""
8637
8638
8639 ds.fixed = True
8640 ds.models = ['R2eff', 'MP05']
8641
8642
8643 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'r1rho_off_res_tp02.py')
8644
8645
8646 self.interpreter.pipe.switch('MP05 - relax_disp')
8647
8648
8649 r1rho_prime = [[10.0058086343329, 15.005806870124], [12.0766320470785, 18.0767503536277]]
8650 pA = [0.775055484521586, 0.500000000036595]
8651 kex = [1235.20361276079, 2378.31403454691]
8652 delta_omega = [7.08194146569694, 5.4083562844306]
8653 chi2 = [0.0370400968727768, 0.182141732163934]
8654
8655
8656 spin1 = cdp.mol[0].res[0].spin[0]
8657 spin2 = cdp.mol[0].res[1].spin[0]
8658
8659
8660 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_R1RHO, frq=500e6)
8661 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_R1RHO, frq=800e6)
8662
8663
8664 print("\n\nOptimised parameters:\n")
8665 print("%-20s %-20s %-20s" % ("Parameter", "Value (:1)", "Value (:2)"))
8666 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin1.r2[r20_key1], spin2.r2[r20_key1]))
8667 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin1.r2[r20_key2], spin2.r2[r20_key2]))
8668 print("%-20s %20.15g %20.15g" % ("pA", spin1.pA, spin2.pA))
8669 print("%-20s %20.15g %20.15g" % ("dw", spin1.dw, spin2.dw))
8670 print("%-20s %20.15g %20.15g" % ("kex", spin1.kex, spin2.kex))
8671 print("%-20s %20.15g %20.15g\n" % ("chi2", spin1.chi2, spin2.chi2))
8672
8673
8674 spin_index = 0
8675 for spin, spin_id in spin_loop(return_id=True):
8676
8677 print("\nSpin %s." % spin_id)
8678
8679
8680 self.assertAlmostEqual(spin.r2[r20_key1]/10, r1rho_prime[spin_index][0]/10, 4)
8681 self.assertAlmostEqual(spin.r2[r20_key2]/10, r1rho_prime[spin_index][1]/10, 4)
8682 self.assertAlmostEqual(spin.pA, pA[spin_index], 3)
8683 self.assertAlmostEqual(spin.dw, delta_omega[spin_index], 3)
8684 self.assertAlmostEqual(spin.kex/1000.0, kex[spin_index]/1000.0, 3)
8685 self.assertAlmostEqual(spin.chi2, chi2[spin_index], 3)
8686
8687
8688 spin_index += 1
8689
8690
8692 """Test the dispersion 'TAP03' model fitting against the 'TP02' test data."""
8693
8694
8695 ds.fixed = True
8696 ds.models = ['R2eff', 'TAP03']
8697
8698
8699 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'r1rho_off_res_tp02.py')
8700
8701
8702 self.interpreter.pipe.switch('TAP03 - relax_disp')
8703
8704
8705 r1rho_prime = [[10.0058156589442, 15.005818505006], [12.0766046472748, 18.076648462452]]
8706 pA = [0.775042569092891, 0.500000000229685]
8707 kex = [1235.20852748765, 2379.47085580169]
8708 delta_omega = [7.08176806468445, 5.40708372863538]
8709 chi2 = [0.0371366837083293, 0.182212857256044]
8710
8711
8712 spin1 = cdp.mol[0].res[0].spin[0]
8713 spin2 = cdp.mol[0].res[1].spin[0]
8714
8715
8716 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_R1RHO, frq=500e6)
8717 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_R1RHO, frq=800e6)
8718
8719
8720 print("\n\nOptimised parameters:\n")
8721 print("%-20s %-20s %-20s" % ("Parameter", "Value (:1)", "Value (:2)"))
8722 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin1.r2[r20_key1], spin2.r2[r20_key1]))
8723 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin1.r2[r20_key2], spin2.r2[r20_key2]))
8724 print("%-20s %20.15g %20.15g" % ("pA", spin1.pA, spin2.pA))
8725 print("%-20s %20.15g %20.15g" % ("dw", spin1.dw, spin2.dw))
8726 print("%-20s %20.15g %20.15g" % ("kex", spin1.kex, spin2.kex))
8727 print("%-20s %20.15g %20.15g\n" % ("chi2", spin1.chi2, spin2.chi2))
8728
8729
8730 self.interpreter.pipe.switch('TAP03 - relax_disp')
8731 spin_index = 0
8732 for spin, spin_id in spin_loop(return_id=True):
8733
8734 print("\nSpin %s." % spin_id)
8735
8736
8737 self.assertAlmostEqual(spin.r2[r20_key1]/10, r1rho_prime[spin_index][0]/10, 4)
8738 self.assertAlmostEqual(spin.r2[r20_key2]/10, r1rho_prime[spin_index][1]/10, 4)
8739 self.assertAlmostEqual(spin.pA, pA[spin_index], 3)
8740 self.assertAlmostEqual(spin.dw, delta_omega[spin_index], 3)
8741 self.assertAlmostEqual(spin.kex/1000.0, kex[spin_index]/1000.0, 3)
8742 self.assertAlmostEqual(spin.chi2, chi2[spin_index], 3)
8743
8744
8745 spin_index += 1
8746
8747
8749 """Implementation of Task #7882 U{https://web.archive.org/web/https://gna.org/task/?7882}: Implement Monte-Carlo simulation, where errors are generated with width of standard deviation or residuals"""
8750
8751
8752
8753
8754 file_name = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'error_testing'+sep+'task_7882'
8755 self.interpreter.results.read(file_name)
8756
8757
8758 spins_cluster = cdp.clustering['sel']
8759 spins_free = cdp.clustering['free spins']
8760
8761
8762 cur_spin_id = spins_cluster[0]
8763 cur_spin = return_spin(cur_spin_id)
8764
8765
8766 N = len(spins_cluster)
8767 N_dp = N * len(cur_spin.r2eff)
8768
8769
8770 N_par = cdp.spectrometer_frq_count * N + N + 1 + 1
8771 dof = N_dp - N_par
8772
8773
8774 print(N_par, N_dp)
8775
8776
8777 mc_nr = 3
8778
8779
8780 self.interpreter.monte_carlo.setup(number=mc_nr)
8781
8782
8783 self.interpreter.monte_carlo.create_data(distribution="red_chi2")
8784
8785
8786 self.interpreter.monte_carlo.setup(number=mc_nr)
8787
8788
8789 self.assertRaises(RelaxError, self.interpreter.monte_carlo.create_data, fixed_error=1.)
8790
8791
8792 self.interpreter.monte_carlo.setup(number=mc_nr)
8793
8794
8795 self.assertRaises(RelaxError, self.interpreter.monte_carlo.create_data, distribution="fixed")
8796
8797
8798 self.interpreter.monte_carlo.create_data(distribution="fixed", fixed_error=1.)
8799
8800
8801 self.interpreter.relax_disp.select_model(MODEL_R2EFF)
8802
8803
8804 self.interpreter.monte_carlo.setup(number=mc_nr)
8805
8806
8807 self.assertRaises(RelaxError, self.interpreter.monte_carlo.create_data, distribution="red_chi2")
8808 self.assertRaises(RelaxError, self.interpreter.monte_carlo.create_data, method="direct", distribution="red_chi2")
8809
8810
8812 """Test related to Task #7882 U{https://web.archive.org/web/https://gna.org/task/?7882}: Try making a confidence interval of kex.
8813 According to the regression book of Graphpad: U{http://www.graphpad.com/faq/file/Prism4RegressionBook.pdf}.
8814 Page 109-111.
8815 """
8816
8817
8818 file_name = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'error_testing'+sep+'task_7882'
8819 self.interpreter.results.read(file_name)
8820
8821
8822 spins_cluster = cdp.clustering['sel']
8823 spins_free = cdp.clustering['free spins']
8824
8825
8826 cur_spin_id = spins_cluster[0]
8827 cur_spin = return_spin(cur_spin_id)
8828
8829
8830 Ns = len(spins_cluster)
8831 N_dp = Ns * len(cur_spin.r2eff)
8832
8833
8834 N_par = cdp.spectrometer_frq_count * Ns + Ns + 1 + 1
8835 dof_fit = N_dp - N_par
8836
8837
8838 self.assertEqual(Ns, 61)
8839 self.assertEqual(N_dp, 1952)
8840 self.assertEqual(N_par, 185)
8841
8842
8843
8844 P = 1
8845
8846 N = N_dp
8847
8848 dof_conf = N - P
8849
8850
8851
8852
8853
8854 F = 3.8462295505435562
8855
8856 scale = F*P/dof_conf +1
8857
8858
8859 SSbest_fit = cur_spin.chi2
8860 SSbest_kex = cur_spin.kex
8861
8862
8863 SSall_fixed = SSbest_fit * scale
8864
8865 print(SSbest_fit, scale, SSall_fixed)
8866
8867
8868 kex_cur = cur_spin.kex
8869 kex_list = linspace(kex_cur - 1500, kex_cur + 3000, 200)
8870
8871 chi2_list = []
8872
8873 for kex in kex_list:
8874 self.interpreter.value.set(val=kex, param='kex')
8875
8876
8877 self.interpreter.minimise.calculate(verbosity=0)
8878
8879
8880 chi2_cur = cur_spin.chi2
8881 print("kex=%3.2f, chi2=%3.2f"%(kex, chi2_cur), chi2_cur<SSall_fixed)
8882
8883
8884 chi2_list.append(chi2_cur)
8885
8886
8887 chi2_list = asarray(chi2_list)
8888
8889
8890 sel_mask = chi2_list < SSall_fixed
8891
8892
8893 kex_sel = kex_list[sel_mask]
8894 chi2_sel = chi2_list[sel_mask]
8895
8896
8897 print(SSbest_kex, SSbest_fit, SSall_fixed)
8898 print(kex_sel)
8899 print(chi2_sel)
8900
8901 if True:
8902 import matplotlib.pyplot as plt
8903
8904 plt.plot(kex_sel, chi2_sel, "bo")
8905 plt.plot(SSbest_kex, SSbest_fit, "g*")
8906 plt.show()
8907
8908
8910 """Test the relaxation dispersion 'TP02' model curve fitting to fixed time synthetic data."""
8911
8912
8913 ds.fixed = True
8914
8915
8916 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'r1rho_off_res_tp02.py')
8917
8918
8919 r1rho_prime = [[10.0, 15.0], [12.0, 18.0]]
8920 pA = 0.7654321
8921 kex = 1234.56789
8922 delta_omega = [7.0, 9.0]
8923
8924
8925 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_R1RHO, frq=500e6)
8926 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_R1RHO, frq=800e6)
8927
8928
8929 self.interpreter.pipe.switch('TP02 - relax_disp')
8930 spin_index = 0
8931 for spin, spin_id in spin_loop(return_id=True):
8932
8933 print("\nSpin %s." % spin_id)
8934
8935
8936 self.assertAlmostEqual(spin.r2[r20_key1]/10, r1rho_prime[spin_index][0]/10, 4)
8937 self.assertAlmostEqual(spin.r2[r20_key2]/10, r1rho_prime[spin_index][1]/10, 4)
8938 self.assertAlmostEqual(spin.dw, delta_omega[spin_index], 3)
8939 self.assertAlmostEqual(spin.kex/1000.0, kex/1000.0, 3)
8940
8941
8942 spin_index += 1
8943
8944
8946 """System test of the value.write function to write intensities for an R1rho setup.
8947 This system test is to make sure, that modifying the API for special parameters theta and w_eff does not alter the functionality value.write.
8948
8949 This uses the data of the saved state attached to U{bug #21344<https://web.archive.org/web/https://gna.org/bugs/?21344>}.
8950 """
8951
8952
8953 statefile = status.install_path+sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21344_trunc.bz2'
8954 self.interpreter.state.load(statefile, force=True)
8955
8956
8957 int_filepath = ds.tmpdir+sep+'int.out'
8958
8959
8960
8961 self.interpreter.value.write(param='peak_intensity', file='int.out', dir=ds.tmpdir, scaling=1.0, force=True)
8962
8963
8964 self.assert_(access(int_filepath, F_OK))
8965
8966
8967 int_file = open(int_filepath, 'r')
8968
8969
8970 for line in int_file:
8971
8972 if line[0] == "#":
8973 continue
8974
8975
8976 linesplit = line.split()
8977
8978
8979 if linesplit[0] == "None" and linesplit[1] == "5" and linesplit[2] == "I":
8980 self.assertEqual(linesplit[5], "115571.4")
8981 elif linesplit[0] == "None" and linesplit[1] == "6" and linesplit[2] == "S":
8982 self.assertEqual(linesplit[5], "68377.52")
8983 elif linesplit[0] == "None" and linesplit[1] == "8" and linesplit[2] == "S":
8984 self.assertEqual(linesplit[5], "9141.689")
8985 elif linesplit[0] == "None" and linesplit[1] == "9" and linesplit[2] == "A":
8986 self.assertEqual(linesplit[5], "29123.77")
8987 elif linesplit[0] == "None" and linesplit[1] == "10" and linesplit[2] == "L":
8988 self.assertEqual(linesplit[5], "58914.94")
8989
8990
8991 int_file.close()
8992
8993
8995 """System test of the value.write function to write return values of theta from calc_rotating_frame_params() function for an R1rho setup.
8996
8997 This uses the data of the saved state attached to U{bug #21344<https://web.archive.org/web/https://gna.org/bugs/?21344>}.
8998 """
8999
9000
9001 statefile = status.install_path+sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21344_trunc.bz2'
9002 self.interpreter.state.load(statefile, force=True)
9003
9004
9005 theta_filepath = ds.tmpdir+sep+'theta.out'
9006
9007
9008 self.interpreter.value.write(param='theta', file='theta.out', dir=ds.tmpdir, scaling=1.0, force=True)
9009
9010
9011 self.assert_(access(theta_filepath, F_OK))
9012
9013
9014 theta_file = open(theta_filepath, 'r')
9015
9016
9017 for line in theta_file:
9018
9019 if line[0] == "#":
9020 continue
9021
9022 print(line[:-1])
9023
9024
9025 linesplit = line.split()
9026
9027
9028 if linesplit[0] == "None" and linesplit[1] == "5" and linesplit[2] == "I":
9029 self.assertNotEqual(linesplit[5], "None")
9030 elif linesplit[0] == "None" and linesplit[1] == "6" and linesplit[2] == "S":
9031 self.assertNotEqual(linesplit[5], "None")
9032 elif linesplit[0] == "None" and linesplit[1] == "8" and linesplit[2] == "S":
9033 self.assertNotEqual(linesplit[5], "None")
9034 elif linesplit[0] == "None" and linesplit[1] == "9" and linesplit[2] == "A":
9035 self.assertNotEqual(linesplit[5], "None")
9036 elif linesplit[0] == "None" and linesplit[1] == "10" and linesplit[2] == "L":
9037 self.assertNotEqual(linesplit[5], "None")
9038
9039
9040 theta_file.close()
9041
9042
9044 """System test of the value.write function to write return values of w_eff from calc_rotating_frame_params() function for an R1rho setup.
9045
9046 This uses the data of the saved state attached to U{bug #21344<https://web.archive.org/web/https://gna.org/bugs/?21344>}.
9047 """
9048
9049
9050 statefile = status.install_path+sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21344_trunc.bz2'
9051 self.interpreter.state.load(statefile, force=True)
9052
9053
9054 w_eff_filepath = ds.tmpdir+sep+'w_eff.out'
9055
9056
9057 self.interpreter.value.write(param='w_eff', file='w_eff.out', dir=ds.tmpdir, scaling=1.0, force=True)
9058
9059
9060 self.assert_(access(w_eff_filepath, F_OK))
9061
9062
9063 w_eff_file = open(w_eff_filepath, 'r')
9064
9065
9066 for line in w_eff_file:
9067
9068 if line[0] == "#":
9069 continue
9070
9071 print(line[:-1])
9072
9073
9074 linesplit = line.split()
9075
9076
9077 if linesplit[0] == "None" and linesplit[1] == "5" and linesplit[2] == "I":
9078 self.assertNotEqual(linesplit[5], "None")
9079 elif linesplit[0] == "None" and linesplit[1] == "6" and linesplit[2] == "S":
9080 self.assertNotEqual(linesplit[5], "None")
9081 elif linesplit[0] == "None" and linesplit[1] == "8" and linesplit[2] == "S":
9082 self.assertNotEqual(linesplit[5], "None")
9083 elif linesplit[0] == "None" and linesplit[1] == "9" and linesplit[2] == "A":
9084 self.assertNotEqual(linesplit[5], "None")
9085 elif linesplit[0] == "None" and linesplit[1] == "10" and linesplit[2] == "L":
9086 self.assertNotEqual(linesplit[5], "None")
9087
9088
9089 w_eff_file.close()
9090
9091
9093 """System test of the auto_analysis value.write function to write theta and w_eff values for an R1rho setup.
9094
9095 This uses the data of the saved state attached to U{bug #21344<https://web.archive.org/web/https://gna.org/bugs/?21344>}.
9096 """
9097
9098
9099 statefile = status.install_path+sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21344.bz2'
9100 self.interpreter.state.load(statefile, force=True)
9101
9102
9103 pipe_name = 'base pipe'
9104 pipe_bundle = 'relax_disp'
9105 pipe_type = 'relax_disp'
9106
9107
9108 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'Kjaergaard_et_al_2013'
9109
9110
9111 self.interpreter.deselect.all()
9112
9113
9114 select_spin_ids = [
9115 ":13@N",
9116 ":15@N",
9117 ":16@N",
9118 ":25@N",
9119 ":26@N",
9120 ":28@N",
9121 ":39@N",
9122 ":40@N",
9123 ":41@N",
9124 ":43@N",
9125 ":44@N",
9126 ":45@N",
9127 ":49@N",
9128 ":52@N",
9129 ":53@N"]
9130
9131
9132 for curspin in select_spin_ids:
9133 print("Selecting spin %s"%curspin)
9134 self.interpreter.deselect.reverse(spin_id=curspin)
9135
9136
9137 self.interpreter.relax_data.read(ri_id='R1', ri_type='R1', frq=cdp.spectrometer_frq_list[0], file='R1_fitted_values.txt', dir=data_path, mol_name_col=1, res_num_col=2, res_name_col=3, spin_num_col=4, spin_name_col=5, data_col=6, error_col=7)
9138
9139
9140 MODELS = ['R2eff']
9141
9142
9143 GRID_INC = 4
9144
9145
9146 MC_NUM = 3
9147
9148
9149 MODSEL = 'AIC'
9150
9151
9152
9153 OPT_FUNC_TOL = 1e-1
9154 relax_disp.Relax_disp.opt_func_tol = OPT_FUNC_TOL
9155 OPT_MAX_ITERATIONS = 1000
9156 relax_disp.Relax_disp.opt_max_iterations = OPT_MAX_ITERATIONS
9157
9158
9159 relax_disp.Relax_disp(pipe_name=pipe_name, pipe_bundle=pipe_bundle, results_dir=ds.tmpdir, models=MODELS, grid_inc=GRID_INC, mc_sim_num=MC_NUM, modsel=MODSEL)
9160
9161
9162
9163 theta_filepath = ds.tmpdir+sep+MODELS[0]+sep+'theta.out'
9164 w_eff_filepath = ds.tmpdir+sep+MODELS[0]+sep+'w_eff.out'
9165
9166
9167 self.assert_(access(theta_filepath, F_OK))
9168 self.assert_(access(w_eff_filepath, F_OK))
9169
9170
9171 theta_file = open(theta_filepath, 'r')
9172 theta_result = [
9173 "# Parameter description: Rotating frame tilt angle : ( theta = arctan(w_1 / Omega) ) (rad).\n",
9174 "#\n",
9175 "# mol_name res_num res_name spin_num spin_name r1rho_799.77739910_118.078_1341.110 sd(r1rho_799.77739910_118.078_1341.110) r1rho_799.77739910_118.078_1648.500 sd(r1rho_799.77739910_118.078_1648.500) r1rho_799.77739910_118.078_431.000 sd(r1rho_799.77739910_118.078_431.000) r1rho_799.77739910_118.078_651.200 sd(r1rho_799.77739910_118.078_651.200) r1rho_799.77739910_118.078_800.500 sd(r1rho_799.77739910_118.078_800.500) r1rho_799.77739910_118.078_984.000 sd(r1rho_799.77739910_118.078_984.000) r1rho_799.77739910_124.247_1341.110 sd(r1rho_799.77739910_124.247_1341.110) r1rho_799.77739910_130.416_1341.110 sd(r1rho_799.77739910_130.416_1341.110) r1rho_799.77739910_130.416_1648.500 sd(r1rho_799.77739910_130.416_1648.500) r1rho_799.77739910_130.416_800.500 sd(r1rho_799.77739910_130.416_800.500) r1rho_799.77739910_142.754_1341.110 sd(r1rho_799.77739910_142.754_1341.110) r1rho_799.77739910_142.754_800.500 sd(r1rho_799.77739910_142.754_800.500) r1rho_799.77739910_179.768_1341.110 sd(r1rho_799.77739910_179.768_1341.110) r1rho_799.77739910_241.459_1341.110 sd(r1rho_799.77739910_241.459_1341.110) \n",
9176 "None 5 I None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
9177 "None 6 S None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
9178 "None 8 S None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
9179 "None 9 A None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
9180 "None 10 L None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
9181 "None 11 Q None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
9182 "None 12 D None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
9183 "None 13 L None N 1.83827367612531 None 1.79015307643158 None 2.2768687598681 None 2.08461171779445 None 2.00120623474388 None 1.92825070277699 None 1.47212860033516 None 1.12978017906854 None 1.20415336139956 None 0.901691390796334 None 0.687390207543568 None 0.455635480573046 None 0.281637123971289 None 0.138259661766539 None \n",
9184 "None 14 L None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
9185 "None 15 R None N 1.58367544790673 None 1.58127411936947 None 1.61085209029811 None 1.59731540507347 None 1.59237108385522 None 1.58834866344307 None 1.2251048782537 None 0.938142786712004 None 1.03297495592991 None 0.683284686224254 None 0.594447788256641 None 0.383528609383686 None 0.262780814059893 None 0.133469839450564 None \n",
9186 "None 16 T None N 1.40984232256624 None 1.43947245672073 None 1.10299856647417 None 1.24811470332083 None 1.30521602599932 None 1.35302443831853 None 1.07923777467974 None 0.833345927788896 None 0.934350308974616 None 0.581325254389991 None 0.543659670184793 None 0.346238480454282 None 0.251454336191817 None 0.130436714663781 None \n",
9187 "None 17 L None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
9188 "None 18 K None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
9189 "None 19 S None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
9190 "None 21 S None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
9191 "None 24 Q None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
9192 "None 25 Q None N 1.81569700258844 None 1.77137827615015 None 2.23175875585624 None 2.04612705363098 None 1.9673155780155 None 1.89908711012298 None 1.44829660124856 None 1.11023386429581 None 1.18716091371256 None 0.877306975624962 None 0.677790118853413 None 0.447932002242236 None 0.279785379050945 None 0.137802891887767 None \n",
9193 "None 26 Q None N 1.61128821168674 None 1.60374392042003 None 1.69619923953765 None 1.65403989292986 None 1.63856717205868 None 1.62595755714564 None 1.24977859227795 None 0.956353494917591 None 1.04972090035774 None 0.702164059520172 None 0.603227813742091 None 0.390116910781037 None 0.264658552037535 None 0.133960994297096 None \n",
9194 "None 27 Q None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
9195 "None 28 Q None N 1.65182797011356 None 1.63676707684161 None 1.81830827892972 None 1.7365089711986 None 1.70601955220877 None 1.68102938663686 None 1.28685736157369 None 0.984047498595701 None 1.0749792109454 None 0.731585685663053 None 0.616577997665602 None 0.400219205533665 None 0.267471993812649 None 0.134690869499646 None \n",
9196 "None 29 V None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
9197 "None 30 L None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
9198 "None 31 N None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
9199 "None 32 I None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
9200 "None 33 L None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
9201 "None 34 K None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
9202 "None 35 S None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
9203 "None 36 N None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
9204 "None 38 Q None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
9205 "None 39 L None N 1.76426439181176 None 1.72885318885161 None 2.11826300085737 None 1.95430201082222 None 1.88794717058464 None 1.83172922971397 None 1.39549951193417 None 1.06783946148624 None 1.14997013232702 None 0.826128785942585 None 0.657105386950171 None 0.431542911580536 None 0.275725736430539 None 0.136791385554619 None \n",
9206 "None 40 M None N 1.5521741199158 None 1.55564594516135 None 1.51290906497298 None 1.53245929150759 None 1.53960430408466 None 1.54541832596591 None 1.19750223001929 None 0.917959090226757 None 1.01428385962747 None 0.662779584695967 None 0.584708929219264 None 0.376271266885303 None 0.260671619214194 None 0.132914250767089 None \n",
9207 "None 41 A None N 1.68339451828261 None 1.66252964414082 None 1.90911961276946 None 1.79959323497326 None 1.75801925517113 None 1.72370710837265 None 1.31646868936419 None 1.00647189763597 None 1.09525348649914 None 0.75605702767542 None 0.627395557358039 None 0.408481831044309 None 0.269716174238842 None 0.135267948387412 None \n",
9208 "None 42 A None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
9209 "None 43 F None N 1.58506597154432 None 1.58240542750303 None 1.61517196062351 None 1.60017740004898 None 1.59469990835425 None 1.59024353162528 None 1.22633651794829 None 0.939047922181951 None 1.03380990731605 None 0.684214484755514 None 0.594884298549546 None 0.383855128702894 None 0.262874695048502 None 0.13349447283116 None \n",
9210 "None 44 I None N 1.57575471961837 None 1.57483015671791 None 1.58622388390755 None 1.58100758841935 None 1.57910319967536 None 1.57755415552211 None 1.21811077066835 None 0.933010299763027 None 1.02823520295828 None 0.67802911457195 None 0.591972285081647 None 0.381678892926696 None 0.262247347241724 None 0.133329708422379 None \n",
9211 "None 45 K None N 1.77147501495754 None 1.73479633022489 None 2.13509660780385 None 1.96751045408372 None 1.89924480319914 None 1.84124387452692 None 1.40277881643715 None 1.07361367582571 None 1.15506365550891 None 0.832963505534767 None 0.659913187081268 None 0.433751178249555 None 0.276282572106685 None 0.13693095791902 None \n",
9212 "None 46 Q None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
9213 "None 48 T None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
9214 "None 49 A None N 2.00297059962685 None 1.92978318052058 None 2.53305709323468 None 2.33052197276846 None 2.22870514722639 None 2.13201782446864 None 1.6587904412969 None 1.29333162369472 None 1.34311052758116 None 1.12559033900783 None 0.770195063841652 None 0.524846264860003 None 0.296857751274362 None 0.141908833673671 None \n",
9215 "None 50 K None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
9216 "None 51 Y None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
9217 "None 52 V None N 1.82421571143794 None 1.77845404105203 None 2.24910726268822 None 2.06078232916932 None 1.98017451806059 None 1.91012195713554 None 1.45724107606646 None 1.11753869321304 None 1.19352234944057 None 0.886361068343012 None 0.681372607920812 None 0.450799407357501 None 0.280478735779163 None 0.137974257665877 None \n",
9218 "None 53 A None N 2.05019708195234 None 1.97089957318506 None 2.58789168363698 None 2.39027806684801 None 2.28731354878582 None 2.1872118539319 None 1.7165709935896 None 1.34832362477229 None 1.38879751095815 None 1.2085314357749 None 0.799450059125864 None 0.550583841461621 None 0.30195492609136 None 0.143090604877102 None \n",
9219 "None 54 N None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
9220 "None 55 Q None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
9221 "None 57 G None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
9222 "None 58 M None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
9223 "None 59 Q None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n"
9224 ]
9225
9226 lines = theta_file.readlines()
9227 for i in range(len(lines)):
9228
9229 if theta_result[i][0] == "#":
9230 self.assertEqual(theta_result[i], lines[i])
9231
9232 if theta_result[i] == lines[i]:
9233 self.assertEqual(theta_result[i], lines[i])
9234
9235 else:
9236
9237 print(theta_result[i])
9238 print(lines[i])
9239
9240
9241 self.assertEqual(theta_result[i][:62], lines[i][:62])
9242
9243
9244 theta_result_s = theta_result[i][62:].split()[::2]
9245 print(theta_result_s )
9246 lines_s = lines[i][62:].split()[::2]
9247 print(lines_s)
9248
9249 for j in range(len(lines_s)):
9250 print(theta_result_s[j], lines_s[j])
9251
9252 self.assertAlmostEqual(float(theta_result_s[j]), float(lines_s[j]), 14)
9253
9254
9255 theta_file.close()
9256
9257 w_eff_file = open(w_eff_filepath, 'r')
9258 w_eff_result = [
9259 "# Parameter description: Effective field in rotating frame : ( w_eff = sqrt(Omega^2 + w_1^2) ) (rad.s^-1).\n",
9260 "#\n",
9261 "# mol_name res_num res_name spin_num spin_name r1rho_799.77739910_118.078_1341.110 sd(r1rho_799.77739910_118.078_1341.110) r1rho_799.77739910_118.078_1648.500 sd(r1rho_799.77739910_118.078_1648.500) r1rho_799.77739910_118.078_431.000 sd(r1rho_799.77739910_118.078_431.000) r1rho_799.77739910_118.078_651.200 sd(r1rho_799.77739910_118.078_651.200) r1rho_799.77739910_118.078_800.500 sd(r1rho_799.77739910_118.078_800.500) r1rho_799.77739910_118.078_984.000 sd(r1rho_799.77739910_118.078_984.000) r1rho_799.77739910_124.247_1341.110 sd(r1rho_799.77739910_124.247_1341.110) r1rho_799.77739910_130.416_1341.110 sd(r1rho_799.77739910_130.416_1341.110) r1rho_799.77739910_130.416_1648.500 sd(r1rho_799.77739910_130.416_1648.500) r1rho_799.77739910_130.416_800.500 sd(r1rho_799.77739910_130.416_800.500) r1rho_799.77739910_142.754_1341.110 sd(r1rho_799.77739910_142.754_1341.110) r1rho_799.77739910_142.754_800.500 sd(r1rho_799.77739910_142.754_800.500) r1rho_799.77739910_179.768_1341.110 sd(r1rho_799.77739910_179.768_1341.110) r1rho_799.77739910_241.459_1341.110 sd(r1rho_799.77739910_241.459_1341.110) \n",
9262 "None 5 I None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
9263 "None 6 S None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
9264 "None 8 S None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
9265 "None 9 A None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
9266 "None 10 L None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
9267 "None 11 Q None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
9268 "None 12 D None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
9269 "None 13 L None N 8737.12883908829 None 10612.1226552258 None 3558.93734069587 None 4698.27194621826 None 5534.46153956037 None 6599.82570817753 None 8467.62674839481 None 9318.00441649087 None 11095.2662520767 None 6412.33580591254 None 13279.9803044242 None 11430.254637056 None 30318.7268264644 None 61141.1080046448 None \n",
9270 "None 14 L None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
9271 "None 15 R None N 8427.14155005377 None 10358.3995676635 None 2710.22680763322 None 4093.04942975722 None 5030.86065069262 None 6183.60685459024 None 8956.28403254202 None 10448.6627754369 None 12060.4428066937 None 7966.64282975241 None 15045.8392092364 None 13441.3586252373 None 32438.4764809909 None 63321.5201471181 None \n",
9272 "None 16 T None N 8536.7818857229 None 10447.792678989 None 3034.01707453628 None 4314.2767521567 None 5212.43600885913 None 6332.21319855067 None 9558.14311447582 None 11384.2336494604 None 12879.4604966293 None 9159.34604475399 None 16290.1746838959 None 14821.0200530829 None 33866.5933527757 None 64785.3205696403 None \n",
9273 "None 17 L None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
9274 "None 18 K None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
9275 "None 19 S None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
9276 "None 21 S None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
9277 "None 24 Q None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
9278 "None 25 Q None N 8685.60895531182 None 10569.7459677762 None 3430.51272680396 None 4601.75421490393 None 5452.76508815826 None 6531.46859076009 None 8490.06475886501 None 9406.58372902508 None 11169.7602637607 None 6540.38696356753 None 13437.7348017798 None 11613.1632549021 None 30514.0741594726 None 61342.4792156782 None \n",
9279 "None 26 Q None N 8433.35533683544 None 10363.4554631194 None 2729.48656005151 None 4105.82770792005 None 5041.26238350827 None 6192.07245313098 None 8880.08366342131 None 10312.6868786802 None 11942.8320576165 None 7787.44854491812 None 14853.4987024375 None 13225.7048162038 None 32213.6690023282 None 63090.7407990801 None \n",
9280 "None 27 Q None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
9281 "None 28 Q None N 8454.18308422202 None 10380.4112885894 None 2793.17494362899 None 4148.43953208179 None 5076.02756135055 None 6220.40920270029 None 8777.91538040813 None 10118.8737706315 None 11775.8792998529 None 7528.90766101027 None 14572.4015102398 None 12909.211050939 None 31882.8171856889 None 62750.9120842199 None \n",
9282 "None 29 V None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
9283 "None 30 L None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
9284 "None 31 N None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
9285 "None 32 I None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
9286 "None 33 L None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
9287 "None 34 K None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
9288 "None 35 S None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
9289 "None 36 N None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
9290 "None 38 Q None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
9291 "None 39 L None N 8586.6405431352 None 10488.5710521378 None 3171.59430904777 None 4412.11227722123 None 5293.69814015286 None 6399.27143075725 None 8557.58926327909 None 9617.45773774313 None 11347.9169998729 None 6840.20010813426 None 13795.1250622375 None 12024.9041436853 None 30951.651485352 None 61793.2130509111 None \n",
9292 "None 40 M None N 8427.90394711227 None 10359.0198301036 None 2712.59646573568 None 4094.61889210019 None 5032.13762965554 None 6184.6458240746 None 9049.68452800053 None 10607.7913029633 None 12198.5639821231 None 8174.23271685285 None 15266.4924700447 None 13687.9010998756 None 32694.9043143038 None 63584.6371927381 None \n",
9293 "None 41 A None N 8480.14299737436 None 10401.5648897003 None 2870.79081440785 None 4201.09083283266 None 5119.14733505123 None 6255.64579267482 None 8706.50768957471 None 9972.71017314947 None 11650.5225246067 None 7331.28858930568 None 14354.1616183112 None 12662.3378547029 None 31623.9195264738 None 62484.8290612112 None \n",
9294 "None 42 A None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
9295 "None 43 F None N 8427.30062786474 None 10358.5289868368 None 2710.7214015056 None 4093.37694357637 None 5031.12711571215 None 6183.82364721878 None 8952.31975962078 None 10441.7375680915 None 12054.4435931163 None 7957.55789315654 None 15036.1316712316 None 13430.4914212645 None 32427.1596037519 None 63309.9050677925 None \n",
9296 "None 44 I None N 8426.54623319716 None 10357.9152496503 None 2708.3751705368 None 4091.82359712664 None 5029.86337809029 None 6182.79552045043 None 8979.12144335458 None 10488.2688526334 None 12094.7720286018 None 8018.51779989075 None 15101.1843990883 None 13503.2816173444 None 32502.9389163062 None 63387.6763306952 None \n",
9297 "None 45 K None N 8599.01176345321 None 10498.7013581079 None 3204.93649737055 None 4436.14046641897 None 5313.74138343704 None 6415.86177652694 None 8546.79665373249 None 9587.16245449134 None 11322.2529042385 None 6797.53838612575 None 13745.1536613763 None 11967.5433300612 None 30890.8603419261 None 61730.6213936947 None \n",
9298 "None 46 Q None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
9299 "None 48 T None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
9300 "None 49 A None N 9279.63849130869 None 11063.0654625247 None 4737.11992391463 None 5643.40583860235 None 6356.45614406507 None 7302.87406141381 None 8459.17105047661 None 8761.54554569995 None 10632.2343488142 None 5572.92782399155 None 12102.1714908775 None 10037.6988885228 None 28806.6916858172 None 59579.0348769179 None \n",
9301 "None 50 K None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
9302 "None 51 Y None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
9303 "None 52 V None N 8704.45610117774 None 10585.2389163429 None 3477.9549539207 None 4637.22923167743 None 5482.73656118686 None 6556.5108895527 None 8481.06470969555 None 9372.86414918436 None 11141.3782476763 None 6491.79686536093 None 13378.2843939736 None 11544.3205736882 None 30440.62308788 None 61266.7742546508 None \n",
9304 "None 53 A None N 9497.02860450276 None 11246.0339326126 None 5149.96766581255 None 5994.15475647208 None 6669.81232845336 None 7577.19152075731 None 8516.77431951689 None 8639.36099840319 None 10531.7750336522 None 5378.79193153767 None 11752.8060152439 None 9613.59939949642 None 28334.9153747994 None 59090.2988815445 None \n",
9305 "None 54 N None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
9306 "None 55 Q None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
9307 "None 57 G None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
9308 "None 58 M None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n",
9309 "None 59 Q None N None None None None None None None None None None None None None None None None None None None None None None None None None None None None \n"
9310 ]
9311
9312 lines = w_eff_file.readlines()
9313 for i in range(len(lines)):
9314
9315 if w_eff_result[i][0] == "#":
9316 self.assertEqual(w_eff_result[i], lines[i])
9317
9318 if w_eff_result[i] == lines[i]:
9319 self.assertEqual(w_eff_result[i], lines[i])
9320
9321 else:
9322
9323 print(w_eff_result[i])
9324 print(lines[i])
9325
9326
9327 self.assertEqual(w_eff_result[i][:62], lines[i][:62])
9328
9329
9330 w_eff_result_s = w_eff_result[i][62:].split()[::2]
9331 print(w_eff_result_s )
9332 lines_s = lines[i][62:].split()[::2]
9333 print(lines_s)
9334
9335 for j in range(len(lines_s)):
9336 print(w_eff_result_s[j], lines_s[j])
9337
9338 self.assertAlmostEqual(float(w_eff_result_s[j]), float(lines_s[j]), 14)
9339
9340
9341 w_eff_file.close()
9342
9343
9345 """Test the user function for estimating R2eff errors from exponential curve fitting, and compare it with Monte-Carlo simulations.
9346
9347 This follows Task 7822.
9348 U{task #7822<https://web.archive.org/web/https://gna.org/task/index.php?7822>}: Implement user function to estimate R2eff and associated errors for exponential curve fitting.
9349
9350 This uses the data from Kjaergaard's paper at U{DOI: 10.1021/bi4001062<http://dx.doi.org/10.1021/bi4001062>}.
9351 Optimisation of the Kjaergaard et al., 2013 Off-resonance R1rho relaxation dispersion experiments using the 'DPL' model.
9352 """
9353
9354
9355 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'Kjaergaard_et_al_2013'+sep
9356
9357
9358 pipe_name = 'base pipe'
9359 pipe_bundle = 'relax_disp'
9360 pipe_type = 'relax_disp'
9361
9362
9363 self.interpreter.pipe.create(pipe_name=pipe_name, bundle=pipe_bundle, pipe_type=pipe_type)
9364
9365 file = data_path + '1_setup_r1rho_GUI.py'
9366 self.interpreter.script(file=file, dir=None)
9367
9368
9369 self.interpreter.deselect.spin(spin_id=':1-100', change_all=False)
9370
9371
9372 self.interpreter.select.spin(spin_id=':52@N', change_all=False)
9373
9374
9375 self.interpreter.relax_disp.select_model(MODEL_R2EFF)
9376
9377
9378 check_intensity_errors()
9379
9380
9381 self.interpreter.minimise.grid_search(lower=None, upper=None, inc=11, constraints=True, verbosity=1)
9382
9383
9384 min_algor = 'Newton'
9385 constraints = True
9386 if constraints:
9387 min_options = ('%s'%(min_algor),)
9388
9389 min_algor = 'Method of Multipliers'
9390 scaling_matrix = assemble_scaling_matrix(scaling=True)
9391
9392
9393 all_spin_ids = []
9394 for cur_spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
9395 all_spin_ids.append(spin_id)
9396
9397 spins = spin_ids_to_containers(all_spin_ids[:1])
9398
9399
9400 A, b = linear_constraints(spins=spins, scaling_matrix=scaling_matrix[0])
9401 else:
9402 min_options = ()
9403 A, b = None, None
9404 min_options = ()
9405 sim_boot = 200
9406 scaling_list = [1.0, 1.0]
9407
9408
9409 self.interpreter.minimise.execute(min_algor=min_algor, constraints=constraints, verbosity=1)
9410
9411
9412 err_attr_list = ['r2eff_err', 'i0_err']
9413
9414 for cur_spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
9415
9416 for err_attr in err_attr_list:
9417 if hasattr(cur_spin, err_attr):
9418 delattr(cur_spin, err_attr)
9419
9420
9421 my_dic = {}
9422 param_key_list = []
9423 est_keys = []
9424 est_key = '-2'
9425 est_keys.append(est_key)
9426 spin_id_list = []
9427
9428 for cur_spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
9429
9430 my_dic[spin_id] = {}
9431
9432
9433 my_dic[spin_id][est_key] = {}
9434
9435
9436 spin_id_list.append(spin_id)
9437
9438
9439 spin_string = generate_spin_string(spin=cur_spin, mol_name=mol_name, res_num=resi, res_name=resn)
9440
9441 for exp_type, frq, offset, point, ei, mi, oi, di in loop_exp_frq_offset_point(return_indices=True):
9442
9443 param_key = return_param_key_from_data(exp_type=exp_type, frq=frq, offset=offset, point=point)
9444
9445
9446 param_key_list.append(param_key)
9447
9448
9449 my_dic[spin_id][est_key][param_key] = {}
9450
9451 values = []
9452 errors = []
9453 times = []
9454 for time in loop_time(exp_type=exp_type, frq=frq, offset=offset, point=point):
9455 values.append(average_intensity(spin=cur_spin, exp_type=exp_type, frq=frq, offset=offset, point=point, time=time))
9456 errors.append(average_intensity(spin=cur_spin, exp_type=exp_type, frq=frq, offset=offset, point=point, time=time, error=True))
9457 times.append(time)
9458
9459
9460 values = asarray(values)
9461 errors = asarray(errors)
9462 times = asarray(times)
9463
9464 r2eff = getattr(cur_spin, 'r2eff')[param_key]
9465 i0 = getattr(cur_spin, 'i0')[param_key]
9466
9467 R_m_sim_l = []
9468 I0_m_sim_l = []
9469 for j in range(sim_boot):
9470 if j in range(0, 100000, 100):
9471 print("Simulation %i"%j)
9472
9473
9474
9475 I_err = []
9476 for j, error in enumerate(errors):
9477 I_error = gauss(values[j], error)
9478 I_err.append(I_error)
9479
9480 I_err = asarray(I_err)
9481
9482 x0 = [r2eff, i0]
9483 model = Relax_fit_opt(num_params=len(x0), values=I_err, errors=errors, relax_times=times, scaling_matrix=scaling_list)
9484
9485
9486
9487
9488
9489
9490
9491
9492 params_minfx_sim_j, chi2_minfx_sim_j, iter_count, f_count, g_count, h_count, warning = generic_minimise(func=model.func, dfunc=model.dfunc, d2func=model.d2func, args=(), x0=x0, min_algor=min_algor, min_options=min_options, A=A, b=b, full_output=True, print_flag=0)
9493
9494 R_m_sim_j, I0_m_sim_j = params_minfx_sim_j
9495 R_m_sim_l.append(R_m_sim_j)
9496 I0_m_sim_l.append(I0_m_sim_j)
9497
9498
9499 sigma_R_sim = std(asarray(R_m_sim_l), ddof=1)
9500 sigma_I0_sim = std(asarray(I0_m_sim_l), ddof=1)
9501 my_dic[spin_id][est_key][param_key]['r2eff_err'] = sigma_R_sim
9502 my_dic[spin_id][est_key][param_key]['i0_err'] = sigma_I0_sim
9503
9504
9505 self.interpreter.relax_disp.r2eff_err_estimate()
9506
9507 est_key = '-1'
9508 est_keys.append(est_key)
9509
9510
9511 for cur_spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
9512
9513 my_dic[spin_id][est_key] = {}
9514
9515 for exp_type, frq, offset, point, ei, mi, oi, di in loop_exp_frq_offset_point(return_indices=True):
9516
9517 param_key = return_param_key_from_data(exp_type=exp_type, frq=frq, offset=offset, point=point)
9518
9519
9520 my_dic[spin_id][est_key][param_key] = {}
9521
9522
9523
9524 for err_attr in err_attr_list:
9525 if hasattr(cur_spin, err_attr):
9526 get_err_attr = getattr(cur_spin, err_attr)[param_key]
9527 else:
9528 get_err_attr = 0.0
9529
9530
9531 my_dic[spin_id][est_key][param_key][err_attr] = get_err_attr
9532
9533
9534
9535 mc_number_list = list(range(0, 1000, 250))
9536
9537 sim_attr_list = ['chi2_sim', 'f_count_sim', 'g_count_sim', 'h_count_sim', 'i0_sim', 'iter_sim', 'peak_intensity_sim', 'r2eff_sim', 'select_sim', 'warning_sim']
9538
9539
9540 for number in mc_number_list:
9541
9542 for cur_spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
9543
9544 for err_attr in err_attr_list:
9545 if hasattr(cur_spin, err_attr):
9546 delattr(cur_spin, err_attr)
9547
9548
9549 for sim_attr in sim_attr_list:
9550 if hasattr(cur_spin, sim_attr):
9551 delattr(cur_spin, sim_attr)
9552
9553 self.interpreter.monte_carlo.setup(number=number)
9554 self.interpreter.monte_carlo.create_data()
9555 self.interpreter.monte_carlo.initial_values()
9556 self.interpreter.minimise.execute(min_algor=min_algor, constraints=constraints)
9557 self.interpreter.eliminate()
9558 self.interpreter.monte_carlo.error_analysis()
9559
9560 est_key = '%i'%number
9561 est_keys.append(est_key)
9562
9563
9564 for cur_spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
9565
9566 my_dic[spin_id][est_key] = {}
9567
9568 for exp_type, frq, offset, point, ei, mi, oi, di in loop_exp_frq_offset_point(return_indices=True):
9569
9570 param_key = return_param_key_from_data(exp_type=exp_type, frq=frq, offset=offset, point=point)
9571
9572
9573 my_dic[spin_id][est_key][param_key] = {}
9574
9575
9576
9577 for err_attr in err_attr_list:
9578 if hasattr(cur_spin, err_attr):
9579 get_err_attr = getattr(cur_spin, err_attr)[param_key]
9580 else:
9581 get_err_attr = 0.0
9582
9583
9584 my_dic[spin_id][est_key][param_key][err_attr] = get_err_attr
9585
9586
9587 err_attr = err_attr_list[0]
9588
9589
9590 text_list = []
9591
9592
9593 for spin_id in spin_id_list:
9594 for est_key in est_keys:
9595
9596 r2eff_err_list = []
9597
9598 for param_key in param_key_list:
9599
9600 r2eff_err = my_dic[spin_id][est_key][param_key][err_attr]
9601
9602
9603 r2eff_err_list.append(r2eff_err)
9604
9605
9606 sum_array = sum(array(r2eff_err_list))
9607
9608
9609 r2eff_err_str = " ".join(format(x, "2.3f") for x in r2eff_err_list)
9610
9611
9612 text = "%8s %s sum= %2.3f" % (est_key, r2eff_err_str, sum_array)
9613 text_list.append(text)
9614
9615
9616
9617 filepath = NamedTemporaryFile(delete=False).name
9618
9619 w_file = open(filepath, 'w')
9620
9621 print("Printing the estimated R2eff error as function of estimation from Co-variance and number of Monte-Carlo simulations.")
9622
9623 for text in text_list:
9624
9625 print(text)
9626
9627
9628 w_file.write(text+"\n")
9629
9630
9631 w_file.close()
9632
9633 print("Filepath is: %s"%filepath)
9634 print("Start 'gnuplot' and write:")
9635 print("set term dumb")
9636 print("plot '%s' using 1:17 title 'R2eff error as function of MC number' w linespoints "%filepath)
9637
9638
9640 """Verification of test_r1rho_kjaergaard_missing_r1."""
9641
9642
9643
9644
9645
9646 print("\n\n################")
9647 print("Printing results")
9648 print("################\n")
9649 for model in models:
9650
9651 if model == MODEL_R2EFF:
9652 continue
9653
9654
9655 self.interpreter.pipe.switch(pipe_name='%s - relax_disp' % (model))
9656 print("\nModel: %s" % (model))
9657
9658
9659 for cur_spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
9660
9661 spin_string = generate_spin_string(spin=cur_spin, mol_name=mol_name, res_num=resi, res_name=resn)
9662
9663
9664 print("Optimised parameters for spin: %s" % (spin_string))
9665 for param in cur_spin.params + ['chi2']:
9666
9667 if param in ['r1', 'r2']:
9668 for exp_type, frq, ei, mi in loop_exp_frq(return_indices=True):
9669
9670 r20_key = generate_r20_key(exp_type=exp_type, frq=frq)
9671
9672
9673 value = getattr(cur_spin, param)[r20_key]
9674
9675
9676 print("%-10s %-6s %-6s %3.8f" % ("Parameter:", param, "Value:", value))
9677
9678
9679 if spin_id == ':52@N':
9680 if param == 'r1':
9681 if model == MODEL_NOREX:
9682 if r2eff_estimate == 'direct':
9683 self.assertAlmostEqual(value, 1.46138805)
9684 elif r2eff_estimate == 'MC2000':
9685 self.assertAlmostEqual(value, 1.46328102)
9686 elif r2eff_estimate == 'chi2_pyt':
9687 self.assertAlmostEqual(value, 1.43820629)
9688 elif model == MODEL_DPL94:
9689 if r2eff_estimate == 'direct':
9690 self.assertAlmostEqual(value, 1.44845742)
9691 elif r2eff_estimate == 'MC2000':
9692 self.assertAlmostEqual(value, 1.45019848)
9693 elif r2eff_estimate == 'chi2_pyt':
9694 self.assertAlmostEqual(value, 1.44666512)
9695 elif model == MODEL_TP02:
9696 if r2eff_estimate == 'direct':
9697 self.assertAlmostEqual(value, 1.54354392)
9698 elif r2eff_estimate == 'MC2000':
9699 self.assertAlmostEqual(value, 1.54352369)
9700 elif r2eff_estimate == 'chi2_pyt':
9701 self.assertAlmostEqual(value, 1.55964020)
9702 elif model == MODEL_TAP03:
9703 if r2eff_estimate == 'direct':
9704 self.assertAlmostEqual(value, 1.54356410)
9705 elif r2eff_estimate == 'MC2000':
9706 self.assertAlmostEqual(value, 1.54354367)
9707 elif r2eff_estimate == 'chi2_pyt':
9708 self.assertAlmostEqual(value, 1.55967157)
9709 elif model == MODEL_MP05:
9710 if r2eff_estimate == 'direct':
9711 self.assertAlmostEqual(value, 1.54356416)
9712 elif r2eff_estimate == 'MC2000':
9713 self.assertAlmostEqual(value, 1.54354372)
9714 elif r2eff_estimate == 'chi2_pyt':
9715 self.assertAlmostEqual(value, 1.55967163)
9716 elif model == MODEL_NS_R1RHO_2SITE:
9717 if r2eff_estimate == 'direct':
9718 self.assertAlmostEqual(value, 1.41359221, 5)
9719 elif r2eff_estimate == 'MC2000':
9720 self.assertAlmostEqual(value, 1.41321968, 5)
9721 elif r2eff_estimate == 'chi2_pyt':
9722 self.assertAlmostEqual(value, 1.36303129, 5)
9723
9724 elif param == 'r2':
9725 if model == MODEL_NOREX:
9726 if r2eff_estimate == 'direct':
9727 self.assertAlmostEqual(value, 11.48392439)
9728 elif r2eff_estimate == 'MC2000':
9729 self.assertAlmostEqual(value, 11.48040934)
9730 elif r2eff_estimate == 'chi2_pyt':
9731 self.assertAlmostEqual(value, 11.47224488)
9732 elif model == MODEL_DPL94:
9733 if r2eff_estimate == 'direct':
9734 self.assertAlmostEqual(value, 10.15688372, 6)
9735 elif r2eff_estimate == 'MC2000':
9736 self.assertAlmostEqual(value, 10.16304887, 6)
9737 elif r2eff_estimate == 'chi2_pyt':
9738 self.assertAlmostEqual(value, 9.20037797, 6)
9739 elif model == MODEL_TP02:
9740 if r2eff_estimate == 'direct':
9741 self.assertAlmostEqual(value, 9.72654896, 6)
9742 elif r2eff_estimate == 'MC2000':
9743 self.assertAlmostEqual(value, 9.72772726, 6)
9744 elif r2eff_estimate == 'chi2_pyt':
9745 self.assertAlmostEqual(value, 9.53948340, 6)
9746 elif model == MODEL_TAP03:
9747 if r2eff_estimate == 'direct':
9748 self.assertAlmostEqual(value, 9.72641887, 6)
9749 elif r2eff_estimate == 'MC2000':
9750 self.assertAlmostEqual(value, 9.72759374, 6)
9751 elif r2eff_estimate == 'chi2_pyt':
9752 self.assertAlmostEqual(value, 9.53926913, 6)
9753 elif model == MODEL_MP05:
9754 if r2eff_estimate == 'direct':
9755 self.assertAlmostEqual(value, 9.72641723, 6)
9756 elif r2eff_estimate == 'MC2000':
9757 self.assertAlmostEqual(value, 9.72759220, 6)
9758 elif r2eff_estimate == 'chi2_pyt':
9759 self.assertAlmostEqual(value, 9.53926778, 6)
9760 elif model == MODEL_NS_R1RHO_2SITE:
9761 if r2eff_estimate == 'direct':
9762 self.assertAlmostEqual(value, 9.34531535, 5)
9763 elif r2eff_estimate == 'MC2000':
9764 self.assertAlmostEqual(value, 9.34602793, 5)
9765 elif r2eff_estimate == 'chi2_pyt':
9766 self.assertAlmostEqual(value, 9.17631409, 5)
9767
9768
9769 else:
9770
9771 value = getattr(cur_spin, param)
9772
9773
9774 print("%-10s %-6s %-6s %3.8f" % ("Parameter:", param, "Value:", value))
9775
9776
9777 if spin_id == ':52@N':
9778 if param == 'phi_ex':
9779 if model == MODEL_DPL94:
9780 if r2eff_estimate == 'direct':
9781 self.assertAlmostEqual(value, 0.07599563)
9782 elif r2eff_estimate == 'MC2000':
9783 self.assertAlmostEqual(value, 0.07561937)
9784 elif r2eff_estimate == 'chi2_pyt':
9785 self.assertAlmostEqual(value, 0.12946061)
9786
9787 elif param == 'pA':
9788 if model == MODEL_TP02:
9789 if r2eff_estimate == 'direct':
9790 self.assertAlmostEqual(value, 0.88827040)
9791 elif r2eff_estimate == 'MC2000':
9792 self.assertAlmostEqual(value, 0.88807487)
9793 elif r2eff_estimate == 'chi2_pyt':
9794 self.assertAlmostEqual(value, 0.87746233)
9795 elif model == MODEL_TAP03:
9796 if r2eff_estimate == 'direct':
9797 self.assertAlmostEqual(value, 0.88828922)
9798 elif r2eff_estimate == 'MC2000':
9799 self.assertAlmostEqual(value, 0.88809318)
9800 elif r2eff_estimate == 'chi2_pyt':
9801 self.assertAlmostEqual(value, 0.87747558)
9802 elif model == MODEL_MP05:
9803 if r2eff_estimate == 'direct':
9804 self.assertAlmostEqual(value, 0.88828924, 6)
9805 elif r2eff_estimate == 'MC2000':
9806 self.assertAlmostEqual(value, 0.88809321)
9807 elif r2eff_estimate == 'chi2_pyt':
9808 self.assertAlmostEqual(value, 0.87747562)
9809 elif model == MODEL_NS_R1RHO_2SITE:
9810 if r2eff_estimate == 'direct':
9811 self.assertAlmostEqual(value, 0.94504369, 6)
9812 elif r2eff_estimate == 'MC2000':
9813 self.assertAlmostEqual(value, 0.94496541, 6)
9814 elif r2eff_estimate == 'chi2_pyt':
9815 self.assertAlmostEqual(value, 0.92084707, 6)
9816
9817 elif param == 'dw':
9818 if model == MODEL_TP02:
9819 if r2eff_estimate == 'direct':
9820 self.assertAlmostEqual(value, 1.08875840, 6)
9821 elif r2eff_estimate == 'MC2000':
9822 self.assertAlmostEqual(value, 1.08765638, 6)
9823 elif r2eff_estimate == 'chi2_pyt':
9824 self.assertAlmostEqual(value, 1.09753230, 6)
9825 elif model == MODEL_TAP03:
9826 if r2eff_estimate == 'direct':
9827 self.assertAlmostEqual(value, 1.08837238, 6)
9828 elif r2eff_estimate == 'MC2000':
9829 self.assertAlmostEqual(value, 1.08726698, 6)
9830 elif r2eff_estimate == 'chi2_pyt':
9831 self.assertAlmostEqual(value, 1.09708821, 6)
9832 elif model == MODEL_MP05:
9833 if r2eff_estimate == 'direct':
9834 self.assertAlmostEqual(value, 1.08837241, 6)
9835 elif r2eff_estimate == 'MC2000':
9836 self.assertAlmostEqual(value, 1.08726706, 6)
9837 elif r2eff_estimate == 'chi2_pyt':
9838 self.assertAlmostEqual(value, 1.09708832, 6)
9839 elif model == MODEL_NS_R1RHO_2SITE:
9840 if r2eff_estimate == 'direct':
9841 self.assertAlmostEqual(value, 1.56001812, 5)
9842 elif r2eff_estimate == 'MC2000':
9843 self.assertAlmostEqual(value, 1.55833321, 5)
9844 elif r2eff_estimate == 'chi2_pyt':
9845 self.assertAlmostEqual(value, 1.36406712, 5)
9846
9847 elif param == 'kex':
9848 if model == MODEL_DPL94:
9849 if r2eff_estimate == 'direct':
9850 self.assertAlmostEqual(value/1e5, 4460.43711569/1e5, 7)
9851 elif r2eff_estimate == 'MC2000':
9852 self.assertAlmostEqual(value/1e5, 4419.03917195/1e5, 7)
9853 elif r2eff_estimate == 'chi2_pyt':
9854 self.assertAlmostEqual(value/1e5, 6790.22736344/1e5, 7)
9855 elif model == MODEL_TP02:
9856 if r2eff_estimate == 'direct':
9857 self.assertAlmostEqual(value/1e5, 4921.28602757/1e5, 7)
9858 elif r2eff_estimate == 'MC2000':
9859 self.assertAlmostEqual(value/1e5, 4904.70144883/1e5, 7)
9860 elif r2eff_estimate == 'chi2_pyt':
9861 self.assertAlmostEqual(value/1e5, 5146.20306591/1e5, 7)
9862 elif model == MODEL_TAP03:
9863 if r2eff_estimate == 'direct':
9864 self.assertAlmostEqual(value/1e5, 4926.42963491/1e5, 7)
9865 elif r2eff_estimate == 'MC2000':
9866 self.assertAlmostEqual(value/1e5, 4909.86877150/1e5, 7)
9867 elif r2eff_estimate == 'chi2_pyt':
9868 self.assertAlmostEqual(value/1e5, 5152.51105814/1e5, 7)
9869 elif model == MODEL_MP05:
9870 if r2eff_estimate == 'direct':
9871 self.assertAlmostEqual(value/1e5, 4926.44236315/1e5, 7)
9872 elif r2eff_estimate == 'MC2000':
9873 self.assertAlmostEqual(value/1e5, 4909.88110195/1e5, 7)
9874 elif r2eff_estimate == 'chi2_pyt':
9875 self.assertAlmostEqual(value/1e5, 5152.52097111/1e5, 7)
9876 elif model == MODEL_NS_R1RHO_2SITE:
9877 if r2eff_estimate == 'direct':
9878 self.assertAlmostEqual(value/1e5, 5628.66061488/1e5, 6)
9879 elif r2eff_estimate == 'MC2000':
9880 self.assertAlmostEqual(value/1e5, 5610.20221435/1e5, 6)
9881 elif r2eff_estimate == 'chi2_pyt':
9882 self.assertAlmostEqual(value/1e5, 5643.34067090/1e5, 6)
9883
9884 elif param == 'chi2':
9885 if model == MODEL_NOREX:
9886 if r2eff_estimate == 'direct':
9887 self.assertAlmostEqual(value, 848.42016907, 5)
9888 elif r2eff_estimate == 'MC2000':
9889 self.assertAlmostEqual(value, 3363.95829122, 5)
9890 elif r2eff_estimate == 'chi2_pyt':
9891 self.assertAlmostEqual(value, 5976.49946726, 5)
9892 elif model == MODEL_DPL94:
9893 if r2eff_estimate == 'direct':
9894 self.assertAlmostEqual(value, 179.47041241)
9895 elif r2eff_estimate == 'MC2000':
9896 self.assertAlmostEqual(value, 710.24767560)
9897 elif r2eff_estimate == 'chi2_pyt':
9898 self.assertAlmostEqual(value, 612.72616697, 5)
9899 elif model == MODEL_TP02:
9900 if r2eff_estimate == 'direct':
9901 self.assertAlmostEqual(value, 29.33882530, 6)
9902 elif r2eff_estimate == 'MC2000':
9903 self.assertAlmostEqual(value, 114.47142772, 6)
9904 elif r2eff_estimate == 'chi2_pyt':
9905 self.assertAlmostEqual(value, 250.50838162, 5)
9906 elif model == MODEL_TAP03:
9907 if r2eff_estimate == 'direct':
9908 self.assertAlmostEqual(value, 29.29050673, 6)
9909 elif r2eff_estimate == 'MC2000':
9910 self.assertAlmostEqual(value, 114.27987534)
9911 elif r2eff_estimate == 'chi2_pyt':
9912 self.assertAlmostEqual(value, 250.04050719, 5)
9913 elif model == MODEL_MP05:
9914 if r2eff_estimate == 'direct':
9915 self.assertAlmostEqual(value, 29.29054301, 6)
9916 elif r2eff_estimate == 'MC2000':
9917 self.assertAlmostEqual(value, 114.28002272)
9918 elif r2eff_estimate == 'chi2_pyt':
9919 self.assertAlmostEqual(value, 250.04077478, 5)
9920 elif model == MODEL_NS_R1RHO_2SITE:
9921 if r2eff_estimate == 'direct':
9922 self.assertAlmostEqual(value, 34.44010543, 6)
9923 elif r2eff_estimate == 'MC2000':
9924 self.assertAlmostEqual(value, 134.14368365)
9925 elif r2eff_estimate == 'chi2_pyt':
9926 self.assertAlmostEqual(value, 278.55121388, 5)
9927
9928
9929
9930 model = 'final'
9931 self.interpreter.pipe.switch(pipe_name='%s - relax_disp' % (model))
9932 print("\nFinal pipe")
9933
9934
9935 for cur_spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
9936
9937 spin_string = generate_spin_string(spin=cur_spin, mol_name=mol_name, res_num=resi, res_name=resn)
9938
9939
9940 print("Optimised model for spin: %s" % (spin_string))
9941 param = 'model'
9942
9943
9944 value = getattr(cur_spin, param)
9945 print("%-10s %-6s %-6s %6s" % ("Parameter:", param, "Value:", value))
9946
9947
9948
9949 file_names = ['r1rho_prime', 'r1']
9950
9951 for file_name_i in file_names:
9952
9953
9954 file_name = "%s.out" % file_name_i
9955
9956
9957 file_path = get_file_path(file_name, result_dir_name + sep + model)
9958
9959
9960 print("Testing file access to: %s"%file_path)
9961 self.assert_(access(file_path, F_OK))
9962
9963
9964 file_prod = open(file_path)
9965 lines_prod = file_prod.readlines()
9966 file_prod.close()
9967
9968
9969 for i, line in enumerate(lines_prod):
9970
9971 line_split = line.split()
9972
9973
9974 if line_split[0] == "#":
9975 print(line),
9976 continue
9977
9978
9979 mol_name, res_num, res_name, spin_num, spin_name, val, sd_error = line_split
9980 print(mol_name, res_num, res_name, spin_num, spin_name, val, sd_error)
9981
9982 if res_num == '52':
9983
9984 self.assertNotEqual(val, 'None')
9985