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

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

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2014 Troels E. Linnet                                         # 
  4  # Copyright (C) 2014,2019 Edward d'Auvergne                                   # 
  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 copy import deepcopy 
 25   
 26  # relax module imports. 
 27  from lib.dispersion.variables import MODEL_B14, MODEL_B14_FULL, MODEL_CR72, MODEL_CR72_FULL, MODEL_DPL94, MODEL_IT99, MODEL_MMQ_CR72, MODEL_LM63, MODEL_LM63_3SITE, MODEL_MP05, MODEL_NOREX, MODEL_NS_CPMG_2SITE_3D, MODEL_NS_CPMG_2SITE_3D_FULL, MODEL_NS_CPMG_2SITE_EXPANDED, MODEL_NS_CPMG_2SITE_STAR, MODEL_NS_CPMG_2SITE_STAR_FULL, MODEL_NS_MMQ_2SITE, MODEL_NS_MMQ_3SITE, MODEL_NS_MMQ_3SITE_LINEAR, MODEL_NS_R1RHO_2SITE, MODEL_NS_R1RHO_3SITE, MODEL_NS_R1RHO_3SITE_LINEAR, MODEL_R2EFF, MODEL_TAP03, MODEL_TP02, MODEL_TSMFK01 
 28  from lib.dispersion.variables import MODEL_PARAMS_B14_FULL, MODEL_PARAMS_CR72, MODEL_PARAMS_CR72_FULL, MODEL_PARAMS_LM63, MODEL_PARAMS_LM63_3SITE, MODEL_PARAMS_MMQ_CR72, MODEL_PARAMS_MP05, MODEL_PARAMS_NS_MMQ_2SITE, MODEL_PARAMS_NS_MMQ_3SITE, MODEL_PARAMS_NS_MMQ_3SITE_LINEAR, MODEL_PARAMS_NS_R1RHO_2SITE, MODEL_PARAMS_NS_R1RHO_3SITE, MODEL_PARAMS_NS_R1RHO_3SITE_LINEAR, MODEL_PARAMS_TAP03 
 29  from specific_analyses.relax_disp.model import nesting_model, nesting_param, sort_models 
 30  from test_suite.unit_tests.base_classes import UnitTestCase 
 31   
 32   
