1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 from numpy import array, float64, int16, pi, zeros
24 from unittest import TestCase
25
26
27 from lib.dispersion.ns_cpmg_2site_expanded import r2eff_ns_cpmg_2site_expanded
28
29
31 """Unit tests for the lib.dispersion.ns_cpmg_2site_expanded relax module."""
32
34 """Set up for all unit tests."""
35
36
37 self.r20 = 2.0
38 self.pA = 0.95
39 self.dw = 0.5
40 self.kex = 100.0
41
42
43 self.num_points = 3
44 self.tcp = array([0.1, 0.2, 0.3], float64)
45 self.num_cpmg = array([1, 2, 3], int16)
46 self.R2eff = zeros(self.num_points, float64)
47
48
49 self.sfrq = 200. * 1E6
50
51
53 """Calculate and check the R2eff values."""
54
55
56 k_AB, k_BA, dw_frq = self.param_conversion(pA=self.pA, kex=self.kex, dw=self.dw, sfrq=self.sfrq)
57
58
59 r2eff_ns_cpmg_2site_expanded(r20=self.r20, pA=self.pA, dw=dw_frq, k_AB=k_AB, k_BA=k_BA, relax_time=0.3, inv_relax_time=1/0.3, tcp=self.tcp, back_calc=self.R2eff, num_points=self.num_points, num_cpmg=self.num_cpmg)
60
61
62 if self.kex >= 1.e5:
63 for i in range(self.num_points):
64 self.assertAlmostEqual(self.R2eff[i], self.r20, 5)
65 else:
66 for i in range(self.num_points):
67 self.assertAlmostEqual(self.R2eff[i], self.r20)
68
69
71 """Convert the parameters.
72
73 @keyword pA: The population of state A.
74 @type pA: float
75 @keyword kex: The rate of exchange.
76 @type kex: float
77 @keyword dw: The chemical exchange difference between states A and B in ppm.
78 @type dw: float
79 @keyword sfrq: The spin Larmor frequencies in Hz.
80 @type sfrq: float
81 @return: The parameters {k_AB, k_BA, dw_frq}.
82 @rtype: tuple of float
83 """
84
85
86 pB = 1.0 - pA
87
88
89 k_BA = pA * kex
90 k_AB = pB * kex
91
92
93 frqs = sfrq * 2 * pi
94
95
96 dw_frq = dw * frqs / 1.e6
97
98
99 return k_AB, k_BA, dw_frq
100
101
103 """Test the r2eff_ns_cpmg_2site_expanded() function for no exchange when dw = 0.0."""
104
105
106 self.dw = 0.0
107
108
109 self.calc_r2eff()
110
111
113 """Test the r2eff_ns_cpmg_2site_expanded() function for no exchange when pA = 1.0."""
114
115
116 self.pA = 1.0
117
118
119 self.calc_r2eff()
120
121
123 """Test the r2eff_ns_cpmg_2site_expanded() function for no exchange when kex = 0.0."""
124
125
126 self.kex = 0.0
127
128
129 self.calc_r2eff()
130
131
133 """Test the r2eff_ns_cpmg_2site_expanded() function for no exchange when dw = 0.0 and pA = 1.0."""
134
135
136 self.pA = 1.0
137 self.dw = 0.0
138
139
140 self.calc_r2eff()
141
142
144 """Test the r2eff_ns_cpmg_2site_expanded() function for no exchange when dw = 0.0 and kex = 0.0."""
145
146
147 self.dw = 0.0
148 self.kex = 0.0
149
150
151 self.calc_r2eff()
152
153
155 """Test the r2eff_ns_cpmg_2site_expanded() function for no exchange when pA = 1.0 and kex = 0.0."""
156
157
158 self.pA = 1.0
159 self.kex = 0.0
160
161
162 self.calc_r2eff()
163
164
166 """Test the r2eff_ns_cpmg_2site_expanded() function for no exchange when dw = 0.0, pA = 1.0, and kex = 0.0."""
167
168
169 self.dw = 0.0
170 self.kex = 0.0
171
172
173 self.calc_r2eff()
174