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 from numpy import array, median
27 import re, math
28 from tempfile import mkdtemp
29
30
31 from auto_analyses import relax_disp
32 from data_store import Relax_data_store; ds = Relax_data_store()
33 import dep_check
34 from pipe_control.mol_res_spin import return_spin, spin_loop
35 from specific_analyses.relax_disp.data import generate_r20_key, get_curve_type, loop_exp_frq, loop_exp_frq_offset_point, return_param_key_from_data
36 from specific_analyses.relax_disp.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_R1RHO, MODEL_B14, MODEL_B14_FULL, MODEL_CR72, MODEL_CR72_FULL, MODEL_IT99, MODEL_LM63, MODEL_M61B, MODEL_NOREX, MODEL_NS_CPMG_2SITE_3D_FULL, MODEL_NS_CPMG_2SITE_EXPANDED, MODEL_NS_CPMG_2SITE_STAR_FULL, MODEL_PARAMS, MODEL_R2EFF
37 from status import Status; status = Status()
38 from test_suite.system_tests.base_classes import SystemTestCase
39
40
42 """Class for testing various aspects specific to relaxation dispersion curve-fitting."""
43
44 - def __init__(self, methodName='runTest'):
45 """Skip certain tests if the C modules are non-functional.
46
47 @keyword methodName: The name of the test.
48 @type methodName: str
49 """
50
51
52 super(Relax_disp, self).__init__(methodName)
53
54
55 if not dep_check.C_module_exp_fn:
56
57 to_skip = [
58 "test_bug_21344_sparse_time_spinlock_acquired_r1rho_fail_relax_disp",
59 "test_exp_fit",
60 "test_m61_exp_data_to_m61",
61 "test_r1rho_kjaergaard",
62 "test_value_write_calc_rotating_frame_params_auto_analysis"
63 ]
64
65
66 if methodName in to_skip:
67 status.skipped_tests.append([methodName, 'Relax curve-fitting C module', self._skip_type])
68
69
71 """Set up for all the functional tests."""
72
73
74 self.interpreter.pipe.create('relax_disp', 'relax_disp')
75
76
77 ds.tmpdir = mkdtemp()
78 self.tmpdir = ds.tmpdir
79
80
82 """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.
83
84 @keyword folder: The name of the folder for the test data.
85 @type folder: str
86 @keyword model_analyse: The name of the model which will be tested.
87 @type model_analyse: str
88 """
89
90 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'Hansen'
91
92
93 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_22146_unpacking_r2a_r2b_cluster'+sep+folder
94
95
96
97 sfrq_1 = 500.0*1E6
98 r20_key_1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=sfrq_1)
99 time_T2_1 = 0.05
100 ncycs_1 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 40, 50]
101
102
103 r2eff_errs_1 = [0.0] * len(ncycs_1)
104 exp_1 = [sfrq_1, time_T2_1, ncycs_1, r2eff_errs_1]
105
106 sfrq_2 = 600.0*1E6
107 r20_key_2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=sfrq_2)
108 time_T2_2 = 0.06
109 ncycs_2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 40, 60]
110
111
112 r2eff_errs_2 = [0.0] * len(ncycs_2)
113 exp_2 = [sfrq_2, time_T2_2, ncycs_2, r2eff_errs_2]
114
115 sfrq_3 = 700.0*1E6
116 r20_key_3 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=sfrq_3)
117 time_T2_3 = 0.07
118 ncycs_3 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 50, 70]
119
120
121 r2eff_errs_3 = [0.0] * len(ncycs_3)
122 exp_3 = [sfrq_3, time_T2_3, ncycs_3, r2eff_errs_3]
123
124
125 exps = [exp_1, exp_2, exp_3]
126
127 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]
128 dw_arr = [1.0, 2.0, 3.0, 4.0]
129 pA_arr = [0.9]
130 kex_arr = [1000.]
131
132 spins = [
133 ['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]}],
134 ['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]}],
135 ['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]}],
136 ['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]}],
137 ]
138
139
140 pipe_name = 'base pipe'
141 pipe_type = 'relax_disp'
142 pipe_bundle = 'relax_disp'
143 self.interpreter.pipe.create(pipe_name=pipe_name, pipe_type=pipe_type, bundle = pipe_bundle)
144
145
146 for res_name, res_num, spin_name, params in spins:
147 self.interpreter.spin.create(res_name=res_name, res_num=res_num, spin_name=spin_name)
148
149
150 self.interpreter.spin.isotope('15N', spin_id='@N')
151
152
153 exp_ids = []
154 for exp in exps:
155 sfrq, time_T2, ncycs, r2eff_errs = exp
156 exp_id = 'CPMG_%3.1f' % (sfrq/1E6)
157 exp_ids.append(exp_id)
158
159 ids = []
160 for ncyc in ncycs:
161 nu_cpmg = ncyc / time_T2
162 cur_id = '%s_%.1f' % (exp_id, nu_cpmg)
163 ids.append(cur_id)
164
165
166 self.interpreter.spectrometer.frequency(id=cur_id, frq=sfrq)
167
168
169 self.interpreter.relax_disp.exp_type(spectrum_id=cur_id, exp_type=EXP_TYPE_CPMG_SQ)
170
171
172 self.interpreter.relax_disp.relax_time(spectrum_id=cur_id, time=time_T2)
173
174
175 self.interpreter.relax_disp.cpmg_setup(spectrum_id=cur_id, cpmg_frq=nu_cpmg)
176
177 print("\n\nThe experiment IDs are %s." % cdp.spectrum_ids)
178
179
180
181
182 pipe_name_MODEL = "%s_%s"%(pipe_name, model_analyse)
183 self.interpreter.pipe.copy(pipe_from=pipe_name, pipe_to=pipe_name_MODEL, bundle_to = pipe_bundle)
184 self.interpreter.pipe.switch(pipe_name=pipe_name_MODEL)
185
186
187 for exp_type, frq, ei, mi in loop_exp_frq(return_indices=True):
188 exp_id = exp_ids[mi]
189 exp = exps[mi]
190 sfrq, time_T2, ncycs, r2eff_errs = exp
191
192
193 for res_name, res_num, spin_name, params in spins:
194 cur_spin_id = ":%i@%s"%(res_num, spin_name)
195
196
197 file_name = "%s%s.txt" % (exp_id, cur_spin_id .replace('#', '_').replace(':', '_').replace('@', '_'))
198
199
200 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)
201
202
203 self.interpreter.relax_disp.select_model(model=model_analyse)
204
205
206 self.interpreter.relax_disp.cluster('model_cluster', ":1-100")
207
208
209 low_arr = R20 + dw_arr + pA_arr + kex_arr
210 self.interpreter.grid_search(lower=low_arr, upper=low_arr, inc=1, constraints=True, verbosity=1)
211
212
213 for i in range(len(spins)):
214 res_name, res_num, spin_name, params = spins[i]
215 cur_spin_id = ":%i@%s"%(res_num, spin_name)
216 cur_spin = return_spin(cur_spin_id)
217
218 for mo_param in cur_spin.params:
219 print(mo_param)
220
221 if isinstance(getattr(cur_spin, mo_param), dict):
222 for key, val in getattr(cur_spin, mo_param).items():
223 should_be = params[mo_param][key]
224 print(cur_spin.model, res_name, cur_spin_id, mo_param, key, float(val), should_be)
225 self.assertAlmostEqual(val, should_be)
226 else:
227 should_be = float(params[mo_param])
228 val = getattr(cur_spin, mo_param)
229 print(cur_spin.model, res_name, cur_spin_id, mo_param, val, should_be)
230 self.assertAlmostEqual(val, should_be)
231
232
233
234 self.assertAlmostEqual(cur_spin.chi2, 0.0, places = places)
235
236
269
270
298
299
301 """Set up the data for the test_korzhnev_2005_data_*() system tests using the 'NS MMQ 2-site' model.
302
303 This loads the proton-heteronuclear SQ, ZQ, DQ, and MQ (MMQ) data from:
304
305 - 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>}).
306
307 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.
308
309
310 @keyword data_list: The list of data to load. It can contain 'SQ', '1H SQ', 'ZQ', 'DQ', 'MQ', and '1H MQ'.
311 @type data_list: list of str
312 """
313
314
315 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'Korzhnev_et_al_2005'
316 self.interpreter.pipe.create(pipe_name='Korzhnev et al., 2005', pipe_type='relax_disp')
317
318
319 self.interpreter.spin.create(res_name='Asp', res_num=9, spin_name='H')
320 self.interpreter.spin.create(res_name='Asp', res_num=9, spin_name='N')
321 self.interpreter.spin.element('H', spin_id='@H')
322 self.interpreter.spin.element('N', spin_id='@N')
323 self.interpreter.spin.isotope('1H', spin_id='@H')
324 self.interpreter.spin.isotope('15N', spin_id='@N')
325
326
327 self.interpreter.interatom.define(spin_id1=':9@N', spin_id2=':9@H', direct_bond=True)
328
329
330 data = [
331 ['1H SQ', '1H_SQ_CPMG_500_MHz', 'hs_500.res', EXP_TYPE_CPMG_PROTON_SQ, ':9@H', 500e6, 0.03],
332 ['1H SQ', '1H_SQ_CPMG_600_MHz', 'hs_600.res', EXP_TYPE_CPMG_PROTON_SQ, ':9@H', 600e6, 0.03],
333 ['1H SQ', '1H_SQ_CPMG_800_MHz', 'hs_800.res', EXP_TYPE_CPMG_PROTON_SQ, ':9@H', 800e6, 0.03],
334 ['SQ', '15N_SQ_CPMG_500_MHz', 'ns_500.res', EXP_TYPE_CPMG_SQ, ':9@N', 500e6, 0.04],
335 ['SQ', '15N_SQ_CPMG_600_MHz', 'ns_600.res', EXP_TYPE_CPMG_SQ, ':9@N', 600e6, 0.04],
336 ['SQ', '15N_SQ_CPMG_800_MHz', 'ns_800.res', EXP_TYPE_CPMG_SQ, ':9@N', 800e6, 0.04],
337 ['DQ', '15N_DQ_CPMG_500_MHz', 'dq_500.res', EXP_TYPE_CPMG_DQ, ':9@N', 500e6, 0.03],
338 ['DQ', '15N_DQ_CPMG_600_MHz', 'dq_600.res', EXP_TYPE_CPMG_DQ, ':9@N', 600e6, 0.03],
339 ['DQ', '15N_DQ_CPMG_800_MHz', 'dq_800.res', EXP_TYPE_CPMG_DQ, ':9@N', 800e6, 0.03],
340 ['ZQ', '15N_ZQ_CPMG_500_MHz', 'zq_500.res', EXP_TYPE_CPMG_ZQ, ':9@N', 500e6, 0.03],
341 ['ZQ', '15N_ZQ_CPMG_600_MHz', 'zq_600.res', EXP_TYPE_CPMG_ZQ, ':9@N', 600e6, 0.03],
342 ['ZQ', '15N_ZQ_CPMG_800_MHz', 'zq_800.res', EXP_TYPE_CPMG_ZQ, ':9@N', 800e6, 0.03],
343 ['1H MQ', '1H_MQ_CPMG_500_MHz', 'hm_500.res', EXP_TYPE_CPMG_PROTON_MQ, ':9@H', 500e6, 0.02],
344 ['1H MQ', '1H_MQ_CPMG_600_MHz', 'hm_600.res', EXP_TYPE_CPMG_PROTON_MQ, ':9@H', 600e6, 0.02],
345 ['1H MQ', '1H_MQ_CPMG_800_MHz', 'hm_800.res', EXP_TYPE_CPMG_PROTON_MQ, ':9@H', 800e6, 0.02],
346 ['MQ', '15N_MQ_CPMG_500_MHz', 'nm_500.res', EXP_TYPE_CPMG_MQ, ':9@N', 500e6, 0.02],
347 ['MQ', '15N_MQ_CPMG_600_MHz', 'nm_600.res', EXP_TYPE_CPMG_MQ, ':9@N', 600e6, 0.02],
348 ['MQ', '15N_MQ_CPMG_800_MHz', 'nm_800.res', EXP_TYPE_CPMG_MQ, ':9@N', 800e6, 0.02]
349 ]
350 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]
351 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]
352 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]
353 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]
354 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]
355 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]
356
357
358 for data_type, id, file, exp_type, spin_id, H_frq, relax_time in data:
359
360 if data_type not in data_list:
361 continue
362
363
364 if data_type == 'SQ':
365 cpmg_frqs = cpmg_frqs_sq
366 elif data_type == '1H SQ':
367 cpmg_frqs = cpmg_frqs_1h_sq
368 elif data_type == 'DQ':
369 cpmg_frqs = cpmg_frqs_dq
370 elif data_type == 'ZQ':
371 cpmg_frqs = cpmg_frqs_zq
372 elif data_type == '1H MQ':
373 cpmg_frqs = cpmg_frqs_1h_mq
374 elif data_type == 'MQ':
375 cpmg_frqs = cpmg_frqs_mq
376
377
378 for cpmg_frq in cpmg_frqs:
379
380 new_id = "%s_%s" % (id, cpmg_frq)
381
382
383 self.interpreter.spectrometer.frequency(id=new_id, frq=H_frq)
384
385
386 self.interpreter.relax_disp.exp_type(spectrum_id=new_id, exp_type=exp_type)
387
388
389 self.interpreter.relax_disp.relax_time(spectrum_id=new_id, time=relax_time)
390
391
392 self.interpreter.relax_disp.cpmg_setup(spectrum_id=new_id, cpmg_frq=cpmg_frq)
393
394
395 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)
396
397
398 self.interpreter.relax_disp.select_model('NS MMQ 2-site')
399
400
401 - def setup_sod1wt_t25(self, pipe_name, pipe_type, pipe_name_r2eff, select_spin_index):
402 """Setup of data SOD1-WT CPMG. From paper at U{http://dx.doi.org/10.1073/pnas.0907387106}.
403
404 Optimisation of Kaare Teilum, Melanie H. Smith, Eike Schulz, Lea C. Christensen, Gleb Solomentseva, Mikael Oliveberg, and Mikael Akkea 2009
405 'SOD1-WT' CPMG data to the CR72 dispersion model.
406
407 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.
408 Data is for experiment at 25 degree Celcius.
409 """
410
411
412 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'sod1wt_t25'
413
414
415 Exps = [
416 ["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"] ],
417 ["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"] ] ]
418
419
420 self.interpreter.pipe.create(pipe_name=pipe_name, pipe_type=pipe_type)
421
422
423 id_lists = []
424 for folder, key, sfrq, time_T2, ncycs, rep_ncyss in Exps:
425
426 self.interpreter.spectrum.read_spins(file="128_FT.ser", dir=data_path+sep+folder)
427 self.interpreter.spectrum.read_spins(file="128_FT.ser", dir=data_path+sep+folder)
428
429
430 id_list = list(key+str(i) for i in range(len(ncycs)))
431 id_lists.append(id_list)
432
433
434 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))) )
435
436
437 for i in range(len(ncycs)):
438 ncyc = ncycs[i]
439 vcpmg = ncyc/time_T2
440
441
442 if float(vcpmg) == 0.0:
443 vcpmg = None
444 else:
445 vcpmg = round(float(vcpmg), 3)
446
447
448 current_id = id_list[i]
449
450
451 self.interpreter.relax_disp.exp_type(spectrum_id=current_id, exp_type='SQ CPMG')
452
453
454 self.interpreter.spectrometer.frequency(id=current_id, frq=sfrq, units='Hz')
455
456
457 self.interpreter.relax_disp.relax_time(spectrum_id=current_id, time=time_T2)
458
459
460 self.interpreter.relax_disp.cpmg_setup(spectrum_id=current_id, cpmg_frq=vcpmg)
461
462
463 self.interpreter.spectrum.replicated(spectrum_ids=Exps[0][5])
464 self.interpreter.spectrum.replicated(spectrum_ids=Exps[1][5])
465
466
467 self.interpreter.spectrum.error_analysis(subset=id_lists[0])
468 self.interpreter.spectrum.error_analysis(subset=id_lists[1])
469
470
471 self.interpreter.spin.isotope(isotope='15N')
472
473
474
475
476 glob_assn = ["G10N-H", "D11N-H", "Q15N-H", "G16N-H", "G37N-H", "G41N-H", "L42N-H", "H43N-H", "H46N-H", "V47N-H", "E49N-H",
477 "E50N-H", "E51N-H", "N53N-H", "T54N-H", "G56N-H", "C57N-H", "T58N-H", "G61N-H", "H63aN-H", "F64aN-H", "N65aN-H",
478 "L67N-H", "S68N-H", "K70N-H", "G72N-H", "G73N-H", "K75N-H", "E78N-H", "R79N-H", "H80N-H", "V81N-H", "G82N-H",
479 "G85N-H", "N86N-H", "V87N-H", "S102N-H", "V103N-H", "I104N-H", "S105N-H", "A111N-H", "I112N-H", "R115N-H",
480 "V118N-H", "E121N-H", "A123N-H", "L126N-H", "G127N-H", "K128N-H", "G129N-H", "G130N-H", "N131N-H", "E133N-H",
481 "S134N-H", "T135N-H", "T137N-H", "G138N-H", "N139N-H", "A140N-H", "G141N-H", "S142N-H", "R143N-H", "C146N-H", "G147N-H"]
482
483
484 self.assertEqual(64, len(glob_assn ))
485
486
487
488 r = re.compile("([a-zA-Z]+)([0-9]+)([a-zA-Z]+)")
489
490
491 relax_glob_ids = []
492
493
494 for assn in glob_assn:
495
496 m = r.match(assn)
497
498 relax_string = ":%s@%s"%(m.group(2), m.group(3))
499
500
501 relax_glob_ids.append([m.group(0), m.group(1), m.group(2), m.group(3), relax_string])
502
503
504
505
506 self.interpreter.deselect.all()
507
508
509 for i in select_spin_index:
510 self.interpreter.select.spin(spin_id=relax_glob_ids[i][4], change_all=False)
511
512
513
514
515 self.interpreter.pipe.copy(pipe_from=pipe_name, pipe_to=pipe_name_r2eff)
516 self.interpreter.pipe.switch(pipe_name=pipe_name_r2eff)
517
518
519 MODEL = "R2eff"
520 self.interpreter.relax_disp.select_model(model=MODEL)
521
522 self.interpreter.calc(verbosity=1)
523
524
526 """Test synthetic data of Andrew J. Baldwin B14 model whereby the simplification R20A = R20B is assumed.
527
528 Support requst sr #3154 U{https://web.archive.org/web/https://gna.org/support/index.php?3154}.
529
530 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.
531 """
532
533
534 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'Baldwin_2014'
535
536
537 pipe_name = 'base pipe'
538 pipe_type = 'relax_disp'
539 pipe_name_r2eff = "%s_R2eff"%(pipe_name)
540
541
542 self.interpreter.pipe.create(pipe_name=pipe_name, pipe_type=pipe_type)
543
544
545 self.interpreter.spin.create(res_name='Ala', res_num=1, spin_name='H')
546
547
548 self.interpreter.spin.isotope('1H', spin_id='@H')
549
550
551
552 ncycs = [2, 4, 8, 10, 20, 40, 500]
553 ids = []
554 for ncyc in ncycs:
555 ids.append('CPMG_%s' % ncyc)
556
557 print("\n\nThe experiment IDs are %s." % ids)
558
559
560
561 sfrq= 200. * 1E6
562
563
564 Trelax=0.04
565
566
567 for i in range(len(ids)):
568 id = ids[i]
569
570 self.interpreter.spectrometer.frequency(id=id, frq=sfrq)
571
572
573 self.interpreter.relax_disp.exp_type(spectrum_id=id, exp_type='SQ CPMG')
574
575
576 self.interpreter.relax_disp.relax_time(spectrum_id=id, time=Trelax)
577
578
579 ncyc = ncycs[i]
580 nu_cpmg = ncyc / Trelax
581 self.interpreter.relax_disp.cpmg_setup(spectrum_id=id, cpmg_frq=nu_cpmg)
582
583
584 self.interpreter.pipe.copy(pipe_from=pipe_name, pipe_to=pipe_name_r2eff)
585 self.interpreter.pipe.switch(pipe_name=pipe_name_r2eff)
586
587
588 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)
589
590
591 data = [
592 ['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}],
593 ['cpmg_frqs_list', list(array(ncycs)/Trelax) ],
594 ['dispersion_points', len(ncycs)],
595 ['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'}],
596 ['exp_type_list', ['SQ CPMG']],
597 ['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}],
598 ['spectrometer_frq_count', 1],
599 ['spectrometer_frq_list', [sfrq]],
600 ['spectrum_ids', ['CPMG_2', 'CPMG_4', 'CPMG_8', 'CPMG_10', 'CPMG_20', 'CPMG_40', 'CPMG_500']]
601 ]
602 for name, value in data:
603
604 self.assert_(hasattr(cdp, name))
605
606
607 obj = getattr(cdp, name)
608 if not isinstance(data, dict):
609 self.assertEqual(obj, value)
610
611
612 else:
613 for id in ids:
614 self.assertEqual(obj[id], value[id])
615
616
617 n_data = [
618 [ 50.000000, 10.367900, 0.1],
619 [ 100.000000, 10.146849, 0.1],
620 [ 200.000000, 9.765987, 0.1],
621 [ 250.000000, 9.409789, 0.1],
622 [ 500.000000, 5.829819, 0.1],
623 [ 1000.000000, 3.191928, 0.1],
624 [ 12500.000000, 2.008231, 0.1]
625 ]
626 for disp_point, value, error in n_data:
627 id = 'sq_cpmg_200.00000000_0.000_%.3f' % disp_point
628 self.assertEqual(cdp.mol[0].res[0].spin[0].r2eff[id], value)
629 self.assertEqual(cdp.mol[0].res[0].spin[0].r2eff_err[id], error)
630
631
632 r20_key = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=sfrq)
633
634
635 MODEL = "B14"
636
637
638 pipe_name_MODEL = "%s_%s"%(pipe_name, MODEL)
639 self.interpreter.pipe.copy(pipe_from=pipe_name_r2eff, pipe_to=pipe_name_MODEL)
640 self.interpreter.pipe.switch(pipe_name=pipe_name_MODEL)
641
642
643 self.interpreter.relax_disp.select_model(model=MODEL)
644
645
646 grid_results = []
647 mini_results = []
648
649
650
651
652 GRID = 13
653
654 if GRID:
655
656
657 self.interpreter.relax_disp.r20_from_min_r2eff(force=False)
658
659
660 self.interpreter.grid_search(lower=None, upper=None, inc=GRID, constraints=True, verbosity=1)
661
662
663 else:
664 for param in MODEL_PARAMS[MODEL]:
665 self.interpreter.value.set(param=param, index=None)
666
667 self.interpreter.grid_search(lower=None, upper=None, inc=1, constraints=True, verbosity=1)
668
669
670 for spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
671 grid_results.append([spin.r2[r20_key], spin.dw, spin.pA, spin.kex, spin.chi2, spin_id, resi, resn])
672
673
674
675 set_func_tol = 1e-10
676 set_max_iter = 1000
677 self.interpreter.minimise(min_algor='simplex', func_tol=set_func_tol, max_iter=set_max_iter, constraints=True, scaling=True, verbosity=1)
678
679
680 for spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
681 mini_results.append([spin.r2[r20_key], spin.dw, spin.pA, spin.kex, spin.chi2, spin_id, resi, resn])
682
683
684 for i in range(len(grid_results)):
685 g_r2, g_dw, g_pA, g_kex, g_chi2, g_spin_id, g_resi, g_resn = grid_results[i]
686 m_r2, m_dw, m_pA, m_kex, m_chi2, m_spin_id, m_resi, m_resn = mini_results[i]
687 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))
688 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))
689
690
691
692 kex=1000.
693
694 pb=0.01
695
696 dw_ppm=2.
697
698 R2g=2.
699
700 R2e=2.
701
702
703
704 self.assertAlmostEqual(cdp.mol[0].res[0].spin[0].r2[r20_key], R2g, 6)
705
706 self.assertAlmostEqual(cdp.mol[0].res[0].spin[0].dw, dw_ppm, 6)
707 self.assertAlmostEqual(cdp.mol[0].res[0].spin[0].pA, 1-pb, 8)
708 self.assertAlmostEqual(cdp.mol[0].res[0].spin[0].kex, kex, 3)
709
710
712 """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}.
713
714 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>}."""
715
716
717 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'Baldwin_2014'
718
719
720 pipe_name = 'base pipe'
721 pipe_type = 'relax_disp'
722 pipe_name_r2eff = "%s_R2eff"%(pipe_name)
723
724
725 self.interpreter.pipe.create(pipe_name=pipe_name, pipe_type=pipe_type)
726
727
728
729 self.interpreter.spin.create(res_name='Ala', res_num=1, spin_name='H')
730
731
732 self.interpreter.spin.isotope('1H', spin_id='@H')
733
734
735
736 ncycs = [2, 4, 8, 10, 20, 40, 500]
737 ids = []
738 for ncyc in ncycs:
739 ids.append('CPMG_%s' % ncyc)
740
741 print("\n\nThe experiment IDs are %s." % ids)
742
743
744
745 sfrq= 200. * 1E6
746
747
748 Trelax=0.04
749
750
751 for i in range(len(ids)):
752 id = ids[i]
753
754 self.interpreter.spectrometer.frequency(id=id, frq=sfrq)
755
756
757 self.interpreter.relax_disp.exp_type(spectrum_id=id, exp_type='SQ CPMG')
758
759
760 self.interpreter.relax_disp.relax_time(spectrum_id=id, time=Trelax)
761
762
763 ncyc = ncycs[i]
764 nu_cpmg = ncyc / Trelax
765 self.interpreter.relax_disp.cpmg_setup(spectrum_id=id, cpmg_frq=nu_cpmg)
766
767
768 self.interpreter.pipe.copy(pipe_from=pipe_name, pipe_to=pipe_name_r2eff)
769 self.interpreter.pipe.switch(pipe_name=pipe_name_r2eff)
770
771
772 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)
773
774
775 data = [
776 ['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}],
777 ['cpmg_frqs_list', list(array(ncycs)/Trelax) ],
778 ['dispersion_points', len(ncycs)],
779 ['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'}],
780 ['exp_type_list', ['SQ CPMG']],
781 ['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}],
782 ['spectrometer_frq_count', 1],
783 ['spectrometer_frq_list', [sfrq]],
784 ['spectrum_ids', ['CPMG_2', 'CPMG_4', 'CPMG_8', 'CPMG_10', 'CPMG_20', 'CPMG_40', 'CPMG_500']]
785 ]
786 for name, value in data:
787
788 self.assert_(hasattr(cdp, name))
789
790
791 obj = getattr(cdp, name)
792 if not isinstance(data, dict):
793 self.assertEqual(obj, value)
794
795
796 else:
797 for id in ids:
798 self.assertEqual(obj[id], value[id])
799
800
801 n_data = [
802 [ 50.000000, 10.286255, 0.1],
803 [ 100.000000, 10.073083, 0.1],
804 [ 200.000000, 9.692746, 0.1],
805 [ 250.000000, 9.382441, 0.1],
806 [ 500.000000, 6.312396, 0.1],
807 [ 1000.000000, 3.957029, 0.1],
808 [ 12500.000000, 2.880420, 0.1]
809 ]
810 for disp_point, value, error in n_data:
811 id = 'sq_cpmg_200.00000000_0.000_%.3f' % disp_point
812 self.assertEqual(cdp.mol[0].res[0].spin[0].r2eff[id], value)
813 self.assertEqual(cdp.mol[0].res[0].spin[0].r2eff_err[id], error)
814
815
816 r20_key = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=sfrq)
817
818
819 MODEL = "B14 full"
820
821
822 pipe_name_MODEL = "%s_%s"%(pipe_name, MODEL)
823 self.interpreter.pipe.copy(pipe_from=pipe_name_r2eff, pipe_to=pipe_name_MODEL)
824 self.interpreter.pipe.switch(pipe_name=pipe_name_MODEL)
825
826
827 self.interpreter.relax_disp.select_model(model=MODEL)
828
829
830 grid_results = []
831 mini_results = []
832 clust_results = []
833
834
835
836
837 GRID = 13
838
839 if GRID:
840
841
842 self.interpreter.relax_disp.r20_from_min_r2eff(force=False)
843
844
845 self.interpreter.grid_search(lower=None, upper=None, inc=GRID, constraints=True, verbosity=1)
846
847
848 else:
849 for param in MODEL_PARAMS[MODEL]:
850 self.interpreter.value.set(param=param, index=None)
851
852 self.interpreter.grid_search(lower=None, upper=None, inc=1, constraints=True, verbosity=1)
853
854
855 for spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
856 grid_results.append([spin.r2a[r20_key], spin.r2b[r20_key], spin.dw, spin.pA, spin.kex, spin.chi2, spin_id, resi, resn])
857
858
859
860 set_func_tol = 1e-11
861 set_max_iter = 10000
862 self.interpreter.minimise(min_algor='simplex', func_tol=set_func_tol, max_iter=set_max_iter, constraints=True, scaling=True, verbosity=1)
863
864
865 for spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
866 mini_results.append([spin.r2a[r20_key], spin.r2b[r20_key], spin.dw, spin.pA, spin.kex, spin.chi2, spin_id, resi, resn])
867
868 print("\n# Now print before and after minimisation-\n")
869
870
871 for i in range(len(grid_results)):
872 g_r2a, g_r2b, g_dw, g_pA, g_kex, g_chi2, g_spin_id, g_resi, g_resn = grid_results[i]
873 m_r2a, m_r2b, m_dw, m_pA, m_kex, m_chi2, m_spin_id, m_resi, m_resn = mini_results[i]
874 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))
875 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))
876
877
878
879 kex=1000.
880
881 pb=0.01
882
883 dw_ppm=2.
884
885 R2g=2.
886
887 R2e=100.
888
889
890
891 self.assertAlmostEqual(cdp.mol[0].res[0].spin[0].r2a[r20_key], R2g, 4)
892 self.assertAlmostEqual(cdp.mol[0].res[0].spin[0].r2b[r20_key], R2e, 2)
893
894 self.assertAlmostEqual(cdp.mol[0].res[0].spin[0].dw, dw_ppm, 6)
895 self.assertAlmostEqual(cdp.mol[0].res[0].spin[0].pA, 1-pb, 6)
896 self.assertAlmostEqual(cdp.mol[0].res[0].spin[0].kex, kex, 2)
897
898
900 """U{Bug #21081<https://web.archive.org/web/https://gna.org/bugs/?21081>} catch, the failure of a cluster analysis when spins are deselected."""
901
902
903 self.interpreter.reset()
904
905
906 state = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'saved_states'+sep+'bug_21081_disp_cluster_fail.bz2'
907 self.interpreter.state.load(state, force=True)
908
909
910 self.interpreter.model_selection(method='AIC', modsel_pipe='final', bundle='relax_disp', pipes=['No Rex', 'CR72'])
911
912
914 """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."""
915
916
917 self.interpreter.reset()
918
919
920 state = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'saved_states'+sep+'bug_21460_bad_fields.bz2'
921 self.interpreter.state.load(state, force=True)
922
923
924 relax_disp.Relax_disp.opt_func_tol = 1e-5
925 relax_disp.Relax_disp.opt_max_iterations = 1000
926 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)
927
928
930 """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."""
931
932
933 self.interpreter.reset()
934
935
936 state = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21344_trunc.bz2'
937 self.interpreter.state.load(state, force=True)
938
939
940 relax_disp.Relax_disp.opt_func_tol = 1e-5
941 relax_disp.Relax_disp.opt_max_iterations = 1000
942 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)
943
944
946 """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 calc()."""
947
948
949 self.interpreter.reset()
950
951
952 state = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21665.bz2'
953 self.interpreter.state.load(state, force=True)
954
955
956 self.interpreter.calc(verbosity=1)
957
958
960 """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."""
961
962
963 self.interpreter.reset()
964
965
966 state = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21665.bz2'
967 self.interpreter.state.load(state, force=True)
968
969
970 relax_disp.Relax_disp.opt_func_tol = 1e-5
971 relax_disp.Relax_disp.opt_max_iterations = 1000
972 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)
973
974
976 """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."""
977
978
979 self.interpreter.reset()
980
981
982 state = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21715_clustered_indexerror'+sep+'state.bz2'
983 self.interpreter.state.load(state, force=True)
984
985
986 pre_run_dir = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21715_clustered_indexerror'+sep+'non_clustered'
987 relax_disp.Relax_disp.opt_func_tol = 1e-5
988 relax_disp.Relax_disp.opt_max_iterations = 1000
989 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=2, modsel='AIC', pre_run_dir=pre_run_dir, insignificance=1.0, numeric_only=True, mc_sim_all_models=False, eliminate=True)
990
991
993 """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."""
994
995
996 self.setup_bug_22146_unpacking_r2a_r2b_cluster(folder='B14_full', model_analyse = MODEL_B14_FULL)
997
998
1000 """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."""
1001
1002
1003 self.setup_bug_22146_unpacking_r2a_r2b_cluster(folder='CR72_full', model_analyse = MODEL_CR72_FULL)
1004
1005
1011
1012
1018
1019
1021 """Test synthetic cpmg data.
1022
1023 This script will produce synthetic CPMG R2eff values according to the NS CPMG 2-site 3D model, and the fit the data with CR72.
1024 """
1025
1026
1027
1028
1029
1030 model_create = 'NS CPMG 2-site 3D'
1031
1032 model_analyse = 'CR72'
1033
1034 sfrq_1 = 599.8908617*1E6
1035 r20_key_1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=sfrq_1)
1036 time_T2_1 = 0.06
1037 ncycs_1 = [2, 4, 8, 10, 20, 30, 40, 60]
1038 r2eff_err_1 = [0, 0, 0, 0, 0, 0, 0, 0]
1039 exp_1 = [sfrq_1, time_T2_1, ncycs_1, r2eff_err_1]
1040
1041 sfrq_2 = 499.8908617*1E6
1042 r20_key_2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=sfrq_2)
1043 time_T2_2 = 0.05
1044 ncycs_2 = [2, 4, 8, 10, 30, 35, 40, 50]
1045 r2eff_err_2 = [0, 0, 0, 0, 0, 0, 0, 0]
1046 exp_2 = [sfrq_2, time_T2_2, ncycs_2, r2eff_err_2]
1047
1048
1049 exps = [exp_1, exp_2]
1050
1051 spins = [
1052 ['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.} ]
1053 ]
1054
1055
1056 ds.data = [model_create, model_analyse, spins, exps]
1057
1058
1059 ds.tmpdir = ds.tmpdir
1060
1061
1062
1063 ds.resdir = ds.tmpdir
1064
1065
1066 ds.r20_from_min_r2eff = True
1067
1068
1069 ds.insignificance = 0.0
1070
1071
1072 ds.GRID_INC = 8
1073
1074
1075 ds.do_cluster = False
1076
1077
1078
1079 ds.set_func_tol = 1e-9
1080
1081
1082
1083 ds.set_max_iter = 1000
1084
1085
1086 ds.verbosity = 1
1087
1088
1089 ds.rel_change = 0.05
1090
1091
1092 ds.plot_curves = False
1093
1094
1095 ds.sherekhan_input = False
1096
1097
1098 ds.opendx = False
1099
1100
1101 ds.r2eff_err = 0.1
1102
1103
1104 ds.print_res = False
1105
1106
1107 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'cpmg_synthetic.py')
1108
1109 cur_spins = ds.data[2]
1110
1111 for i in range(len(cur_spins)):
1112 res_name, res_num, spin_name, params = cur_spins[i]
1113 cur_spin_id = ":%i@%s"%(res_num, spin_name)
1114 cur_spin = return_spin(cur_spin_id)
1115
1116 grid_params = ds.grid_results[i][3]
1117 min_params = ds.min_results[i][3]
1118
1119 print("For spin: '%s'"%cur_spin_id)
1120 for mo_param in cur_spin.params:
1121
1122 if isinstance(getattr(cur_spin, mo_param), dict):
1123 grid_r2 = grid_params[mo_param]
1124 min_r2 = min_params[mo_param]
1125 set_r2 = params[mo_param]
1126 for key, val in set_r2.items():
1127 grid_r2_frq = grid_r2[key]
1128 min_r2_frq = min_r2[key]
1129 set_r2_frq = set_r2[key]
1130 frq = float(key.split(EXP_TYPE_CPMG_SQ+' - ')[-1].split('MHz')[0])
1131 rel_change = math.sqrt( (min_r2_frq - set_r2_frq)**2/(min_r2_frq)**2 )
1132 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) )
1133 if rel_change > ds.rel_change:
1134 print("WARNING: rel change level is above %.2f, and is %.4f."%(ds.rel_change, rel_change))
1135 print("###################################")
1136
1137
1138 self.assertAlmostEqual(set_r2_frq, min_r2_frq, 2)
1139 else:
1140 grid_val = grid_params[mo_param]
1141 min_val = min_params[mo_param]
1142 set_val = params[mo_param]
1143 rel_change = math.sqrt( (min_val - set_val)**2/(min_val)**2 )
1144 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) )
1145 if rel_change > ds.rel_change:
1146 print("WARNING: rel change level is above %.2f, and is %.4f."%(ds.rel_change, rel_change))
1147 print("###################################")
1148
1149
1150 if mo_param == 'dw':
1151 self.assertAlmostEqual(set_val/10, min_val/10, 1)
1152 elif mo_param == 'kex':
1153 self.assertAlmostEqual(set_val/1000, min_val/1000, 1)
1154 elif mo_param == 'pA':
1155 self.assertAlmostEqual(set_val, min_val, 3)
1156
1157
1159 """Test synthetic cpmg data.
1160
1161 This script will produce synthetic CPMG R2eff values according to the NS CPMG 2-site 3D model, and the fit the data with B14.
1162 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.
1163 """
1164
1165
1166
1167
1168
1169 model_create = 'NS CPMG 2-site 3D'
1170
1171 model_analyse = 'B14'
1172
1173 sfrq_1 = 599.8908617*1E6
1174 r20_key_1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=sfrq_1)
1175 time_T2_1 = 0.06
1176 ncycs_1 = [2, 4, 8, 10, 20, 30, 40, 60]
1177 r2eff_err_1 = [0, 0, 0, 0, 0, 0, 0, 0]
1178 exp_1 = [sfrq_1, time_T2_1, ncycs_1, r2eff_err_1]
1179
1180 sfrq_2 = 499.8908617*1E6
1181 r20_key_2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=sfrq_2)
1182 time_T2_2 = 0.05
1183 ncycs_2 = [2, 4, 8, 10, 30, 35, 40, 50]
1184 r2eff_err_2 = [0, 0, 0, 0, 0, 0, 0, 0]
1185 exp_2 = [sfrq_2, time_T2_2, ncycs_2, r2eff_err_2]
1186
1187
1188 exps = [exp_1, exp_2]
1189
1190 spins = [
1191 ['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.} ]
1192 ]
1193
1194
1195 ds.data = [model_create, model_analyse, spins, exps]
1196
1197
1198 ds.tmpdir = ds.tmpdir
1199
1200
1201
1202 ds.resdir = ds.tmpdir
1203
1204
1205 ds.r20_from_min_r2eff = True
1206
1207
1208 ds.insignificance = 0.0
1209
1210
1211 ds.GRID_INC = 8
1212
1213
1214 ds.do_cluster = False
1215
1216
1217
1218 ds.set_func_tol = 1e-9
1219
1220
1221
1222 ds.set_max_iter = 1000
1223
1224
1225 ds.verbosity = 1
1226
1227
1228 ds.rel_change = 0.05
1229
1230
1231 ds.plot_curves = False
1232
1233
1234 ds.sherekhan_input = False
1235
1236
1237 ds.opendx = False
1238
1239
1240 ds.r2eff_err = 0.1
1241
1242
1243 ds.print_res = False
1244
1245
1246 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'cpmg_synthetic.py')
1247
1248 cur_spins = ds.data[2]
1249
1250 for i in range(len(cur_spins)):
1251 res_name, res_num, spin_name, params = cur_spins[i]
1252 cur_spin_id = ":%i@%s"%(res_num, spin_name)
1253 cur_spin = return_spin(cur_spin_id)
1254
1255 grid_params = ds.grid_results[i][3]
1256 min_params = ds.min_results[i][3]
1257
1258 print("For spin: '%s'"%cur_spin_id)
1259 for mo_param in cur_spin.params:
1260
1261 if isinstance(getattr(cur_spin, mo_param), dict):
1262 grid_r2 = grid_params[mo_param]
1263 min_r2 = min_params[mo_param]
1264 set_r2 = params[mo_param]
1265 for key, val in set_r2.items():
1266 grid_r2_frq = grid_r2[key]
1267 min_r2_frq = min_r2[key]
1268 set_r2_frq = set_r2[key]
1269 frq = float(key.split(EXP_TYPE_CPMG_SQ+' - ')[-1].split('MHz')[0])
1270 rel_change = math.sqrt( (min_r2_frq - set_r2_frq)**2/(min_r2_frq)**2 )
1271 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) )
1272 if rel_change > ds.rel_change:
1273 print("WARNING: rel change level is above %.2f, and is %.4f."%(ds.rel_change, rel_change))
1274 print("###################################")
1275
1276
1277 self.assertAlmostEqual(set_r2_frq, min_r2_frq, 2)
1278 else:
1279 grid_val = grid_params[mo_param]
1280 min_val = min_params[mo_param]
1281 set_val = params[mo_param]
1282 rel_change = math.sqrt( (min_val - set_val)**2/(min_val)**2 )
1283 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) )
1284 if rel_change > ds.rel_change:
1285 print("WARNING: rel change level is above %.2f, and is %.4f."%(ds.rel_change, rel_change))
1286 print("###################################")
1287
1288
1289 if mo_param == 'dw':
1290 self.assertAlmostEqual(set_val/10, min_val/10, 5)
1291 elif mo_param == 'kex':
1292 self.assertAlmostEqual(set_val/1000, min_val/1000, 5)
1293 elif mo_param == 'pA':
1294 self.assertAlmostEqual(set_val, min_val, 6)
1295
1296
1298 """Test synthetic cpmg data. For CR72 with small noise and cluster.
1299
1300 This script will produce synthetic CPMG R2eff values according to the selected model, and the fit the selected model.
1301 """
1302
1303
1304
1305
1306
1307 model_create = 'NS CPMG 2-site 3D'
1308
1309 model_analyse = 'CR72'
1310
1311
1312 sfrq_1 = 599.8908617*1E6
1313 r20_key_1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=sfrq_1)
1314 time_T2_1 = 0.06
1315 ncycs_1 = [2, 4, 8, 10, 20, 30, 40, 60]
1316 r2eff_errs_1 = [0.05, -0.05, 0.05, -0.05, 0.05, -0.05, 0.05, -0.05]
1317
1318 exp_1 = [sfrq_1, time_T2_1, ncycs_1, r2eff_errs_1]
1319
1320 sfrq_2 = 499.8908617*1E6
1321 r20_key_2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=sfrq_2)
1322 time_T2_2 = 0.05
1323 ncycs_2 = [2, 4, 8, 10, 30, 35, 40, 50]
1324 r2eff_errs_2 = [0.05, -0.05, 0.05, -0.05, 0.05, -0.05, 0.05, -0.05]
1325
1326 exp_2 = [sfrq_2, time_T2_2, ncycs_2, r2eff_errs_2]
1327
1328
1329 exps = [exp_1, exp_2]
1330
1331 spins = [
1332 ['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.} ],
1333 ['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.} ]
1334 ]
1335
1336
1337 ds.data = [model_create, model_analyse, spins, exps]
1338
1339
1340 ds.tmpdir = ds.tmpdir
1341
1342
1343
1344 ds.resdir = ds.tmpdir
1345
1346
1347 ds.r20_from_min_r2eff = True
1348
1349
1350 ds.insignificance = 0.0
1351
1352
1353 ds.GRID_INC = 13
1354
1355
1356 ds.do_cluster = True
1357
1358
1359
1360 ds.set_func_tol = 1e-8
1361
1362
1363
1364 ds.set_max_iter = 10000
1365
1366
1367 ds.verbosity = 1
1368
1369
1370 ds.rel_change = 0.05
1371
1372
1373 ds.plot_curves = False
1374
1375
1376 ds.sherekhan_input = False
1377
1378
1379 ds.opendx = False
1380
1381
1382 ds.r2eff_err = 0.1
1383
1384
1385 ds.print_res = False
1386
1387
1388 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'cpmg_synthetic.py')
1389
1390 cur_spins = ds.data[2]
1391
1392 for i in range(len(cur_spins)):
1393 res_name, res_num, spin_name, params = cur_spins[i]
1394 cur_spin_id = ":%i@%s"%(res_num, spin_name)
1395 cur_spin = return_spin(cur_spin_id)
1396
1397 grid_params = ds.grid_results[i][3]
1398
1399
1400 min_params = ds.clust_results[i][3]
1401
1402 print("For spin: '%s'"%cur_spin_id)
1403 for mo_param in cur_spin.params:
1404
1405 if isinstance(getattr(cur_spin, mo_param), dict):
1406 grid_r2 = grid_params[mo_param]
1407 min_r2 = min_params[mo_param]
1408 set_r2 = params[mo_param]
1409 for key, val in set_r2.items():
1410 grid_r2_frq = grid_r2[key]
1411 min_r2_frq = min_r2[key]
1412 set_r2_frq = set_r2[key]
1413 frq = float(key.split(EXP_TYPE_CPMG_SQ+' - ')[-1].split('MHz')[0])
1414 rel_change = math.sqrt( (min_r2_frq - set_r2_frq)**2/(min_r2_frq)**2 )
1415 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) )
1416 if rel_change > ds.rel_change:
1417 print("WARNING: rel change level is above %.2f, and is %.4f."%(ds.rel_change, rel_change))
1418 print("###################################")
1419
1420
1421 self.assertAlmostEqual(set_r2_frq, min_r2_frq, 1)
1422 else:
1423 grid_val = grid_params[mo_param]
1424 min_val = min_params[mo_param]
1425 set_val = params[mo_param]
1426 rel_change = math.sqrt( (min_val - set_val)**2/(min_val)**2 )
1427 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) )
1428 if rel_change > ds.rel_change:
1429 print("WARNING: rel change level is above %.2f, and is %.4f."%(ds.rel_change, rel_change))
1430 print("###################################")
1431
1432
1433 if mo_param == 'dw':
1434 self.assertAlmostEqual(set_val/10, min_val/10, 1)
1435 elif mo_param == 'kex':
1436 self.assertAlmostEqual(set_val/1000, min_val/1000, 1)
1437 elif mo_param == 'pA':
1438 self.assertAlmostEqual(set_val, min_val, 2)
1439
1440
1442 """Test synthetic cpmg data, calling the dx.map function with one or two points.
1443
1444 This script will produce synthetic CPMG R2eff values according to the selected model, and the fit the selected model.
1445 """
1446
1447
1448
1449
1450
1451 model_create = MODEL_NS_CPMG_2SITE_EXPANDED
1452 model_analyse = 'CR72'
1453
1454 sfrq_1 = 599.8908617*1E6
1455 r20_key_1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=sfrq_1)
1456 time_T2_1 = 0.06
1457 ncycs_1 = [2, 4, 8, 10, 20, 30, 40, 60]
1458 r2eff_err_1 = [0, 0, 0, 0, 0, 0, 0, 0]
1459 exp_1 = [sfrq_1, time_T2_1, ncycs_1, r2eff_err_1]
1460
1461 sfrq_2 = 499.8908617*1E6
1462 r20_key_2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=sfrq_2)
1463 time_T2_2 = 0.05
1464 ncycs_2 = [2, 4, 8, 10, 30, 35, 40, 50]
1465 r2eff_err_2 = [0, 0, 0, 0, 0, 0, 0, 0]
1466 exp_2 = [sfrq_2, time_T2_2, ncycs_2, r2eff_err_2]
1467
1468
1469 exps = [exp_1, exp_2]
1470
1471 spins = [
1472 ['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} ]
1473 ]
1474
1475
1476 ds.data = [model_create, model_analyse, spins, exps]
1477
1478
1479 ds.tmpdir = ds.tmpdir
1480
1481
1482
1483 ds.resdir = ds.tmpdir
1484
1485
1486 ds.r20_from_min_r2eff = True
1487
1488
1489 ds.insignificance = 0.0
1490
1491
1492 ds.GRID_INC = None
1493
1494
1495 ds.do_cluster = False
1496
1497
1498
1499 ds.set_func_tol = 1e-9
1500
1501
1502
1503 ds.set_max_iter = 1000
1504
1505
1506 ds.verbosity = 1
1507
1508
1509 ds.rel_change = 0.05
1510
1511
1512 ds.plot_curves = False
1513
1514
1515 ds.sherekhan_input = False
1516
1517
1518 ds.opendx = False
1519
1520
1521 ds.r2eff_err = 0.1
1522
1523
1524 ds.print_res = False
1525
1526
1527 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'cpmg_synthetic.py')
1528
1529
1530 cur_spins = ds.data[2]
1531
1532
1533 ds.pipe_name_MODEL_MAP = "%s_%s_map"%(ds.pipe_name, model_analyse)
1534 self.interpreter.pipe.copy(pipe_from=ds.pipe_name, pipe_to=ds.pipe_name_MODEL_MAP, bundle_to = ds.pipe_bundle)
1535 self.interpreter.pipe.switch(pipe_name=ds.pipe_name_MODEL_MAP)
1536
1537
1538 self.interpreter.value.copy(pipe_from=ds.pipe_name_r2eff, pipe_to=ds.pipe_name_MODEL_MAP, param='r2eff')
1539
1540
1541 self.interpreter.relax_disp.select_model(model=model_analyse)
1542
1543
1544 ds.dx_inc = 4
1545 ds.dx_params = ['dw', 'pA', 'kex']
1546
1547 res_name, res_num, spin_name, params = cur_spins[0]
1548 cur_spin_id = ":%i@%s"%(res_num, spin_name)
1549 cur_spin = return_spin(cur_spin_id)
1550
1551 print("Params for dx map is")
1552 print(ds.dx_params)
1553 print("Point param for dx map is")
1554 print(ds.dx_set_val)
1555 cur_model = model_analyse.replace(' ', '_')
1556 file_name_map = "%s_map%s" % (cur_model, cur_spin_id.replace('#', '_').replace(':', '_').replace('@', '_'))
1557 file_name_point = "%s_point%s" % (cur_model, cur_spin_id .replace('#', '_').replace(':', '_').replace('@', '_'))
1558 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)
1559
1560
1561
1562 map_cfg = ds.tmpdir+sep+file_name_map+".cfg"
1563 map_net = ds.tmpdir+sep+file_name_map+".net"
1564 map_general = ds.tmpdir+sep+file_name_map+".general"
1565
1566 point_general = ds.tmpdir+sep+file_name_point+".general"
1567 point_point = ds.tmpdir+sep+file_name_point
1568
1569
1570 self.assert_(access(map_cfg, F_OK))
1571 self.assert_(access(map_net, F_OK))
1572 self.assert_(access(map_general, F_OK))
1573 self.assert_(access(point_general, F_OK))
1574 self.assert_(access(point_point, F_OK))
1575
1576
1577
1578 print("\nChecking the dx map .cfg file.")
1579 res_file = [
1580 '//'+"\n",
1581 '//'+"\n",
1582 '// time: Thu May 8 18:55:31 2014'+"\n",
1583 '//'+"\n",
1584 '// version: 3.2.0 (format), 4.3.2 (DX)'+"\n",
1585 '//'+"\n",
1586 '//'+"\n",
1587 '// panel[0]: position = (0.0164,0.0000), size = 0.2521x0.1933, startup = 1, devstyle = 1'+"\n",
1588 '// title: value = Control Panel'+"\n",
1589 '//'+"\n",
1590 '// workspace: width = 251, height = 142'+"\n",
1591 '// layout: snap = 0, width = 50, height = 50, align = NN'+"\n",
1592 '//'+"\n",
1593 '// interactor Selector[1]: num_components = 1, value = 1 '+"\n",
1594 '// selections: maximum = 2, current = 0 '+"\n",
1595 '// option[0]: name = "Colour", value = 1'+"\n",
1596 '// option[1]: name = "Grey", value = 2'+"\n",
1597 '// instance: panel = 0, x = 81, y = 6, style = Scrolled List, vertical = 1, size = 170x136'+"\n",
1598 '// label: value = Colour Selector'+"\n",
1599 '//'+"\n",
1600 '// node Image[3]:'+"\n",
1601 '// title: value = Surface'+"\n",
1602 '// depth: value = 24'+"\n",
1603 '// window: position = (0.0000,0.0400), size = 0.9929x0.9276'+"\n",
1604 ]
1605 file = open(map_cfg, 'r')
1606 lines = file.readlines()
1607 file.close()
1608 for i in range(len(res_file)):
1609
1610 if i == 2:
1611 continue
1612 self.assertEqual(res_file[i], lines[i])
1613
1614 print("\nChecking the dx map .general file.")
1615 res_file = [
1616 'file = CR72_map_1_N'+"\n",
1617 'grid = 5 x 5 x 5'+"\n",
1618 'format = ascii'+"\n",
1619 'interleaving = field'+"\n",
1620 'majority = row'+"\n",
1621 'field = data'+"\n",
1622 'structure = scalar'+"\n",
1623 'type = float'+"\n",
1624 'dependency = positions'+"\n",
1625 'positions = regular, regular, regular, 0, 1, 0, 1, 0, 1'+"\n",
1626 ''+"\n",
1627 'end'+"\n",
1628 ]
1629 file = open(map_general, 'r')
1630 lines = file.readlines()
1631 file.close()
1632 for i in range(len(res_file)):
1633
1634
1635
1636 self.assertEqual(res_file[i], lines[i])
1637
1638 print("\nChecking the dx point .general file.")
1639 res_file = [
1640 'file = CR72_point_1_N'+"\n",
1641 'points = 2'+"\n",
1642 'format = ascii'+"\n",
1643 'interleaving = field'+"\n",
1644 'field = locations, field0'+"\n",
1645 'structure = 3-vector, scalar'+"\n",
1646 'type = float, float'+"\n",
1647 ''+"\n",
1648 'end'+"\n",
1649 ]
1650 file = open(point_general, 'r')
1651 lines = file.readlines()
1652 file.close()
1653 for i in range(len(res_file)):
1654
1655
1656
1657 self.assertEqual(res_file[i], lines[i])
1658
1659 print("\nChecking the dx point point file.")
1660 res_file = [
1661 '0.8 3.92 0.39964 1'+"\n",
1662 '0.76981 3.9169 0.41353 1'+"\n",
1663 ]
1664 file = open(point_point, 'r')
1665 lines = file.readlines()
1666 file.close()
1667 for i in range(len(res_file)):
1668
1669
1670
1671 self.assertEqual(res_file[i], lines[i])
1672
1673
1675 """Test the curve type detection using the Dr. Flemming Hansen's CPMG fixed time test data."""
1676
1677
1678 self.interpreter.reset()
1679
1680
1681 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'Hansen'
1682 self.interpreter.state.load(data_path+sep+'r2eff_values')
1683
1684
1685 curve_type = get_curve_type(id='500_133.33.in')
1686 self.assertEqual(curve_type, 'fixed time')
1687
1688
1690 """Test the curve type detection using the 'M61' exponential test data."""
1691
1692
1693 self.interpreter.reset()
1694
1695
1696 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'r1rho_on_res_m61'
1697 self.interpreter.state.load(data_path+sep+'r2eff_values')
1698
1699
1700 curve_type = get_curve_type(id='nu_2000_ncyc9')
1701 self.assertEqual(curve_type, 'exponential')
1702
1703
1705 """Test the curve type detection using the 'TP02' fixed time test data."""
1706
1707
1708 self.interpreter.reset()
1709
1710
1711 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'r1rho_off_res_tp02'
1712 self.interpreter.state.load(data_path+sep+'r2eff_values')
1713
1714
1715 curve_type = get_curve_type(id='nu_1000.0_500MHz')
1716 self.assertEqual(curve_type, 'fixed time')
1717
1718
1720 """Test the relaxation dispersion 'DPL94' model curve fitting to fixed time synthetic data."""
1721
1722
1723 ds.fixed = True
1724
1725
1726 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')
1727
1728
1729 i0 = [100000.0, 20000.0]
1730 r1rho_prime = [2.25, 24.0]
1731 pA = 0.7
1732 kex = 1000.0
1733 delta_omega = [1.0, 2.0]
1734 phi_ex = []
1735 for i in range(2):
1736 phi_ex.append(pA * (1.0 - pA) * delta_omega[i]**2)
1737
1738
1739 self.interpreter.pipe.switch('DPL94 - relax_disp')
1740 spin_index = 0
1741 for spin, spin_id in spin_loop(return_id=True):
1742
1743 print("\nSpin %s." % spin_id)
1744
1745
1746 self.assertAlmostEqual(spin.r2['R1rho - 800.00000000 MHz']/10, r1rho_prime[spin_index]/10, 2)
1747 self.assertAlmostEqual(spin.phi_ex, phi_ex[spin_index], 2)
1748 self.assertAlmostEqual(spin.kex/1000.0, kex/1000.0, 2)
1749
1750
1751 spin_index += 1
1752
1753
1755 """Test the relaxation dispersion 'exp_fit' model curve fitting."""
1756
1757
1758 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'exp_fit.py')
1759
1760
1761 res_data = [
1762 [15., 10., 20000., 25000.],
1763 [12., 11., 50000., 51000.],
1764 [17., 9., 100000., 96000.]
1765 ]
1766
1767
1768 blacklist = ['cpmg_frqs', 'r2', 'rex', 'kex', 'r2a', 'k_AB', 'dw']
1769
1770
1771 for i in range(len(res_data)):
1772
1773 print("\nResidue number %s." % (i+1))
1774
1775
1776 self.assertAlmostEqual(cdp.mol[0].res[i].spin[0].r2eff['r1rho_1200.00000000_0.000_1000.000'], res_data[i][0], places=2)
1777 self.assertAlmostEqual(cdp.mol[0].res[i].spin[0].r2eff['r1rho_1200.00000000_0.000_2000.000'], res_data[i][1], places=2)
1778 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)
1779 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)
1780
1781
1782 self.assert_(cdp.mol[0].res[i].spin[0].r2eff_err['r1rho_1200.00000000_0.000_1000.000'] < 5.0)
1783 self.assert_(cdp.mol[0].res[i].spin[0].r2eff_err['r1rho_1200.00000000_0.000_2000.000'] < 5.0)
1784 self.assert_(cdp.mol[0].res[i].spin[0].i0_err['r1rho_1200.00000000_0.000_1000.000']/10000 < 5.0)
1785 self.assert_(cdp.mol[0].res[i].spin[0].i0_err['r1rho_1200.00000000_0.000_2000.000']/10000 < 5.0)
1786
1787
1788 for param in blacklist:
1789 print("\tChecking for the absence of the '%s' parameter." % param)
1790 self.assert_(not hasattr(cdp.mol[0].res[i].spin[0], param))
1791
1792
1793 self.assert_(hasattr(cdp, 'clustering'))
1794 keys = ['free spins', 'cluster']
1795 for key in keys:
1796 self.assert_(key in cdp.clustering)
1797 self.assert_('test' not in cdp.clustering)
1798 self.assertEqual(cdp.clustering['free spins'], [':2@N'])
1799 self.assertEqual(cdp.clustering['cluster'], [':1@N', ':3@N'])
1800
1801
1912
1913
1915 """Test of the dispersion auto-analysis using Dr. Flemming Hansen's CPMG data.
1916
1917 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.
1918 """
1919
1920
1921 ds.models = [
1922 MODEL_NOREX,
1923 MODEL_LM63,
1924 MODEL_CR72,
1925 MODEL_IT99
1926 ]
1927
1928
1929 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'hansen_data.py')
1930 self.interpreter.state.save('analysis_heights', dir=ds.tmpdir, force=True)
1931
1932
1933 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6)
1934 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6)
1935
1936
1937 self.interpreter.pipe.switch(pipe_name='No Rex - relax_disp')
1938 spin70 = return_spin(":70")
1939 spin71 = return_spin(":71")
1940 print("\n\nOptimised parameters:\n")
1941 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)"))
1942 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin70.r2[r20_key1], spin71.r2[r20_key1]))
1943 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin70.r2[r20_key2], spin71.r2[r20_key2]))
1944 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2))
1945 self.assertAlmostEqual(spin70.r2[r20_key1], 10.5340593984683, 3)
1946 self.assertAlmostEqual(spin70.r2[r20_key2], 16.1112170102734, 3)
1947 self.assertAlmostEqual(spin70.chi2, 8973.84810025761, 3)
1948 self.assertAlmostEqual(spin71.r2[r20_key1], 5.83139953954648, 3)
1949 self.assertAlmostEqual(spin71.r2[r20_key2], 8.90856319376098, 3)
1950 self.assertAlmostEqual(spin71.chi2, 3908.00127830003, 3)
1951
1952
1953 self.interpreter.pipe.switch(pipe_name='LM63 - relax_disp')
1954 spin70 = return_spin(":70")
1955 spin71 = return_spin(":71")
1956 print("\n\nOptimised parameters:\n")
1957 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)"))
1958 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin70.r2[r20_key1], spin71.r2[r20_key1]))
1959 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin70.r2[r20_key2], spin71.r2[r20_key2]))
1960 print("%-20s %20.15g %20.15g" % ("phi_ex", spin70.phi_ex, spin71.phi_ex))
1961 print("%-20s %20.15g %20.15g" % ("kex", spin70.kex, spin71.kex))
1962 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2))
1963 self.assertAlmostEqual(spin70.r2[r20_key1], 6.74326615264889, 2)
1964 self.assertAlmostEqual(spin70.r2[r20_key2], 6.57331164382438, 2)
1965 self.assertAlmostEqual(spin70.phi_ex, 0.312767653822936, 3)
1966 self.assertAlmostEqual(spin70.kex/10000, 4723.44390412119/10000, 3)
1967 self.assertAlmostEqual(spin70.chi2, 363.534049046805, 3)
1968 self.assertAlmostEqual(spin71.r2[r20_key1], 5.00778024769786, 3)
1969 self.assertAlmostEqual(spin71.r2[r20_key2], 6.83343630016037, 3)
1970 self.assertAlmostEqual(spin71.phi_ex, 0.0553791362097596, 3)
1971 self.assertAlmostEqual(spin71.kex/10000, 2781.67925957068/10000, 3)
1972 self.assertAlmostEqual(spin71.chi2, 17.0776426190574, 3)
1973
1974
1975 self.interpreter.pipe.switch(pipe_name='CR72 - relax_disp')
1976 spin70 = return_spin(":70")
1977 spin71 = return_spin(":71")
1978 print("\n\nOptimised parameters:\n")
1979 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)"))
1980 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin70.r2[r20_key1], spin71.r2[r20_key1]))
1981 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin70.r2[r20_key2], spin71.r2[r20_key2]))
1982 print("%-20s %20.15g %20.15g" % ("pA", spin70.pA, spin71.pA))
1983 print("%-20s %20.15g %20.15g" % ("dw", spin70.dw, spin71.dw))
1984 print("%-20s %20.15g %20.15g" % ("kex", spin70.kex, spin71.kex))
1985 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2))
1986 self.assertAlmostEqual(spin70.r2[r20_key1], 6.97233943292193, 3)
1987 self.assertAlmostEqual(spin70.r2[r20_key2], 9.409506394526, 2)
1988 self.assertAlmostEqual(spin70.pA, 0.989856804525044, 3)
1989 self.assertAlmostEqual(spin70.dw, 5.60889078920945, 3)
1990 self.assertAlmostEqual(spin70.kex/10000, 1753.01607073019/10000, 3)
1991 self.assertAlmostEqual(spin70.chi2, 53.8382158551706, 3)
1992 self.assertAlmostEqual(spin71.r2[r20_key1], 5.003171547206, 3)
1993 self.assertAlmostEqual(spin71.r2[r20_key2], 6.90210797727492, 3)
1994 self.assertAlmostEqual(spin71.pA, 0.985922406455826, 3)
1995 self.assertAlmostEqual(spin71.dw, 2.00500965892672, 2)
1996 self.assertAlmostEqual(spin71.kex/10000, 2481.10839579617/10000, 3)
1997 self.assertAlmostEqual(spin71.chi2, 15.6595374286822, 3)
1998
1999
2001 """Test of the numeric model only dispersion auto-analysis using Dr. Flemming Hansen's CPMG data.
2002
2003 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.
2004 """
2005
2006
2007 ds.models = [
2008 MODEL_NOREX,
2009 MODEL_CR72,
2010 MODEL_NS_CPMG_2SITE_EXPANDED
2011 ]
2012 ds.numeric_only = True
2013
2014
2015 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'hansen_data.py')
2016
2017
2018 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6)
2019 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6)
2020
2021
2022 self.interpreter.pipe.switch(pipe_name='No Rex - relax_disp')
2023 spin70 = return_spin(":70")
2024 spin71 = return_spin(":71")
2025 print("\n\nOptimised parameters:\n")
2026 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)"))
2027 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin70.r2[r20_key1], spin71.r2[r20_key1]))
2028 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin70.r2[r20_key2], spin71.r2[r20_key2]))
2029 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2))
2030 self.assertAlmostEqual(spin70.r2[r20_key1], 10.5340593984683, 3)
2031 self.assertAlmostEqual(spin70.r2[r20_key2], 16.1112170102734, 3)
2032 self.assertAlmostEqual(spin70.chi2/10000, 8973.84810025761/10000, 3)
2033 self.assertAlmostEqual(spin71.r2[r20_key1], 5.83139953954648, 3)
2034 self.assertAlmostEqual(spin71.r2[r20_key2], 8.90856319376098, 3)
2035 self.assertAlmostEqual(spin71.chi2/10000, 3908.00127830003/10000, 3)
2036
2037
2038 self.interpreter.pipe.switch(pipe_name='CR72 - relax_disp')
2039 spin70 = return_spin(":70")
2040 spin71 = return_spin(":71")
2041 print("\n\nOptimised parameters:\n")
2042 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)"))
2043 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin70.r2[r20_key1], spin71.r2[r20_key1]))
2044 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin70.r2[r20_key2], spin71.r2[r20_key2]))
2045 print("%-20s %20.15g %20.15g" % ("pA", spin70.pA, spin71.pA))
2046 print("%-20s %20.15g %20.15g" % ("dw", spin70.dw, spin71.dw))
2047 print("%-20s %20.15g %20.15g" % ("kex", spin70.kex, spin71.kex))
2048 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2))
2049 self.assertAlmostEqual(spin70.r2[r20_key1], 6.97233943292193, 3)
2050 self.assertAlmostEqual(spin70.r2[r20_key2], 9.409506394526, 2)
2051 self.assertAlmostEqual(spin70.pA, 0.989856804525044, 3)
2052 self.assertAlmostEqual(spin70.dw, 5.60889078920945, 3)
2053 self.assertAlmostEqual(spin70.kex/10000, 1753.01607073019/10000, 3)
2054 self.assertAlmostEqual(spin70.chi2, 53.8382158551706, 3)
2055 self.assertAlmostEqual(spin71.r2[r20_key1], 5.003171547206, 3)
2056 self.assertAlmostEqual(spin71.r2[r20_key2], 6.90210797727492, 3)
2057 self.assertAlmostEqual(spin71.pA, 0.985922406455826, 3)
2058 self.assertAlmostEqual(spin71.dw, 2.00500965892672, 2)
2059 self.assertAlmostEqual(spin71.kex/10000, 2481.10839579617/10000, 3)
2060 self.assertAlmostEqual(spin71.chi2, 15.6595374286822, 3)
2061
2062
2063 self.interpreter.pipe.switch(pipe_name='NS CPMG 2-site expanded - relax_disp')
2064 spin70 = return_spin(":70")
2065 spin71 = return_spin(":71")
2066 print("\n\nOptimised parameters:\n")
2067 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)"))
2068 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin70.r2[r20_key1], spin71.r2[r20_key1]))
2069 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin70.r2[r20_key2], spin71.r2[r20_key2]))
2070 print("%-20s %20.15g %20.15g" % ("pA", spin70.pA, spin71.pA))
2071 print("%-20s %20.15g %20.15g" % ("dw", spin70.dw, spin71.dw))
2072 print("%-20s %20.15g %20.15g" % ("kex", spin70.kex, spin71.kex))
2073 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2))
2074 self.assertAlmostEqual(spin70.r2[r20_key1], 6.95815351460902, 3)
2075 self.assertAlmostEqual(spin70.r2[r20_key2], 9.39649535771294, 3)
2076 self.assertAlmostEqual(spin70.pA, 0.989701014493195, 3)
2077 self.assertAlmostEqual(spin70.dw, 5.67314464776128, 3)
2078 self.assertAlmostEqual(spin70.kex/10000, 1713.65380495429/10000, 3)
2079 self.assertAlmostEqual(spin70.chi2, 52.5106880917473, 3)
2080 self.assertAlmostEqual(spin71.r2[r20_key1], 4.99889337382435, 3)
2081 self.assertAlmostEqual(spin71.r2[r20_key2], 6.89822887466673, 3)
2082 self.assertAlmostEqual(spin71.pA, 0.986709050819695, 3)
2083 self.assertAlmostEqual(spin71.dw, 2.09238266766502, 3)
2084 self.assertAlmostEqual(spin71.kex/10000, 2438.27019901422/10000, 3)
2085 self.assertAlmostEqual(spin71.chi2, 15.1644906963987, 3)
2086
2087
2088 self.interpreter.pipe.switch(pipe_name='final - relax_disp')
2089 spin70 = return_spin(":70")
2090 spin71 = return_spin(":71")
2091 self.assertEqual(spin70.model, 'NS CPMG 2-site expanded')
2092 self.assertEqual(spin71.model, 'NS CPMG 2-site expanded')
2093
2094
2096 """Test of the dispersion auto-analysis using Dr. Flemming Hansen's CPMG data (using the R2eff data directly instead of peak intensities).
2097
2098 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.
2099 """
2100
2101
2102 ds.models = [
2103 MODEL_NOREX,
2104 MODEL_LM63,
2105 MODEL_CR72,
2106 MODEL_IT99
2107 ]
2108
2109
2110 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'hansen_r2eff_data.py')
2111 self.interpreter.state.save('analysis_r2eff', dir=ds.tmpdir, force=True)
2112
2113
2114 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6)
2115 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6)
2116
2117
2118 self.interpreter.pipe.switch(pipe_name='No Rex - relax_disp')
2119 spin70 = return_spin(":70")
2120 spin71 = return_spin(":71")
2121 print("\n\nOptimised parameters:\n")
2122 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)"))
2123 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin70.r2[r20_key1], spin71.r2[r20_key1]))
2124 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin70.r2[r20_key2], spin71.r2[r20_key2]))
2125 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2))
2126 self.assertAlmostEqual(spin70.r2[r20_key1], 10.5340593984683, 3)
2127 self.assertAlmostEqual(spin70.r2[r20_key2], 16.1112170102734, 3)
2128 self.assertAlmostEqual(spin70.chi2, 8973.84810025761, 3)
2129 self.assertAlmostEqual(spin71.r2[r20_key1], 5.83139953954648, 3)
2130 self.assertAlmostEqual(spin71.r2[r20_key2], 8.90856319376098, 3)
2131 self.assertAlmostEqual(spin71.chi2, 3908.00127830003, 3)
2132
2133
2134 self.interpreter.pipe.switch(pipe_name='LM63 - relax_disp')
2135 spin70 = return_spin(":70")
2136 spin71 = return_spin(":71")
2137 print("\n\nOptimised parameters:\n")
2138 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)"))
2139 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin70.r2[r20_key1], spin71.r2[r20_key1]))
2140 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin70.r2[r20_key2], spin71.r2[r20_key2]))
2141 print("%-20s %20.15g %20.15g" % ("phi_ex", spin70.phi_ex, spin71.phi_ex))
2142 print("%-20s %20.15g %20.15g" % ("kex", spin70.kex, spin71.kex))
2143 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2))
2144 self.assertAlmostEqual(spin70.r2[r20_key1], 6.74326615264889, 2)
2145 self.assertAlmostEqual(spin70.r2[r20_key2], 6.57331164382438, 2)
2146 self.assertAlmostEqual(spin70.phi_ex, 0.312767653822936, 3)
2147 self.assertAlmostEqual(spin70.kex/10000, 4723.44390412119/10000, 3)
2148 self.assertAlmostEqual(spin70.chi2, 363.534049046805, 3)
2149 self.assertAlmostEqual(spin71.r2[r20_key1], 5.00778024769786, 3)
2150 self.assertAlmostEqual(spin71.r2[r20_key2], 6.83343630016037, 3)
2151 self.assertAlmostEqual(spin71.phi_ex, 0.0553791362097596, 3)
2152 self.assertAlmostEqual(spin71.kex/10000, 2781.67925957068/10000, 3)
2153 self.assertAlmostEqual(spin71.chi2, 17.0776426190574, 3)
2154
2155
2156 self.interpreter.pipe.switch(pipe_name='CR72 - relax_disp')
2157 spin70 = return_spin(":70")
2158 spin71 = return_spin(":71")
2159 print("\n\nOptimised parameters:\n")
2160 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)"))
2161 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin70.r2[r20_key1], spin71.r2[r20_key1]))
2162 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin70.r2[r20_key2], spin71.r2[r20_key2]))
2163 print("%-20s %20.15g %20.15g" % ("pA", spin70.pA, spin71.pA))
2164 print("%-20s %20.15g %20.15g" % ("dw", spin70.dw, spin71.dw))
2165 print("%-20s %20.15g %20.15g" % ("kex", spin70.kex, spin71.kex))
2166 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2))
2167 self.assertAlmostEqual(spin70.r2[r20_key1], 6.97233943292193, 3)
2168 self.assertAlmostEqual(spin70.r2[r20_key2], 9.409506394526, 2)
2169 self.assertAlmostEqual(spin70.pA, 0.989856804525044, 3)
2170 self.assertAlmostEqual(spin70.dw, 5.60889078920945, 3)
2171 self.assertAlmostEqual(spin70.kex/10000, 1753.01607073019/10000, 3)
2172 self.assertAlmostEqual(spin70.chi2, 53.8382158551706, 3)
2173 self.assertAlmostEqual(spin71.r2[r20_key1], 5.00317154730225, 3)
2174 self.assertAlmostEqual(spin71.r2[r20_key2], 6.90210797713541, 3)
2175 self.assertAlmostEqual(spin71.pA, 0.985922406429147, 3)
2176 self.assertAlmostEqual(spin71.dw, 2.00500965887772, 2)
2177 self.assertAlmostEqual(spin71.kex/10000, 2481.10839579804/10000, 3)
2178 self.assertAlmostEqual(spin71.chi2, 15.6595374288635, 3)
2179
2180
2182 """Test of the dispersion auto-analysis using Dr. Flemming Hansen's CPMG data with parts missing.
2183
2184 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.
2185 """
2186
2187
2188 ds.models = [
2189 MODEL_R2EFF,
2190 MODEL_NOREX,
2191 MODEL_CR72,
2192 MODEL_NS_CPMG_2SITE_EXPANDED
2193 ]
2194
2195
2196 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'hansen_data_missing.py')
2197 self.interpreter.state.save('analysis_heights', dir=ds.tmpdir, force=True)
2198
2199
2200 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6)
2201 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6)
2202
2203
2204 self.interpreter.pipe.switch(pipe_name='No Rex - relax_disp')
2205 spin4 = return_spin(":4")
2206 spin70 = return_spin(":70")
2207 spin71 = return_spin(":71")
2208 print("\n\nOptimised parameters:\n")
2209 print("%-20s %-20s %-20s %-20s" % ("Parameter", "Value (:4)", "Value (:70)", "Value (:71)"))
2210 print("%-20s %20.15g %20.15g %20.15g" % ("R2 (500 MHz)", spin4.r2[r20_key1], spin70.r2[r20_key1], spin71.r2[r20_key1]))
2211 print("%-20s %20.15g %20.15g %20.15g" % ("R2 (800 MHz)", spin4.r2[r20_key2], spin70.r2[r20_key2], spin71.r2[r20_key2]))
2212 print("%-20s %20.15g %20.15g %20.15g\n" % ("chi2", spin4.chi2, spin70.chi2, spin71.chi2))
2213 self.assertAlmostEqual(spin4.r2[r20_key1], 1.60463084515171, 3)
2214 self.assertAlmostEqual(spin4.r2[r20_key2], 1.63220784651911, 3)
2215 self.assertAlmostEqual(spin4.chi2, 26.7356700694891, 3)
2216 self.assertAlmostEqual(spin70.r2[r20_key1], 10.534285641325, 3)
2217 self.assertAlmostEqual(spin70.r2[r20_key2], 16.1112794857068, 3)
2218 self.assertAlmostEqual(spin70.chi2, 8973.84809774722, 3)
2219 self.assertAlmostEqual(spin71.r2[r20_key1], 5.83136858890037, 3)
2220 self.assertAlmostEqual(spin71.chi2, 182.60081909193, 3)
2221
2222
2223 self.interpreter.pipe.switch(pipe_name='CR72 - relax_disp')
2224 spin4 = return_spin(":4")
2225 spin70 = return_spin(":70")
2226 spin71 = return_spin(":71")
2227 print("\n\nOptimised parameters:\n")
2228 print("%-20s %-20s %-20s %-20s" % ("Parameter", "Value (:4)", "Value (:70)", "Value (:71)"))
2229 print("%-20s %20.15g %20.15g %20.15g" % ("R2 (500 MHz)", spin4.r2[r20_key1], spin70.r2[r20_key1], spin71.r2[r20_key1]))
2230 print("%-20s %20.15g %20.15g %20.15g" % ("R2 (800 MHz)", spin4.r2[r20_key2], spin70.r2[r20_key2], spin71.r2[r20_key2]))
2231 print("%-20s %20.15g %20.15g %20.15g" % ("pA", spin4.pA, spin70.pA, spin71.pA))
2232 print("%-20s %20.15g %20.15g %20.15g" % ("dw", spin4.dw, spin70.dw, spin71.dw))
2233 print("%-20s %20.15g %20.15g %20.15g" % ("kex", spin4.kex, spin70.kex, spin71.kex))
2234 print("%-20s %20.15g %20.15g %20.15g\n" % ("chi2", spin4.chi2, spin70.chi2, spin71.chi2))
2235 self.assertAlmostEqual(spin4.r2[r20_key1], 1.60463650370664, 2)
2236 self.assertAlmostEqual(spin4.r2[r20_key2], 1.63221675941434, 3)
2237
2238 self.assertAlmostEqual(spin4.dw, 0.0, 6)
2239 self.assertAlmostEqual(spin4.kex/10000, 0.0, 3)
2240 self.assertAlmostEqual(spin4.chi2, 26.7356711142038, 3)
2241 self.assertAlmostEqual(spin70.r2[r20_key1], 6.97268077496405, 3)
2242 self.assertAlmostEqual(spin70.r2[r20_key2], 9.41028133407727, 3)
2243 self.assertAlmostEqual(spin70.pA, 0.989856641885939, 3)
2244 self.assertAlmostEqual(spin70.dw, 5.60889911049405, 3)
2245 self.assertAlmostEqual(spin70.kex/10000, 1752.62025618632/10000, 3)
2246 self.assertAlmostEqual(spin70.chi2, 53.8382196964083, 3)
2247 self.assertAlmostEqual(spin71.r2[r20_key1], 4.98123328466942, 3)
2248 self.assertAlmostEqual(spin71.pA, 0.996607425484157, 3)
2249 self.assertAlmostEqual(spin71.dw, 4.34346257383825, 3)
2250 self.assertAlmostEqual(spin71.kex/10000, 1936.73197158804/10000, 3)
2251 self.assertAlmostEqual(spin71.chi2, 5.51703791653689, 3)
2252
2253
2255 """Optimisation of Dr. Flemming Hansen's CPMG data to the CR72 dispersion model.
2256
2257 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.
2258 """
2259
2260
2261 self.setup_hansen_cpmg_data(model='CR72')
2262
2263
2264 spin70 = return_spin(":70")
2265 spin71 = return_spin(":71")
2266
2267
2268 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6)
2269 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6)
2270
2271
2272 spin70.r2 = {r20_key1: 7.0, r20_key2: 9.0}
2273 spin70.pA = 0.9
2274 spin70.dw = 6.0
2275 spin70.kex = 1500.0
2276 spin71.r2 = {r20_key1: 5, r20_key2: 9.0}
2277 spin71.pA = 0.9
2278 spin71.dw = 4.0
2279 spin71.kex = 1900.0
2280
2281
2282 self.interpreter.minimise(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)
2283
2284
2285 print("\n\nOptimised parameters:\n")
2286 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)"))
2287 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin70.r2[r20_key1], spin71.r2[r20_key1]))
2288 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin70.r2[r20_key2], spin71.r2[r20_key2]))
2289 print("%-20s %20.15g %20.15g" % ("pA", spin70.pA, spin71.pA))
2290 print("%-20s %20.15g %20.15g" % ("dw", spin70.dw, spin71.dw))
2291 print("%-20s %20.15g %20.15g" % ("kex", spin70.kex, spin71.kex))
2292 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2))
2293
2294
2295 self.assertAlmostEqual(spin70.r2[r20_key1], 6.9724581325007, 4)
2296 self.assertAlmostEqual(spin70.r2[r20_key2], 9.40968331038162, 2)
2297 self.assertAlmostEqual(spin70.pA, 0.989856656702431, 4)
2298 self.assertAlmostEqual(spin70.dw, 5.60885879594746, 3)
2299 self.assertAlmostEqual(spin70.kex/1000, 1752.91052702273/1000, 3)
2300 self.assertAlmostEqual(spin70.chi2, 53.8382133597495, 4)
2301
2302
2303 self.assertAlmostEqual(spin71.r2[r20_key1], 5.0030740940524, 4)
2304 self.assertAlmostEqual(spin71.pA, 0.985941082507823, 4)
2305 self.assertAlmostEqual(spin71.dw, 2.00640384113696, 4)
2306 self.assertAlmostEqual(spin71.kex/1000, 2480.79614442041/1000, 4)
2307 self.assertAlmostEqual(spin71.chi2, 15.6595388312451, 4)
2308
2309
2310 self.assertEqual(spin70.k_AB, spin70.kex * (1.0 - spin70.pA))
2311 self.assertEqual(spin71.k_AB, spin71.kex * (1.0 - spin71.pA))
2312
2313
2314 self.assertEqual(spin70.k_BA, spin70.kex * spin70.pA)
2315 self.assertEqual(spin71.k_BA, spin71.kex * spin71.pA)
2316
2317
2319 """Optimisation of Dr. Flemming Hansen's CPMG data to the CR72 full dispersion model.
2320
2321 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.
2322 """
2323
2324
2325 self.setup_hansen_cpmg_data(model='CR72 full')
2326
2327
2328 spin70 = return_spin(":70")
2329 spin71 = return_spin(":71")
2330
2331
2332 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6)
2333 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6)
2334
2335
2336 spin70.r2a = {r20_key1: 7.0, r20_key2: 9.0}
2337 spin70.r2b = {r20_key1: 7.0, r20_key2: 9.0}
2338 spin70.pA = 0.9
2339 spin70.dw = 6.0
2340 spin70.kex = 1500.0
2341 spin71.r2a = {r20_key1: 5.0, r20_key2: 9.0}
2342 spin71.r2b = {r20_key1: 5.0, r20_key2: 9.0}
2343 spin71.pA = 0.9
2344 spin71.dw = 4.0
2345 spin71.kex = 1900.0
2346
2347
2348 self.interpreter.minimise(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)
2349
2350
2351 print("\n\nOptimised parameters:\n")
2352 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)"))
2353 print("%-20s %20.15g %20.15g" % ("R2A (500 MHz)", spin70.r2a[r20_key1], spin71.r2a[r20_key1]))
2354 print("%-20s %20.15g %20.15g" % ("R2B (500 MHz)", spin70.r2b[r20_key1], spin71.r2b[r20_key1]))
2355 print("%-20s %20.15g %20.15g" % ("R2A (800 MHz)", spin70.r2a[r20_key2], spin71.r2a[r20_key2]))
2356 print("%-20s %20.15g %20.15g" % ("R2B (800 MHz)", spin70.r2b[r20_key2], spin71.r2b[r20_key2]))
2357 print("%-20s %20.15g %20.15g" % ("pA", spin70.pA, spin71.pA))
2358 print("%-20s %20.15g %20.15g" % ("dw", spin70.dw, spin71.dw))
2359 print("%-20s %20.15g %20.15g" % ("kex", spin70.kex, spin71.kex))
2360 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2))
2361
2362
2363 self.assertAlmostEqual(spin70.r2a[r20_key1], 6.87485258365614, 4)
2364 self.assertAlmostEqual(spin70.r2b[r20_key1], 1.26075839074614, 4)
2365 self.assertAlmostEqual(spin70.r2a[r20_key2], 8.79580446260797, 4)
2366 self.assertAlmostEqual(spin70.r2b[r20_key2], 51.188411562843, 4)
2367 self.assertAlmostEqual(spin70.pA, 0.989384178573802, 4)
2368 self.assertAlmostEqual(spin70.dw, 5.54738203723682, 4)
2369 self.assertAlmostEqual(spin70.kex/1000, 1831.4566463179/1000, 4)
2370 self.assertAlmostEqual(spin70.chi2, 50.450410782403, 4)
2371
2372
2373 self.assertAlmostEqual(spin71.r2a[r20_key1], 5.04185695754972, 4)
2374 self.assertAlmostEqual(spin71.r2b[r20_key1], 1.62857899941921, 4)
2375 self.assertAlmostEqual(spin71.pA, 0.988832866751676, 4)
2376 self.assertAlmostEqual(spin71.dw, 2.24905251856265, 4)
2377 self.assertAlmostEqual(spin71.kex/1000, 2397.64122642946/1000, 4)
2378 self.assertAlmostEqual(spin71.chi2, 15.8586492923672, 4)
2379
2380
2381 self.assertEqual(spin70.k_AB, spin70.kex * (1.0 - spin70.pA))
2382 self.assertEqual(spin71.k_AB, spin71.kex * (1.0 - spin71.pA))
2383
2384
2385 self.assertEqual(spin70.k_BA, spin70.kex * spin70.pA)
2386 self.assertEqual(spin71.k_BA, spin71.kex * spin71.pA)
2387
2388
2390 """Optimisation of Dr. Flemming Hansen's CPMG data to the IT99 dispersion model.
2391
2392 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.
2393 """
2394
2395
2396 self.setup_hansen_cpmg_data(model='IT99')
2397
2398
2399 spin70 = return_spin(":70")
2400 spin71 = return_spin(":71")
2401
2402
2403 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6)
2404 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6)
2405
2406
2407 spin70.r2 = {r20_key1: 8.8, r20_key2: 16.6}
2408 spin70.dw = 10.0
2409 spin70.pA = 0.5
2410 spin70.tex = 1000.09
2411 spin71.r2 = {r20_key1: 1.0, r20_key2: 1.0}
2412 spin71.dw = 10.0
2413 spin71.pA = 0.95
2414 spin71.tex = 0.1
2415
2416
2417 self.interpreter.minimise(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)
2418
2419
2420 print("\n\nOptimised parameters:\n")
2421 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)"))
2422 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin70.r2[r20_key1], spin71.r2[r20_key1]))
2423 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin70.r2[r20_key2], spin71.r2[r20_key2]))
2424 print("%-20s %20.15g %20.15g" % ("dw", spin70.dw, spin71.dw))
2425 print("%-20s %20.15g %20.15g" % ("pA", spin70.pA, spin71.pA))
2426 print("%-20s %20.15g %20.15g" % ("tex", spin70.tex, spin71.tex))
2427 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2))
2428
2429
2430 self.assertAlmostEqual(spin70.r2[r20_key1], 7.24471197811838, 4)
2431 self.assertAlmostEqual(spin70.r2[r20_key2], 10.0571040704729, 4)
2432 self.assertAlmostEqual(spin70.dw, 5.2116923222744, 4)
2433 self.assertAlmostEqual(spin70.pA, 0.990253627907212, 4)
2434 self.assertAlmostEqual(spin70.tex*1000, 0.000638394793480444*1000, 4)
2435 self.assertAlmostEqual(spin70.chi2, 93.5135798618747, 4)
2436
2437
2438 self.assertAlmostEqual(spin71.r2[r20_key1], 5.05971235970214, 4)
2439 self.assertAlmostEqual(spin71.r2[r20_key2], 6.96641194493447, 4)
2440 self.assertAlmostEqual(spin71.dw, 0.435389946897141, 4)
2441 self.assertAlmostEqual(spin71.pA, 0.500000000213519, 3)
2442 self.assertAlmostEqual(spin71.tex*1000, 0.000372436400585538*1000, 4)
2443 self.assertAlmostEqual(spin71.chi2, 23.7895798801404, 4)
2444
2445
2447 """Optimisation of Dr. Flemming Hansen's CPMG data to the LM63 dispersion model.
2448
2449 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.
2450 """
2451
2452
2453 self.setup_hansen_cpmg_data(model='LM63')
2454
2455
2456 spin70 = return_spin(":70")
2457 spin71 = return_spin(":71")
2458
2459
2460 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6)
2461 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6)
2462
2463
2464 spin70.r2 = {r20_key1: 7.0, r20_key2: 7.0}
2465 spin70.phi_ex = 0.3
2466 spin70.kex = 5000.0
2467 spin71.r2 = {r20_key1: 5.0, r20_key2: 9.0}
2468 spin71.phi_ex = 0.1
2469 spin71.kex = 2500.0
2470
2471
2472 self.interpreter.minimise(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)
2473
2474
2475 print("\n\nOptimised parameters:\n")
2476 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)"))
2477 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin70.r2[r20_key1], spin71.r2[r20_key1]))
2478 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin70.r2[r20_key2], spin71.r2[r20_key2]))
2479 print("%-20s %20.15g %20.15g" % ("phi_ex", spin70.phi_ex, spin71.phi_ex))
2480 print("%-20s %20.15g %20.15g" % ("kex", spin70.kex, spin71.kex))
2481 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2))
2482
2483
2484 self.assertAlmostEqual(spin70.r2[r20_key1], 6.7436229263957, 5)
2485 self.assertAlmostEqual(spin70.r2[r20_key2], 6.57406788826655, 5)
2486 self.assertAlmostEqual(spin70.phi_ex, 0.31273301746411, 5)
2487 self.assertAlmostEqual(spin70.kex/1000, 4723.09901154387/1000, 5)
2488 self.assertAlmostEqual(spin70.chi2, 363.534044873483, 5)
2489
2490
2491 self.assertAlmostEqual(spin71.r2[r20_key1], 5.00776657729728, 5)
2492 self.assertAlmostEqual(spin71.phi_ex, 0.0553787825650613, 5)
2493 self.assertAlmostEqual(spin71.kex/1000, 2781.72292994154/1000, 5)
2494 self.assertAlmostEqual(spin71.chi2, 17.0776399916287, 5)
2495
2496
2498 """Optimisation of Dr. Flemming Hansen's CPMG data to the 'NS CPMG 2-site 3D' dispersion model.
2499
2500 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.
2501 """
2502
2503
2504 self.setup_hansen_cpmg_data(model='NS CPMG 2-site 3D')
2505
2506
2507 spin70 = return_spin(":70")
2508 spin71 = return_spin(":71")
2509
2510
2511 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6)
2512 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6)
2513
2514
2515 spin70.r2 = {r20_key1: 6.994165925, r20_key2: 9.428129427}
2516 spin70.pA = 0.9897754407
2517 spin70.dw = 5.642418428
2518 spin70.kex = 1743.666375
2519 spin71.r2 = {r20_key1: 4.978654237, r20_key2: 9.276918959}
2520 spin71.pA = 0.9968032899
2521 spin71.dw = 4.577891393
2522 spin71.kex = 1830.044597
2523
2524
2525 self.interpreter.minimise(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)
2526
2527
2528 print("\n\nOptimised parameters:\n")
2529 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)"))
2530 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin70.r2[r20_key1], spin71.r2[r20_key1]))
2531 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin70.r2[r20_key2], spin71.r2[r20_key2]))
2532 print("%-20s %20.15g %20.15g" % ("pA", spin70.pA, spin71.pA))
2533 print("%-20s %20.15g %20.15g" % ("dw", spin70.dw, spin71.dw))
2534 print("%-20s %20.15g %20.15g" % ("kex", spin70.kex, spin71.kex))
2535 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2))
2536
2537
2538 self.assertAlmostEqual(spin70.r2[r20_key1], 6.95797760459016, 4)
2539 self.assertAlmostEqual(spin70.r2[r20_key2], 9.39628959312699, 4)
2540 self.assertAlmostEqual(spin70.pA, 0.989700985380975, 4)
2541 self.assertAlmostEqual(spin70.dw, 5.6733714171086, 4)
2542 self.assertAlmostEqual(spin70.kex/1000, 1713.63101361545/1000, 4)
2543 self.assertAlmostEqual(spin70.chi2, 52.5106928523775, 4)
2544
2545
2546 self.assertAlmostEqual(spin71.r2[r20_key1], 4.99893565849977, 4)
2547 self.assertAlmostEqual(spin71.r2[r20_key2], 6.89825625944034, 4)
2548 self.assertAlmostEqual(spin71.pA, 0.986716058519642, 4)
2549 self.assertAlmostEqual(spin71.dw, 2.09292495350993, 4)
2550 self.assertAlmostEqual(spin71.kex/1000, 2438.04423541463/1000, 4)
2551 self.assertAlmostEqual(spin71.chi2, 15.164490242352, 4)
2552
2553
2554 self.assertEqual(spin70.k_AB, spin70.kex * (1.0 - spin70.pA))
2555 self.assertEqual(spin71.k_AB, spin71.kex * (1.0 - spin71.pA))
2556
2557
2558 self.assertEqual(spin70.k_BA, spin70.kex * spin70.pA)
2559 self.assertEqual(spin71.k_BA, spin71.kex * spin71.pA)
2560
2561
2563 """Optimisation of Dr. Flemming Hansen's CPMG data to the 'NS CPMG 2-site 3D full' dispersion model.
2564
2565 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.
2566 """
2567
2568
2569 self.setup_hansen_cpmg_data(model='NS CPMG 2-site 3D full')
2570
2571
2572 spin70 = return_spin(":70")
2573 spin71 = return_spin(":71")
2574
2575
2576 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6)
2577 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6)
2578
2579
2580 spin70.r2a = {r20_key1: 6.644753428, r20_key2: 7.891776687}
2581 spin70.r2b = {r20_key1: 7.163478485, r20_key2: 138.5170395}
2582 spin70.pA = 0.9884781357
2583 spin70.dw = 5.456507396
2584 spin70.kex = 1906.521189
2585 spin71.r2a = {r20_key1: 4.99893524108981, r20_key2: 100.0}
2586 spin71.r2b = {r20_key1: 8.27456243639973, r20_key2: 100.0}
2587 spin71.pA = 0.986709616684097
2588 spin71.dw = 2.09245158280905
2589 spin71.kex = 2438.2766211401
2590
2591
2592 self.interpreter.minimise(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)
2593
2594
2595 print("\n\nOptimised parameters:\n")
2596 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)"))
2597 print("%-20s %20.15g %20.15g" % ("R2A (500 MHz)", spin70.r2a[r20_key1], spin71.r2a[r20_key1]))
2598 print("%-20s %20.15g %20.15g" % ("R2B (500 MHz)", spin70.r2b[r20_key1], spin71.r2b[r20_key1]))
2599 print("%-20s %20.15g %20.15g" % ("R2A (800 MHz)", spin70.r2a[r20_key2], spin71.r2a[r20_key2]))
2600 print("%-20s %20.15g %20.15g" % ("R2B (800 MHz)", spin70.r2b[r20_key2], spin71.r2b[r20_key2]))
2601 print("%-20s %20.15g %20.15g" % ("pA", spin70.pA, spin71.pA))
2602 print("%-20s %20.15g %20.15g" % ("dw", spin70.dw, spin71.dw))
2603 print("%-20s %20.15g %20.15g" % ("kex", spin70.kex, spin71.kex))
2604 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2))
2605
2606
2607 self.assertAlmostEqual(spin70.r2a[r20_key1], 6.61176004043484, 4)
2608 self.assertAlmostEqual(spin70.r2b[r20_key1], 7.4869316381241, 4)
2609 self.assertAlmostEqual(spin70.r2a[r20_key2], 7.78200386067591, 4)
2610 self.assertAlmostEqual(spin70.r2b[r20_key2], 141.703593742468, 4)
2611 self.assertAlmostEqual(spin70.pA, 0.988404987055969, 4)
2612 self.assertAlmostEqual(spin70.dw, 5.4497360203213, 4)
2613 self.assertAlmostEqual(spin70.kex/1000, 1934.09304607082/1000, 4)
2614 self.assertAlmostEqual(spin70.chi2, 44.6793752187925, 4)
2615
2616
2617 self.assertAlmostEqual(spin71.r2a[r20_key1], 4.6013095731966, 4)
2618 self.assertAlmostEqual(spin71.r2b[r20_key1], 13.3245678276332, 4)
2619 self.assertAlmostEqual(spin71.r2a[r20_key2], 2.08243621257779, 4)
2620 self.assertAlmostEqual(spin71.r2b[r20_key2], 153.355765094575, 4)
2621 self.assertAlmostEqual(spin71.pA, 0.9665748685124, 4)
2622 self.assertAlmostEqual(spin71.dw, 1.41898001408953, 4)
2623 self.assertAlmostEqual(spin71.kex/1000, 2580.65795560688/1000, 4)
2624 self.assertAlmostEqual(spin71.chi2, 13.4937006732165, 4)
2625
2626
2627 self.assertEqual(spin70.k_AB, spin70.kex * (1.0 - spin70.pA))
2628 self.assertEqual(spin71.k_AB, spin71.kex * (1.0 - spin71.pA))
2629
2630
2631 self.assertEqual(spin70.k_BA, spin70.kex * spin70.pA)
2632 self.assertEqual(spin71.k_BA, spin71.kex * spin71.pA)
2633
2634
2636 """Optimisation of Dr. Flemming Hansen's CPMG data to the 'NS CPMG 2-site expanded' dispersion model.
2637
2638 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.
2639 """
2640
2641
2642 self.setup_hansen_cpmg_data(model='NS CPMG 2-site expanded')
2643
2644
2645 spin70 = return_spin(":70")
2646 spin71 = return_spin(":71")
2647
2648
2649 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6)
2650 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6)
2651
2652
2653 spin70.r2 = {r20_key1: 7.0, r20_key2: 9.0}
2654 spin70.pA = 0.9
2655 spin70.dw = 6.0
2656 spin70.kex = 1500.0
2657 spin71.r2 = {r20_key1: 5.0, r20_key2: 9.0}
2658 spin71.pA = 0.9
2659 spin71.dw = 4.0
2660 spin71.kex = 1900.0
2661
2662
2663 self.interpreter.minimise(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)
2664
2665
2666 print("\n\nOptimised parameters:\n")
2667 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)"))
2668 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin70.r2[r20_key1], spin71.r2[r20_key1]))
2669 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin70.r2[r20_key2], spin71.r2[r20_key2]))
2670 print("%-20s %20.15g %20.15g" % ("pA", spin70.pA, spin71.pA))
2671 print("%-20s %20.15g %20.15g" % ("dw", spin70.dw, spin71.dw))
2672 print("%-20s %20.15g %20.15g" % ("kex", spin70.kex, spin71.kex))
2673 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2))
2674
2675
2676 self.assertAlmostEqual(spin70.r2[r20_key1], 6.95813330991529, 4)
2677 self.assertAlmostEqual(spin70.r2[r20_key2], 9.39663480561524, 4)
2678 self.assertAlmostEqual(spin70.pA, 0.989700843879574, 4)
2679 self.assertAlmostEqual(spin70.dw, 5.67315878825691, 4)
2680 self.assertAlmostEqual(spin70.kex/1000, 1713.56110716632/1000, 4)
2681 self.assertAlmostEqual(spin70.chi2, 52.5106879242812, 4)
2682
2683
2684 self.assertAlmostEqual(spin71.r2[r20_key1], 4.99881666793312, 4)
2685 self.assertAlmostEqual(spin71.r2[r20_key2], 6.89817482453042, 4)
2686 self.assertAlmostEqual(spin71.pA, 0.986712911453639, 4)
2687 self.assertAlmostEqual(spin71.dw, 2.09273069372236, 4)
2688 self.assertAlmostEqual(spin71.kex/1000, 2438.20525930405/1000, 4)
2689 self.assertAlmostEqual(spin71.chi2, 15.1644913030633, 4)
2690
2691
2692 self.assertEqual(spin70.k_AB, spin70.kex * (1.0 - spin70.pA))
2693 self.assertEqual(spin71.k_AB, spin71.kex * (1.0 - spin71.pA))
2694
2695
2696 self.assertEqual(spin70.k_BA, spin70.kex * spin70.pA)
2697 self.assertEqual(spin71.k_BA, spin71.kex * spin71.pA)
2698
2699
2701 """Optimisation of Dr. Flemming Hansen's CPMG data to the 'NS CPMG 2-site star' dispersion model.
2702
2703 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.
2704 """
2705
2706
2707 self.setup_hansen_cpmg_data(model='NS CPMG 2-site star')
2708
2709
2710 spin70 = return_spin(":70")
2711 spin71 = return_spin(":71")
2712
2713
2714 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6)
2715 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6)
2716
2717
2718 spin70.r2 = {r20_key1: 6.996327746, r20_key2: 9.452051268}
2719 spin70.pA = 0.9897519798
2720 spin70.dw = 5.644862195
2721 spin70.kex = 1723.820567
2722 spin71.r2 = {r20_key1: 4.978654237, r20_key2: 9.276918959}
2723 spin71.pA = 0.9968032899
2724 spin71.dw = 4.577891393
2725 spin71.kex = 1830.044597
2726
2727
2728 self.interpreter.minimise(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)
2729
2730
2731 print("\n\nOptimised parameters:\n")
2732 print("%-20s %-20s %-20s" % ("Parameter", "Value (:70)", "Value (:71)"))
2733 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin70.r2[r20_key1], spin71.r2[r20_key1]))
2734 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin70.r2[r20_key2], spin71.r2[r20_key2]))
2735 print("%-20s %20.15g %20.15g" % ("pA", spin70.pA, spin71.pA))
2736 print("%-20s %20.15g %20.15g" % ("dw", spin70.dw, spin71.dw))
2737 print("%-20s %20.15g %20.15g" % ("kex", spin70.kex, spin71.kex))
2738 print("%-20s %20.15g %20.15g\n" % ("chi2", spin70.chi2, spin71.chi2))
2739
2740
2741 self.assertAlmostEqual(spin70.r2[r20_key1], 6.95543947938561, 1)
2742 self.assertAlmostEqual(spin70.r2[r20_key2], 9.38991914134929, 1)
2743 self.assertAlmostEqual(spin70.pA, 0.989702750971153, 3)
2744 self.assertAlmostEqual(spin70.dw, 5.67527122494516, 1)
2745 self.assertAlmostEqual(spin70.kex/1000, 1715.72032391817/1000, 1)
2746 self.assertAlmostEqual(spin70.chi2, 52.5011991483842, 1)
2747
2748
2749 self.assertAlmostEqual(spin71.r2[r20_key1], 4.992594256544, 1)
2750 self.assertAlmostEqual(spin71.pA, 0.992258541625787, 2)
2751 self.assertAlmostEqual(spin71.dw/100, 2.75140650899058/100, 2)
2752 self.assertAlmostEqual(spin71.kex/100000, 2106.60885247431/100000, 2)
2753 self.assertAlmostEqual(spin71.chi2/100, 17.3293856656588/100, 1)
2754
2755
2756 self.assertEqual(spin70.k_AB, spin70.kex * (1.0 - spin70.pA))
2757 self.assertEqual(spin71.k_AB, spin71.kex * (1.0 - spin71.pA))
2758
2759
2760 self.assertEqual(spin70.k_BA, spin70.kex * spin70.pA)
2761 self.assertEqual(spin71.k_BA, spin71.kex * spin71.pA)
2762
2763
2765 """Optimisation of Dr. Flemming Hansen's CPMG data to the 'NS CPMG 2-site star full' dispersion model.
2766
2767 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.
2768 """
2769
2770
2771 self.setup_hansen_cpmg_data(model='NS CPMG 2-site star full')
2772
2773
2774 spin70 = return_spin(":70")
2775 spin71 = return_spin(":71")
2776
2777
2778 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6)
2779 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6)
2780
2781
2782 spin70.r2a = {r20_key1: 6.44836878645126, r20_key2: 7.00382877393494}
2783 spin70.r2b = {r20_key1: 12.2083127421994, r20_key2: 199.862962628402}
2784 spin70.pA = 0.987648082613451
2785 spin70.dw = 5.30679853807572
2786 spin70.kex = 2033.25380420666
2787 spin71.r2a = {r20_key1: 4.992594256544, r20_key2: 6.98674718938435}
2788 spin71.r2b = {r20_key1: 4.992594256544, r20_key2: 6.98674718938435}
2789 spin71.pA = 0.992258541625787
2790 spin71.dw = 2.75140650899058
2791 spin71.kex = 2106.60885247431
2792
2793
2794 self.interpreter.calc()
2795
2796
2797 self.assertAlmostEqual(spin70.chi2/10, 45.773987568491123/10, 2)
2798 self.assertAlmostEqual(spin71.chi2/10, 17.329385665659192/10, 2)
2799
2800
2942
2943
2945 """Optimisation of the Korzhnev et al., 2005 15N DQ CPMG data using the 'NS MMQ 2-site' model.
2946
2947 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.
2948
2949 Here only the 15N DQ data will be optimised. The values found by cpmg_fit using just this data are:
2950
2951 - r2 = {'500': 9.487269007171426, '600': 11.718267257562591, '800': 13.624551743116887},
2952 - pA = 0.965402506690231,
2953 - dw = 0.805197170133360,
2954 - dwH = -0.595536627771890,
2955 - kex = 569.003663067619868,
2956 - chi2 = 9.297671357952812.
2957 """
2958
2959
2960 self.setup_korzhnev_2005_data(data_list=['DQ'])
2961
2962
2963 spin = return_spin(":9@N")
2964
2965
2966 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_DQ, frq=500e6)
2967 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_DQ, frq=600e6)
2968 r20_key3 = generate_r20_key(exp_type=EXP_TYPE_CPMG_DQ, frq=800e6)
2969
2970
2971 spin.r2 = {r20_key1: 9.48527908326952, r20_key2: 11.7135951595536, r20_key3: 13.6153887849344}
2972 spin.pA = 0.965638501551899
2973 spin.dw = 2.8537583461577
2974 spin.dwH = -0.387633062766635
2975 spin.kex = 573.704033851592
2976
2977
2978 self.interpreter.minimise(min_algor='simplex', func_tol=1e-05, max_iter=1000)
2979
2980
2981 self.interpreter.monte_carlo.setup(number=2)
2982 self.interpreter.monte_carlo.create_data(method='back_calc')
2983 self.interpreter.monte_carlo.initial_values()
2984 self.interpreter.minimise(min_algor='simplex', max_iter=10)
2985 self.interpreter.monte_carlo.error_analysis()
2986
2987
2988 self.interpreter.relax_disp.plot_disp_curves(dir=ds.tmpdir, force=True)
2989
2990
2991 self.interpreter.state.save('state', dir=ds.tmpdir, compress_type=1, force=True)
2992
2993
2994 print("\n\nOptimised parameters:\n")
2995 print("%-20s %-20s" % ("Parameter", "Value (:9)"))
2996 print("%-20s %20.15g" % ("R2 (500 MHz)", spin.r2[r20_key1]))
2997 print("%-20s %20.15g" % ("R2 (600 MHz)", spin.r2[r20_key2]))
2998 print("%-20s %20.15g" % ("R2 (800 MHz)", spin.r2[r20_key3]))
2999 print("%-20s %20.15g" % ("pA", spin.pA))
3000 print("%-20s %20.15g" % ("dw", spin.dw))
3001 print("%-20s %20.15g" % ("dwH", spin.dwH))
3002 print("%-20s %20.15g" % ("kex", spin.kex))
3003 print("%-20s %20.15g\n" % ("chi2", spin.chi2))
3004
3005
3006 self.assertAlmostEqual(spin.r2[r20_key1], 9.48527908326952, 2)
3007 self.assertAlmostEqual(spin.r2[r20_key2], 11.7135951595536, 2)
3008 self.assertAlmostEqual(spin.r2[r20_key3], 13.6153887849344, 2)
3009 self.assertAlmostEqual(spin.pA, 0.965638501551899, 4)
3010 self.assertAlmostEqual(spin.dw, 2.8537583461577, 1)
3011 self.assertAlmostEqual(spin.dwH, -0.387633062766635, 2)
3012 self.assertAlmostEqual(spin.kex/1000, 573.704033851592/1000, 3)
3013 self.assertAlmostEqual(spin.chi2, 9.29563496654824, 2)
3014
3015
3017 """Optimisation of the Korzhnev et al., 2005 15N MQ CPMG data using the 'NS MMQ 2-site' model.
3018
3019 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.
3020
3021 Here only the 15N MQ data will be optimised. The values found by cpmg_fit using just this data are:
3022
3023 - r2 = {'500': 5.993083514798655, '600': 6.622184438384841, '800': 8.640765919352019},
3024 - pA = 0.930027999814003,
3025 - dw = 4.338620619954370,
3026 - dwH = -0.274250775560818,
3027 - kex = 344.613362916544475,
3028 - chi2 = 10.367733168217050.
3029 """
3030
3031
3032 self.setup_korzhnev_2005_data(data_list=['MQ'])
3033
3034
3035 spin = return_spin(":9@N")
3036
3037
3038 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_MQ, frq=500e6)
3039 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_MQ, frq=600e6)
3040 r20_key3 = generate_r20_key(exp_type=EXP_TYPE_CPMG_MQ, frq=800e6)
3041
3042
3043 spin.r2 = {r20_key1: 6.02016436619016, r20_key2: 6.65421500772308, r20_key3: 8.6729591487622}
3044 spin.pA = 0.930083249288083
3045 spin.dw = 4.33890689462363
3046 spin.dwH = -0.274316585638047
3047 spin.kex = 344.329651956132
3048
3049
3050 self.interpreter.minimise(min_algor='simplex', func_tol=1e-05, max_iter=1000)
3051
3052
3053 self.interpreter.monte_carlo.setup(number=2)
3054 self.interpreter.monte_carlo.create_data(method='back_calc')
3055 self.interpreter.monte_carlo.initial_values()
3056 self.interpreter.minimise(min_algor='simplex', max_iter=10)
3057 self.interpreter.monte_carlo.error_analysis()
3058
3059
3060 self.interpreter.relax_disp.plot_disp_curves(dir=ds.tmpdir, force=True)
3061
3062
3063 self.interpreter.state.save('state', dir=ds.tmpdir, compress_type=1, force=True)
3064
3065
3066 print("\n\nOptimised parameters:\n")
3067 print("%-20s %-20s" % ("Parameter", "Value (:9)"))
3068 print("%-20s %20.15g" % ("R2 (500 MHz)", spin.r2[r20_key1]))
3069 print("%-20s %20.15g" % ("R2 (600 MHz)", spin.r2[r20_key2]))
3070 print("%-20s %20.15g" % ("R2 (800 MHz)", spin.r2[r20_key3]))
3071 print("%-20s %20.15g" % ("pA", spin.pA))
3072 print("%-20s %20.15g" % ("dw", spin.dw))
3073 print("%-20s %20.15g" % ("dwH", spin.dwH))
3074 print("%-20s %20.15g" % ("kex", spin.kex))
3075 print("%-20s %20.15g\n" % ("chi2", spin.chi2))
3076
3077
3078 self.assertAlmostEqual(spin.r2[r20_key1], 6.02016436619016, 1)
3079 self.assertAlmostEqual(spin.r2[r20_key2], 6.65421500772308, 1)
3080 self.assertAlmostEqual(spin.r2[r20_key3], 8.6729591487622, 1)
3081 self.assertAlmostEqual(spin.pA, 0.930083249288083, 3)
3082 self.assertAlmostEqual(spin.dw, 4.33890689462363, 2)
3083 self.assertAlmostEqual(spin.dwH, -0.274316585638047, 3)
3084 self.assertAlmostEqual(spin.kex/1000, 344.329651956132/1000, 3)
3085 self.assertAlmostEqual(spin.chi2, 10.3654315659173, 2)
3086
3087
3089 """Optimisation of the Korzhnev et al., 2005 15N SQ CPMG data using the 'NS MMQ 2-site' model.
3090
3091 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.
3092
3093 Here only the 15N SQ data will be optimised. The values found by cpmg_fit using just this data are:
3094
3095 - r2 = {'500': 8.335037972570017, '600': 8.761366016417508, '800': 10.225001019091822},
3096 - pA = 0.950003458294991,
3097 - dw = 4.358402855315123,
3098 - kex = 429.906473361926999,
3099 - chi2 = 17.393331915567252.
3100 """
3101
3102
3103 self.setup_korzhnev_2005_data(data_list=['SQ'])
3104
3105
3106 spin = return_spin(":9@N")
3107
3108
3109 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6)
3110 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=600e6)
3111 r20_key3 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6)
3112
3113
3114 spin.r2 = {r20_key1: 8.334232330326190, r20_key2: 8.756773997879968, r20_key3: 10.219320492033058}
3115 spin.pA = 0.950310172115387
3116 spin.dw = 4.356737157889636
3117 spin.kex = 433.176323890829849
3118
3119
3120 self.interpreter.minimise(min_algor='simplex', func_tol=1e-05, max_iter=1000)
3121
3122
3123 self.interpreter.monte_carlo.setup(number=2)
3124 self.interpreter.monte_carlo.create_data(method='back_calc')
3125 self.interpreter.monte_carlo.initial_values()
3126 self.interpreter.minimise(min_algor='simplex', max_iter=10)
3127 self.interpreter.monte_carlo.error_analysis()
3128
3129
3130 self.interpreter.relax_disp.plot_disp_curves(dir=ds.tmpdir, force=True)
3131
3132
3133 self.interpreter.state.save('state', dir=ds.tmpdir, compress_type=1, force=True)
3134
3135
3136 print("\n\nOptimised parameters:\n")
3137 print("%-20s %-20s" % ("Parameter", "Value (:9)"))
3138 print("%-20s %20.15g" % ("R2 (500 MHz)", spin.r2[r20_key1]))
3139 print("%-20s %20.15g" % ("R2 (600 MHz)", spin.r2[r20_key2]))
3140 print("%-20s %20.15g" % ("R2 (800 MHz)", spin.r2[r20_key3]))
3141 print("%-20s %20.15g" % ("pA", spin.pA))
3142 print("%-20s %20.15g" % ("dw", spin.dw))
3143 print("%-20s %20.15g" % ("kex", spin.kex))
3144 print("%-20s %20.15g\n" % ("chi2", spin.chi2))
3145
3146
3147 self.assertAlmostEqual(spin.r2[r20_key1], 8.334232330326190, 2)
3148 self.assertAlmostEqual(spin.r2[r20_key2], 8.756773997879968, 2)
3149 self.assertAlmostEqual(spin.r2[r20_key3], 10.219320492033058, 1)
3150 self.assertAlmostEqual(spin.pA, 0.950310172115387, 3)
3151 self.assertAlmostEqual(spin.dw, 4.356737157889636, 2)
3152 self.assertAlmostEqual(spin.kex/1000, 433.176323890829849/1000, 3)
3153 self.assertAlmostEqual(spin.chi2, 17.37460582872912, 1)
3154
3155
3157 """Optimisation of the Korzhnev et al., 2005 15N ZQ CPMG data using the 'NS MMQ 2-site' model.
3158
3159 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.
3160
3161 Here only the 15N ZQ data will be optimised. The values found by cpmg_fit using just this data are:
3162
3163 - r2 = {'500': 5.909812628572937, '600': 6.663690132557320, '800': 6.787171647689906},
3164 - pA = 0.942452612380140,
3165 - dw = 0.858972784230892,
3166 - dwH = 0.087155962730608,
3167 - kex = 373.219151384798920,
3168 - chi2 = 23.863208106025152.
3169 """
3170
3171
3172 self.setup_korzhnev_2005_data(data_list=['ZQ'])
3173
3174
3175 spin = return_spin(":9@N")
3176
3177
3178 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_ZQ, frq=500e6)
3179 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_ZQ, frq=600e6)
3180 r20_key3 = generate_r20_key(exp_type=EXP_TYPE_CPMG_ZQ, frq=800e6)
3181
3182
3183 spin.r2 = {r20_key1: 5.91033272691614, r20_key2: 6.66368695342258, r20_key3: 6.78922219135537}
3184 spin.pA = 0.942457332074014
3185 spin.dw = 0.850592422908884
3186 spin.dwH = 0.0881272284455416
3187 spin.kex = 372.745483351305
3188
3189
3190 self.interpreter.minimise(min_algor='simplex', func_tol=1e-05, max_iter=1000)
3191
3192
3193 self.interpreter.monte_carlo.setup(number=2)
3194 self.interpreter.monte_carlo.create_data(method='back_calc')
3195 self.interpreter.monte_carlo.initial_values()
3196 self.interpreter.minimise(min_algor='simplex', max_iter=10)
3197 self.interpreter.monte_carlo.error_analysis()
3198
3199
3200 self.interpreter.relax_disp.plot_disp_curves(dir=ds.tmpdir, force=True)
3201
3202
3203 self.interpreter.state.save('state', dir=ds.tmpdir, compress_type=1, force=True)
3204
3205
3206 print("\n\nOptimised parameters:\n")
3207 print("%-20s %-20s" % ("Parameter", "Value (:9)"))
3208 print("%-20s %20.15g" % ("R2 (500 MHz)", spin.r2[r20_key1]))
3209 print("%-20s %20.15g" % ("R2 (600 MHz)", spin.r2[r20_key2]))
3210 print("%-20s %20.15g" % ("R2 (800 MHz)", spin.r2[r20_key3]))
3211 print("%-20s %20.15g" % ("pA", spin.pA))
3212 print("%-20s %20.15g" % ("dw", spin.dw))
3213 print("%-20s %20.15g" % ("dwH", spin.dwH))
3214 print("%-20s %20.15g" % ("kex", spin.kex))
3215 print("%-20s %20.15g\n" % ("chi2", spin.chi2))
3216
3217
3218 self.assertAlmostEqual(spin.r2[r20_key1], 5.91033272691614, 2)
3219 self.assertAlmostEqual(spin.r2[r20_key2], 6.66368695342258, 2)
3220 self.assertAlmostEqual(spin.r2[r20_key3], 6.78922219135537, 2)
3221 self.assertAlmostEqual(spin.pA, 0.942457332074014, 4)
3222 self.assertAlmostEqual(spin.dw, 0.850592422908884, 1)
3223 self.assertAlmostEqual(spin.dwH, 0.0881272284455416, 2)
3224 self.assertAlmostEqual(spin.kex/1000, 372.745483351305/1000, 3)
3225 self.assertAlmostEqual(spin.chi2, 23.8464637019392, 1)
3226
3227
3229 """Optimisation of the Korzhnev et al., 2005 1H MQ CPMG data using the 'NS MMQ 2-site' model.
3230
3231 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.
3232
3233 Here only the 1H MQ data will be optimised. The values found by cpmg_fit using just this data are:
3234
3235 - r2 = {'500': -0.000016676911302, '600': 0.036594127620440, '800': 2.131014839635728},
3236 - pA = 0.936911090448340,
3237 - dw = 4.325314846914845,
3238 - dwH = -0.213870168665628,
3239 - kex = 487.361914835074117,
3240 - chi2 = 14.870371897291138.
3241 """
3242
3243
3244 self.setup_korzhnev_2005_data(data_list=['1H MQ'])
3245
3246
3247 spin = return_spin(":9@N")
3248
3249
3250 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_MQ, frq=500e6)
3251 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_MQ, frq=600e6)
3252 r20_key3 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_MQ, frq=800e6)
3253
3254
3255 spin.r2 = {r20_key1: 0.000022585022901, r20_key2: 0.039223196112941, r20_key3: 2.136576686700357}
3256 spin.pA = 0.936884348941701
3257 spin.dw = 4.326454531583964
3258 spin.dwH = -0.214026093221782
3259 spin.kex = 487.043592705469223
3260
3261
3262 self.interpreter.minimise(min_algor='simplex', func_tol=1e-05, max_iter=100)
3263
3264
3265 self.interpreter.monte_carlo.setup(number=2)
3266 self.interpreter.monte_carlo.create_data(method='back_calc')
3267 self.interpreter.monte_carlo.initial_values()
3268 self.interpreter.minimise(min_algor='simplex', max_iter=10)
3269 self.interpreter.monte_carlo.error_analysis()
3270
3271
3272 self.interpreter.relax_disp.plot_disp_curves(dir=ds.tmpdir, force=True)
3273
3274
3275 self.interpreter.state.save('state', dir=ds.tmpdir, compress_type=1, force=True)
3276
3277
3278 print("\n\nOptimised parameters:\n")
3279 print("%-20s %-20s" % ("Parameter", "Value (:9)"))
3280 print("%-20s %20.15g" % ("R2 (500 MHz)", spin.r2[r20_key1]))
3281 print("%-20s %20.15g" % ("R2 (600 MHz)", spin.r2[r20_key2]))
3282 print("%-20s %20.15g" % ("R2 (800 MHz)", spin.r2[r20_key3]))
3283 print("%-20s %20.15g" % ("pA", spin.pA))
3284 print("%-20s %20.15g" % ("dw", spin.dw))
3285 print("%-20s %20.15g" % ("dwH", spin.dwH))
3286 print("%-20s %20.15g" % ("kex", spin.kex))
3287 print("%-20s %20.15g\n" % ("chi2", spin.chi2))
3288
3289
3290 self.assertAlmostEqual(spin.r2[r20_key1], 0.000023714274046, 4)
3291 self.assertAlmostEqual(spin.r2[r20_key2], 0.039223196112941, 2)
3292 self.assertAlmostEqual(spin.r2[r20_key3], 2.13657668670036, 2)
3293 self.assertAlmostEqual(spin.pA, 0.936884348941701, 4)
3294 self.assertAlmostEqual(spin.dw, 4.32645453158396, 2)
3295 self.assertAlmostEqual(spin.dwH, -0.214026093221782, 2)
3296 self.assertAlmostEqual(spin.kex/1000, 487.043592705469/1000, 4)
3297 self.assertAlmostEqual(spin.chi2, 14.8642315375301, 2)
3298
3299
3301 """Optimisation of the Korzhnev et al., 2005 1H SQ CPMG data using the 'NS MMQ 2-site' model.
3302
3303 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.
3304
3305 Here only the 1H SQ data will be optimised. The values found by cpmg_fit using just this data are:
3306
3307 - r2 = {'500': 6.691697587650816, '600': 6.998915158708793, '800': 5.519267837559072},
3308 - pA = 0.946949480545876,
3309 - dwH = -0.265279672133308,
3310 - kex = 406.548178869750700,
3311 - chi2 = 50.400680290545026.
3312 """
3313
3314
3315 self.setup_korzhnev_2005_data(data_list=['1H SQ'])
3316
3317
3318 spin = return_spin(":9@N")
3319
3320
3321 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_SQ, frq=500e6)
3322 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_SQ, frq=600e6)
3323 r20_key3 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_SQ, frq=800e6)
3324
3325
3326 spin.r2 = {r20_key1: 6.69107911078939, r20_key2: 6.99888898689085, r20_key3: 5.52012880268077}
3327 spin.pA = 0.946990967372467
3328 spin.dwH = -0.265308128403529
3329 spin.kex = 406.843250675648
3330
3331
3332 self.interpreter.minimise(min_algor='simplex', func_tol=1e-05, max_iter=1000)
3333
3334
3335 self.interpreter.monte_carlo.setup(number=2)
3336 self.interpreter.monte_carlo.create_data(method='back_calc')
3337 self.interpreter.monte_carlo.initial_values()
3338 self.interpreter.minimise(min_algor='simplex', max_iter=10)
3339 self.interpreter.monte_carlo.error_analysis()
3340
3341
3342 self.interpreter.relax_disp.plot_disp_curves(dir=ds.tmpdir, force=True)
3343
3344
3345 self.interpreter.state.save('state', dir=ds.tmpdir, compress_type=1, force=True)
3346
3347
3348 print("\n\nOptimised parameters:\n")
3349 print("%-20s %-20s" % ("Parameter", "Value (:9)"))
3350 print("%-20s %20.15g" % ("R2 (500 MHz)", spin.r2[r20_key1]))
3351 print("%-20s %20.15g" % ("R2 (600 MHz)", spin.r2[r20_key2]))
3352 print("%-20s %20.15g" % ("R2 (800 MHz)", spin.r2[r20_key3]))
3353 print("%-20s %20.15g" % ("pA", spin.pA))
3354 print("%-20s %20.15g" % ("dwH", spin.dwH))
3355 print("%-20s %20.15g" % ("kex", spin.kex))
3356 print("%-20s %20.15g\n" % ("chi2", spin.chi2))
3357
3358
3359 self.assertAlmostEqual(spin.r2[r20_key1], 6.69107911078939, 2)
3360 self.assertAlmostEqual(spin.r2[r20_key2], 6.99888898689085, 2)
3361 self.assertAlmostEqual(spin.r2[r20_key3], 5.52012880268077, 2)
3362 self.assertAlmostEqual(spin.pA, 0.946990967372467, 4)
3363 self.assertAlmostEqual(spin.dwH, -0.265308128403529, 4)
3364 self.assertAlmostEqual(spin.kex/1000, 406.843250675648/1000, 2)
3365 self.assertAlmostEqual(spin.chi2, 50.3431330819767, 1)
3366
3367
3369 """Optimisation of all the Korzhnev et al., 2005 CPMG data using the 'NS MMQ 2-site' model.
3370
3371 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.
3372
3373 Here all data will be optimised. The values found by cpmg_fit using just this data are:
3374
3375 - r2 = {'H-S 500': 6.671649051677150, 'H-S 600': 6.988634195648529, 'H-S 800': 5.527971316790596,
3376 'N-S 500': 8.394988400015988, 'N-S 600': 8.891359568401835, 'N-S 800': 10.405356669006709,
3377 'NHZ 500': 5.936446687394352, 'NHZ 600': 6.717058062814535, 'NHZ 800': 6.838733853403030,
3378 'NHD 500': 8.593136215779710, 'NHD 600': 10.651511259239674, 'NHD 800': 12.567902357560627,
3379 'HNM 500': 7.851325614877817, 'HNM 600': 8.408803624020202, 'HNM 800': 11.227489645758979,
3380 'NHM 500': 9.189159145380575, 'NHM 600': 9.856814478405868, 'NHM 800': 11.967910041807118},
3381 - pA = 0.943125351763911,
3382 - dw = 4.421827493809807,
3383 - dwH = -0.272637034755752,
3384 - kex = 360.609744568697238,
3385 - chi2 = 162.589570340050813.
3386 """
3387
3388
3389 self.setup_korzhnev_2005_data(data_list=['SQ', '1H SQ', 'DQ', 'ZQ', 'MQ', '1H MQ'])
3390
3391
3392 spin = return_spin(":9@N")
3393
3394
3395 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_SQ, frq=500e6)
3396 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_SQ, frq=600e6)
3397 r20_key3 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_SQ, frq=800e6)
3398 r20_key4 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6)
3399 r20_key5 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=600e6)
3400 r20_key6 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6)
3401 r20_key7 = generate_r20_key(exp_type=EXP_TYPE_CPMG_ZQ, frq=500e6)
3402 r20_key8 = generate_r20_key(exp_type=EXP_TYPE_CPMG_ZQ, frq=600e6)
3403 r20_key9 = generate_r20_key(exp_type=EXP_TYPE_CPMG_ZQ, frq=800e6)
3404 r20_key10 = generate_r20_key(exp_type=EXP_TYPE_CPMG_DQ, frq=500e6)
3405 r20_key11 = generate_r20_key(exp_type=EXP_TYPE_CPMG_DQ, frq=600e6)
3406 r20_key12 = generate_r20_key(exp_type=EXP_TYPE_CPMG_DQ, frq=800e6)
3407 r20_key13 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_MQ, frq=500e6)
3408 r20_key14 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_MQ, frq=600e6)
3409 r20_key15 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_MQ, frq=800e6)
3410 r20_key16 = generate_r20_key(exp_type=EXP_TYPE_CPMG_MQ, frq=500e6)
3411 r20_key17 = generate_r20_key(exp_type=EXP_TYPE_CPMG_MQ, frq=600e6)
3412 r20_key18 = generate_r20_key(exp_type=EXP_TYPE_CPMG_MQ, frq=800e6)
3413
3414
3415 spin.r2 = {
3416 r20_key1: 6.67288025927458, r20_key2: 6.98951408255098, r20_key3: 5.52959273852704,
3417 r20_key4: 8.39471048876782, r20_key5: 8.89290699178799, r20_key6: 10.40770687236930,
3418 r20_key7: 5.93611174376373, r20_key8: 6.71735669582514, r20_key9: 6.83835225518265,
3419 r20_key10: 8.59615074668922, r20_key11: 10.65121378892910, r20_key12: 12.57108229191090,
3420 r20_key13: 7.85956711501608, r20_key14: 8.41891642907918, r20_key15: 11.23620892230380,
3421 r20_key16: 9.19654863789350, r20_key17: 9.86031627358462, r20_key18: 11.97523755925750
3422 }
3423 spin.pA = 0.943129019477673
3424 spin.dw = 4.42209952545181
3425 spin.dwH = -0.27258970590969
3426 spin.kex = 360.516132791038
3427
3428
3429 self.interpreter.minimise(min_algor='simplex', func_tol=1e-05, max_iter=10)
3430
3431
3432 self.interpreter.monte_carlo.setup(number=2)
3433 self.interpreter.monte_carlo.create_data(method='back_calc')
3434 self.interpreter.monte_carlo.initial_values()
3435 self.interpreter.minimise(min_algor='simplex', max_iter=10)
3436 self.interpreter.monte_carlo.error_analysis()
3437
3438
3439 self.interpreter.relax_disp.plot_disp_curves(dir=ds.tmpdir, force=True)
3440
3441
3442 self.interpreter.state.save('state', dir=ds.tmpdir, compress_type=1, force=True)
3443
3444
3445 print("\n\nOptimised parameters:\n")
3446 print("%-20s %-20s" % ("Parameter", "Value (:9)"))
3447 print("%-20s %20.15g" % ("R2 (1H SQ - 500 MHz)", spin.r2[r20_key1]))
3448 print("%-20s %20.15g" % ("R2 (1H SQ - 600 MHz)", spin.r2[r20_key2]))
3449 print("%-20s %20.15g" % ("R2 (1H SQ - 800 MHz)", spin.r2[r20_key3]))
3450 print("%-20s %20.15g" % ("R2 (SQ - 500 MHz)", spin.r2[r20_key4]))
3451 print("%-20s %20.15g" % ("R2 (SQ - 600 MHz)", spin.r2[r20_key5]))
3452 print("%-20s %20.15g" % ("R2 (SQ - 800 MHz)", spin.r2[r20_key6]))
3453 print("%-20s %20.15g" % ("R2 (ZQ - 500 MHz)", spin.r2[r20_key7]))
3454 print("%-20s %20.15g" % ("R2 (ZQ - 600 MHz)", spin.r2[r20_key8]))
3455 print("%-20s %20.15g" % ("R2 (ZQ - 800 MHz)", spin.r2[r20_key9]))
3456 print("%-20s %20.15g" % ("R2 (DQ - 500 MHz)", spin.r2[r20_key10]))
3457 print("%-20s %20.15g" % ("R2 (DQ - 600 MHz)", spin.r2[r20_key11]))
3458 print("%-20s %20.15g" % ("R2 (DQ - 800 MHz)", spin.r2[r20_key12]))
3459 print("%-20s %20.15g" % ("R2 (1H MQ - 500 MHz)", spin.r2[r20_key13]))
3460 print("%-20s %20.15g" % ("R2 (1H MQ - 600 MHz)", spin.r2[r20_key14]))
3461 print("%-20s %20.15g" % ("R2 (1H MQ - 800 MHz)", spin.r2[r20_key15]))
3462 print("%-20s %20.15g" % ("R2 (MQ - 500 MHz)", spin.r2[r20_key16]))
3463 print("%-20s %20.15g" % ("R2 (MQ - 600 MHz)", spin.r2[r20_key17]))
3464 print("%-20s %20.15g" % ("R2 (MQ - 800 MHz)", spin.r2[r20_key18]))
3465 print("%-20s %20.15g" % ("pA", spin.pA))
3466 print("%-20s %20.15g" % ("dw", spin.dw))
3467 print("%-20s %20.15g" % ("dwH", spin.dwH))
3468 print("%-20s %20.15g" % ("kex", spin.kex))
3469 print("%-20s %20.15g\n" % ("chi2", spin.chi2))
3470
3471
3472 self.assertAlmostEqual(spin.r2[r20_key1], 6.67288025927458, 4)
3473 self.assertAlmostEqual(spin.r2[r20_key2], 6.98951408255098, 4)
3474 self.assertAlmostEqual(spin.r2[r20_key3], 5.52959273852704, 4)
3475 self.assertAlmostEqual(spin.r2[r20_key4], 8.39471048876782, 4)
3476 self.assertAlmostEqual(spin.r2[r20_key5], 8.89290699178799, 4)
3477 self.assertAlmostEqual(spin.r2[r20_key6], 10.4077068723693, 4)
3478 self.assertAlmostEqual(spin.r2[r20_key7], 5.93611174376373, 4)
3479 self.assertAlmostEqual(spin.r2[r20_key8], 6.71735669582514, 4)
3480 self.assertAlmostEqual(spin.r2[r20_key9], 6.83835225518265, 4)
3481 self.assertAlmostEqual(spin.r2[r20_key10], 8.59615074668922, 4)
3482 self.assertAlmostEqual(spin.r2[r20_key11], 10.6512137889291, 4)
3483 self.assertAlmostEqual(spin.r2[r20_key12], 12.5710822919109, 4)
3484 self.assertAlmostEqual(spin.r2[r20_key13], 7.85956711501608, 4)
3485 self.assertAlmostEqual(spin.r2[r20_key14], 8.41891642907918, 4)
3486 self.assertAlmostEqual(spin.r2[r20_key15], 11.2362089223038, 4)
3487 self.assertAlmostEqual(spin.r2[r20_key16], 9.1965486378935, 4)
3488 self.assertAlmostEqual(spin.r2[r20_key17], 9.86031627358462, 4)
3489 self.assertAlmostEqual(spin.r2[r20_key18], 11.9752375592575, 4)
3490 self.assertAlmostEqual(spin.pA, 0.943129019477673, 4)
3491 self.assertAlmostEqual(spin.dw, 4.42209952545181, 4)
3492 self.assertAlmostEqual(spin.dwH, -0.27258970590969, 4)
3493 self.assertAlmostEqual(spin.kex/1000, 360.516132791038/1000, 4)
3494 self.assertAlmostEqual(spin.chi2/1000, 162.511988511609/1000, 3)
3495
3496
3498 """Optimisation of Kaare Teilum, Flemming M Poulsen, Mikael Akke 2006 "acyl-CoA binding protein" CPMG data to the CR72 dispersion model.
3499
3500 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).
3501 """
3502
3503
3504 self.setup_kteilum_fmpoulsen_makke_cpmg_data(model='CR72', expfolder="acbp_cpmg_disp_048MGuHCl_40C_041223")
3505
3506
3507 res61L = cdp.mol[0].res[0].spin[0]
3508
3509
3510 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=599.89086220e6)
3511
3512
3513 res61L.r2 = {r20_key1: 8.0}
3514 res61L.pA = 0.9
3515 res61L.dw = 6.0
3516 res61L.kex = 600.0
3517
3518
3519 self.interpreter.minimise(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)
3520
3521
3522 print("\n\nOptimised parameters:\n")
3523 print("%-20s %-20s" % ("Parameter", "Value (:61)"))
3524 print("%-20s %20.15g" % ("R2 (600 MHz)", res61L.r2[r20_key1]))
3525 print("%-20s %20.15g" % ("pA", res61L.pA))
3526 print("%-20s %20.15g" % ("dw", res61L.dw))
3527 print("%-20s %20.15g" % ("kex", res61L.kex))
3528 print("%-20s %20.15g\n" % ("chi2", res61L.chi2))
3529
3530
3531 self.assertAlmostEqual(res61L.r2[r20_key1], 8.69277980194016, 4)
3532 self.assertAlmostEqual(res61L.pA, 0.9943781590842946, 5)
3533 self.assertAlmostEqual(res61L.dw, 6.389453131263374, 3)
3534 self.assertAlmostEqual(res61L.kex, 609.262167216419, 0)
3535 self.assertAlmostEqual(res61L.chi2, 65.99987828889657, 5)
3536
3537
3538 self.assertEqual(res61L.k_AB, res61L.kex * (1.0 - res61L.pA))
3539
3540
3541 self.assertEqual(res61L.k_BA, res61L.kex * res61L.pA)
3542
3543
3545 """Optimisation of Kaare Teilum, Flemming M Poulsen, Mikael Akke 2006 "acyl-CoA binding protein" CPMG data to the CR72 dispersion model.
3546
3547 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).
3548 """
3549
3550
3551 self.setup_kteilum_fmpoulsen_makke_cpmg_data(model='CR72 full', expfolder="acbp_cpmg_disp_048MGuHCl_40C_041223")
3552
3553
3554 res61L = cdp.mol[0].res[0].spin[0]
3555
3556
3557 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=599.89086220e6)
3558
3559
3560 res61L.r2a = {r20_key1: 8.0}
3561 res61L.r2b = {r20_key1: 105.0}
3562 res61L.pA = 0.9
3563 res61L.dw = 6.0
3564 res61L.kex = 500.0
3565
3566
3567 self.interpreter.minimise(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)
3568
3569
3570 print("\n\nOptimised parameters:\n")
3571 print("%-20s %-20s" % ("Parameter", "Value (:61)"))
3572 print("%-20s %20.15g" % ("R2A (600 MHz)", res61L.r2a[r20_key1]))
3573 print("%-20s %20.15g" % ("R2B (600 MHz)", res61L.r2b[r20_key1]))
3574 print("%-20s %20.15g" % ("pA", res61L.pA))
3575 print("%-20s %20.15g" % ("dw", res61L.dw))
3576 print("%-20s %20.15g" % ("kex", res61L.kex))
3577 print("%-20s %20.15g\n" % ("chi2", res61L.chi2))
3578
3579
3580 self.assertAlmostEqual(res61L.r2a[r20_key1], 8.044428899438309, 0)
3581 self.assertAlmostEqual(res61L.r2b[r20_key1], 105.11894506392449, -2)
3582 self.assertAlmostEqual(res61L.pA, 0.992066883657578, 2)
3583 self.assertAlmostEqual(res61L.dw, 6.389453586338883, 3)
3584 self.assertAlmostEqual(res61L.kex, 513.483608742063, -2)
3585 self.assertAlmostEqual(res61L.chi2, 65.99987828890289, 5)
3586
3587
3589 """Optimisation of Kaare Teilum, Flemming M Poulsen, Mikael Akke 2006 "acyl-CoA binding protein" CPMG data to the CR72 dispersion model.
3590
3591 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).
3592
3593 Figure 3 shows the ln( k_a [s^-1]) for different concentrations of GuHCl. The precise values are:
3594
3595 - [GuHCL][M] ln(k_a[s^-1]) k_a[s^-1]
3596 - 0.483 0.89623903 2.4503699912708878
3597 - 0.545 1.1694838
3598 - 0.545 1.1761503
3599 - 0.622 1.294
3600 - 0.669 1.5176493
3601 - 0.722 1.6238791
3602 - 0.813 1.9395758
3603 - 1.011 2.3558415 10.547000429321157
3604 """
3605
3606
3607 self.setup_kteilum_fmpoulsen_makke_cpmg_data(model='TSMFK01', expfolder="acbp_cpmg_disp_048MGuHCl_40C_041223")
3608
3609
3610 res61L = cdp.mol[0].res[0].spin[0]
3611
3612
3613 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=599.89086220e6)
3614
3615
3616 res61L.r2a = {r20_key1: 8.0}
3617 res61L.dw = 6.5
3618 res61L.k_AB = 2.5
3619
3620
3621 self.interpreter.minimise(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)
3622
3623
3624 print("\n\nOptimised parameters:\n")
3625 print("%-20s %-20s" % ("Parameter", "Value (:61)"))
3626 print("%-20s %20.15g" % ("R2A (600 MHz)", res61L.r2a[r20_key1]))
3627 print("%-20s %20.15g" % ("dw", res61L.dw))
3628 print("%-20s %20.15g" % ("k_AB", res61L.k_AB))
3629 print("%-20s %20.15g\n" % ("chi2", res61L.chi2))
3630
3631
3632
3633 self.assertAlmostEqual(res61L.k_AB, 2.45, 1)
3634
3635
3637 """Optimisation of Kaare Teilum, Flemming M Poulsen, Mikael Akke 2006 "acyl-CoA binding protein" CPMG data to the CR72 dispersion model.
3638
3639 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).
3640
3641 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.
3642
3643 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:
3644
3645 1. The dotted line represents a residue-specific fit of all parameters in Eq. 1:
3646 - k_AB = 11.3 +/- 0.7 s^-1,
3647 - dw = (2.45 +/- 0.09) * 10^3 s^-1,
3648 - R2 = 8.0 +/- 0.5 s^-1.
3649
3650 2. The solid line represents a global fit of k_AB to all protein residues and a residue-specific fit of dw and R2.:
3651 - k_AB = 10.55 +/- 0.08 s^-1,
3652 - dw = (2.44 +/- 0.08) * 10^3 s^-1,
3653 - R2 = 8.4 +/- 0.3 s^-1.
3654
3655 Conversion of paper results to relax results is performed by:
3656
3657 - 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.
3658
3659 Figure 3 shows the ln( k_a [s^-1]) for different concentrations of GuHCl. The precise values are:
3660
3661 - [GuHCL][M] ln(k_a[s^-1]) k_a[s^-1]
3662 - 0.483 0.89623903 2.4503699912708878
3663 - 0.545 1.1694838
3664 - 0.545 1.1761503
3665 - 0.622 1.294
3666 - 0.669 1.5176493
3667 - 0.722 1.6238791
3668 - 0.813 1.9395758
3669 - 1.011 2.3558415 10.547000429321157
3670 """
3671
3672
3673 self.setup_kteilum_fmpoulsen_makke_cpmg_data(model='TSMFK01', expfolder="acbp_cpmg_disp_101MGuHCl_40C_041223")
3674
3675
3676 res61L = cdp.mol[0].res[0].spin[0]
3677
3678
3679 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=599.89086270e6)
3680
3681
3682 res61L.r2a = {r20_key1: 8.0}
3683 res61L.dw = 6.5
3684 res61L.k_AB = 11.0
3685
3686
3687 self.interpreter.minimise(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)
3688
3689
3690 print("\n\nOptimised parameters:\n")
3691 print("%-20s %-20s" % ("Parameter", "Value (:61)"))
3692 print("%-20s %20.15g" % ("R2A (600 MHz)", res61L.r2a[r20_key1]))
3693 print("%-20s %20.15g" % ("dw", res61L.dw))
3694 print("%-20s %20.15g" % ("k_AB", res61L.k_AB))
3695 print("%-20s %20.15g\n" % ("chi2", res61L.chi2))
3696
3697
3698
3699 self.assertAlmostEqual(res61L.r2a[r20_key1], 8.4, 0)
3700 self.assertAlmostEqual(res61L.dw, 6.41, 0)
3701 self.assertAlmostEqual(res61L.k_AB, 10.55, 0)
3702
3703
3705 """Test the 'LM63 3-site' dispersion model using the pure noise-free synthetic data."""
3706
3707
3708 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'lm63_3site'
3709
3710
3711 self.interpreter.reset()
3712 self.interpreter.state.load(data_path+sep+'r2eff_values')
3713
3714
3715 self.interpreter.pipe.copy(pipe_from='base pipe', pipe_to='LM63 3-site', bundle_to='relax_disp')
3716 self.interpreter.pipe.switch(pipe_name='LM63 3-site')
3717
3718
3719 self.interpreter.relax_disp.select_model(model='LM63 3-site')
3720 self.interpreter.value.copy(pipe_from='R2eff - relax_disp', pipe_to='LM63 3-site', param='r2eff')
3721 self.interpreter.spin.isotope('15N')
3722
3723
3724 spin1 = return_spin(":1")
3725 spin2 = return_spin(":2")
3726
3727
3728 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6)
3729 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6)
3730
3731
3732 spin1.r2 = {r20_key1: 12.0, r20_key2: 12.0}
3733 spin1.phi_ex_B = 0.1
3734 spin1.phi_ex_C = 0.5
3735 spin1.kB = 1500.0
3736 spin1.kC = 2500.0
3737 spin2.r2 = {r20_key1: 15.0, r20_key2: 15.0}
3738 spin2.phi_ex_B = 0.1
3739 spin2.phi_ex_C = 0.5
3740 spin2.kB = 1500.0
3741 spin2.kC = 2500.0
3742
3743
3744 self.interpreter.minimise(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)
3745
3746
3747 self.interpreter.monte_carlo.setup(number=3)
3748 self.interpreter.monte_carlo.create_data(method='back_calc')
3749 self.interpreter.monte_carlo.initial_values()
3750 self.interpreter.minimise(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)
3751 self.interpreter.monte_carlo.error_analysis()
3752
3753
3754 self.interpreter.results.write(file='devnull', compress_type=1, force=True)
3755
3756
3757 print("\n\nOptimised parameters:\n")
3758 print("%-20s %-20s %-20s" % ("Parameter", "Value (:1)", "Value (:2)"))
3759 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin1.r2[r20_key1], spin2.r2[r20_key1]))
3760 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin1.r2[r20_key2], spin2.r2[r20_key2]))
3761 print("%-20s %20.15g %20.15g" % ("phi_ex_B", spin1.phi_ex_B, spin2.phi_ex_B))
3762 print("%-20s %20.15g %20.15g" % ("phi_ex_C", spin1.phi_ex_C, spin2.phi_ex_C))
3763 print("%-20s %20.15g %20.15g" % ("kB", spin1.kB, spin2.kB))
3764 print("%-20s %20.15g %20.15g" % ("kC", spin1.kC, spin2.kC))
3765 print("%-20s %20.15g %20.15g\n" % ("chi2", spin1.chi2, spin2.chi2))
3766 self.assertAlmostEqual(spin1.r2[r20_key1], 12.0, 2)
3767 self.assertAlmostEqual(spin1.r2[r20_key2], 12.0, 2)
3768 self.assertAlmostEqual(spin1.phi_ex_B, 0.1, 3)
3769 self.assertAlmostEqual(spin1.phi_ex_C, 0.5, 3)
3770 self.assertAlmostEqual(spin1.kB/1000, 1500.0/1000, 3)
3771 self.assertAlmostEqual(spin1.kC/1000, 2500.0/1000, 3)
3772 self.assertAlmostEqual(spin1.chi2, 0.0, 3)
3773 self.assertAlmostEqual(spin2.r2[r20_key1], 15.0, 3)
3774 self.assertAlmostEqual(spin2.r2[r20_key2], 15.0, 3)
3775 self.assertAlmostEqual(spin1.phi_ex_B, 0.1, 3)
3776 self.assertAlmostEqual(spin1.phi_ex_C, 0.5, 3)
3777 self.assertAlmostEqual(spin1.kB/1000, 1500.0/1000, 3)
3778 self.assertAlmostEqual(spin1.kC/1000, 2500.0/1000, 3)
3779 self.assertAlmostEqual(spin2.chi2, 0.0, 3)
3780
3781
3783 """Test the relaxation dispersion 'M61' model curve fitting to fixed time synthetic data."""
3784
3785
3786 ds.fixed = True
3787
3788
3789 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')
3790
3791
3792 i0 = [100000.0, 20000.0]
3793 r1rho_prime = [2.25, 24.0]
3794 pA = 0.7
3795 kex = 1000.0
3796 delta_omega = [1.0, 2.0]
3797 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']
3798 phi_ex = []
3799 for i in range(2):
3800 phi_ex.append(pA * (1.0 - pA) * delta_omega[i]**2)
3801 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]]
3802
3803
3804 self.interpreter.pipe.switch('R2eff - relax_disp')
3805 spin_index = 0
3806 for spin, spin_id in spin_loop(return_id=True):
3807
3808 print("\nSpin %s." % spin_id)
3809
3810
3811 for i in range(len(keys)):
3812 self.assertAlmostEqual(spin.r2eff[keys[i]]/10.0, rates[spin_index][i]/10.0, 2)
3813
3814
3815 spin_index += 1
3816
3817
3818 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_R1RHO, frq=800e6)
3819
3820
3821 self.interpreter.pipe.switch('M61 - relax_disp')
3822 spin_index = 0
3823 for spin, spin_id in spin_loop(return_id=True):
3824
3825 print("\nSpin %s." % spin_id)
3826
3827
3828 self.assertAlmostEqual(spin.r2[r20_key1]/10, r1rho_prime[spin_index]/10, 2)
3829 self.assertAlmostEqual(spin.phi_ex, phi_ex[spin_index], 2)
3830 self.assertAlmostEqual(spin.kex/1000.0, kex/1000.0, 2)
3831
3832
3833 spin_index += 1
3834
3835
3837 """Test the relaxation dispersion 'M61' model curve fitting to the full exponential synthetic data."""
3838
3839
3840 ds.fixed = False
3841
3842
3843 ds.single = True
3844
3845
3846 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')
3847
3848
3849 i0 = [100000.0, 20000.0]
3850 r1rho_prime = [2.25, 24.0]
3851 pA = 0.7
3852 kex = 1000.0
3853 delta_omega = [1.0, 2.0]
3854 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']
3855 phi_ex = []
3856 for i in range(2):
3857 phi_ex.append(pA * (1.0 - pA) * delta_omega[i]**2)
3858 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]]
3859
3860
3861 self.interpreter.pipe.switch('R2eff - relax_disp')
3862 spin_index = 0
3863 for spin, spin_id in spin_loop(return_id=True):
3864
3865 print("\nSpin %s." % spin_id)
3866
3867
3868 for i in range(len(keys)):
3869 self.assertAlmostEqual(spin.r2eff[keys[i]]/10.0, rates[spin_index][i]/10.0, 2)
3870
3871
3872 spin_index += 1
3873
3874
3875 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_R1RHO, frq=800e6)
3876
3877
3878 self.interpreter.pipe.switch('M61 - relax_disp')
3879 spin_index = 0
3880 for spin, spin_id in spin_loop(return_id=True):
3881
3882 print("\nSpin %s." % spin_id)
3883
3884
3885 self.assertAlmostEqual(spin.r2[r20_key1]/10, r1rho_prime[spin_index]/10, 2)
3886 self.assertAlmostEqual(spin.phi_ex, phi_ex[spin_index], 2)
3887 self.assertAlmostEqual(spin.kex/1000.0, kex/1000.0, 2)
3888
3889
3890 spin_index += 1
3891
3892
3894 """Test the relaxation dispersion 'M61 skew' model curve fitting to fixed time synthetic data."""
3895
3896
3897 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')
3898
3899
3900 i0 = [100000.0, 20000.0]
3901 r1rho_prime = [10.0, 24.0]
3902 pA = 0.95
3903 kex = 2000.0
3904 delta_omega = [1.0, 2.0]
3905
3906
3907 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_R1RHO, frq=800e6)
3908
3909
3910 self.interpreter.pipe.switch("%s - relax_disp" % MODEL_M61B)
3911 spin_index = 0
3912 for spin, spin_id in spin_loop(return_id=True):
3913
3914 print("\nSpin %s." % spin_id)
3915
3916
3917 self.assertAlmostEqual(spin.r2[r20_key1]/10, r1rho_prime[spin_index]/10, 2)
3918 self.assertAlmostEqual(spin.pA, pA, 2)
3919 self.assertAlmostEqual(spin.dw, dw[spin_index], 2)
3920 self.assertAlmostEqual(spin.kex/1000.0, kex/1000.0, 2)
3921
3922
3923 spin_index += 1
3924
3925
3927 """Compare the 'NS MMQ 3-site' dispersion model to synthetic data from cpmg_fit."""
3928
3929
3930 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'ns_mmq_3site.py')
3931
3932
3933 self.assertAlmostEqual(cdp.mol[0].res[0].spin[1].chi2, 0.0, 3)
3934
3935
3937 """Compare the 'NS MMQ 3-site linear' dispersion model to synthetic data from cpmg_fit."""
3938
3939
3940 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')
3941
3942
3943 self.assertAlmostEqual(cdp.mol[0].res[0].spin[1].chi2, 0.0, 3)
3944
3945
3947 """Compare the 'NS R1rho 3-site' dispersion model to synthetic data from cpmg_fit."""
3948
3949
3950 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'ns_r1rho_3site.py')
3951
3952
3953 self.assertAlmostEqual(cdp.mol[0].res[0].spin[0].chi2, 136.13141468674999, 3)
3954
3955
3957 """Compare the 'NS R1rho 3-site linear' dispersion model to synthetic data from cpmg_fit."""
3958
3959
3960 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')
3961
3962
3963 self.assertAlmostEqual(cdp.mol[0].res[0].spin[0].chi2, 0.030959849811015544, 3)
3964
3965
3967 """Optimisation of the Kjaergaard et al., 2013 Off-resonance R1rho relaxation dispersion experiments using the 'DPL' model.
3968
3969 This uses the data from Kjaergaard's paper at U{DOI: 10.1021/bi4001062<http://dx.doi.org/10.1021/bi4001062>}.
3970
3971 """
3972
3973
3974 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'Kjaergaard_et_al_2013'
3975
3976
3977 pipe_name = 'base pipe'
3978 pipe_bundle = 'relax_disp'
3979 pipe_type= 'relax_disp'
3980
3981
3982 self.interpreter.pipe.create(pipe_name=pipe_name, bundle=pipe_bundle, pipe_type=pipe_type)
3983
3984
3985 self.interpreter.spectrum.read_spins(file='1_0_46_0_max_standard.ser', dir=data_path+sep+'peak_lists')
3986
3987
3988 self.assertEqual(len(cdp.mol), 1)
3989 self.assertEqual(cdp.mol[0].name, None)
3990 self.assertEqual(len(cdp.mol[0].res), 48)
3991
3992
3993 self.interpreter.spin.isotope(isotope='15N')
3994
3995
3996 NR_exp = 70
3997
3998
3999 expfile = open(data_path+sep+'exp_parameters_sort.txt', 'r')
4000 expfileslines = expfile.readlines()[:NR_exp]
4001 expfile.close()
4002
4003
4004 yOBS = 81.050
4005
4006 yCAR = 118.078
4007 centerPPM_N15 = yCAR
4008
4009
4010 self.interpreter.chemical_shift.read(file='1_0_46_0_max_standard.ser', dir=data_path+sep+'peak_lists')
4011
4012
4013 cs = [122.223, 122.162, 114.250, 125.852, 118.626, 117.449, 119.999, 122.610, 118.602, 118.291, 115.393,
4014 121.288, 117.448, 116.378, 116.316, 117.263, 122.211, 118.748, 118.103, 119.421, 119.317, 119.386, 117.279,
4015 122.103, 120.038, 116.698, 111.811, 118.639, 118.285, 121.318, 117.770, 119.948, 119.759, 118.314, 118.160,
4016 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]
4017
4018 i = 0
4019 for spin, spin_id in spin_loop(return_id=True):
4020
4021 self.assertEqual(spin.chemical_shift, cs[i])
4022
4023
4024 i += 1
4025
4026
4027 spin_lock_field_strengths_Hz = {'35': 431.0, '39': 651.2, '41': 800.5, '43': 984.0, '46': 1341.11, '48': 1648.5}
4028
4029
4030
4031 j = 0
4032 for i in range(len(expfileslines)):
4033 line=expfileslines[i]
4034 if line[0] == "#":
4035 continue
4036 else:
4037
4038 DIRN = line.split()[0]
4039 I = int(line.split()[1])
4040 deltadof2 = line.split()[2]
4041 dpwr2slock = line.split()[3]
4042 ncyc = int(line.split()[4])
4043 trim = float(line.split()[5])
4044 ss = int(line.split()[6])
4045 set_sfrq = float(line.split()[7])
4046 apod_rmsd = float(line.split()[8])
4047 spin_lock_field_strength = spin_lock_field_strengths_Hz[dpwr2slock]
4048
4049
4050 time_sl = 2*ncyc*trim
4051
4052
4053 FNAME = "%s_%s_%s_%s_max_standard.ser"%(I, deltadof2, dpwr2slock, ncyc)
4054 sp_id = "%s_%s_%s_%s"%(I, deltadof2, dpwr2slock, ncyc)
4055
4056
4057 self.interpreter.spectrum.read_intensities(file=FNAME, dir=data_path+sep+'peak_lists', spectrum_id=sp_id, int_method='height')
4058
4059
4060 self.interpreter.spectrum.baseplane_rmsd(error=apod_rmsd, spectrum_id=sp_id)
4061
4062
4063 self.interpreter.relax_disp.exp_type(spectrum_id=sp_id, exp_type='R1rho')
4064
4065
4066 self.interpreter.relax_disp.spin_lock_field(spectrum_id=sp_id, field=spin_lock_field_strength)
4067
4068
4069 frq_N15_Hz = yOBS * 1E6
4070 offset_ppm_N15 = float(deltadof2) / frq_N15_Hz * 1E6
4071 omega_rf_ppm = centerPPM_N15 + offset_ppm_N15
4072
4073
4074 self.interpreter.relax_disp.spin_lock_offset(spectrum_id=sp_id, offset=omega_rf_ppm)
4075
4076
4077 self.interpreter.relax_disp.relax_time(spectrum_id=sp_id, time=time_sl)
4078
4079
4080 self.interpreter.spectrometer.frequency(id=sp_id, frq=set_sfrq, units='MHz')
4081
4082
4083 j += 1
4084
4085
4086 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)
4087
4088 print("Testing the number of settings")
4089 print("Number of settings iterations is: %s. Number of cdp.exp_type.keys() is: %s"%(i, len(cdp.exp_type.keys() ) ) )
4090 self.assertEqual(70, len(expfileslines))
4091 self.assertEqual(69, j)
4092 self.assertEqual(69, len(cdp.exp_type.keys()) )
4093
4094
4095 cluster_ids = [
4096 ":13@N",
4097 ":15@N",
4098 ":16@N",
4099 ":25@N",
4100 ":26@N",
4101 ":28@N",
4102 ":39@N",
4103 ":40@N",
4104 ":41@N",
4105 ":43@N",
4106 ":44@N",
4107 ":45@N",
4108 ":49@N",
4109 ":52@N",
4110 ":53@N"]
4111
4112
4113 for curspin in cluster_ids:
4114 print("Adding spin %s to cluster"%curspin)
4115 self.interpreter.relax_disp.cluster('model_cluster', curspin)
4116
4117
4118 for free_spin in cdp.clustering['free spins']:
4119 print("Deselecting free spin %s"%free_spin)
4120 self.interpreter.deselect.spin(spin_id=free_spin, change_all=False)
4121
4122
4123 i = 0
4124 j = 0
4125
4126 for curspin, mol_name, res_num, res_name, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=False):
4127 if curspin.select == True:
4128 i += 1
4129 if curspin.select == False:
4130 j += 1
4131
4132
4133 self.assertEqual(i, len(cluster_ids))
4134 self.assertEqual(j, 48-len(cluster_ids))
4135
4136
4137
4138
4139 ref = dict()
4140 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]
4141 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]
4142 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]
4143 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]
4144 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]
4145 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]
4146 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]
4147 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]
4148 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]
4149 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]
4150 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]
4151 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]
4152 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]
4153 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]
4154 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]
4155
4156 guess = dict()
4157 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]
4158 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]
4159 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]
4160 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]
4161 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]
4162 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]
4163 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]
4164 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]
4165 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]
4166 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]
4167 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]
4168 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]
4169 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]
4170 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]
4171 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]
4172
4173
4174 for spin, spin_id in spin_loop(return_id=True):
4175 if spin_id in cluster_ids:
4176 print("spin_id %s in cluster ids"%(spin_id))
4177 spin.kex = guess[spin_id][6]
4178 spin.phi_ex = guess[spin_id][10]
4179 else:
4180 print("spin_id %s NOT in cluster ids"%(spin_id))
4181
4182
4183 self.assertEqual(cdp.mol[0].res[7].num, 13)
4184 self.assertEqual(cdp.mol[0].res[7].spin[0].kex, guess[':13@N'][6])
4185 self.assertEqual(cdp.mol[0].res[7].spin[0].ri_data['R1'], ref[':13@N'][2])
4186
4187 self.assertEqual(cdp.mol[0].res[9].num, 15)
4188 self.assertEqual(cdp.mol[0].res[9].spin[0].kex, guess[':15@N'][6])
4189 self.assertEqual(cdp.mol[0].res[9].spin[0].ri_data['R1'], ref[':15@N'][2])
4190
4191 self.assertEqual(cdp.mol[0].res[10].num, 16)
4192 self.assertEqual(cdp.mol[0].res[10].spin[0].kex, guess[':16@N'][6])
4193 self.assert_(hasattr(cdp.mol[0].res[10].spin[0], 'ri_data'))
4194
4195 self.assertEqual(cdp.mol[0].res[16].num, 25)
4196 self.assertEqual(cdp.mol[0].res[16].spin[0].kex, guess[':25@N'][6])
4197 self.assert_(hasattr(cdp.mol[0].res[16].spin[0], 'ri_data'))
4198
4199 self.assertEqual(cdp.mol[0].res[17].num, 26)
4200 self.assertEqual(cdp.mol[0].res[17].spin[0].kex, guess[':26@N'][6])
4201 self.assert_(hasattr(cdp.mol[0].res[17].spin[0], 'ri_data'))
4202
4203 self.assertEqual(cdp.mol[0].res[19].num, 28)
4204 self.assertEqual(cdp.mol[0].res[19].spin[0].kex, guess[':28@N'][6])
4205 self.assert_(hasattr(cdp.mol[0].res[19].spin[0], 'ri_data'))
4206
4207 self.assertEqual(cdp.mol[0].res[29].num, 39)
4208 self.assertEqual(cdp.mol[0].res[29].spin[0].kex, guess[':39@N'][6])
4209 self.assert_(hasattr(cdp.mol[0].res[29].spin[0], 'ri_data'))
4210
4211 self.assertEqual(cdp.mol[0].res[30].num, 40)
4212 self.assertEqual(cdp.mol[0].res[30].spin[0].kex, guess[':40@N'][6])
4213 self.assert_(hasattr(cdp.mol[0].res[30].spin[0], 'ri_data'))
4214
4215 self.assertEqual(cdp.mol[0].res[31].num, 41)
4216 self.assertEqual(cdp.mol[0].res[31].spin[0].kex, guess[':41@N'][6])
4217 self.assert_(hasattr(cdp.mol[0].res[31].spin[0], 'ri_data'))
4218
4219 self.assertEqual(cdp.mol[0].res[33].num, 43)
4220 self.assertEqual(cdp.mol[0].res[33].spin[0].kex, guess[':43@N'][6])
4221 self.assert_(hasattr(cdp.mol[0].res[33].spin[0], 'ri_data'))
4222
4223 self.assertEqual(cdp.mol[0].res[34].num, 44)
4224 self.assertEqual(cdp.mol[0].res[34].spin[0].kex, guess[':44@N'][6])
4225 self.assert_(hasattr(cdp.mol[0].res[34].spin[0], 'ri_data'))
4226
4227 self.assertEqual(cdp.mol[0].res[35].num, 45)
4228 self.assertEqual(cdp.mol[0].res[35].spin[0].kex, guess[':45@N'][6])
4229 self.assert_(hasattr(cdp.mol[0].res[35].spin[0], 'ri_data'))
4230
4231 self.assertEqual(cdp.mol[0].res[38].num, 49)
4232 self.assertEqual(cdp.mol[0].res[38].spin[0].kex, guess[':49@N'][6])
4233 self.assert_(hasattr(cdp.mol[0].res[38].spin[0], 'ri_data'))
4234
4235 self.assertEqual(cdp.mol[0].res[41].num, 52)
4236 self.assertEqual(cdp.mol[0].res[41].spin[0].kex, guess[':52@N'][6])
4237 self.assert_(hasattr(cdp.mol[0].res[41].spin[0], 'ri_data'))
4238
4239 self.assertEqual(cdp.mol[0].res[42].num, 53)
4240 self.assertEqual(cdp.mol[0].res[42].spin[0].kex, guess[':53@N'][6])
4241 self.assert_(hasattr(cdp.mol[0].res[42].spin[0], 'ri_data'))
4242
4243
4244 MODELS = ['R2eff', 'DPL94']
4245
4246
4247 GRID_INC = 4
4248
4249
4250 MC_NUM = 3
4251
4252
4253 MODSEL = 'AIC'
4254
4255
4256
4257 OPT_FUNC_TOL = 1e-1
4258 relax_disp.Relax_disp.opt_func_tol = OPT_FUNC_TOL
4259 OPT_MAX_ITERATIONS = 1000
4260 relax_disp.Relax_disp.opt_max_iterations = OPT_MAX_ITERATIONS
4261
4262 analysis_mode = "auto"
4263
4264 if analysis_mode == "auto":
4265
4266 for curspin in cluster_ids:
4267 self.interpreter.relax_disp.cluster('free spins', curspin)
4268
4269 self.interpreter.deselect.spin(spin_id=curspin, change_all=False)
4270
4271
4272
4273
4274
4275
4276
4277
4278 self.interpreter.select.spin(spin_id=':52@N', change_all=False)
4279
4280
4281
4282 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)
4283
4284
4285
4286
4287
4288 elif analysis_mode == "man":
4289 for curspin in cluster_ids:
4290 self.interpreter.relax_disp.cluster('free spins', curspin)
4291
4292
4293 self.interpreter.spectrum.error_analysis(subset=['46_0_35_0', '48_0_35_4', '47_0_35_10', '49_0_35_20', '36_0_39_0', '39_0_39_4', '37_0_39_10', '40_0_39_20', '38_0_39_40', '41_0_41_0', '44_0_41_4', '42_0_41_10', '45_0_41_20', '43_0_41_40', '31_0_43_0', '34_0_43_4', '32_0_43_10', '35_0_43_20', '33_0_43_40', '1_0_46_0', '4_0_46_4', '2_0_46_10', '5_0_46_20', '3_0_46_40', '60_0_48_0', '63_0_48_4', '61_0_48_10', '62_0_48_14', '64_0_48_20', '11_500_46_0', '14_500_46_4', '12_500_46_10', '15_500_46_20', '13_500_46_40', '50_1000_41_0', '53_1000_41_4', '51_1000_41_10', '54_1000_41_20', '52_1000_41_40', '21_1000_46_0', '24_1000_46_4', '22_1000_46_10', '25_1000_46_20', '23_1000_46_40', '65_1000_48_0', '68_1000_48_4', '66_1000_48_10', '67_1000_48_14', '69_1000_48_20', '55_2000_41_0', '58_2000_41_4', '56_2000_41_10', '59_2000_41_20', '57_2000_41_40', '6_2000_46_0', '9_2000_46_4', '7_2000_46_10', '10_2000_46_20', '8_2000_46_40', '16_5000_46_0', '19_5000_46_4', '17_5000_46_10', '20_5000_46_20', '18_5000_46_40', '26_10000_46_0', '29_10000_46_4', '27_10000_46_10', '30_10000_46_20', '28_10000_46_40'])
4294
4295
4296 self.interpreter.pipe.copy(pipe_from='base pipe', pipe_to='R2eff - relax_disp', bundle_to='relax_disp')
4297 self.interpreter.pipe.switch(pipe_name='R2eff - relax_disp')
4298 self.interpreter.relax_disp.select_model(model='R2eff')
4299 self.interpreter.grid_search(lower=None, upper=None, inc=GRID_INC, constraints=True, verbosity=1)
4300
4301 self.interpreter.minimise(min_algor='simplex', line_search=None, hessian_mod=None, hessian_type=None, func_tol=OPT_FUNC_TOL, grad_tol=None, max_iter=OPT_MAX_ITERATIONS, constraints=True, scaling=True, verbosity=1)
4302 self.interpreter.eliminate(function=None, args=None)
4303 self.interpreter.monte_carlo.setup(number=MC_NUM)
4304 self.interpreter.monte_carlo.create_data(method='back_calc')
4305 self.interpreter.monte_carlo.initial_values()
4306
4307 self.interpreter.minimise(min_algor='simplex', line_search=None, hessian_mod=None, hessian_type=None, func_tol=OPT_FUNC_TOL, grad_tol=None, max_iter=OPT_MAX_ITERATIONS, constraints=True, scaling=True, verbosity=1)
4308 self.interpreter.eliminate(function=None, args=None)
4309 self.interpreter.monte_carlo.error_analysis()
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327 self.interpreter.pipe.copy(pipe_from='base pipe', pipe_to='No Rex - relax_disp', bundle_to='relax_disp')
4328 self.interpreter.pipe.switch(pipe_name='No Rex - relax_disp')
4329 self.interpreter.relax_disp.select_model(model='No Rex')
4330 self.interpreter.value.copy(pipe_from='R2eff - relax_disp', pipe_to='No Rex - relax_disp', param='r2eff')
4331 self.interpreter.grid_search(lower=None, upper=None, inc=GRID_INC, constraints=True, verbosity=1)
4332
4333 self.interpreter.minimise(min_algor='simplex', line_search=None, hessian_mod=None, hessian_type=None, func_tol=OPT_FUNC_TOL, grad_tol=None, max_iter=OPT_MAX_ITERATIONS, constraints=True, scaling=True, verbosity=1)
4334 self.interpreter.eliminate(function=None, args=None)
4335
4336
4337
4338
4339
4340
4341
4342
4343 self.interpreter.results.write(file='results', dir=ds.tmpdir+sep+'resultsR1'+sep+'No Rex', compress_type=1, force=True)
4344
4345
4346 self.interpreter.pipe.copy(pipe_from='base pipe', pipe_to='DPL94 - relax_disp', bundle_to='relax_disp')
4347 self.interpreter.pipe.switch(pipe_name='DPL94 - relax_disp')
4348 self.interpreter.relax_disp.select_model(model='DPL94')
4349 self.interpreter.value.copy(pipe_from='R2eff - relax_disp', pipe_to='DPL94 - relax_disp', param='r2eff')
4350 self.interpreter.relax_disp.insignificance(level=1.0)
4351 self.interpreter.grid_search(lower=None, upper=None, inc=GRID_INC, constraints=True, verbosity=1)
4352
4353 self.interpreter.minimise(min_algor='simplex', line_search=None, hessian_mod=None, hessian_type=None, func_tol=OPT_FUNC_TOL, grad_tol=None, max_iter=OPT_MAX_ITERATIONS, constraints=True, scaling=True, verbosity=1)
4354 self.interpreter.eliminate(function=None, args=None)
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374 self.interpreter.model_selection(method='AIC', modsel_pipe='final - relax_disp', bundle='relax_disp', pipes=['No Rex - relax_disp', 'DPL94 - relax_disp'])
4375 self.interpreter.monte_carlo.setup(number=MC_NUM)
4376 self.interpreter.monte_carlo.create_data(method='back_calc')
4377 self.interpreter.monte_carlo.initial_values()
4378
4379 self.interpreter.minimise(min_algor='simplex', line_search=None, hessian_mod=None, hessian_type=None, func_tol=OPT_FUNC_TOL, grad_tol=None, max_iter=OPT_MAX_ITERATIONS, constraints=True, scaling=True, verbosity=1)
4380 self.interpreter.eliminate(function=None, args=None)
4381 self.interpreter.monte_carlo.error_analysis()
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391 self.interpreter.value.write(param='phi_ex', file='phi_ex.out', dir=ds.tmpdir+sep+'resultsR1'+sep+'final', scaling=1.0, comment=None, bc=False, force=True)
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402 self.interpreter.value.write(param='kex', file='kex.out', dir=ds.tmpdir+sep+'resultsR1'+sep+'final', scaling=1.0, comment=None, bc=False, force=True)
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417 self.interpreter.value.write(param='theta', file='theta.out', dir=ds.tmpdir+sep+'resultsR1'+sep+'final', scaling=1.0, comment=None, bc=False, force=True)
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427 self.assert_(access(ds.tmpdir+sep+'resultsR1'+sep+'final'+sep+'phi_ex.out', F_OK))
4428 self.assert_(access(ds.tmpdir+sep+'resultsR1'+sep+'final'+sep+'kex.out', F_OK))
4429
4430
4432 """Test the operation of the relax_disp.r2eff_read user function."""
4433
4434
4435 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'Hansen'+sep+'800_MHz'
4436
4437
4438 self.interpreter.sequence.read(file='66.667.in', dir=data_path, res_num_col=1)
4439
4440
4441 id = 'test'
4442
4443
4444 self.interpreter.spectrometer.frequency(id=id, frq=800e6)
4445 self.interpreter.relax_disp.exp_type(spectrum_id=id, exp_type='SQ CPMG')
4446
4447
4448 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)
4449
4450
4451 data = [
4452 ['cpmg_frqs', {'test': 66.667}],
4453 ['cpmg_frqs_list', [66.667]],
4454 ['dispersion_points', 1],
4455 ['exp_type', {'test': 'SQ CPMG'}],
4456 ['exp_type_list', ['SQ CPMG']],
4457 ['spectrometer_frq', {'test': 800000000.0}],
4458 ['spectrometer_frq_count', 1],
4459 ['spectrometer_frq_list', [800000000.0]],
4460 ['spectrum_ids', ['test']]
4461 ]
4462 for name, value in data:
4463
4464 self.assert_(hasattr(cdp, name))
4465
4466
4467 obj = getattr(cdp, name)
4468 self.assertEqual(obj, value)
4469
4470
4471 data = [
4472 [1, 2.3035747e+04, 8.5467725e+01],
4473 [2, 9.9629762e+04, 2.8322033e+02],
4474 [3, 9.5663137e+04, 2.8632929e+02],
4475 [4, 1.7089893e+05, 3.1089428e+02],
4476 [5, 4.7323876e+04, 1.0084269e+02],
4477 [6, 2.0199122e+04, 1.0135220e+02],
4478 [7, 1.6655488e+05, 3.1609061e+02],
4479 [8, 9.0061074e+04, 1.9176585e+02],
4480 [10, 8.4726204e+04, 2.8898155e+02],
4481 [11, 1.5050233e+05, 4.3138029e+02],
4482 [12, 9.2998531e+04, 3.0440191e+02],
4483 [13, 1.6343507e+05, 3.3144097e+02],
4484 [14, 1.0137301e+05, 3.7314642e+02],
4485 [15, 8.3407837e+04, 1.6546473e+02],
4486 [16, 1.3819126e+05, 3.3388517e+02],
4487 [17, 1.1010490e+05, 3.5639222e+02],
4488 [18, 9.4324035e+04, 3.2343585e+02],
4489 [19, 1.1135179e+05, 3.0706671e+02],
4490 [20, 7.6339410e+04, 1.7377460e+02],
4491 [21, 6.2008453e+04, 1.7327150e+02],
4492 [22, 1.0590404e+05, 2.4814635e+02],
4493 [23, 1.0630198e+05, 2.3601100e+02],
4494 [24, 7.2996320e+04, 1.4952465e+02],
4495 [25, 9.5486742e+04, 2.7080766e+02],
4496 [26, 5.8067989e+04, 1.6820462e+02],
4497 [27, -1.7168510e+04, 2.2519560e+02],
4498 [28, 1.6891473e+05, 2.3497525e+02],
4499 [29, 9.4038555e+04, 2.0357593e+02],
4500 [30, 2.1386951e+04, 2.2153532e+02],
4501 [31, 9.3982899e+04, 2.0937056e+02],
4502 [32, 8.6097484e+04, 2.3868467e+02],
4503 [33, 1.0194337e+05, 2.7370704e+02],
4504 [34, 8.5683111e+04, 2.0838076e+02],
4505 [35, 8.6985768e+04, 2.0889310e+02],
4506 [36, 8.6011237e+04, 1.7498390e+02],
4507 [37, 1.0984097e+05, 2.7622998e+02],
4508 [38, 8.7017879e+04, 2.6547994e+02],
4509 [39, 9.1682649e+04, 5.2777676e+02],
4510 [40, 7.6370440e+04, 1.9873214e+02],
4511 [41, 9.1393531e+04, 2.4483824e+02],
4512 [42, 1.1017111e+05, 2.8020699e+02],
4513 [43, 9.4552366e+04, 3.4394150e+02],
4514 [44, 1.2858281e+05, 6.8449252e+02],
4515 [45, 7.4583525e+04, 1.9544210e+02],
4516 [46, 9.2087490e+04, 2.0491066e+02],
4517 [47, 9.7507255e+04, 2.5162839e+02],
4518 [48, 1.0033842e+05, 2.7566430e+02],
4519 [49, 1.3048305e+05, 2.6797466e+02],
4520 [50, 1.0546796e+05, 1.9304384e+02],
4521 [51, 9.3099697e+04, 2.0773311e+02],
4522 [52, 4.6863758e+04, 1.3169068e+02],
4523 [53, 6.1055806e+04, 1.5448477e+02],
4524 [55, 6.8629994e+04, 1.6868673e+02],
4525 [56, 1.1005552e+05, 2.1940465e+02],
4526 [57, 1.0572760e+05, 1.9768486e+02],
4527 [58, 1.1176950e+05, 3.0009610e+02],
4528 [59, 9.8758603e+04, 3.3803895e+02],
4529 [60, 9.9517201e+04, 3.5137994e+02],
4530 [61, 5.4357946e+04, 2.5896579e+02],
4531 [62, 1.0899978e+05, 2.8720371e+02],
4532 [63, 8.4549759e+04, 4.1401837e+02],
4533 [64, 5.5014550e+04, 2.1135781e+02],
4534 [65, 8.0569666e+04, 2.3249709e+02],
4535 [66, 1.2936610e+05, 3.5218725e+02],
4536 [67, 3.6438010e+04, 8.7924003e+01],
4537 [70, 3.8763157e+04, 1.3325040e+02],
4538 [71, 8.5711411e+04, 2.9316183e+02],
4539 [72, 3.3211541e+04, 1.2182123e+02],
4540 [73, 3.2070576e+04, 1.2305430e+02]
4541 ]
4542 for res_num, value, error in data:
4543
4544 spin = return_spin(spin_id=":%s"%res_num)
4545
4546
4547 self.assertEqual(spin.r2eff['sq_cpmg_800.00000000_0.000_66.667'], value)
4548 self.assertEqual(spin.r2eff_err['sq_cpmg_800.00000000_0.000_66.667'], error)
4549
4550
4552 """Test the operation of the relax_disp.r2eff_read_spin user function."""
4553
4554
4555 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'Korzhnev_et_al_2005'
4556
4557
4558 self.interpreter.spin.create(res_name='Asp', res_num=9, spin_name='H')
4559 self.interpreter.spin.create(res_name='Asp', res_num=9, spin_name='N')
4560 self.interpreter.spin.isotope('1H', spin_id='@H')
4561 self.interpreter.spin.isotope('15N', spin_id='@N')
4562
4563
4564 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]
4565 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]
4566 ids = []
4567 for value in H_disp_points:
4568 ids.append('1H_CPMG_%s' % value)
4569 for value in N_disp_points:
4570 ids.append('15N_CPMG_%s' % value)
4571 print("\n\nThe experiment IDs are %s." % ids)
4572
4573
4574 for id in ids:
4575 self.interpreter.spectrometer.frequency(id=id, frq=500e6)
4576 self.interpreter.relax_disp.exp_type(spectrum_id=id, exp_type='SQ CPMG')
4577 for value in H_disp_points:
4578 self.interpreter.relax_disp.cpmg_setup(spectrum_id='1H_CPMG_%s' % value, cpmg_frq=value)
4579 for value in N_disp_points:
4580 self.interpreter.relax_disp.cpmg_setup(spectrum_id='15N_CPMG_%s' % value, cpmg_frq=value)
4581
4582
4583 for id, file, spin_id in [['1H_CPMG', 'hs_500.res', ':9@H'], ['15N_CPMG', 'ns_500.res', ':9@N']]:
4584
4585 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)
4586
4587
4588 data = [
4589 ['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}],
4590 ['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]],
4591 ['dispersion_points', 24],
4592 ['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'}],
4593 ['exp_type_list', ['SQ CPMG']],
4594 ['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}],
4595 ['spectrometer_frq_count', 1],
4596 ['spectrometer_frq_list', [500000000.0]],
4597 ['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']]
4598 ]
4599 for name, value in data:
4600
4601 self.assert_(hasattr(cdp, name))
4602
4603
4604 obj = getattr(cdp, name)
4605 if not isinstance(data, dict):
4606 self.assertEqual(obj, value)
4607
4608
4609 else:
4610 for id in ids:
4611 self.assertEqual(obj[id], value[id])
4612
4613
4614 h_data = [
4615 [ 67.0, 21.47924, 0.42958],
4616 [ 133.0, 16.73898, 0.33478],
4617 [ 267.0, 9.97357, 0.19947],
4618 [ 400.0, 8.23877, 0.24737],
4619 [ 533.0, 7.59290, 0.24263],
4620 [ 667.0, 7.45843, 0.24165],
4621 [ 800.0, 7.11222, 0.23915],
4622 [ 933.0, 7.40880, 0.24129],
4623 [1067.0, 6.55191, 0.16629],
4624 [1600.0, 6.72177, 0.23637],
4625 [2133.0, 7.09629, 0.23904],
4626 [2667.0, 7.14675, 0.23940]
4627 ]
4628 for disp_point, value, error in h_data:
4629 id = 'sq_cpmg_500.00000000_0.000_%.3f' % disp_point
4630 self.assertEqual(cdp.mol[0].res[0].spin[0].r2eff[id], value)
4631 self.assertEqual(cdp.mol[0].res[0].spin[0].r2eff_err[id], error)
4632 n_data = [
4633 [ 50.0, 27.15767, 0.54315],
4634 [ 100.0, 26.55781, 0.53116],
4635 [ 150.0, 24.73462, 0.49469],
4636 [ 200.0, 20.98617, 0.41972],
4637 [ 250.0, 17.82442, 0.35649],
4638 [ 300.0, 15.55352, 0.31107],
4639 [ 350.0, 13.78958, 0.27579],
4640 [ 400.0, 12.48334, 0.24967],
4641 [ 500.0, 11.55724, 0.23114],
4642 [ 600.0, 10.53874, 0.21077],
4643 [ 700.0, 10.07395, 0.20148],
4644 [ 800.0, 9.62952, 0.19259],
4645 [ 900.0, 9.49994, 0.19000],
4646 [1000.0, 8.71350, 0.17427]
4647 ]
4648 for disp_point, value, error in n_data:
4649 id = 'sq_cpmg_500.00000000_0.000_%.3f' % disp_point
4650 self.assertEqual(cdp.mol[0].res[0].spin[1].r2eff[id], value)
4651 self.assertEqual(cdp.mol[0].res[0].spin[1].r2eff_err[id], error)
4652
4653
4655 """Test the relaxation dispersion 'R2eff' model for fixed time data in the auto-analysis."""
4656
4657
4658 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_disp'+sep+'r2eff_calc.py')
4659
4660
4662 """Test the reading of a file containing r2eff values."""
4663
4664
4665 self.interpreter.residue.create(1, 'Gly')
4666 self.interpreter.residue.create(2, 'Gly')
4667 self.interpreter.residue.create(3, 'Gly')
4668
4669
4670 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)
4671
4672
4673 self.assertEqual(cdp.mol[0].res[0].spin[0].ri_data['R2eff.600'], 15.000)
4674 self.assertEqual(cdp.mol[0].res[1].spin[0].ri_data['R2eff.600'], 4.2003)
4675 self.assertEqual(cdp.mol[0].res[2].spin[0].ri_data['R2eff.600'], 7.2385)
4676
4677
4679 """Test speeding up grid search. Support requst sr #3151 U{https://web.archive.org/web/https://gna.org/support/index.php?3151}.
4680
4681 User function to set the R20 parameters in the default grid search using the minimum R2eff value.
4682
4683 Optimisation of Kaare Teilum, Melanie H. Smith, Eike Schulz, Lea C. Christensen, Gleb Solomentseva, Mikael Oliveberg, and Mikael Akkea 2009
4684 'SOD1-WT' CPMG data to the CR72 dispersion model.
4685
4686 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.
4687 Data is for experiment at 25 degree Celcius.
4688 """
4689
4690
4691 pipe_name = 'base pipe'
4692 pipe_type = 'relax_disp'
4693 pipe_name_r2eff = "%s_R2eff"%(pipe_name)
4694 select_spin_index = list(range(0, 1))
4695 self.setup_sod1wt_t25(pipe_name=pipe_name, pipe_type=pipe_type, pipe_name_r2eff=pipe_name_r2eff, select_spin_index=select_spin_index)
4696
4697
4698 r20_key_600 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=599.8908617*1E6)
4699 r20_key_500 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=499.862139*1E6)
4700
4701
4702 MODEL = "CR72"
4703
4704
4705 pipe_name_MODEL = "%s_%s"%(pipe_name, MODEL)
4706 self.interpreter.pipe.copy(pipe_from=pipe_name_r2eff, pipe_to=pipe_name_MODEL)
4707 self.interpreter.pipe.switch(pipe_name=pipe_name_MODEL)
4708
4709
4710 self.interpreter.relax_disp.select_model(model=MODEL)
4711
4712
4713 self.interpreter.relax_disp.r20_from_min_r2eff(force=False)
4714
4715
4716 for spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
4717
4718 spin_params = spin.params
4719
4720
4721 if spin_id == ":10@N":
4722 self.assertEqual(spin.r2[r20_key_600], 20.282732526087106)
4723 self.assertEqual(spin.r2[r20_key_500], 18.475299724356649)
4724
4725
4726 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))
4727
4728
4729 self.assert_(spin.r2[r20_key_600] != spin.r2[r20_key_500])
4730
4731
4732 self.assert_(spin.r2[r20_key_600] > 0.0)
4733 self.assert_(spin.r2[r20_key_500] > 0.0)
4734
4735
4736 r2eff_600 = []
4737 r2eff_500 = []
4738 for exp_type, frq, offset, point, ei, mi, oi, di in loop_exp_frq_offset_point(return_indices=True):
4739
4740 data_key = return_param_key_from_data(exp_type=exp_type, frq=frq, offset=offset, point=point)
4741
4742
4743 r2eff = spin.r2eff[data_key]
4744 if frq == 599.8908617*1E6:
4745 r2eff_600.append(r2eff)
4746 elif frq == 499.862139*1E6:
4747 r2eff_500.append(r2eff)
4748
4749
4750 r2eff_600.sort()
4751 r2eff_500.sort()
4752
4753
4754 print("For r20 600MHz min r2eff=%3.3f."%(min(r2eff_600)))
4755 print(r2eff_600)
4756 self.assertEqual(spin.r2[r20_key_600], min(r2eff_600))
4757 print("")
4758
4759 print("For r20 500MHz min r2eff=%3.3f."%(min(r2eff_500)))
4760 print(r2eff_500)
4761 self.assertEqual(spin.r2[r20_key_500], min(r2eff_500))
4762 print("")
4763
4764 print("###########################################")
4765 print("Trying GRID SEARCH for minimum R2eff values")
4766
4767
4768 GRID_INC = 5
4769
4770 self.interpreter.grid_search(lower=None, upper=None, inc=GRID_INC, constraints=True, verbosity=1)
4771
4772
4773
4774 pipe_name_MODEL = "%s_%s_2"%(pipe_name, MODEL)
4775 self.interpreter.pipe.copy(pipe_from=pipe_name_r2eff, pipe_to=pipe_name_MODEL)
4776 self.interpreter.pipe.switch(pipe_name=pipe_name_MODEL)
4777
4778
4779 self.interpreter.relax_disp.select_model(model=MODEL)
4780
4781
4782 for param in spin_params:
4783 print("Setting standard parameter for param: %s"%param)
4784 self.interpreter.value.set(param=param, index=None)
4785
4786
4787 for spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
4788
4789 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))
4790
4791
4792 self.assertEqual(spin.r2[r20_key_600], 10.00)
4793 self.assertEqual(spin.r2[r20_key_500], 10.00)
4794 self.assertEqual(spin.pA, 0.9)
4795 self.assertEqual(spin.dw, 1.0)
4796 self.assertEqual(spin.kex, 1000.0)
4797
4798 print("###########################################")
4799 print("Trying GRID SEARCH for standard R2eff values")
4800
4801
4802 GRID_INC = 5
4803
4804 self.interpreter.grid_search(lower=None, upper=None, inc=GRID_INC, constraints=True, verbosity=1)
4805
4806
4807
4808 GRID_INC = 5
4809
4810
4811 MC_NUM = 3
4812
4813
4814 MODSEL = 'AIC'
4815
4816
4817
4818 OPT_FUNC_TOL = 1e-1
4819 relax_disp.Relax_disp.opt_func_tol = OPT_FUNC_TOL
4820 OPT_MAX_ITERATIONS = 1000
4821 relax_disp.Relax_disp.opt_max_iterations = OPT_MAX_ITERATIONS
4822
4823
4824 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)
4825
4826
4828 """Error analysis of SOD1-WT CPMG. From paper at U{http://dx.doi.org/10.1073/pnas.0907387106}.
4829
4830 Optimisation of Kaare Teilum, Melanie H. Smith, Eike Schulz, Lea C. Christensen, Gleb Solomentseva, Mikael Oliveberg, and Mikael Akkea 2009
4831 'SOD1-WT' CPMG data to the CR72 dispersion model.
4832
4833 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.
4834 Data is for experiment at 25 degree Celcius.
4835
4836 bug #21954 U{https://web.archive.org/web/https://gna.org/bugs/index.php?21954}: Order of spectrum.error_analysis is important.
4837 """
4838
4839
4840 pipe_name = 'base pipe'
4841 pipe_type = 'relax_disp'
4842 pipe_name_r2eff = "%s_R2eff"%(pipe_name)
4843 select_spin_index = list(range(0, 1))
4844 self.setup_sod1wt_t25(pipe_name=pipe_name, pipe_type=pipe_type, pipe_name_r2eff=pipe_name_r2eff, select_spin_index=select_spin_index)
4845
4846
4847 repl_A = ['Z_A1', 'Z_A15']
4848 repl_B = ['Z_B1', 'Z_B18']
4849
4850
4851 spectrum_ids_A = []
4852 spectrum_ids_B = []
4853 for spectrum_id in cdp.spectrum_ids:
4854 if "A" in spectrum_id:
4855 spectrum_ids_A.append(spectrum_id)
4856 elif "B" in spectrum_id:
4857 spectrum_ids_B.append(spectrum_id)
4858
4859
4860 delattr(cdp, "var_I")
4861 delattr(cdp, "sigma_I")
4862
4863
4864 self.interpreter.spectrum.error_analysis(subset=spectrum_ids_A)
4865 self.interpreter.spectrum.error_analysis(subset=spectrum_ids_B)
4866
4867
4868 Errors_A_B = []
4869 for spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
4870 A_err = spin.peak_intensity_err[spectrum_ids_A[0]]
4871 B_err = spin.peak_intensity_err[spectrum_ids_B[0]]
4872 Errors_A_B.append([A_err, B_err])
4873
4874
4875 delattr(cdp, "var_I")
4876 delattr(cdp, "sigma_I")
4877
4878
4879 self.interpreter.spectrum.error_analysis(subset=spectrum_ids_B)
4880 self.interpreter.spectrum.error_analysis(subset=spectrum_ids_A)
4881
4882
4883 Errors_B_A = []
4884 for spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
4885 A_err = spin.peak_intensity_err[spectrum_ids_A[0]]
4886 B_err = spin.peak_intensity_err[spectrum_ids_B[0]]
4887 Errors_B_A.append([A_err, B_err])
4888
4889
4890 for i in range(len(Errors_A_B)):
4891 Error_A_B = Errors_A_B[i]
4892 Error_B_A = Errors_B_A[i]
4893 self.assertAlmostEqual(Error_A_B[0], Error_B_A[0], 4)
4894 self.assertAlmostEqual(Error_A_B[1], Error_B_A[1], 4)
4895
4896
4897 std_A = math.sqrt((cdp.var_I[repl_A[0]] + cdp.var_I[repl_A[1]])/2)
4898 std_A_fix = 2785.7263335738567
4899
4900 for id_A in spectrum_ids_A:
4901 self.assertEqual(cdp.sigma_I[id_A], std_A)
4902 self.assertAlmostEqual(cdp.sigma_I[id_A], std_A_fix, 7)
4903
4904 std_B = math.sqrt((cdp.var_I[repl_B[0]] + cdp.var_I[repl_B[1]])/2)
4905 std_B_fix = 4967.3772030667988
4906
4907 for id_B in spectrum_ids_B:
4908 self.assertEqual(cdp.sigma_I[id_B], std_B)
4909 self.assertAlmostEqual(cdp.sigma_I[id_B], std_B_fix, 7)
4910
4911
4913 """Optimisation of SOD1-WT CPMG. From paper at U{http://dx.doi.org/10.1073/pnas.0907387106}.
4914
4915 Optimisation of Kaare Teilum, Melanie H. Smith, Eike Schulz, Lea C. Christensen, Gleb Solomentseva, Mikael Oliveberg, and Mikael Akkea 2009
4916 'SOD1-WT' CPMG data to the CR72 dispersion model.
4917
4918 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.
4919 Data is for experiment at 25 degree Celcius.
4920 """
4921
4922
4923 pipe_name = 'base pipe'
4924 pipe_type = 'relax_disp'
4925 pipe_name_r2eff = "%s_R2eff"%(pipe_name)
4926 select_spin_index = list(range(0, 2))
4927 self.setup_sod1wt_t25(pipe_name=pipe_name, pipe_type=pipe_type, pipe_name_r2eff=pipe_name_r2eff, select_spin_index=select_spin_index)
4928
4929
4930 r20_key_600 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=599.8908617*1E6)
4931 r20_key_500 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=499.862139*1E6)
4932
4933
4934 MODEL = "CR72"
4935
4936
4937 pipe_name_MODEL = "%s_%s"%(pipe_name, MODEL)
4938 self.interpreter.pipe.copy(pipe_from=pipe_name_r2eff, pipe_to=pipe_name_MODEL)
4939 self.interpreter.pipe.switch(pipe_name=pipe_name_MODEL)
4940
4941
4942 self.interpreter.relax_disp.select_model(model=MODEL)
4943
4944
4945 GRID_INC = 7
4946
4947
4948 grid_results = []
4949 mini_results = []
4950 clust_results = []
4951
4952
4953 self.interpreter.relax_disp.r20_from_min_r2eff(force=False)
4954
4955
4956 self.interpreter.relax_disp.insignificance(level=1.0)
4957
4958
4959 self.interpreter.grid_search(lower=None, upper=None, inc=GRID_INC, constraints=True, verbosity=1)
4960
4961
4962 for spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
4963
4964 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])
4965
4966
4967
4968 set_func_tol = 1e-9
4969 set_max_iter = 100000
4970 self.interpreter.minimise(min_algor='simplex', func_tol=set_func_tol, max_iter=set_max_iter, constraints=True, scaling=True, verbosity=1)
4971
4972
4973 pA_values = []
4974 kex_values = []
4975 for spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
4976
4977 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])
4978
4979
4980 pA_values.append(spin.pA)
4981
4982
4983 kex_values.append(spin.kex)
4984
4985 print("\n# Now print before and after minimisation.\n")
4986
4987
4988 for i in range(len(grid_results)):
4989
4990 g_r2_600, g_r2_500, g_dw, g_pA, g_kex, g_chi2, g_spin_id, g_resi, g_resn = grid_results[i]
4991 m_r2_600, m_r2_500, m_dw, m_pA, m_kex, m_chi2, m_spin_id, m_resi, m_resn = mini_results[i]
4992
4993 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))
4994 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))
4995
4996
4997
4998 pipe_name_MODEL_CLUSTER = "%s_%s_Cluster"%(pipe_name, MODEL)
4999 self.interpreter.pipe.copy(pipe_from=pipe_name_r2eff, pipe_to=pipe_name_MODEL_CLUSTER)
5000 self.interpreter.pipe.switch(pipe_name=pipe_name_MODEL_CLUSTER)
5001
5002
5003 self.interpreter.relax_disp.select_model(model=MODEL)
5004
5005
5006 cluster_id = 'clust'
5007
5008
5009 for spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
5010 self.interpreter.relax_disp.cluster(cluster_id, spin_id)
5011
5012
5013 self.interpreter.relax_disp.parameter_copy(pipe_from=pipe_name_MODEL, pipe_to=pipe_name_MODEL_CLUSTER)
5014
5015
5016 for spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
5017 print(pA_values)
5018
5019 self.assertEqual(median(pA_values), spin.pA)
5020
5021
5022 self.assertEqual(median(kex_values), spin.kex)
5023
5024
5025 self.interpreter.minimise(min_algor='simplex', func_tol=set_func_tol, max_iter=set_max_iter, constraints=True, scaling=True, verbosity=1)
5026
5027
5028 for spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True):
5029
5030 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])
5031
5032
5033 clust_pA = spin.pA
5034 clust_kex = spin.kex
5035
5036 print("\n# Now testing.\n")
5037
5038
5039 test_res = {}
5040 test_res[':10@N'] = {}
5041 test_res[':10@N']['r2600'] = 18.429755324773360
5042 test_res[':10@N']['r2500'] = 16.981349161968630
5043 test_res[':10@N']['dw'] = 2.700755859433969
5044 test_res[':10@N']['pA'] = 0.971531659288657
5045 test_res[':10@N']['kex'] = 3831.766337047963134
5046 test_res[':11@N'] = {}
5047 test_res[':11@N']['r2600'] = 18.193409421115213
5048 test_res[':11@N']['r2500'] = 17.308838135567765
5049 test_res[':11@N']['dw'] = 2.706650302761793
5050 test_res[':11@N']['pA'] = 0.971531659288657
5051 test_res[':11@N']['kex'] = 3831.766337047963134
5052
5053
5054 for i in range(len(grid_results)):
5055
5056 g_r2_600, g_r2_500, g_dw, g_pA, g_kex, g_chi2, g_spin_id, g_resi, g_resn = grid_results[i]
5057 m_r2_600, m_r2_500, m_dw, m_pA, m_kex, m_chi2, m_spin_id, m_resi, m_resn = mini_results[i]
5058 c_r2_600, c_r2_500, c_dw, c_pA, c_kex, c_chi2, c_spin_id, c_resi, c_resn = clust_results[i]
5059
5060 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))
5061 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))
5062 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))
5063
5064
5065 self.assertEqual(clust_pA, c_pA)
5066 self.assertEqual(clust_kex, c_kex)
5067
5068
5069 if c_spin_id in test_res:
5070 self.assertAlmostEqual(c_r2_600, test_res[c_spin_id]['r2600'], 4)
5071 self.assertAlmostEqual(c_r2_500, test_res[c_spin_id]['r2500'], 4)
5072 self.assertAlmostEqual(c_dw, test_res[c_spin_id]['dw'], 3)
5073 self.assertAlmostEqual(c_pA, test_res[c_spin_id]['pA'], 5)
5074 self.assertAlmostEqual(c_kex, test_res[c_spin_id]['kex'], 1)
5075
5076
5077
5078
5079
5246
5247
5249 """Test the 'MMQ CR72' model fitting against Remco Sprangers' ClpP data.
5250
5251 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.
5252 """
5253
5254
5255 self.interpreter.reset()
5256
5257
5258 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'Sprangers_ClpP'
5259 self.interpreter.state.load(data_path+sep+'r2eff_values')
5260
5261
5262 model = 'MMQ CR72'
5263 pipe_name = "%s - relax_disp" % model
5264 self.interpreter.pipe.copy(pipe_from='base pipe', pipe_to=pipe_name, bundle_to='relax_disp')
5265 self.interpreter.pipe.switch(pipe_name=pipe_name)
5266
5267
5268 self.interpreter.relax_disp.select_model(model=model)
5269
5270
5271 self.interpreter.relax_disp.cluster(cluster_id='all', spin_id=":135-137")
5272
5273
5274 self.interpreter.value.copy(pipe_from='R2eff', pipe_to=pipe_name, param='r2eff')
5275
5276
5277 spin135S = cdp.mol[0].res[0].spin[0]
5278 spin135F = cdp.mol[0].res[0].spin[1]
5279 spin137S = cdp.mol[0].res[1].spin[0]
5280 spin137F = cdp.mol[0].res[1].spin[1]
5281
5282
5283 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_MQ, frq=600e6)
5284 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_MQ, frq=800e6)
5285
5286
5287 spin135S.pA = 0.836591763632
5288 spin135S.kex = 241.806525261
5289
5290
5291 spin135S.r2 = {r20_key1: 28.2493431552, r20_key2: 31.7517334715}
5292 spin135S.dw = 0.583003118785
5293 spin135S.dwH = 0.0361441944301
5294
5295 spin135F.r2 = {r20_key1: 42.7201839991, r20_key2: 57.3178617389}
5296 spin135F.dw = 0.805849745104
5297 spin135F.dwH = 0.0215791945715
5298
5299 spin137S.r2 = {r20_key1: 26.0134115256, r20_key2: 30.575806934}
5300 spin137S.dw = 0.688107568372
5301 spin137S.dwH = 0.0344463604043
5302
5303 spin137F.r2 = {r20_key1: 46.6969397337, r20_key2: 58.602384101}
5304 spin137F.dw = 0.94978299907
5305 spin137F.dwH = 1.4818877939e-07
5306
5307
5308 self.interpreter.minimise(min_algor='simplex', func_tol=1e-10, max_iter=1000)
5309
5310
5311 print("\n\nOptimised parameters:\n")
5312 print("%-20s %-20s %-20s %-20s %-20s" % ("Parameter", "Value (:135@S)", "Value (:135@F)", "Value (:137@S)", "Value (:137@F)"))
5313 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]))
5314 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]))
5315 print("%-20s %20.15g %20.15g %20.15g %20.15g" % ("pA", spin135S.pA, spin135F.pA, spin137S.pA, spin137F.pA))
5316 print("%-20s %20.15g %20.15g %20.15g %20.15g" % ("dw", spin135S.dw, spin135F.dw, spin137S.dw, spin137F.dw))
5317 print("%-20s %20.15g %20.15g %20.15g %20.15g" % ("dwH", spin135S.dwH, spin135F.dwH, spin137S.dwH, spin137F.dwH))
5318 print("%-20s %20.15g %20.15g %20.15g %20.15g" % ("kex", spin135S.kex, spin135F.kex, spin137S.kex, spin137F.kex))
5319 print("%-20s %20.15g %20.15g %20.15g %20.15g\n" % ("chi2", spin135S.chi2, spin135F.chi2, spin137S.chi2, spin137F.chi2))
5320 print("\n # Set the cluster specific parameters (only for the first spin).")
5321 print(" spin135S.pA = %s" % spin135S.pA)
5322 print(" spin135S.kex = %s" % spin135S.kex)
5323 print("\n # Set the initial parameter values.")
5324 print(" spin135S.r2 = {r20_key1: %s, r20_key2: %s}" % (spin135S.r2[r20_key1], spin135S.r2[r20_key2]))
5325 print(" spin135S.dw = %s" % spin135S.dw)
5326 print(" spin135S.dwH = %s" % spin135S.dwH)
5327 print("\n spin135F.r2 = {r20_key1: %s, r20_key2: %s}" % (spin135F.r2[r20_key1], spin135F.r2[r20_key2]))
5328 print(" spin135F.dw = %s" % spin135F.dw)
5329 print(" spin135F.dwH = %s" % spin135F.dwH)
5330 print("\n spin137S.r2 = {r20_key1: %s, r20_key2: %s}" % (spin137S.r2[r20_key1], spin137S.r2[r20_key2]))
5331 print(" spin137S.dw = %s" % spin137S.dw)
5332 print(" spin137S.dwH = %s" % spin137S.dwH)
5333 print("\n spin137F.r2 = {r20_key1: %s, r20_key2: %s}" % (spin137F.r2[r20_key1], spin137F.r2[r20_key2]))
5334 print(" spin137F.dw = %s" % spin137F.dw)
5335 print(" spin137F.dwH = %s" % spin137F.dwH)
5336
5337
5338 self.assertAlmostEqual(spin135S.r2[r20_key1], 28.2493445347425, 4)
5339 self.assertAlmostEqual(spin135S.r2[r20_key2], 31.7517352342937, 4)
5340 self.assertAlmostEqual(spin135S.pA, 0.836591714049569, 4)
5341 self.assertAlmostEqual(spin135S.dw, 0.583003004605869, 4)
5342 self.assertAlmostEqual(spin135S.dwH, 0.0361441894065963, 4)
5343 self.assertAlmostEqual(spin135S.kex/100, 241.806464344233/100, 4)
5344 self.assertAlmostEqual(spin135S.chi2, 12.4224060116473, 4)
5345
5346
5347 self.assertAlmostEqual(spin135F.r2[r20_key1], 42.7201844426839, 4)
5348 self.assertAlmostEqual(spin135F.r2[r20_key2], 57.3178718548898, 4)
5349 self.assertAlmostEqual(spin135F.pA, 0.836591714049569, 4)
5350 self.assertAlmostEqual(spin135F.dw, 0.805849748711916, 4)
5351 self.assertAlmostEqual(spin135F.dwH, 0.0215791669142752, 4)
5352 self.assertAlmostEqual(spin135F.kex/100, 241.806464344233/100, 4)
5353 self.assertAlmostEqual(spin135F.chi2, 12.4224060116473, 4)
5354
5355
5356 self.assertAlmostEqual(spin137S.r2[r20_key1], 26.013412509919, 4)
5357 self.assertAlmostEqual(spin137S.r2[r20_key2], 30.5758092335097, 4)
5358 self.assertAlmostEqual(spin137S.pA, 0.836591714049569, 4)
5359 self.assertAlmostEqual(spin137S.dw, 0.688107406812537, 4)
5360 self.assertAlmostEqual(spin137S.dwH, 0.034446357344577, 4)
5361 self.assertAlmostEqual(spin137S.kex/100, 241.806464344233/100, 4)
5362 self.assertAlmostEqual(spin137S.chi2, 12.4224060116473, 4)
5363
5364
5365 self.assertAlmostEqual(spin137F.r2[r20_key1], 46.696935090697, 4)
5366 self.assertAlmostEqual(spin137F.r2[r20_key2], 58.6023842513446, 4)
5367 self.assertAlmostEqual(spin137F.pA, 0.836591714049569, 4)
5368 self.assertAlmostEqual(spin137F.dw, 0.94978325541294, 4)
5369 self.assertAlmostEqual(spin137F.dwH, 1.5189362257653e-07, 4)
5370 self.assertAlmostEqual(spin137F.kex/100, 241.806464344233/100, 4)
5371 self.assertAlmostEqual(spin137F.chi2, 12.4224060116473, 4)
5372
5373
5375 """Test the 'NS MMQ 2-site' model fitting against Remco Sprangers' ClpP data.
5376
5377 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.
5378 """
5379
5380
5381 self.interpreter.reset()
5382
5383
5384 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'Sprangers_ClpP'
5385 self.interpreter.state.load(data_path+sep+'r2eff_values')
5386
5387
5388 model = 'NS MMQ 2-site'
5389 pipe_name = "%s - relax_disp" % model
5390 self.interpreter.pipe.copy(pipe_from='base pipe', pipe_to=pipe_name, bundle_to='relax_disp')
5391 self.interpreter.pipe.switch(pipe_name=pipe_name)
5392
5393
5394 self.interpreter.relax_disp.select_model(model=model)
5395
5396
5397 self.interpreter.relax_disp.cluster(cluster_id='all', spin_id=":135-137")
5398
5399
5400 self.interpreter.value.copy(pipe_from='R2eff', pipe_to=pipe_name, param='r2eff')
5401
5402
5403 spin135S = cdp.mol[0].res[0].spin[0]
5404 spin135F = cdp.mol[0].res[0].spin[1]
5405 spin137S = cdp.mol[0].res[1].spin[0]
5406 spin137F = cdp.mol[0].res[1].spin[1]
5407
5408
5409 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_MQ, frq=800e6)
5410 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_MQ, frq=800e6)
5411
5412
5413 spin135S.pA = 0.847378444499757
5414 spin135S.kex = 264.055604934724329
5415
5416
5417 spin135S.r2 = {r20_key1: 30.315119723745390, r20_key2: 37.411874745645299}
5418 spin135S.dw = 0.585574008745351
5419 spin135S.dwH = 0.000000000000002
5420
5421 spin135F.r2 = {r20_key1: 41.440843383778287, r20_key2: 56.989726795397893}
5422 spin135F.dw = 0.856699277665748
5423 spin135F.dwH = 0.000000000582587
5424
5425 spin137S.r2 = {r20_key1: 23.051695938570266, r20_key2: 28.352806483953824}
5426 spin137S.dw = 0.772904450844973
5427 spin137S.dwH = 0.183351478512970
5428
5429 spin137F.r2 = {r20_key1: 44.702032074210429, r20_key2: 56.453146052685319}
5430 spin137F.dw = 0.984568590342831
5431 spin137F.dwH = 0.000000001993458
5432
5433
5434 self.interpreter.minimise(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)
5435
5436
5437 print("\n\nOptimised parameters:\n")
5438 print("%-20s %-20s %-20s %-20s %-20s" % ("Parameter", "Value (:135@S)", "Value (:135@F)", "Value (:137@S)", "Value (:137@F)"))
5439 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]))
5440 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]))
5441 print("%-20s %20.15g %20.15g %20.15g %20.15g" % ("pA", spin135S.pA, spin135F.pA, spin137S.pA, spin137F.pA))
5442 print("%-20s %20.15g %20.15g %20.15g %20.15g" % ("dw", spin135S.dw, spin135F.dw, spin137S.dw, spin137F.dw))
5443 print("%-20s %20.15g %20.15g %20.15g %20.15g" % ("dwH", spin135S.dwH, spin135F.dwH, spin137S.dwH, spin137F.dwH))
5444 print("%-20s %20.15g %20.15g %20.15g %20.15g" % ("kex", spin135S.kex, spin135F.kex, spin137S.kex, spin137F.kex))
5445 print("%-20s %20.15g %20.15g %20.15g %20.15g\n" % ("chi2", spin135S.chi2, spin135F.chi2, spin137S.chi2, spin137F.chi2))
5446
5447
5448 return
5449
5450
5451 self.assertAlmostEqual(spin135S.r2[r20_key1], 30.3151197237454, 4)
5452 self.assertAlmostEqual(spin135S.r2[r20_key2], 37.4118747456453, 4)
5453 self.assertAlmostEqual(spin135S.pA, 0.847378444499757, 4)
5454 self.assertAlmostEqual(spin135S.dw, 0.585574008745351, 4)
5455 self.assertAlmostEqual(spin135S.dwH, 2e-15, 4)
5456 self.assertAlmostEqual(spin135S.kex, 264.055604934724, 4)
5457 self.assertAlmostEqual(spin135S.chi2, 13.859423588071, 1)
5458
5459
5460 self.assertAlmostEqual(spin135F.r2[r20_key1], 41.4408433837783, 4)
5461 self.assertAlmostEqual(spin135F.r2[r20_key2], 56.9897267953979, 4)
5462 self.assertAlmostEqual(spin135F.pA, 0.847378444499757, 4)
5463 self.assertAlmostEqual(spin135F.dw, 0.856699277665748, 4)
5464 self.assertAlmostEqual(spin135F.dwH, 5.82587e-10, 4)
5465 self.assertAlmostEqual(spin135F.kex, 264.055604934724, 4)
5466 self.assertAlmostEqual(spin135F.chi2, 13.859423588071, 1)
5467
5468
5469 self.assertAlmostEqual(spin137S.r2[r20_key1], 23.0516959385703, 4)
5470 self.assertAlmostEqual(spin137S.r2[r20_key2], 28.3528064839538, 4)
5471 self.assertAlmostEqual(spin137S.pA, 0.847378444499757, 4)
5472 self.assertAlmostEqual(spin137S.dw, 0.772904450844973, 4)
5473 self.assertAlmostEqual(spin137S.dwH, 0.18335147851297, 4)
5474 self.assertAlmostEqual(spin137S.kex, 264.055604934724, 4)
5475 self.assertAlmostEqual(spin137S.chi2, 13.859423588071, 1)
5476
5477
5478 self.assertAlmostEqual(spin137F.r2[r20_key1], 44.7020320742104, 4)
5479 self.assertAlmostEqual(spin137F.r2[r20_key2], 56.4531460526853, 4)
5480 self.assertAlmostEqual(spin137F.pA, 0.847378444499757, 4)
5481 self.assertAlmostEqual(spin137F.dw, 0.984568590342831, 4)
5482 self.assertAlmostEqual(spin137F.dwH, 2.0931309e-09, 4)
5483 self.assertAlmostEqual(spin137F.kex, 264.055604934724, 4)
5484 self.assertAlmostEqual(spin137F.chi2, 13.859423588071, 1)
5485
5486
5488 """Test the relaxation dispersion 'NS R1rho 2-site' model fitting against the 'TP02' test data."""
5489
5490
5491 self.interpreter.reset()
5492
5493
5494 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'r1rho_off_res_tp02'
5495 self.interpreter.state.load(data_path+sep+'r2eff_values')
5496
5497
5498 model = 'NS R1rho 2-site'
5499 pipe_name = "%s - relax_disp" % model
5500 self.interpreter.pipe.copy(pipe_from='base pipe', pipe_to=pipe_name, bundle_to='relax_disp')
5501 self.interpreter.pipe.switch(pipe_name=pipe_name)
5502
5503
5504 self.interpreter.relax_disp.select_model(model=model)
5505
5506
5507 self.interpreter.value.copy(pipe_from='R2eff', pipe_to=pipe_name, param='r2eff')
5508
5509
5510 spin1 = cdp.mol[0].res[0].spin[0]
5511 spin2 = cdp.mol[0].res[1].spin[0]
5512
5513
5514 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_R1RHO, frq=500e6)
5515 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_R1RHO, frq=800e6)
5516
5517
5518 spin1.r2 = {r20_key1: 9.9963793866185, r20_key2: 15.0056724422684}
5519 spin1.pA = 0.779782428085762
5520 spin1.dw = 7.57855284496424
5521 spin1.kex = 1116.7911285203
5522 spin2.r2 = {r20_key1: 11.9983346935434, r20_key2: 18.0076097513337}
5523 spin2.pA = 0.826666229688602
5524 spin2.dw = 9.5732624231366
5525 spin2.kex = 1380.46162655657
5526
5527
5528 self.interpreter.minimise(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)
5529
5530
5531 print("\n\nOptimised parameters:\n")
5532 print("%-20s %-20s %-20s" % ("Parameter", "Value (:1)", "Value (:2)"))
5533 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin1.r2[r20_key1], spin2.r2[r20_key1]))
5534 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin1.r2[r20_key2], spin2.r2[r20_key2]))
5535 print("%-20s %20.15g %20.15g" % ("pA", spin1.pA, spin2.pA))
5536 print("%-20s %20.15g %20.15g" % ("dw", spin1.dw, spin2.dw))
5537 print("%-20s %20.15g %20.15g" % ("kex", spin1.kex, spin2.kex))
5538 print("%-20s %20.15g %20.15g\n" % ("chi2", spin1.chi2, spin2.chi2))
5539
5540
5541 self.assertAlmostEqual(spin1.r2[r20_key1], 8.50207717367548, 4)
5542 self.assertAlmostEqual(spin1.r2[r20_key2], 13.4680429589972, 4)
5543 self.assertAlmostEqual(spin1.pA, 0.864523128842393, 4)
5544 self.assertAlmostEqual(spin1.dw, 8.85204828994151, 4)
5545 self.assertAlmostEqual(spin1.kex/1000, 1199.56359549637/1000, 4)
5546 self.assertAlmostEqual(spin1.chi2, 2.99182130153514, 4)
5547
5548
5549 self.assertAlmostEqual(spin2.r2[r20_key1], 10.2099357790203, 4)
5550 self.assertAlmostEqual(spin2.r2[r20_key2], 16.2137648697873, 4)
5551 self.assertAlmostEqual(spin2.pA, 0.836488681031685, 4)
5552 self.assertAlmostEqual(spin2.dw, 9.5505714779503, 4)
5553 self.assertAlmostEqual(spin2.kex/1000, 1454.45726998929/1000, 4)
5554 self.assertAlmostEqual(spin2.chi2, 0.000402231563481261, 4)
5555
5556
5558 """Test the dispersion 'MP05' model fitting against the 'TP02' test data."""
5559
5560
5561 ds.fixed = True
5562 ds.models = ['R2eff', 'MP05']
5563
5564
5565 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')
5566
5567
5568 self.interpreter.pipe.switch('MP05 - relax_disp')
5569
5570
5571 r1rho_prime = [[10.0058086343329, 15.005806870124], [12.0766320470785, 18.0767503536277]]
5572 pA = [0.775055484521586, 0.500000000036595]
5573 kex = [1235.20361276079, 2378.31403454691]
5574 delta_omega = [7.08194146569694, 5.4083562844306]
5575 chi2 = [0.0370400968727768, 0.182141732163934]
5576
5577
5578 spin1 = cdp.mol[0].res[0].spin[0]
5579 spin2 = cdp.mol[0].res[1].spin[0]
5580
5581
5582 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_R1RHO, frq=500e6)
5583 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_R1RHO, frq=800e6)
5584
5585
5586 print("\n\nOptimised parameters:\n")
5587 print("%-20s %-20s %-20s" % ("Parameter", "Value (:1)", "Value (:2)"))
5588 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin1.r2[r20_key1], spin2.r2[r20_key1]))
5589 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin1.r2[r20_key2], spin2.r2[r20_key2]))
5590 print("%-20s %20.15g %20.15g" % ("pA", spin1.pA, spin2.pA))
5591 print("%-20s %20.15g %20.15g" % ("dw", spin1.dw, spin2.dw))
5592 print("%-20s %20.15g %20.15g" % ("kex", spin1.kex, spin2.kex))
5593 print("%-20s %20.15g %20.15g\n" % ("chi2", spin1.chi2, spin2.chi2))
5594
5595
5596 spin_index = 0
5597 for spin, spin_id in spin_loop(return_id=True):
5598
5599 print("\nSpin %s." % spin_id)
5600
5601
5602 self.assertAlmostEqual(spin.r2[r20_key1]/10, r1rho_prime[spin_index][0]/10, 4)
5603 self.assertAlmostEqual(spin.r2[r20_key2]/10, r1rho_prime[spin_index][1]/10, 4)
5604 self.assertAlmostEqual(spin.pA, pA[spin_index], 3)
5605 self.assertAlmostEqual(spin.dw, delta_omega[spin_index], 3)
5606 self.assertAlmostEqual(spin.kex/1000.0, kex[spin_index]/1000.0, 3)
5607 self.assertAlmostEqual(spin.chi2, chi2[spin_index], 3)
5608
5609
5610 spin_index += 1
5611
5612
5614 """Test the dispersion 'TAP03' model fitting against the 'TP02' test data."""
5615
5616
5617 ds.fixed = True
5618 ds.models = ['R2eff', 'TAP03']
5619
5620
5621 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')
5622
5623
5624 self.interpreter.pipe.switch('TAP03 - relax_disp')
5625
5626
5627 r1rho_prime = [[10.0058156589442, 15.005818505006], [12.0766046472748, 18.076648462452]]
5628 pA = [0.775042569092891, 0.500000000229685]
5629 kex = [1235.20852748765, 2379.47085580169]
5630 delta_omega = [7.08176806468445, 5.40708372863538]
5631 chi2 = [0.0371366837083293, 0.182212857256044]
5632
5633
5634 spin1 = cdp.mol[0].res[0].spin[0]
5635 spin2 = cdp.mol[0].res[1].spin[0]
5636
5637
5638 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_R1RHO, frq=500e6)
5639 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_R1RHO, frq=800e6)
5640
5641
5642 print("\n\nOptimised parameters:\n")
5643 print("%-20s %-20s %-20s" % ("Parameter", "Value (:1)", "Value (:2)"))
5644 print("%-20s %20.15g %20.15g" % ("R2 (500 MHz)", spin1.r2[r20_key1], spin2.r2[r20_key1]))
5645 print("%-20s %20.15g %20.15g" % ("R2 (800 MHz)", spin1.r2[r20_key2], spin2.r2[r20_key2]))
5646 print("%-20s %20.15g %20.15g" % ("pA", spin1.pA, spin2.pA))
5647 print("%-20s %20.15g %20.15g" % ("dw", spin1.dw, spin2.dw))
5648 print("%-20s %20.15g %20.15g" % ("kex", spin1.kex, spin2.kex))
5649 print("%-20s %20.15g %20.15g\n" % ("chi2", spin1.chi2, spin2.chi2))
5650
5651
5652 self.interpreter.pipe.switch('TAP03 - relax_disp')
5653 spin_index = 0
5654 for spin, spin_id in spin_loop(return_id=True):
5655
5656 print("\nSpin %s." % spin_id)
5657
5658
5659 self.assertAlmostEqual(spin.r2[r20_key1]/10, r1rho_prime[spin_index][0]/10, 4)
5660 self.assertAlmostEqual(spin.r2[r20_key2]/10, r1rho_prime[spin_index][1]/10, 4)
5661 self.assertAlmostEqual(spin.pA, pA[spin_index], 3)
5662 self.assertAlmostEqual(spin.dw, delta_omega[spin_index], 3)
5663 self.assertAlmostEqual(spin.kex/1000.0, kex[spin_index]/1000.0, 3)
5664 self.assertAlmostEqual(spin.chi2, chi2[spin_index], 3)
5665
5666
5667 spin_index += 1
5668
5669
5671 """Test the relaxation dispersion 'TP02' model curve fitting to fixed time synthetic data."""
5672
5673
5674 ds.fixed = True
5675
5676
5677 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')
5678
5679
5680 r1rho_prime = [[10.0, 15.0], [12.0, 18.0]]
5681 pA = 0.7654321
5682 kex = 1234.56789
5683 delta_omega = [7.0, 9.0]
5684
5685
5686 r20_key1 = generate_r20_key(exp_type=EXP_TYPE_R1RHO, frq=500e6)
5687 r20_key2 = generate_r20_key(exp_type=EXP_TYPE_R1RHO, frq=800e6)
5688
5689
5690 self.interpreter.pipe.switch('TP02 - relax_disp')
5691 spin_index = 0
5692 for spin, spin_id in spin_loop(return_id=True):
5693
5694 print("\nSpin %s." % spin_id)
5695
5696
5697 self.assertAlmostEqual(spin.r2[r20_key1]/10, r1rho_prime[spin_index][0]/10, 4)
5698 self.assertAlmostEqual(spin.r2[r20_key2]/10, r1rho_prime[spin_index][1]/10, 4)
5699 self.assertAlmostEqual(spin.dw, delta_omega[spin_index], 3)
5700 self.assertAlmostEqual(spin.kex/1000.0, kex/1000.0, 3)
5701
5702
5703 spin_index += 1
5704
5705
5707 """System test of the value.write function to write intensities for an R1rho setup.
5708 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.
5709
5710 This uses the data of the saved state attached to U{bug #21344<https://web.archive.org/web/https://gna.org/bugs/?21344>}.
5711 """
5712
5713
5714 statefile = status.install_path+sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21344_trunc.bz2'
5715 self.interpreter.state.load(statefile, force=True)
5716
5717
5718 int_filepath = ds.tmpdir+sep+'int.out'
5719
5720
5721
5722 self.interpreter.value.write(param='peak_intensity', file='int.out', dir=ds.tmpdir, scaling=1.0, force=True)
5723
5724
5725 self.assert_(access(int_filepath, F_OK))
5726
5727
5728 int_file = open(int_filepath, 'r')
5729
5730
5731 for line in int_file:
5732
5733 if line[0] == "#":
5734 continue
5735
5736
5737 linesplit = line.split()
5738
5739
5740 if linesplit[0] == "None" and linesplit[1] == "5" and linesplit[2] == "I":
5741 self.assertEqual(linesplit[5], "115571.4")
5742 elif linesplit[0] == "None" and linesplit[1] == "6" and linesplit[2] == "S":
5743 self.assertEqual(linesplit[5], "68377.52")
5744 elif linesplit[0] == "None" and linesplit[1] == "8" and linesplit[2] == "S":
5745 self.assertEqual(linesplit[5], "9141.689")
5746 elif linesplit[0] == "None" and linesplit[1] == "9" and linesplit[2] == "A":
5747 self.assertEqual(linesplit[5], "29123.77")
5748 elif linesplit[0] == "None" and linesplit[1] == "10" and linesplit[2] == "L":
5749 self.assertEqual(linesplit[5], "58914.94")
5750
5751
5752 int_file.close()
5753
5754
5756 """System test of the value.write function to write return values of theta from calc_rotating_frame_params() function for an R1rho setup.
5757
5758 This uses the data of the saved state attached to U{bug #21344<https://web.archive.org/web/https://gna.org/bugs/?21344>}.
5759 """
5760
5761
5762 statefile = status.install_path+sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21344_trunc.bz2'
5763 self.interpreter.state.load(statefile, force=True)
5764
5765
5766 theta_filepath = ds.tmpdir+sep+'theta.out'
5767
5768
5769 self.interpreter.value.write(param='theta', file='theta.out', dir=ds.tmpdir, scaling=1.0, force=True)
5770
5771
5772 self.assert_(access(theta_filepath, F_OK))
5773
5774
5775 theta_file = open(theta_filepath, 'r')
5776
5777
5778 for line in theta_file:
5779
5780 if line[0] == "#":
5781 continue
5782
5783 print(line[:-1])
5784
5785
5786 linesplit = line.split()
5787
5788
5789 if linesplit[0] == "None" and linesplit[1] == "5" and linesplit[2] == "I":
5790 self.assertNotEqual(linesplit[5], "None")
5791 elif linesplit[0] == "None" and linesplit[1] == "6" and linesplit[2] == "S":
5792 self.assertNotEqual(linesplit[5], "None")
5793 elif linesplit[0] == "None" and linesplit[1] == "8" and linesplit[2] == "S":
5794 self.assertNotEqual(linesplit[5], "None")
5795 elif linesplit[0] == "None" and linesplit[1] == "9" and linesplit[2] == "A":
5796 self.assertNotEqual(linesplit[5], "None")
5797 elif linesplit[0] == "None" and linesplit[1] == "10" and linesplit[2] == "L":
5798 self.assertNotEqual(linesplit[5], "None")
5799
5800
5801 theta_file.close()
5802
5803
5805 """System test of the value.write function to write return values of w_eff from calc_rotating_frame_params() function for an R1rho setup.
5806
5807 This uses the data of the saved state attached to U{bug #21344<https://web.archive.org/web/https://gna.org/bugs/?21344>}.
5808 """
5809
5810
5811 statefile = status.install_path+sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21344_trunc.bz2'
5812 self.interpreter.state.load(statefile, force=True)
5813
5814
5815 w_eff_filepath = ds.tmpdir+sep+'w_eff.out'
5816
5817
5818 self.interpreter.value.write(param='w_eff', file='w_eff.out', dir=ds.tmpdir, scaling=1.0, force=True)
5819
5820
5821 self.assert_(access(w_eff_filepath, F_OK))
5822
5823
5824 w_eff_file = open(w_eff_filepath, 'r')
5825
5826
5827 for line in w_eff_file:
5828
5829 if line[0] == "#":
5830 continue
5831
5832 print(line[:-1])
5833
5834
5835 linesplit = line.split()
5836
5837
5838 if linesplit[0] == "None" and linesplit[1] == "5" and linesplit[2] == "I":
5839 self.assertNotEqual(linesplit[5], "None")
5840 elif linesplit[0] == "None" and linesplit[1] == "6" and linesplit[2] == "S":
5841 self.assertNotEqual(linesplit[5], "None")
5842 elif linesplit[0] == "None" and linesplit[1] == "8" and linesplit[2] == "S":
5843 self.assertNotEqual(linesplit[5], "None")
5844 elif linesplit[0] == "None" and linesplit[1] == "9" and linesplit[2] == "A":
5845 self.assertNotEqual(linesplit[5], "None")
5846 elif linesplit[0] == "None" and linesplit[1] == "10" and linesplit[2] == "L":
5847 self.assertNotEqual(linesplit[5], "None")
5848
5849
5850 w_eff_file.close()
5851
5852
5854 """System test of the auto_analysis value.write function to write theta and w_eff values for an R1rho setup.
5855
5856 This uses the data of the saved state attached to U{bug #21344<https://web.archive.org/web/https://gna.org/bugs/?21344>}.
5857 """
5858
5859
5860 statefile = status.install_path+sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21344.bz2'
5861 self.interpreter.state.load(statefile, force=True)
5862
5863
5864 pipe_name = 'base pipe'
5865 pipe_bundle = 'relax_disp'
5866 pipe_type= 'relax_disp'
5867
5868
5869 data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'Kjaergaard_et_al_2013'
5870
5871
5872 self.interpreter.deselect.all()
5873
5874
5875 select_spin_ids = [
5876 ":13@N",
5877 ":15@N",
5878 ":16@N",
5879 ":25@N",
5880 ":26@N",
5881 ":28@N",
5882 ":39@N",
5883 ":40@N",
5884 ":41@N",
5885 ":43@N",
5886 ":44@N",
5887 ":45@N",
5888 ":49@N",
5889 ":52@N",
5890 ":53@N"]
5891
5892
5893 for curspin in select_spin_ids:
5894 print("Selecting spin %s"%curspin)
5895 self.interpreter.deselect.reverse(spin_id=curspin)
5896
5897
5898 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)
5899
5900
5901 MODELS = ['R2eff']
5902
5903
5904 GRID_INC = 4
5905
5906
5907 MC_NUM = 3
5908
5909
5910 MODSEL = 'AIC'
5911
5912
5913
5914 OPT_FUNC_TOL = 1e-1
5915 relax_disp.Relax_disp.opt_func_tol = OPT_FUNC_TOL
5916 OPT_MAX_ITERATIONS = 1000
5917 relax_disp.Relax_disp.opt_max_iterations = OPT_MAX_ITERATIONS
5918
5919
5920 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)
5921
5922
5923
5924 theta_filepath = ds.tmpdir+sep+MODELS[0]+sep+'theta.out'
5925 w_eff_filepath = ds.tmpdir+sep+MODELS[0]+sep+'w_eff.out'
5926
5927
5928 self.assert_(access(theta_filepath, F_OK))
5929 self.assert_(access(w_eff_filepath, F_OK))
5930
5931
5932 theta_file = open(theta_filepath, 'r')
5933 theta_result = [
5934 "# Parameter description: Rotating frame tilt angle : ( theta = arctan(w_1 / Omega) ) (rad).\n",
5935 "#\n",
5936 "# 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",
5937 "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",
5938 "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",
5939 "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",
5940 "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",
5941 "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",
5942 "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",
5943 "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",
5944 "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",
5945 "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",
5946 "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",
5947 "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",
5948 "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",
5949 "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",
5950 "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",
5951 "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",
5952 "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",
5953 "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",
5954 "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",
5955 "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",
5956 "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",
5957 "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",
5958 "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",
5959 "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",
5960 "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",
5961 "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",
5962 "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",
5963 "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",
5964 "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",
5965 "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",
5966 "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",
5967 "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",
5968 "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",
5969 "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",
5970 "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",
5971 "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",
5972 "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",
5973 "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",
5974 "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",
5975 "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",
5976 "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",
5977 "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",
5978 "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",
5979 "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",
5980 "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",
5981 "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",
5982 "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",
5983 "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",
5984 "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"
5985 ]
5986
5987 lines = theta_file.readlines()
5988 for i in range(len(lines)):
5989
5990 if theta_result[i][0] == "#":
5991 self.assertEqual(theta_result[i], lines[i])
5992
5993 if theta_result[i] == lines[i]:
5994 self.assertEqual(theta_result[i], lines[i])
5995
5996 else:
5997
5998 print(theta_result[i])
5999 print(lines[i])
6000
6001
6002 self.assertEqual(theta_result[i][:62], lines[i][:62])
6003
6004
6005 theta_result_s = theta_result[i][62:].split()[::2]
6006 print(theta_result_s )
6007 lines_s = lines[i][62:].split()[::2]
6008 print(lines_s)
6009
6010 for j in range(len(lines_s)):
6011 print(theta_result_s[j], lines_s[j])
6012
6013 self.assertAlmostEqual(float(theta_result_s[j]), float(lines_s[j]), 14)
6014
6015
6016 theta_file.close()
6017
6018 w_eff_file = open(w_eff_filepath, 'r')
6019 w_eff_result = [
6020 "# Parameter description: Effective field in rotating frame : ( w_eff = sqrt(Omega^2 + w_1^2) ) (rad.s^-1).\n",
6021 "#\n",
6022 "# 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",
6023 "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",
6024 "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",
6025 "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",
6026 "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",
6027 "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",
6028 "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",
6029 "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",
6030 "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",
6031 "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",
6032 "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",
6033 "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",
6034 "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",
6035 "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",
6036 "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",
6037 "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",
6038 "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",
6039 "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",
6040 "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",
6041 "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",
6042 "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",
6043 "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",
6044 "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",
6045 "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",
6046 "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",
6047 "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",
6048 "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",
6049 "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",
6050 "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",
6051 "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",
6052 "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",
6053 "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",
6054 "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",
6055 "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",
6056 "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",
6057 "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",
6058 "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",
6059 "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",
6060 "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",
6061 "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",
6062 "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",
6063 "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",
6064 "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",
6065 "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",
6066 "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",
6067 "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",
6068 "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",
6069 "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",
6070 "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"
6071 ]
6072
6073 lines = w_eff_file.readlines()
6074 for i in range(len(lines)):
6075
6076 if w_eff_result[i][0] == "#":
6077 self.assertEqual(w_eff_result[i], lines[i])
6078
6079 if w_eff_result[i] == lines[i]:
6080 self.assertEqual(w_eff_result[i], lines[i])
6081
6082 else:
6083
6084 print(w_eff_result[i])
6085 print(lines[i])
6086
6087
6088 self.assertEqual(w_eff_result[i][:62], lines[i][:62])
6089
6090
6091 w_eff_result_s = w_eff_result[i][62:].split()[::2]
6092 print(w_eff_result_s )
6093 lines_s = lines[i][62:].split()[::2]
6094 print(lines_s)
6095
6096 for j in range(len(lines_s)):
6097 print(w_eff_result_s[j], lines_s[j])
6098
6099 self.assertAlmostEqual(float(w_eff_result_s[j]), float(lines_s[j]), 14)
6100
6101
6102 w_eff_file.close()
6103