33 -class Test_model(UnitTestCase):
34 """Unit tests for the functions of the lib.dispersion.variables module.""" 35 36
38 """Unit test of function nesting_model, which determine which model to nest from, testing for CPMG experiments.""" 39 40 ## Test numerical model return. 41 # Define all the models tested in the analysis. 42 self_models = [MODEL_R2EFF, MODEL_NOREX, MODEL_CR72, MODEL_CR72_FULL, MODEL_IT99, MODEL_TSMFK01, MODEL_B14, MODEL_B14_FULL, MODEL_NS_CPMG_2SITE_EXPANDED, MODEL_NS_CPMG_2SITE_3D, MODEL_NS_CPMG_2SITE_3D_FULL, MODEL_NS_CPMG_2SITE_STAR, MODEL_NS_CPMG_2SITE_STAR_FULL] 43 44 # Define which current model is selected 45 model = MODEL_NS_CPMG_2SITE_STAR 46 model_nest = MODEL_NS_CPMG_2SITE_EXPANDED 47 48 print("self.models is:", self_models) 49 print("Current model to analyse is:", model) 50 print("Expected nest model is:", model_nest) 51 52 # Test the return. 53 self.assertEqual(nesting_model(self_models=self_models, model=model)[1].model, model_nest)
54 55
57 """Unit test of function nesting_model, which determine which model to nest from, testing for CPMG experiments.""" 58 59 ## Test numerical full model return. 60 # Define all the models tested in the analysis. 61 self_models = [MODEL_R2EFF, MODEL_NOREX, MODEL_CR72, MODEL_CR72_FULL, MODEL_IT99, MODEL_TSMFK01, MODEL_B14, MODEL_B14_FULL, MODEL_NS_CPMG_2SITE_EXPANDED, MODEL_NS_CPMG_2SITE_3D, MODEL_NS_CPMG_2SITE_3D_FULL, MODEL_NS_CPMG_2SITE_STAR, MODEL_NS_CPMG_2SITE_STAR_FULL] 62 63 # Define which current model is selected 64 model = MODEL_NS_CPMG_2SITE_STAR_FULL 65 model_nest = MODEL_NS_CPMG_2SITE_3D_FULL 66 67 print("self.models is:", self_models) 68 print("Current model to analyse is:", model) 69 print("Expected nest model is:", model_nest) 70 71 # Test the return. 72 self.assertEqual(nesting_model(self_models=self_models, model=model)[1].model, model_nest)
73 74
76 """Unit test of function nesting_model, which determine which model to nest from, testing for CPMG experiments.""" 77 78 ## Test silico simple return from a full model request. 79 # Define all the models tested in the analysis. 80 self_models = [MODEL_R2EFF, MODEL_NOREX, MODEL_NS_CPMG_2SITE_EXPANDED, MODEL_B14_FULL] 81 82 # Define which current model is selected 83 model = MODEL_B14_FULL 84 model_nest = MODEL_NS_CPMG_2SITE_EXPANDED 85 86 print("self.models is:", self_models) 87 print("Current model to analyse is:", model) 88 print("Expected nest model is:", model_nest) 89 90 # Test the return. 91 self.assertEqual(nesting_model(self_models=self_models, model=model)[1].model, model_nest)
92 93
95 """Unit test of function nesting_model, which determine which model to nest from, testing for CPMG experiments.""" 96 97 ## Test LM63 model request. 98 # Define all the models tested in the analysis. 99 self_models = [MODEL_R2EFF, MODEL_NOREX, MODEL_LM63, MODEL_LM63_3SITE] 100 101 # Define which current model is selected 102 model = MODEL_LM63_3SITE 103 model_nest = MODEL_LM63 104 105 print("self.models is:", self_models) 106 print("Current model to analyse is:", model) 107 print("Expected nest model is:", model_nest) 108 109 # Test the return. 110 self.assertEqual(nesting_model(self_models=self_models, model=model)[1].model, model_nest)
111 112
114 """Unit test of function nesting_model, which determine which model to nest from, testing for CPMG experiments.""" 115 116 ## Test MODEL_CR72_FULL model request. 117 # Define all the models tested in the analysis. 118 self_models = [MODEL_R2EFF, MODEL_NOREX, MODEL_CR72, MODEL_CR72_FULL, MODEL_B14, MODEL_B14_FULL] 119 120 # Define which current model is selected 121 model = MODEL_CR72_FULL 122 model_nest = MODEL_CR72 123 124 print("self.models is:", self_models) 125 print("Current model to analyse is:", model) 126 print("Expected nest model is:", model_nest) 127 128 # Test the return. 129 self.assertEqual(nesting_model(self_models=self_models, model=model)[1].model, model_nest)
130 131
133 """Unit test of function nesting_model, which determine which model to nest from, testing for CPMG experiments.""" 134 135 ## Test MODEL_CR72_FULL model request, when models are ordered different. 136 # Define all the models tested in the analysis. 137 self_models = [MODEL_R2EFF, MODEL_NOREX, MODEL_B14, MODEL_B14_FULL, MODEL_CR72, MODEL_CR72_FULL] 138 139 # Define which current model is selected 140 model = MODEL_CR72_FULL 141 model_nest = MODEL_B14_FULL 142 143 print("self.models is:", self_models) 144 print("Current model to analyse is:", model) 145 print("Expected nest model is:", model_nest) 146 147 # Test the return. 148 self.assertEqual(nesting_model(self_models=self_models, model=model)[1].model, model_nest)
149 150
152 """Unit test of function nesting_model, which determine which model to nest from, testing for CPMG experiments.""" 153 154 ## Test MODEL_CR72 model request, when models are LM63. 155 # Define all the models tested in the analysis. 156 self_models = [MODEL_R2EFF, MODEL_NOREX, MODEL_LM63, MODEL_CR72] 157 158 # Define which current model is selected 159 model = MODEL_CR72 160 model_nest = None 161 162 print("self.models is:", self_models) 163 print("Current model to analyse is:", model) 164 print("Expected nest model is:", model_nest) 165 166 # Test the return. 167 self.assertEqual(nesting_model(self_models=self_models, model=model)[1], model_nest)
168 169
171 """Unit test of function nesting_model, which determine which model to nest from, testing for CPMG experiments.""" 172 173 ## Test MODEL_IT99 model request, when models are CR72. 174 # Define all the models tested in the analysis. 175 self_models = [MODEL_R2EFF, MODEL_NOREX, MODEL_CR72, MODEL_IT99] 176 177 # Define which current model is selected 178 model = MODEL_IT99 179 model_nest = None 180 181 print("self.models is:", self_models) 182 print("Current model to analyse is:", model) 183 print("Expected nest model is:", model_nest) 184 185 # Test the return. 186 self.assertEqual(nesting_model(self_models=self_models, model=model)[1], model_nest)
187 188
190 """Unit test of function nesting_model, which determine which model to nest from, testing for CPMG experiments.""" 191 192 ## Test MODEL_CR72 model request, when models are MODEL_IT99. 193 # Define all the models tested in the analysis. 194 self_models = [MODEL_R2EFF, MODEL_NOREX, MODEL_IT99, MODEL_CR72] 195 196 # Define which current model is selected 197 model = MODEL_CR72 198 model_nest = None 199 200 print("self.models is:", self_models) 201 print("Current model to analyse is:", model) 202 print("Expected nest model is:", model_nest) 203 204 # Test the return. 205 self.assertEqual(nesting_model(self_models=self_models, model=model)[1], model_nest)
206 207
209 """Unit test of function nesting_model, which determine which model to nest from, testing for CPMG MMQ experiments.""" 210 211 ## Test MODEL_MMQ_CR72 model request, when models are MODEL_CR72. 212 # Define all the models tested in the analysis. 213 self_models = [MODEL_R2EFF, MODEL_NOREX, MODEL_CR72, MODEL_MMQ_CR72] 214 215 # Define which current model is selected 216 model = MODEL_MMQ_CR72 217 model_nest = None 218 219 print("self.models is:", self_models) 220 print("Current model to analyse is:", model) 221 print("Expected nest model is:", model_nest) 222 223 # Test the return. 224 self.assertEqual(nesting_model(self_models=self_models, model=model)[1], model_nest)
225 226
228 """Unit test of function nesting_model, which determine which model to nest from, testing for CPMG MMQ experiments.""" 229 230 ## Test MODEL_NS_MMQ_3SITE_LINEAR model request, when models are MODEL_NS_MMQ_2SITE. 231 # Define all the models tested in the analysis. 232 self_models = [MODEL_R2EFF, MODEL_NOREX, MODEL_NS_MMQ_2SITE, MODEL_NS_MMQ_3SITE_LINEAR] 233 234 # Define which current model is selected 235 model = MODEL_NS_MMQ_3SITE_LINEAR 236 model_nest = MODEL_NS_MMQ_2SITE 237 238 print("self.models is:", self_models) 239 print("Current model to analyse is:", model) 240 print("Expected nest model is:", model_nest) 241 242 # Test the return. 243 self.assertEqual(nesting_model(self_models=self_models, model=model)[1].model, model_nest)
244 245
247 """Unit test of function nesting_model, which determine which model to nest from, testing for CPMG MMQ experiments.""" 248 249 ## Test MODEL_NS_MMQ_3SITE model request, when models are MODEL_NS_MMQ_3SITE_LINEAR. 250 # Define all the models tested in the analysis. 251 self_models = [MODEL_R2EFF, MODEL_NOREX, MODEL_NS_MMQ_3SITE_LINEAR, MODEL_NS_MMQ_3SITE] 252 253 # Define which current model is selected 254 model = MODEL_NS_MMQ_3SITE 255 model_nest = MODEL_NS_MMQ_3SITE_LINEAR 256 257 print("self.models is:", self_models) 258 print("Current model to analyse is:", model) 259 print("Expected nest model is:", model_nest) 260 261 # Test the return. 262 self.assertEqual(nesting_model(self_models=self_models, model=model)[1].model, model_nest)
263 264
266 """Unit test of function nesting_model, which determine which model to nest from, testing for CPMG MMQ experiments.""" 267 268 ## Test MODEL_NS_MMQ_3SITE model request, when models are MODEL_NS_MMQ_2SITE. 269 # Define all the models tested in the analysis. 270 self_models = [MODEL_R2EFF, MODEL_NOREX, MODEL_NS_MMQ_2SITE, MODEL_NS_MMQ_3SITE] 271 272 # Define which current model is selected 273 model = MODEL_NS_MMQ_3SITE 274 model_nest = MODEL_NS_MMQ_2SITE 275 276 print("self.models is:", self_models) 277 print("Current model to analyse is:", model) 278 print("Expected nest model is:", model_nest) 279 280 # Test the return. 281 self.assertEqual(nesting_model(self_models=self_models, model=model)[1].model, model_nest)
282 283
285 """Unit test of function nesting_model, which determine which model to nest from, testing for numerical R1rho experiments.""" 286 287 ## Test MODEL_NS_R1RHO_3SITE_LINEAR model request, when models are MODEL_NS_R1RHO_2SITE. 288 # Define all the models tested in the analysis. 289 self_models = [MODEL_R2EFF, MODEL_NOREX, MODEL_NS_R1RHO_2SITE, MODEL_NS_R1RHO_3SITE_LINEAR] 290 291 # Define which current model is selected 292 model = MODEL_NS_R1RHO_3SITE_LINEAR 293 model_nest = MODEL_NS_R1RHO_2SITE 294 295 print("self.models is:", self_models) 296 print("Current model to analyse is:", model) 297 print("Expected nest model is:", model_nest) 298 299 # Test the return. 300 self.assertEqual(nesting_model(self_models=self_models, model=model)[1].model, model_nest)
301 302
304 """Unit test of function nesting_model, which determine which model to nest from, testing for numerical R1rho experiments.""" 305 306 ## Test MODEL_NS_R1RHO_3SITE model request, when models are MODEL_NS_R1RHO_3SITE_LINEAR. 307 # Define all the models tested in the analysis. 308 self_models = [MODEL_R2EFF, MODEL_NOREX, MODEL_NS_R1RHO_3SITE_LINEAR, MODEL_NS_R1RHO_3SITE] 309 310 # Define which current model is selected 311 model = MODEL_NS_R1RHO_3SITE 312 model_nest = MODEL_NS_R1RHO_3SITE_LINEAR 313 314 print("self.models is:", self_models) 315 print("Current model to analyse is:", model) 316 print("Expected nest model is:", model_nest) 317 318 # Test the return. 319 self.assertEqual(nesting_model(self_models=self_models, model=model)[1].model, model_nest)
320 321
323 """Unit test of function nesting_model, which determine which model to nest from, testing for numerical R1rho experiments.""" 324 325 ## Test MODEL_NS_R1RHO_3SITE model request, when models are MODEL_NS_R1RHO_2SITE. 326 # Define all the models tested in the analysis. 327 self_models = [MODEL_R2EFF, MODEL_NOREX, MODEL_NS_R1RHO_2SITE, MODEL_NS_R1RHO_3SITE] 328 329 # Define which current model is selected 330 model = MODEL_NS_R1RHO_3SITE 331 model_nest = MODEL_NS_R1RHO_2SITE 332 333 print("self.models is:", self_models) 334 print("Current model to analyse is:", model) 335 print("Expected nest model is:", model_nest) 336 337 # Test the return. 338 self.assertEqual(nesting_model(self_models=self_models, model=model)[1].model, model_nest)
339 340
342 """Unit test of function nesting_model, which determine which model to nest from, testing for R1rho experiments.""" 343 344 ## Test MODEL_MP05 model request, when models are all R1rho models with fitted R1. 345 # Define all the models tested in the analysis. 346 self_models = [MODEL_R2EFF, MODEL_NOREX, MODEL_DPL94, MODEL_TP02, MODEL_TAP03, MODEL_MP05, MODEL_NS_R1RHO_2SITE] 347 348 # Define which current model is selected 349 model = MODEL_MP05 350 model_nest = MODEL_TAP03 351 352 print("self.models is:", self_models) 353 print("Current model to analyse is:", model) 354 print("Expected nest model is:", model_nest) 355 356 # Test the return. 357 self.assertEqual(nesting_model(self_models=self_models, model=model)[1].model, model_nest)
358 359
361 """Unit test of function nesting_model, which determine which model to nest from, testing for R1rho experiments.""" 362 363 ## Test MODEL_TP02 model request, when models are all R1rho models with fitted R1, and MODEL_NS_R1RHO_2SITE was fitted first. 364 # Define all the models tested in the analysis. 365 self_models = [MODEL_R2EFF, MODEL_NOREX, MODEL_NS_R1RHO_2SITE, MODEL_TP02] 366 367 # Define which current model is selected 368 model = MODEL_TP02 369 model_nest = None 370 371 print("self.models is:", self_models) 372 print("Current model to analyse is:", model) 373 print("Expected nest model is:", model_nest) 374 375 # Test the return. 376 self.assertEqual(nesting_model(self_models=self_models, model=model)[1], model_nest)
377 378
380 """Unit test of function nesting_model, which determine which model to nest from, testing for R1rho experiments.""" 381 382 ## Test MODEL_DPL94 model request, when models are all R1rho models with fitted R1, and MODEL_NS_R1RHO_2SITE was fitted first. 383 # Define all the models tested in the analysis. 384 self_models = [MODEL_R2EFF, MODEL_NOREX, MODEL_NS_R1RHO_2SITE, MODEL_DPL94] 385 386 # Define which current model is selected 387 model = MODEL_DPL94 388 model_nest = None 389 390 print("self.models is:", self_models) 391 print("Current model to analyse is:", model) 392 print("Expected nest model is:", model_nest) 393 394 # Test the return. 395 self.assertEqual(nesting_model(self_models=self_models, model=model)[1], model_nest)
396 397
399 """Unit test of function nesting_model, which determine which model to nest from, testing for R1rho experiments.""" 400 401 ## Test MODEL_TP02 model request, when model are all R1rho models with fitted R1, and MODEL_DPL94 was fitted first. 402 # Define all the models tested in the analysis. 403 self_models = [MODEL_R2EFF, MODEL_NOREX, MODEL_DPL94, MODEL_TP02] 404 405 # Define which current model is selected 406 model = MODEL_TP02 407 model_nest = None 408 409 print("self.models is:", self_models) 410 print("Current model to analyse is:", model) 411 print("Expected nest model is:", model_nest) 412 413 # Test the return. 414 self.assertEqual(nesting_model(self_models=self_models, model=model)[1], model_nest)
415 416
417 - def test_nesting_param_1(self):
418 """Unit test of function nesting_param, which determine how model parameters are converted for nesting.""" 419 420 # Define parameters 421 model_params = deepcopy(MODEL_PARAMS_LM63_3SITE) 422 nested_model_params = deepcopy(MODEL_PARAMS_LM63) 423 424 # Get the dictionary of parameter conversion. 425 par_dic = nesting_param(model_params=model_params, nested_model_params=nested_model_params) 426 427 # Test the number of elements in the dictionary. 428 self.assertEqual(len(par_dic), len(model_params)) 429 430 print("model parameters", model_params) 431 print("nested_model_params", nested_model_params) 432 433 # Test content of dictionary. 434 self.assertEqual(par_dic['r2'], 'r2') 435 self.assertEqual(par_dic['phi_ex_B'], 'phi_ex') 436 self.assertEqual(par_dic['phi_ex_C'], 'phi_ex') 437 self.assertEqual(par_dic['kB'], 'kex') 438 self.assertEqual(par_dic['kC'], 'kex')
439 440
441 - def test_nesting_param_2(self):
442 """Unit test of function nesting_param, which determine how model parameters are converted for nesting.""" 443 444 # Define parameters 445 model_params = deepcopy(MODEL_PARAMS_CR72_FULL) 446 nested_model_params = deepcopy(MODEL_PARAMS_CR72) 447 448 # Get the dictionary of parameter conversion. 449 par_dic = nesting_param(model_params=model_params, nested_model_params=nested_model_params) 450 451 # Test the number of elements in the dictionary. 452 self.assertEqual(len(par_dic), len(model_params)) 453 454 print("model parameters", model_params) 455 print("nested_model_params", nested_model_params) 456 457 # Test content of dictionary. 458 self.assertEqual(par_dic['r2a'], 'r2') 459 self.assertEqual(par_dic['r2b'], 'r2') 460 self.assertEqual(par_dic['pA'], 'pA') 461 self.assertEqual(par_dic['dw'], 'dw') 462 self.assertEqual(par_dic['kex'], 'kex')
463 464
465 - def test_nesting_param_3(self):
466 """Unit test of function nesting_param, which determine how model parameters are converted for nesting.""" 467 468 # Define parameters 469 model_params = deepcopy(MODEL_PARAMS_CR72) 470 nested_model_params = deepcopy(MODEL_PARAMS_CR72_FULL) 471 472 # Get the dictionary of parameter conversion. 473 par_dic = nesting_param(model_params=model_params, nested_model_params=nested_model_params) 474 475 # Test the number of elements in the dictionary. 476 self.assertEqual(len(par_dic), len(model_params)) 477 478 print("model parameters", model_params) 479 print("nested_model_params", nested_model_params) 480 481 # Test content of dictionary. 482 self.assertEqual(par_dic['r2'], 'r2a') 483 self.assertEqual(par_dic['pA'], 'pA') 484 self.assertEqual(par_dic['dw'], 'dw') 485 self.assertEqual(par_dic['kex'], 'kex')
486 487
488 - def test_nesting_param_4(self):
489 """Unit test of function nesting_param, which determine how model parameters are converted for nesting.""" 490 491 # Define parameters 492 model_params = deepcopy(MODEL_PARAMS_B14_FULL) 493 nested_model_params = deepcopy(MODEL_PARAMS_CR72_FULL) 494 495 # Get the dictionary of parameter conversion. 496 par_dic = nesting_param(model_params=model_params, nested_model_params=nested_model_params) 497 498 # Test the number of elements in the dictionary. 499 self.assertEqual(len(par_dic), len(model_params)) 500 501 print("model parameters", model_params) 502 print("nested_model_params", nested_model_params) 503 504 # Test content of dictionary. 505 self.assertEqual(par_dic['r2a'], 'r2a') 506 self.assertEqual(par_dic['r2b'], 'r2b') 507 self.assertEqual(par_dic['pA'], 'pA') 508 self.assertEqual(par_dic['dw'], 'dw') 509 self.assertEqual(par_dic['kex'], 'kex')
510 511
512 - def test_nesting_param_5(self):
513 """Unit test of function nesting_param, which determine how model parameters are converted for nesting.""" 514 515 # Define parameters 516 model_params = deepcopy(MODEL_PARAMS_TAP03) 517 nested_model_params = deepcopy(MODEL_PARAMS_MP05) 518 519 # Get the dictionary of parameter conversion. 520 par_dic = nesting_param(model_params=model_params, nested_model_params=nested_model_params) 521 522 # Test the number of elements in the dictionary. 523 self.assertEqual(len(par_dic), len(model_params)) 524 525 print("model parameters", model_params) 526 print("nested_model_params", nested_model_params) 527 528 # Test content of dictionary. 529 self.assertEqual(par_dic['r2'], 'r2') 530 self.assertEqual(par_dic['pA'], 'pA') 531 self.assertEqual(par_dic['dw'], 'dw') 532 self.assertEqual(par_dic['kex'], 'kex')
533 534
535 - def test_nesting_param_6(self):
536 """Unit test of function nesting_param, which determine how model parameters are converted for nesting.""" 537 538 # Define parameters 539 model_params = deepcopy(MODEL_PARAMS_NS_R1RHO_3SITE) 540 nested_model_params = deepcopy(MODEL_PARAMS_NS_R1RHO_3SITE_LINEAR) 541 542 # Get the dictionary of parameter conversion. 543 par_dic = nesting_param(model_params=model_params, nested_model_params=nested_model_params) 544 545 # Test the number of elements in the dictionary. 546 self.assertEqual(len(par_dic), len(model_params)) 547 548 print("model parameters", model_params) 549 print("nested_model_params", nested_model_params) 550 551 # Test content of dictionary. 552 self.assertEqual(par_dic['r2'], 'r2') 553 self.assertEqual(par_dic['pA'], 'pA') 554 self.assertEqual(par_dic['dw_AB'], 'dw_AB') 555 self.assertEqual(par_dic['kex_AB'], 'kex_AB') 556 self.assertEqual(par_dic['pB'], 'pB') 557 self.assertEqual(par_dic['dw_BC'], 'dw_BC') 558 self.assertEqual(par_dic['kex_BC'], 'kex_BC') 559 self.assertEqual(par_dic['kex_AC'], '0.0')
560 561
562 - def test_nesting_param_7(self):
563 """Unit test of function nesting_param, which determine how model parameters are converted for nesting.""" 564 565 # Define parameters 566 model_params = deepcopy(MODEL_PARAMS_NS_R1RHO_3SITE) 567 nested_model_params = deepcopy(MODEL_PARAMS_NS_R1RHO_2SITE) 568 569 # Get the dictionary of parameter conversion. 570 par_dic = nesting_param(model_params=model_params, nested_model_params=nested_model_params) 571 572 # Test the number of elements in the dictionary. 573 self.assertEqual(len(par_dic), len(model_params)) 574 575 print("model parameters", model_params) 576 print("nested_model_params", nested_model_params) 577 578 # Test content of dictionary. 579 self.assertEqual(par_dic['r2'], 'r2') 580 self.assertEqual(par_dic['pA'], 'pA') 581 self.assertEqual(par_dic['dw_AB'], 'dw') 582 self.assertEqual(par_dic['kex_AB'], 'kex') 583 self.assertEqual(par_dic['pB'], '1 - pA') 584 self.assertEqual(par_dic['dw_BC'], 'dw') 585 self.assertEqual(par_dic['kex_BC'], 'kex') 586 self.assertEqual(par_dic['kex_AC'], 'kex')
587 588
589 - def test_nesting_param_8(self):
590 """Unit test of function nesting_param, which determine how model parameters are converted for nesting.""" 591 592 # Define parameters 593 model_params = deepcopy(MODEL_PARAMS_NS_MMQ_2SITE) 594 nested_model_params = deepcopy(MODEL_PARAMS_MMQ_CR72) 595 596 # Get the dictionary of parameter conversion. 597 par_dic = nesting_param(model_params=model_params, nested_model_params=nested_model_params) 598 599 # Test the number of elements in the dictionary. 600 self.assertEqual(len(par_dic), len(model_params)) 601 602 print("model parameters", model_params) 603 print("nested_model_params", nested_model_params) 604 605 # Test content of dictionary. 606 self.assertEqual(par_dic['r2'], 'r2') 607 self.assertEqual(par_dic['pA'], 'pA') 608 self.assertEqual(par_dic['dw'], 'dw') 609 self.assertEqual(par_dic['dwH'], 'dwH') 610 self.assertEqual(par_dic['kex'], 'kex')
611 612
613 - def test_nesting_param_9(self):
614 """Unit test of function nesting_param, which determine how model parameters are converted for nesting.""" 615 616 # Define parameters 617 model_params = deepcopy(MODEL_PARAMS_NS_MMQ_3SITE) 618 nested_model_params = deepcopy(MODEL_PARAMS_NS_MMQ_3SITE_LINEAR) 619 620 # Get the dictionary of parameter conversion. 621 par_dic = nesting_param(model_params=model_params, nested_model_params=nested_model_params) 622 623 # Test the number of elements in the dictionary. 624 self.assertEqual(len(par_dic), len(model_params)) 625 626 print("model parameters", model_params) 627 print("nested_model_params", nested_model_params) 628 629 # Test content of dictionary. 630 self.assertEqual(par_dic['r2'], 'r2') 631 self.assertEqual(par_dic['pA'], 'pA') 632 self.assertEqual(par_dic['dw_AB'], 'dw_AB') 633 self.assertEqual(par_dic['dwH_AB'], 'dwH_AB') 634 self.assertEqual(par_dic['kex_AB'], 'kex_AB') 635 self.assertEqual(par_dic['pB'], 'pB') 636 self.assertEqual(par_dic['dw_BC'], 'dw_BC') 637 self.assertEqual(par_dic['dwH_BC'], 'dwH_BC') 638 self.assertEqual(par_dic['kex_BC'], 'kex_BC') 639 self.assertEqual(par_dic['kex_AC'], '0.0')
640 641
642 - def test_nesting_param_10(self):
643 """Unit test of function nesting_param, which determine how model parameters are converted for nesting.""" 644 645 # Define parameters 646 model_params = deepcopy(MODEL_PARAMS_NS_MMQ_3SITE) 647 nested_model_params = deepcopy(MODEL_PARAMS_NS_MMQ_2SITE) 648 649 # Get the dictionary of parameter conversion. 650 par_dic = nesting_param(model_params=model_params, nested_model_params=nested_model_params) 651 652 # Test the number of elements in the dictionary. 653 self.assertEqual(len(par_dic), len(model_params)) 654 655 print("model parameters", model_params) 656 print("nested_model_params", nested_model_params) 657 658 # Test content of dictionary. 659 self.assertEqual(par_dic['r2'], 'r2') 660 self.assertEqual(par_dic['pA'], 'pA') 661 self.assertEqual(par_dic['dw_AB'], 'dw') 662 self.assertEqual(par_dic['dwH_AB'], 'dwH') 663 self.assertEqual(par_dic['kex_AB'], 'kex') 664 self.assertEqual(par_dic['pB'], '1 - pA') 665 self.assertEqual(par_dic['dw_BC'], 'dw') 666 self.assertEqual(par_dic['dwH_BC'], 'dwH') 667 self.assertEqual(par_dic['kex_BC'], 'kex') 668 self.assertEqual(par_dic['kex_AC'], 'kex')
669 670
671 - def test_sort_models(self):
672 """Unit test of function sort_models, which determine how to sort models for auto analyses.""" 673 674 ## Test sort of models, when models are all R1rho models with fitted R1. 675 # Define all the models tested in the analysis. 676 self_models = [MODEL_R2EFF, MODEL_NOREX, MODEL_DPL94, MODEL_TP02, MODEL_TAP03, MODEL_MP05, MODEL_NS_R1RHO_2SITE] 677 expected_result = [MODEL_R2EFF, MODEL_NOREX, MODEL_MP05, MODEL_TAP03, MODEL_TP02, MODEL_DPL94, MODEL_NS_R1RHO_2SITE] 678 679 # Test the return. 680 self.assertEqual(sort_models(models=self_models), expected_result) 681 682 ## Test sort of models, when models are all CPMG models. 683 # Define all the models tested in the analysis. 684 self_models = [MODEL_R2EFF, MODEL_NOREX, MODEL_CR72, MODEL_CR72_FULL, MODEL_IT99, MODEL_TSMFK01, MODEL_B14, MODEL_B14_FULL, MODEL_NS_CPMG_2SITE_EXPANDED, MODEL_NS_CPMG_2SITE_3D, MODEL_NS_CPMG_2SITE_3D_FULL, MODEL_NS_CPMG_2SITE_STAR, MODEL_NS_CPMG_2SITE_STAR_FULL] 685 expected_result = [MODEL_R2EFF, MODEL_NOREX, MODEL_NS_CPMG_2SITE_EXPANDED, MODEL_B14, MODEL_B14_FULL, MODEL_TSMFK01, MODEL_IT99, MODEL_CR72, MODEL_CR72_FULL, MODEL_NS_CPMG_2SITE_3D, MODEL_NS_CPMG_2SITE_STAR, MODEL_NS_CPMG_2SITE_3D_FULL, MODEL_NS_CPMG_2SITE_STAR_FULL] 686 687 # Test the return. 688 self.assertEqual(sort_models(models=self_models), expected_result) 689 690 ## Test sort of models, when models are all CPMG MMQ models. 691 # Define all the models tested in the analysis. 692 self_models = [MODEL_R2EFF, MODEL_NOREX, MODEL_NS_MMQ_3SITE, MODEL_NS_MMQ_2SITE, MODEL_MMQ_CR72, MODEL_NS_MMQ_3SITE_LINEAR] 693 expected_result = [MODEL_R2EFF, MODEL_NOREX, MODEL_MMQ_CR72, MODEL_NS_MMQ_2SITE, MODEL_NS_MMQ_3SITE_LINEAR, MODEL_NS_MMQ_3SITE] 694 695 # Test the return. 696 self.assertEqual(sort_models(models=self_models), expected_result) 697 698 ## Test sort of models, when models are mix of CPMG and CPMG MMQ models. 699 # Define all the models tested in the analysis. 700 self_models = [MODEL_R2EFF, MODEL_NOREX, MODEL_NS_MMQ_3SITE, MODEL_NS_MMQ_2SITE, MODEL_MMQ_CR72, MODEL_CR72, MODEL_B14, MODEL_NS_MMQ_3SITE_LINEAR] 701 expected_result = [MODEL_R2EFF, MODEL_NOREX, MODEL_B14, MODEL_CR72, MODEL_MMQ_CR72, MODEL_NS_MMQ_2SITE, MODEL_NS_MMQ_3SITE_LINEAR, MODEL_NS_MMQ_3SITE] 702 703 ## Test the return. 704 self.assertEqual(sort_models(models=self_models), expected_result)
705