1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 from numpy import array, float64, ones, pi, zeros
25 from unittest import TestCase
26
27
28 from lib.dispersion.mmq_cr72 import r2eff_mmq_cr72
29
30
32 """Unit tests for the lib.dispersion.mmq_cr72 relax module."""
33
35 """Set up for all unit tests."""
36
37
38 self.r20 = 2.0
39 self.pA = 0.95
40 self.dw = 2.0
41 self.dwH = 0.5
42 self.kex = 1000.0
43
44
45 self.num_points = 6
46 self.ncyc = array([2, 4, 8, 10, 20, 40])
47 relax_times = 0.04
48 self.cpmg_frqs = self.ncyc / relax_times
49 self.inv_relax_times = 1.0 / relax_times
50 self.tau_cpmg = 0.25 / self.cpmg_frqs
51 self.R2eff = zeros(self.num_points, float64)
52
53
54 self.sfrq = 200. * 1E6
55
56
58 """Calculate and check the R2eff values."""
59
60
61 k_AB, k_BA, pB, dw_frq, dwH_frq = self.param_conversion(pA=self.pA, kex=self.kex, dw=self.dw, dwH=self.dwH, sfrq=self.sfrq)
62
63 a = ones(self.ncyc.shape)
64
65
66 r2eff_mmq_cr72(r20=self.r20*a, pA=self.pA, dw=dw_frq*a, dwH=dwH_frq*a, kex=self.kex, cpmg_frqs=self.cpmg_frqs, inv_tcpmg=self.inv_relax_times, tcp=self.tau_cpmg, back_calc=self.R2eff)
67
68
69 for i in range(self.num_points):
70 self.assertAlmostEqual(self.R2eff[i], self.r20)
71
72
74 """Convert the parameters.
75
76 @keyword pA: The population of state A.
77 @type pA: float
78 @keyword kex: The rate of exchange.
79 @type kex: float
80 @keyword dw: The chemical exchange difference between states A and B in ppm.
81 @type dw: float
82 @keyword dwH: The proton chemical exchange difference between states A and B in ppm.
83 @type dwH: float
84 @keyword sfrq: The spin Larmor frequencies in Hz.
85 @type sfrq: float
86 @return: The parameters {k_AB, k_BA, pB, dw_frq}.
87 @rtype: tuple of float
88 """
89
90
91 pB = 1.0 - pA
92
93
94 k_BA = pA * kex
95 k_AB = pB * kex
96
97
98 frqs = sfrq * 2 * pi
99
100
101 dw_frq = dw * frqs / 1.e6
102
103
104 dwH_frq = dwH * frqs / 1.e6
105
106
107 return k_AB, k_BA, pB, dw_frq, dwH_frq
108
109
111 """Test the r2eff_mmq_cr72() function for no exchange when dw = 0.0 and dwH = 0.0."""
112
113
114 self.dw = 0.0
115 self.dwH = 0.0
116
117
118 self.calc_r2eff()
119
120
122 """Test the r2eff_mmq_cr72() function for no exchange when pA = 1.0."""
123
124
125 self.pA = 1.0
126
127
128 self.calc_r2eff()
129
130
132 """Test the r2eff_mmq_cr72() function for no exchange when kex = 0.0."""
133
134
135 self.kex = 0.0
136
137
138 self.calc_r2eff()
139
140
142 """Test the r2eff_mmq_cr72() function for no exchange when dw = 0.0, dwH = 0.0 and pA = 1.0."""
143
144
145 self.pA = 1.0
146 self.dw = 0.0
147 self.dwH = 0.0
148
149
150 self.calc_r2eff()
151
152
154 """Test the r2eff_mmq_cr72() function for no exchange when dw = 0.0, dwH = 0.0 and kex = 0.0."""
155
156
157 self.dw = 0.0
158 self.dwH = 0.0
159 self.kex = 0.0
160
161
162 self.calc_r2eff()
163
164
166 """Test the r2eff_mmq_cr72() function for no exchange when pA = 1.0 and kex = 0.0."""
167
168
169 self.pA = 1.0
170 self.kex = 0.0
171
172
173 self.calc_r2eff()
174
175
177 """Test the r2eff_mmq_cr72() function for no exchange when dw = 0.0, dwH = 0.0, pA = 1.0, and kex = 0.0."""
178
179
180 self.dw = 0.0
181 self.dwH = 0.0
182 self.pA = 1.0
183 self.kex = 0.0
184
185
186 self.calc_r2eff()
187
188
190 """Test the r2eff_mmq_cr72() function for no exchange when kex = 1e8."""
191
192
193 self.kex = 1e8
194
195
196 self.calc_r2eff()
197