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