Package test_suite :: Package unit_tests :: Package _specific_analyses :: Package _relax_disp :: Module test_data
[hide private]
[frames] | no frames]

Source Code for Module test_suite.unit_tests._specific_analyses._relax_disp.test_data

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2008-2014 Edward d'Auvergne                                   # 
  4  # Copyright (C) 2014 Troels E. Linnet                                         # 
  5  #                                                                             # 
  6  # This file is part of the program relax (http://www.nmr-relax.com).          # 
  7  #                                                                             # 
  8  # This program is free software: you can redistribute it and/or modify        # 
  9  # it under the terms of the GNU General Public License as published by        # 
 10  # the Free Software Foundation, either version 3 of the License, or           # 
 11  # (at your option) any later version.                                         # 
 12  #                                                                             # 
 13  # This program is distributed in the hope that it will be useful,             # 
 14  # but WITHOUT ANY WARRANTY; without even the implied warranty of              # 
 15  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               # 
 16  # GNU General Public License for more details.                                # 
 17  #                                                                             # 
 18  # You should have received a copy of the GNU General Public License           # 
 19  # along with this program.  If not, see <http://www.gnu.org/licenses/>.       # 
 20  #                                                                             # 
 21  ############################################################################### 
 22   
 23  # Python module imports. 
 24  from os import sep 
 25   
 26  # relax module imports. 
 27  from data_store import Relax_data_store; ds = Relax_data_store() 
 28  from math import atan, pi 
 29  from pipe_control import state 
 30  from pipe_control.mol_res_spin import get_spin_ids, return_spin 
 31  from specific_analyses.relax_disp.checks import get_times 
 32  from specific_analyses.relax_disp.data import calc_rotating_frame_params, count_relax_times, find_intensity_keys, get_curve_type, has_exponential_exp_type, loop_exp_frq, loop_exp_frq_offset, loop_exp_frq_offset_point, loop_exp_frq_offset_point_time, loop_time, return_offset_data, return_spin_lock_nu1 
 33  from status import Status; status = Status() 
 34  from test_suite.unit_tests.base_classes import UnitTestCase 
 35   
 36   
