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