37 -class Test_data(UnitTestCase):
38 """Unit tests for the functions of the specific_analyses.relax_disp.data module.""" 39
40 - def setUp(self):
41 """Setup some structures for the unit tests.""" 42 43 # Create a dispersion data pipe. 44 ds.add(pipe_name='orig', pipe_type='relax_disp')
45 46
48 """Unit test of the calc_rotating_frame_params() function for R1rho setup. 49 50 This uses the data of the saved state attached to U{bug #21344<https://web.archive.org/web/https://gna.org/bugs/?21344>}. 51 """ 52 53 # Load the state. 54 statefile = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21344_trunc.bz2' 55 state.load_state(statefile, force=True) 56 57 curspin_id = ':5@N' 58 curspin = return_spin(curspin_id) 59 60 # Use calc_tilt_angle function 61 theta_spin_dic, Domega_spin_dic, w_eff_spin_dic, dic_key_list = calc_rotating_frame_params(spin = curspin, spin_id = curspin_id) 62 63 for dic_key in dic_key_list: 64 print(dic_key, theta_spin_dic[dic_key], Domega_spin_dic[dic_key], w_eff_spin_dic[dic_key])
65 66
68 """Unit test of the count_relax_times() function. 69 70 This uses the data of the saved state attached to U{bug #21665<https://web.archive.org/web/https://gna.org/bugs/?21665>}. 71 """ 72 73 # Load the state. 74 statefile = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21665.bz2' 75 state.load_state(statefile, force=True) 76 77 # Original data (exp_type, frq). 78 data = [ 79 ['SQ CPMG', 499862140.0], 80 ['SQ CPMG', 599890858.69999993] 81 ] 82 83 # Original indices (ei, mi). 84 indices = [ 85 [0, 0], 86 [0, 1] 87 ] 88 89 # Check the number of time counts. 90 print("Checking the number of time counts.") 91 for id in cdp.exp_type.keys(): 92 exp_type = cdp.exp_type[id] 93 frq = cdp.spectrometer_frq[id] 94 point = cdp.cpmg_frqs[id] 95 count = count_relax_times(exp_type = exp_type, frq = frq, point = point, ei = cdp.exp_type_list.index(cdp.exp_type[id])) 96 print(id, exp_type, frq, point, count) 97 98 # Test the data 99 if id.split('A')[0] == 'Z_': 100 self.assertEqual(exp_type, data[0][0]) 101 self.assertEqual(frq, data[0][1]) 102 elif id.split('B')[0] == 'Z_': 103 self.assertEqual(exp_type, data[1][0]) 104 self.assertEqual(frq, data[1][1]) 105 # Test the time count 106 self.assertEqual(count, 1)
107 108
110 """Unit test of the count_relax_times() function. 111 112 This uses the data of the saved state attached to U{bug #21344<https://web.archive.org/web/https://gna.org/bugs/?21344>}. 113 """ 114 115 # Load the state. 116 statefile = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21344_trunc.bz2' 117 state.load_state(statefile, force=True) 118 119 # Original data (spectrum id: exp_type, frq, omega_rf_ppm, spin_lock_field_strength, time_spin_lock). 120 data = dict() 121 data['46_0_35_0'] = ['R1rho', 799777399.1, 118.078, 431.0, 0.0] 122 data['48_0_35_4'] = ['R1rho', 799777399.1, 118.078, 431.0, 0.04] 123 data['47_0_35_10'] = ['R1rho', 799777399.1, 118.078, 431.0, 0.1] 124 data['49_0_35_20'] = ['R1rho', 799777399.1, 118.078, 431.0, 0.2] 125 data['36_0_39_0'] = ['R1rho', 799777399.1, 118.078, 651.2, 0.0] 126 data['39_0_39_4'] = ['R1rho', 799777399.1, 118.078, 651.2, 0.04] 127 data['37_0_39_10'] = ['R1rho', 799777399.1, 118.078, 651.2, 0.1] 128 data['40_0_39_20'] = ['R1rho', 799777399.1, 118.078, 651.2, 0.2] 129 data['38_0_39_40'] = ['R1rho', 799777399.1, 118.078, 651.2, 0.4] 130 data['41_0_41_0'] = ['R1rho', 799777399.1, 118.078, 800.5, 0.0] 131 data['44_0_41_4'] = ['R1rho', 799777399.1, 118.078, 800.5, 0.04] 132 data['42_0_41_10'] = ['R1rho', 799777399.1, 118.078, 800.5, 0.1] 133 data['45_0_41_20'] = ['R1rho', 799777399.1, 118.078, 800.5, 0.2] 134 data['43_0_41_40'] = ['R1rho', 799777399.1, 118.078, 800.5, 0.4] 135 data['31_0_43_0'] = ['R1rho', 799777399.1, 118.078, 984.0, 0.0] 136 data['34_0_43_4'] = ['R1rho', 799777399.1, 118.078, 984.0, 0.04] 137 data['32_0_43_10'] = ['R1rho', 799777399.1, 118.078, 984.0, 0.1] 138 data['35_0_43_20'] = ['R1rho', 799777399.1, 118.078, 984.0, 0.2] 139 data['33_0_43_40'] = ['R1rho', 799777399.1, 118.078, 984.0, 0.4] 140 data['1_0_46_0'] = ['R1rho', 799777399.1, 118.078, 1341.11, 0.0] 141 data['4_0_46_4'] = ['R1rho', 799777399.1, 118.078, 1341.11, 0.04] 142 data['2_0_46_10'] = ['R1rho', 799777399.1, 118.078, 1341.11, 0.1] 143 data['5_0_46_20'] = ['R1rho', 799777399.1, 118.078, 1341.11, 0.2] 144 data['3_0_46_40'] = ['R1rho', 799777399.1, 118.078, 1341.11, 0.4] 145 data['60_0_48_0'] = ['R1rho', 799777399.1, 118.078, 1648.5, 0.0] 146 data['63_0_48_4'] = ['R1rho', 799777399.1, 118.078, 1648.5, 0.04] 147 data['61_0_48_10'] = ['R1rho', 799777399.1, 118.078, 1648.5, 0.1] 148 data['62_0_48_14'] = ['R1rho', 799777399.1, 118.078, 1648.5, 0.14] 149 data['64_0_48_20'] = ['R1rho', 799777399.1, 118.078, 1648.5, 0.2] 150 data['11_500_46_0'] = ['R1rho', 799777399.1, 124.24703146206046, 1341.11, 0.0] 151 data['14_500_46_4'] = ['R1rho', 799777399.1, 124.24703146206046, 1341.11, 0.04] 152 data['12_500_46_10'] = ['R1rho', 799777399.1, 124.24703146206046, 1341.11, 0.1] 153 data['15_500_46_20'] = ['R1rho', 799777399.1, 124.24703146206046, 1341.11, 0.2] 154 data['13_500_46_40'] = ['R1rho', 799777399.1, 124.24703146206046, 1341.11, 0.4] 155 data['50_1000_41_0'] = ['R1rho', 799777399.1, 130.41606292412092, 800.5, 0.0] 156 data['53_1000_41_4'] = ['R1rho', 799777399.1, 130.41606292412092, 800.5, 0.04] 157 data['51_1000_41_10'] = ['R1rho', 799777399.1, 130.41606292412092, 800.5, 0.1] 158 data['54_1000_41_20'] = ['R1rho', 799777399.1, 130.41606292412092, 800.5, 0.2] 159 data['52_1000_41_40'] = ['R1rho', 799777399.1, 130.41606292412092, 800.5, 0.4] 160 data['21_1000_46_0'] = ['R1rho', 799777399.1, 130.41606292412092, 1341.11, 0.0] 161 data['24_1000_46_4'] = ['R1rho', 799777399.1, 130.41606292412092, 1341.11, 0.04] 162 data['22_1000_46_10'] = ['R1rho', 799777399.1, 130.41606292412092, 1341.11, 0.1] 163 data['25_1000_46_20'] = ['R1rho', 799777399.1, 130.41606292412092, 1341.11, 0.2] 164 data['23_1000_46_40'] = ['R1rho', 799777399.1, 130.41606292412092, 1341.11, 0.4] 165 data['65_1000_48_0'] = ['R1rho', 799777399.1, 130.41606292412092, 1648.5, 0.0] 166 data['68_1000_48_4'] = ['R1rho', 799777399.1, 130.41606292412092, 1648.5, 0.04] 167 data['66_1000_48_10'] = ['R1rho', 799777399.1, 130.41606292412092, 1648.5, 0.1] 168 data['67_1000_48_14'] = ['R1rho', 799777399.1, 130.41606292412092, 1648.5, 0.14] 169 data['69_1000_48_20'] = ['R1rho', 799777399.1, 130.41606292412092, 1648.5, 0.2] 170 data['55_2000_41_0'] = ['R1rho', 799777399.1, 142.75412584824184, 800.5, 0.0] 171 data['58_2000_41_4'] = ['R1rho', 799777399.1, 142.75412584824184, 800.5, 0.04] 172 data['56_2000_41_10'] = ['R1rho', 799777399.1, 142.75412584824184, 800.5, 0.1] 173 data['59_2000_41_20'] = ['R1rho', 799777399.1, 142.75412584824184, 800.5, 0.2] 174 data['57_2000_41_40'] = ['R1rho', 799777399.1, 142.75412584824184, 800.5, 0.4] 175 data['6_2000_46_0'] = ['R1rho', 799777399.1, 142.75412584824184, 1341.11, 0.0] 176 data['9_2000_46_4'] = ['R1rho', 799777399.1, 142.75412584824184, 1341.11, 0.04] 177 data['7_2000_46_10'] = ['R1rho', 799777399.1, 142.75412584824184, 1341.11, 0.1] 178 data['10_2000_46_20'] = ['R1rho', 799777399.1, 142.75412584824184, 1341.11, 0.2] 179 data['8_2000_46_40'] = ['R1rho', 799777399.1, 142.75412584824184, 1341.11, 0.4] 180 data['16_5000_46_0'] = ['R1rho', 799777399.1, 179.76831462060457, 1341.11, 0.0] 181 data['19_5000_46_4'] = ['R1rho', 799777399.1, 179.76831462060457, 1341.11, 0.04] 182 data['17_5000_46_10'] = ['R1rho', 799777399.1, 179.76831462060457, 1341.11, 0.1] 183 data['20_5000_46_20'] = ['R1rho', 799777399.1, 179.76831462060457, 1341.11, 0.2] 184 data['18_5000_46_40'] = ['R1rho', 799777399.1, 179.76831462060457, 1341.11, 0.4] 185 data['26_10000_46_0'] = ['R1rho', 799777399.1, 241.45862924120914, 1341.11, 0.0] 186 data['29_10000_46_4'] = ['R1rho', 799777399.1, 241.45862924120914, 1341.11, 0.04] 187 data['27_10000_46_10'] = ['R1rho', 799777399.1, 241.45862924120914, 1341.11, 0.1] 188 data['30_10000_46_20'] = ['R1rho', 799777399.1, 241.45862924120914, 1341.11, 0.2] 189 data['28_10000_46_40'] = ['R1rho', 799777399.1, 241.45862924120914, 1341.11, 0.4] 190 191 time_comp = { 192 '118.078_431.00':4, 193 '118.078_651.20':5, 194 '118.078_800.50':5, 195 '118.078_984.00':5, 196 '118.078_1341.11':5, 197 '118.078_1648.50':5, 198 '124.247_1341.11':5, 199 '130.416_800.50':5, 200 '130.416_1341.11':5, 201 '130.416_1648.50':5, 202 '142.754_800.50':5, 203 '142.754_1341.11':5, 204 '179.768_1341.11':5, 205 '241.459_1341.11':5} 206 207 # Check the number of time counts. 208 print("Checking the number of time counts.") 209 for id in cdp.exp_type.keys(): 210 exp_type = cdp.exp_type[id] 211 frq = cdp.spectrometer_frq[id] 212 offset = cdp.spin_lock_offset[id] 213 point = cdp.spin_lock_nu1[id] 214 count = count_relax_times(exp_type = exp_type, frq = frq, offset=offset, point = point, ei = cdp.exp_type_list.index(cdp.exp_type[id])) 215 print(id, exp_type, frq, offset, point, count) 216 217 # Test the time count 218 print(time_comp) 219 self.assertEqual(count, time_comp['%.3f_%.2f'%(offset, point)])
220 221
223 """Unit test of the find_intensity_keys() function. 224 225 This uses the data of the saved state attached to U{bug #21344<https://web.archive.org/web/https://gna.org/bugs/?21344>}. 226 """ 227 228 # Load the state. 229 statefile = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21344_trunc.bz2' 230 state.load_state(statefile, force=True) 231 232 # Original data (spectrum id: exp_type, frq, omega_rf_ppm, spin_lock_field_strength, time_spin_lock). 233 data = dict() 234 data['118_431.00_0.00'] = ['46_0_35_0', 'R1rho', 799777399.1, 118.078, 431.0, 0.0] 235 data['118_431.00_0.04'] = ['48_0_35_4', 'R1rho', 799777399.1, 118.078, 431.0, 0.04] 236 data['118_431.00_0.10'] = ['47_0_35_10', 'R1rho', 799777399.1, 118.078, 431.0, 0.1] 237 data['118_431.00_0.20'] = ['49_0_35_20', 'R1rho', 799777399.1, 118.078, 431.0, 0.2] 238 data['118_651.20_0.00'] = ['36_0_39_0', 'R1rho', 799777399.1, 118.078, 651.2, 0.0] 239 data['118_651.20_0.04'] = ['39_0_39_4', 'R1rho', 799777399.1, 118.078, 651.2, 0.04] 240 data['118_651.20_0.10'] = ['37_0_39_10', 'R1rho', 799777399.1, 118.078, 651.2, 0.1] 241 data['118_651.20_0.20'] = ['40_0_39_20', 'R1rho', 799777399.1, 118.078, 651.2, 0.2] 242 data['118_651.20_0.40'] = ['38_0_39_40', 'R1rho', 799777399.1, 118.078, 651.2, 0.4] 243 data['118_800.50_0.00'] = ['41_0_41_0', 'R1rho', 799777399.1, 118.078, 800.5, 0.0] 244 data['118_800.50_0.04'] = ['44_0_41_4', 'R1rho', 799777399.1, 118.078, 800.5, 0.04] 245 data['118_800.50_0.10'] = ['42_0_41_10', 'R1rho', 799777399.1, 118.078, 800.5, 0.1] 246 data['118_800.50_0.20'] = ['45_0_41_20', 'R1rho', 799777399.1, 118.078, 800.5, 0.2] 247 data['118_800.50_0.40'] = ['43_0_41_40', 'R1rho', 799777399.1, 118.078, 800.5, 0.4] 248 data['118_984.00_0.00'] = ['31_0_43_0', 'R1rho', 799777399.1, 118.078, 984.0, 0.0] 249 data['118_984.00_0.04'] = ['34_0_43_4', 'R1rho', 799777399.1, 118.078, 984.0, 0.04] 250 data['118_984.00_0.10'] = ['32_0_43_10', 'R1rho', 799777399.1, 118.078, 984.0, 0.1] 251 data['118_984.00_0.20'] = ['35_0_43_20', 'R1rho', 799777399.1, 118.078, 984.0, 0.2] 252 data['118_984.00_0.40'] = ['33_0_43_40', 'R1rho', 799777399.1, 118.078, 984.0, 0.4] 253 data['118_1341.11_0.00'] = ['1_0_46_0', 'R1rho', 799777399.1, 118.078, 1341.11, 0.0] 254 data['118_1341.11_0.04'] = ['4_0_46_4', 'R1rho', 799777399.1, 118.078, 1341.11, 0.04] 255 data['118_1341.11_0.10'] = ['2_0_46_10', 'R1rho', 799777399.1, 118.078, 1341.11, 0.1] 256 data['118_1341.11_0.20'] = ['5_0_46_20', 'R1rho', 799777399.1, 118.078, 1341.11, 0.2] 257 data['118_1341.11_0.40'] = ['3_0_46_40', 'R1rho', 799777399.1, 118.078, 1341.11, 0.4] 258 data['118_1648.50_0.00'] = ['60_0_48_0', 'R1rho', 799777399.1, 118.078, 1648.5, 0.0] 259 data['118_1648.50_0.04'] = ['63_0_48_4', 'R1rho', 799777399.1, 118.078, 1648.5, 0.04] 260 data['118_1648.50_0.10'] = ['61_0_48_10', 'R1rho', 799777399.1, 118.078, 1648.5, 0.1] 261 data['118_1648.50_0.14'] = ['62_0_48_14', 'R1rho', 799777399.1, 118.078, 1648.5, 0.14] 262 data['118_1648.50_0.20'] = ['64_0_48_20', 'R1rho', 799777399.1, 118.078, 1648.5, 0.2] 263 data['124_1341.11_0.00'] = ['11_500_46_0', 'R1rho', 799777399.1, 124.247031462, 1341.11, 0.0] 264 data['124_1341.11_0.04'] = ['14_500_46_4', 'R1rho', 799777399.1, 124.247031462, 1341.11, 0.04] 265 data['124_1341.11_0.10'] = ['12_500_46_10', 'R1rho', 799777399.1, 124.247031462, 1341.11, 0.1] 266 data['124_1341.11_0.20'] = ['15_500_46_20', 'R1rho', 799777399.1, 124.247031462, 1341.11, 0.2] 267 data['124_1341.11_0.40'] = ['13_500_46_40', 'R1rho', 799777399.1, 124.247031462, 1341.11, 0.4] 268 data['130_800.50_0.00'] = ['50_1000_41_0', 'R1rho', 799777399.1, 130.416062924, 800.5, 0.0] 269 data['130_800.50_0.04'] = ['53_1000_41_4', 'R1rho', 799777399.1, 130.416062924, 800.5, 0.04] 270 data['130_800.50_0.10'] = ['51_1000_41_10', 'R1rho', 799777399.1, 130.416062924, 800.5, 0.1] 271 data['130_800.50_0.20'] = ['54_1000_41_20', 'R1rho', 799777399.1, 130.416062924, 800.5, 0.2] 272 data['130_800.50_0.40'] = ['52_1000_41_40', 'R1rho', 799777399.1, 130.416062924, 800.5, 0.4] 273 data['130_1341.11_0.00'] = ['21_1000_46_0', 'R1rho', 799777399.1, 130.416062924, 1341.11, 0.0] 274 data['130_1341.11_0.04'] = ['24_1000_46_4', 'R1rho', 799777399.1, 130.416062924, 1341.11, 0.04] 275 data['130_1341.11_0.10'] = ['22_1000_46_10', 'R1rho', 799777399.1, 130.416062924, 1341.11, 0.1] 276 data['130_1341.11_0.20'] = ['25_1000_46_20', 'R1rho', 799777399.1, 130.416062924, 1341.11, 0.2] 277 data['130_1341.11_0.40'] = ['23_1000_46_40', 'R1rho', 799777399.1, 130.416062924, 1341.11, 0.4] 278 data['130_1648.50_0.00'] = ['65_1000_48_0', 'R1rho', 799777399.1, 130.416062924, 1648.5, 0.0] 279 data['130_1648.50_0.04'] = ['68_1000_48_4', 'R1rho', 799777399.1, 130.416062924, 1648.5, 0.04] 280 data['130_1648.50_0.10'] = ['66_1000_48_10', 'R1rho', 799777399.1, 130.416062924, 1648.5, 0.1] 281 data['130_1648.50_0.14'] = ['67_1000_48_14', 'R1rho', 799777399.1, 130.416062924, 1648.5, 0.14] 282 data['130_1648.50_0.20'] = ['69_1000_48_20', 'R1rho', 799777399.1, 130.416062924, 1648.5, 0.2] 283 data['143_800.50_0.00'] = ['55_2000_41_0', 'R1rho', 799777399.1, 142.754125848, 800.5, 0.0] 284 data['143_800.50_0.04'] = ['58_2000_41_4', 'R1rho', 799777399.1, 142.754125848, 800.5, 0.04] 285 data['143_800.50_0.10'] = ['56_2000_41_10', 'R1rho', 799777399.1, 142.754125848, 800.5, 0.1] 286 data['143_800.50_0.20'] = ['59_2000_41_20', 'R1rho', 799777399.1, 142.754125848, 800.5, 0.2] 287 data['143_800.50_0.40'] = ['57_2000_41_40', 'R1rho', 799777399.1, 142.754125848, 800.5, 0.4] 288 data['143_1341.11_0.00'] = ['6_2000_46_0', 'R1rho', 799777399.1, 142.754125848, 1341.11, 0.0] 289 data['143_1341.11_0.04'] = ['9_2000_46_4', 'R1rho', 799777399.1, 142.754125848, 1341.11, 0.04] 290 data['143_1341.11_0.10'] = ['7_2000_46_10', 'R1rho', 799777399.1, 142.754125848, 1341.11, 0.1] 291 data['143_1341.11_0.20'] = ['10_2000_46_20', 'R1rho', 799777399.1, 142.754125848, 1341.11, 0.2] 292 data['143_1341.11_0.40'] = ['8_2000_46_40', 'R1rho', 799777399.1, 142.754125848, 1341.11, 0.4] 293 data['180_1341.11_0.00'] = ['16_5000_46_0', 'R1rho', 799777399.1, 179.768314621, 1341.11, 0.0] 294 data['180_1341.11_0.04'] = ['19_5000_46_4', 'R1rho', 799777399.1, 179.768314621, 1341.11, 0.04] 295 data['180_1341.11_0.10'] = ['17_5000_46_10', 'R1rho', 799777399.1, 179.768314621, 1341.11, 0.1] 296 data['180_1341.11_0.20'] = ['20_5000_46_20', 'R1rho', 799777399.1, 179.768314621, 1341.11, 0.2] 297 data['180_1341.11_0.40'] = ['18_5000_46_40', 'R1rho', 799777399.1, 179.768314621, 1341.11, 0.4] 298 data['241_1341.11_0.00'] = ['26_10000_46_0', 'R1rho', 799777399.1, 241.458629241, 1341.11, 0.0] 299 data['241_1341.11_0.04'] = ['29_10000_46_4', 'R1rho', 799777399.1, 241.458629241, 1341.11, 0.04] 300 data['241_1341.11_0.10'] = ['27_10000_46_10', 'R1rho', 799777399.1, 241.458629241, 1341.11, 0.1] 301 data['241_1341.11_0.20'] = ['30_10000_46_20', 'R1rho', 799777399.1, 241.458629241, 1341.11, 0.2] 302 data['241_1341.11_0.40'] = ['28_10000_46_40', 'R1rho', 799777399.1, 241.458629241, 1341.11, 0.4] 303 304 # Check the number of time counts. 305 print("Checking the id return experiment.") 306 for id in cdp.exp_type.keys(): 307 exp_type = cdp.exp_type[id] 308 frq = cdp.spectrometer_frq[id] 309 offset = cdp.spin_lock_offset[id] 310 point = cdp.spin_lock_nu1[id] 311 312 # Loop over time 313 for time in loop_time(exp_type=exp_type, frq=frq, offset=offset, point=point): 314 ids = find_intensity_keys(exp_type=exp_type, frq=frq, offset=offset, point=point, time=time) 315 316 print(exp_type, frq, offset, point, time, data["%3.0f_%3.2f_%1.2f"%(offset, point, time)][5], id, ids) 317 318 # Test the id return 319 self.assertEqual(len(ids), 1) 320 # Test the time point 321 self.assertEqual(time, data["%3.0f_%3.2f_%1.2f"%(offset, point, time)][5]) 322 self.assertEqual(ids[0], data["%3.0f_%3.2f_%1.2f"%(offset, point, time)][0])
323 324
325 - def test_get_curve_type_cpmg(self):
326 """Unit test of the get_curve_type() function. 327 328 This uses the data of the saved state attached to U{bug #21665<https://web.archive.org/web/https://gna.org/bugs/?21665>}. 329 """ 330 331 # Load the state. 332 statefile = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21665.bz2' 333 state.load_state(statefile, force=True) 334 335 # Check the return of get_curve_type function. 336 curve_type = get_curve_type() 337 print(curve_type) 338 self.assertEqual(curve_type, 'fixed time')
339 340
341 - def test_get_times_cpmg(self):
342 """Unit test of the get_times() function. 343 344 This uses the data of the saved state attached to U{bug #21665<https://web.archive.org/web/https://gna.org/bugs/?21665>}. 345 """ 346 347 # Load the state. 348 statefile = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21665.bz2' 349 state.load_state(statefile, force=True) 350 351 # Check the return of get_times(). 352 times = get_times() 353 for exp_type in times: 354 print(times[exp_type]) 355 self.assertEqual(len(times[exp_type]), 2)
356 357
359 """Unit test of the has_exponential_exp_type() function. 360 361 This uses the data of the saved state attached to U{bug #21665<https://web.archive.org/web/https://gna.org/bugs/?21665>}. 362 """ 363 364 # Load the state. 365 statefile = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21665.bz2' 366 state.load_state(statefile, force=True) 367 368 # Check the return of has_exponential_exp_type. 369 exponential_exp_type = has_exponential_exp_type() 370 print(exponential_exp_type) 371 self.assertEqual(exponential_exp_type, False)
372 373
374 - def test_loop_exp_frq_cpmg(self):
375 """Unit test of the loop_exp_frq() function. 376 377 This uses the data of the saved state attached to U{bug #21665<https://web.archive.org/web/https://gna.org/bugs/?21665>}. 378 """ 379 380 # Load the state. 381 statefile = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21665.bz2' 382 state.load_state(statefile, force=True) 383 384 # Original data (exp_type, frq). 385 data = [ 386 ['SQ CPMG', 499862140.0], 387 ['SQ CPMG', 599890858.69999993] 388 ] 389 390 # Original indices (ei, mi). 391 indices = [ 392 [0, 0], 393 [0, 1] 394 ] 395 396 # Check the number of iterations. 397 print("Checking the number of iterations of the loop.") 398 count = 0 399 for exp_type, frq, ei, mi in loop_exp_frq(return_indices=True): 400 print(exp_type, frq, ei, mi) 401 count += 1 402 self.assertEqual(count, 2) 403 404 # Check the values. 405 print("Checking the values returned by the loop.") 406 index = 0 407 for exp_type, frq, ei, mi in loop_exp_frq(return_indices=True): 408 # Check the experiment info. 409 self.assertEqual(exp_type, data[index][0]) 410 self.assertEqual(ei, indices[index][0]) 411 412 # Check the frequency info. 413 self.assertEqual(frq, data[index][1]) 414 self.assertEqual(mi, indices[index][1]) 415 416 # Increment the data index. 417 index += 1
418 419
421 """Unit test of the loop_exp_frq_offset() function. 422 423 This uses the data of the saved state attached to U{bug #21665<https://web.archive.org/web/https://gna.org/bugs/?21665>}. 424 """ 425 426 # Load the state. 427 statefile = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21665.bz2' 428 state.load_state(statefile, force=True) 429 430 # Original data (exp_type, frq, offset). 431 data = [ 432 ['SQ CPMG', 499862140.0, 0], 433 ['SQ CPMG', 599890858.69999993, 0] 434 ] 435 436 # Original indices (ei, mi, oi). 437 indices = [ 438 [0, 0, 0], 439 [0, 1, 0] 440 ] 441 442 # Check the number of iterations. 443 print("Checking the number of iterations of the loop.") 444 count = 0 445 for exp_type, frq, offset, ei, mi, oi in loop_exp_frq_offset(return_indices=True): 446 print(exp_type, frq, offset, ei, mi, oi) 447 count += 1 448 self.assertEqual(count, 2) 449 450 # Check the values. 451 print("Checking the values returned by the loop.") 452 index = 0 453 for exp_type, frq, offset, ei, mi, oi in loop_exp_frq_offset(return_indices=True): 454 # Check the experiment info. 455 self.assertEqual(exp_type, data[index][0]) 456 self.assertEqual(ei, indices[index][0]) 457 458 # Check the frequency info. 459 self.assertEqual(frq, data[index][1]) 460 self.assertEqual(mi, indices[index][1]) 461 462 # Check the offset info. 463 self.assertEqual(offset, data[index][2]) 464 self.assertEqual(oi, indices[index][2]) 465 466 # Increment the data index. 467 index += 1
468 469
471 """Unit test of the loop_exp_frq_offset_point() function. 472 473 This uses the data of the saved state attached to U{bug #21665<https://web.archive.org/web/https://gna.org/bugs/?21665>}. 474 """ 475 476 # Load the state. 477 statefile = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21665.bz2' 478 state.load_state(statefile, force=True) 479 480 # Original data (exp_type, frq, offset, point). 481 data = [ 482 ['SQ CPMG', 499862140.0, 0, [50.0, 100.0, 150.0, 200.0, 250.0, 300.0, 350.0, 400.0, 450.0, 500.0, 550.0, 600.0, 650.0, 700.0, 800.0, 900.0, 1000.0]], 483 ['SQ CPMG', 599890858.69999993, 0, [33.3333, 66.666, 100.0, 133.333, 166.666, 200.0, 233.333, 266.666, 300.0, 333.333, 366.666, 400.0, 466.666, 533.333, 666.666, 866.666, 1000.0]] 484 ] 485 486 # Original indices (ei, mi, oi). 487 indices = [ 488 [0, 0, 0, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]], 489 [0, 1, 0, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]] 490 ] 491 492 # Check the number of iterations. 493 print("Checking the number of iterations of the loop.") 494 count = 0 495 for exp_type, frq, offset, point, ei, mi, oi, di in loop_exp_frq_offset_point(return_indices=True): 496 print(exp_type, frq, offset, point, ei, mi, oi, di) 497 count += 1 498 self.assertEqual(count, 34) 499 500 # Check the values. 501 print("Checking the values returned by the loop.") 502 frq_index = 0 503 disp_index = 0 504 for exp_type, frq, offset, point, ei, mi, oi, di in loop_exp_frq_offset_point(return_indices=True): 505 # Check the experiment info. 506 self.assertEqual(exp_type, data[frq_index][0]) 507 self.assertEqual(ei, indices[frq_index][0]) 508 509 # Check the frequency info. 510 self.assertEqual(frq, data[frq_index][1]) 511 self.assertEqual(mi, indices[frq_index][1]) 512 513 # Check the offset info. 514 self.assertEqual(offset, data[frq_index][2]) 515 self.assertEqual(oi, indices[frq_index][2]) 516 517 # Check the dispersion point info. 518 self.assertAlmostEqual(point, data[frq_index][3][disp_index], 2) 519 self.assertEqual(di, indices[frq_index][3][disp_index]) 520 521 # Increment the data index. 522 if disp_index == 16: 523 frq_index += 1 524 disp_index = 0 525 else: 526 disp_index += 1
527 528
530 """Unit test of the loop_exp_frq_offset_point_time() function. 531 532 This uses the data of the saved state attached to U{bug #21665<https://web.archive.org/web/https://gna.org/bugs/?21665>}. 533 """ 534 535 # Load the state. 536 statefile = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21665.bz2' 537 state.load_state(statefile, force=True) 538 539 # Original data (exp_type, frq, offset, point). 540 data = [ 541 ['SQ CPMG', 499862140.0, 0, [50.0, 100.0, 150.0, 200.0, 250.0, 300.0, 350.0, 400.0, 450.0, 500.0, 550.0, 600.0, 650.0, 700.0, 800.0, 900.0, 1000.0], 0.04], 542 ['SQ CPMG', 599890858.69999993, 0, [33.3333, 66.666, 100.0, 133.333, 166.666, 200.0, 233.333, 266.666, 300.0, 333.333, 366.666, 400.0, 466.666, 533.333, 666.666, 866.666, 1000.0], 0.06] 543 ] 544 545 # Original indices (ei, mi, oi). 546 indices = [ 547 [0, 0, 0, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], 0], 548 [0, 1, 0, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], 0] 549 ] 550 551 # Check the number of iterations. 552 print("Checking the number of iterations of the loop.") 553 count = 0 554 for exp_type, frq, offset, point, time, ei, mi, oi, di, ti in loop_exp_frq_offset_point_time(return_indices=True): 555 print(exp_type, frq, offset, point, time, ei, mi, oi, di, ti) 556 count += 1 557 self.assertEqual(count, 34) 558 559 # Check the values. 560 print("Checking the values returned by the loop.") 561 frq_index = 0 562 disp_index = 0 563 for exp_type, frq, offset, point, time, ei, mi, oi, di, ti in loop_exp_frq_offset_point_time(return_indices=True): 564 # Check the experiment info. 565 self.assertEqual(exp_type, data[frq_index][0]) 566 self.assertEqual(ei, indices[frq_index][0]) 567 568 # Check the frequency info. 569 self.assertEqual(frq, data[frq_index][1]) 570 self.assertEqual(mi, indices[frq_index][1]) 571 572 # Check the offset info. 573 self.assertEqual(offset, data[frq_index][2]) 574 self.assertEqual(oi, indices[frq_index][2]) 575 576 # Check the dispersion point info. 577 self.assertAlmostEqual(point, data[frq_index][3][disp_index], 2) 578 self.assertEqual(di, indices[frq_index][3][disp_index]) 579 580 # Check the time point info. 581 self.assertEqual(time, data[frq_index][4]) 582 self.assertEqual(ti, indices[frq_index][4]) 583 584 # Increment the data index. 585 if disp_index == 16: 586 frq_index += 1 587 disp_index = 0 588 else: 589 disp_index += 1
590 591
593 """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().""" 594 595 # Load the state. 596 statefile = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21665.bz2' 597 state.load_state(statefile, force=True) 598 599 # Original data 600 ncyc_1 = [20, 16, 10, 36, 2, 12, 4, 22, 18, 40, 14, 26, 8, 32, 24, 6, 28] 601 sfrq_1 = 499.86214*1E6 602 time_T2_1 = 0.04 603 cpmg_1 = sorted([ncyc/time_T2_1 for ncyc in ncyc_1]) 604 605 ncyc_2 = [28, 4, 32, 60, 2, 10, 16, 8, 20, 52, 18, 40, 6, 12, 24, 14, 22] 606 sfrq_2 = 599.8908587*1E6 607 time_T2_2 = 0.06 608 cpmg_2 = sorted([ncyc/time_T2_2 for ncyc in ncyc_2]) 609 610 # Test the loop function. 611 # First initialize index for the two lists. 612 i = -1 613 j = -1 614 for exp_type, frq, offset, point, time, ei, mi, oi, di, ti in loop_exp_frq_offset_point_time(return_indices=True): 615 if frq == sfrq_1: 616 i += 1 617 self.assertEqual(time, time_T2_1) 618 self.assertAlmostEqual(point, cpmg_1[i], 3) 619 if frq == sfrq_2: 620 j += 1 621 self.assertEqual(time, time_T2_2) 622 self.assertAlmostEqual(point, cpmg_2[j], 3)
623 624
625 - def test_loop_time_cpmg(self):
626 """Unit test of the loop_time() function. 627 628 This uses the data of the saved state attached to U{bug #21665<https://web.archive.org/web/https://gna.org/bugs/?21665>}. 629 """ 630 631 # Load the state. 632 statefile = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21665.bz2' 633 state.load_state(statefile, force=True) 634 635 # Original data (exp_type, frq, offset, point). 636 data = [ 637 ['SQ CPMG', 499862140.0, 0, [50.0, 100.0, 150.0, 200.0, 250.0, 300.0, 350.0, 400.0, 450.0, 500.0, 550.0, 600.0, 650.0, 700.0, 800.0, 900.0, 1000.0], 0.04], 638 ['SQ CPMG', 599890858.69999993, 0, [33.3333, 66.666, 100.0, 133.333, 166.666, 200.0, 233.333, 266.666, 300.0, 333.333, 366.666, 400.0, 466.666, 533.333, 666.666, 866.666, 1000.0], 0.06] 639 ] 640 641 # Original indices (ei, mi, oi, ti). 642 indices = [ 643 [0, 0, 0, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], 0], 644 [0, 1, 0, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], 0] 645 ] 646 647 # Check the number of iterations. 648 print("Checking the number of iterations of the loop.") 649 count_frq = 0 650 for dat in data: 651 frq = dat[1] 652 for time, ti in loop_time(frq=frq, return_indices=True): 653 print(time, ti) 654 count_frq += 1 655 self.assertEqual(count_frq, 2)
656 657
658 - def test_loop_time_r1rho(self):
659 """Unit test of the loop_time() function for R1rho setup. 660 661 This uses the data of the saved state attached to U{bug #21344<https://web.archive.org/web/https://gna.org/bugs/?21344>}. 662 """ 663 664 # Load the state. 665 statefile = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21344_trunc.bz2' 666 state.load_state(statefile, force=True) 667 668 # Offset and point combinations, with their associated time. 669 offset_point_time_list = [ 670 [118.078, 431.0, [0.0, 0.04, 0.1, 0.2]], 671 [118.078, 651.2, [0.0, 0.04, 0.1, 0.2, 0.4]], 672 [118.078, 800.5, [0.0, 0.04, 0.1, 0.2, 0.4]], 673 [118.078, 984.0, [0.0, 0.04, 0.1, 0.2, 0.4]], 674 [118.078, 1341.11, [0.0, 0.04, 0.1, 0.2, 0.4]], 675 [118.078, 1648.5, [0.0, 0.04, 0.1, 0.14, 0.2]], 676 [124.247031462, 1341.11, [0.0, 0.04, 0.1, 0.2, 0.4]], 677 [130.416062924, 800.5, [0.0, 0.04, 0.1, 0.2, 0.4]], 678 [130.416062924, 1341.11, [0.0, 0.04, 0.1, 0.2, 0.4]], 679 [130.416062924, 1648.5, [0.0, 0.04, 0.1, 0.14, 0.2]], 680 [142.754125848, 800.5, [0.0, 0.04, 0.1, 0.2, 0.4]], 681 [142.754125848, 1341.11, [0.0, 0.04, 0.1, 0.2, 0.4]], 682 [179.768314621, 1341.11, [0.0, 0.04, 0.1, 0.2, 0.4]], 683 [241.458629241, 1341.11, [0.0, 0.04, 0.1, 0.2, 0.4]]] 684 685 686 # Check the number of iterations. 687 print("Checking the number of iterations of the loop.") 688 frq = 799777399.1 689 690 for offset, point, time_list in offset_point_time_list: 691 # Define count 692 count = 0 693 for time, ti in loop_time(frq=frq, offset=offset, point=point, return_indices=True): 694 print(frq, offset, point, time, ti, count) 695 self.assertEqual(time, time_list[count]) 696 self.assertEqual(ti, count) 697 count += 1
698 699
700 - def test_return_offset_data(self):
701 """Unit test of the return_offset_data() function for R1rho setup. 702 703 This uses the data of the saved state attached to U{bug #21344<https://web.archive.org/web/https://gna.org/bugs/?21344>}. 704 """ 705 706 # Load the state. 707 statefile = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21344_trunc.bz2' 708 state.load_state(statefile, force=True) 709 710 # Get the field count 711 field_count = cdp.spectrometer_frq_count 712 713 # Get the spin_lock_field points 714 spin_lock_nu1 = return_spin_lock_nu1(ref_flag=False) 715 716 # Initialize data containers 717 all_spin_ids = get_spin_ids() 718 719 # Containers for only selected spins 720 cur_spin_ids = [] 721 cur_spins = [] 722 for curspin_id in all_spin_ids: 723 # Get the spin 724 curspin = return_spin(curspin_id) 725 726 # Check if is selected 727 if curspin.select == True: 728 cur_spin_ids.append(curspin_id) 729 cur_spins.append(curspin) 730 731 # Get the spectometer frequency 732 sfrq = cdp.spectrometer_frq_list[0] 733 734 # Gyromagnetic ratios 735 g1H = 26.7522212 * 1e7 736 g15N = -2.7126 * 1e7 737 738 # The offset and R1 data. 739 chemical_shifts, offsets, tilt_angles, Delta_omega, w_eff = return_offset_data(spins=cur_spins, spin_ids=cur_spin_ids, field_count=field_count, fields=spin_lock_nu1) 740 741 # Loop over the index of spins, then exp_type, frq, offset 742 print("Printing the following") 743 print("exp_type curspin_id frq offset{ppm} offsets[ei][si][mi][oi]{rad/s} ei mi oi si di cur_spin.chemical_shift{ppm} chemical_shifts[ei][si][mi]{rad/s} spin_lock_nu1{Hz} tilt_angles[ei][si][mi][oi]{rad}") 744 for si in range(len(cur_spin_ids)): 745 curspin_id = cur_spin_ids[si] 746 cur_spin = cur_spins[si] 747 for exp_type, frq, offset, ei, mi, oi in loop_exp_frq_offset(return_indices=True): 748 # Loop over the dispersion points. 749 spin_lock_fields = spin_lock_nu1[ei][mi][oi] 750 for di in range(len(spin_lock_fields)): 751 print("%-8s %-10s %11.1f %8.4f %12.5f %i %i %i %i %i %7.3f %12.5f %12.5f %12.5f"%(exp_type, curspin_id, frq, offset, offsets[ei][si][mi][oi], ei, mi, oi, si, di, cur_spin.chemical_shift, chemical_shifts[ei][si][mi], spin_lock_fields[di], tilt_angles[ei][si][mi][oi][di])) 752 # Test chemical shift conversion 753 self.assertEqual(chemical_shifts[ei][si][mi], cur_spin.chemical_shift * 2.0 * pi * sfrq / g1H * g15N * 1e-6) 754 # Test the offset conversion 755 self.assertEqual(offsets[ei][si][mi][oi], offset * 2.0 * pi * sfrq / g1H * g15N * 1e-6) 756 # Test the tiltangle 757 c_omega1 = spin_lock_fields[di] * 2.0 * pi 758 c_Delta_omega = chemical_shifts[ei][si][mi] - offsets[ei][si][mi][oi] 759 if c_omega1 / c_Delta_omega > 0: 760 c_theta = atan(c_omega1 / c_Delta_omega) 761 else: 762 c_theta = pi + atan(c_omega1 / c_Delta_omega) 763 self.assertAlmostEqual(tilt_angles[ei][si][mi][oi][di], c_theta, 15)
764