Package test_suite :: Package unit_tests :: Package _generic_fns :: Module test_mol_res_spin
[hide private]
[frames] | no frames]

Source Code for Module test_suite.unit_tests._generic_fns.test_mol_res_spin

   1  ############################################################################### 
   2  #                                                                             # 
   3  # Copyright (C) 2007-2011 Edward d'Auvergne                                   # 
   4  #                                                                             # 
   5  # This file is part of the program relax.                                     # 
   6  #                                                                             # 
   7  # relax is free software; you can redistribute it and/or modify               # 
   8  # it under the terms of the GNU General Public License as published by        # 
   9  # the Free Software Foundation; either version 2 of the License, or           # 
  10  # (at your option) any later version.                                         # 
  11  #                                                                             # 
  12  # relax is distributed in the hope that it will be useful,                    # 
  13  # but WITHOUT ANY WARRANTY; without even the implied warranty of              # 
  14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               # 
  15  # GNU General Public License for more details.                                # 
  16  #                                                                             # 
  17  # You should have received a copy of the GNU General Public License           # 
  18  # along with relax; if not, write to the Free Software                        # 
  19  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   # 
  20  #                                                                             # 
  21  ############################################################################### 
  22   
  23  # relax module imports. 
  24  from data import Relax_data_store; ds = Relax_data_store() 
  25  from generic_fns import mol_res_spin, pipes 
  26  from generic_fns.reset import reset 
  27  from relax_errors import RelaxError, RelaxNoPipeError 
  28  from test_suite.unit_tests.base_classes import UnitTestCase 
  29   
  30   
31 -class Test_mol_res_spin(UnitTestCase):
32 """Unit tests for the functions of the 'generic_fns.mol_res_spin' module.""" 33
34 - def setUp(self):
35 """Set up some molecules, residues, and spins for testing.""" 36 37 # Add a data pipe to the data store. 38 ds.add(pipe_name='orig', pipe_type='mf') 39 40 # Name the first molecule. 41 cdp.mol[0].name = 'Ap4Aase' 42 43 # Add a second molecule to the system. 44 cdp.mol.add_item(mol_name='RNA') 45 46 # Add two more residues to the first molecule (and set the residue number of the first). 47 cdp.mol[0].res[0].num = 1 48 cdp.mol[0].res.add_item(res_num=2, res_name='Glu') 49 cdp.mol[0].res.add_item(res_num=4, res_name='Pro') 50 51 # Add some spin info to this molecule. 52 cdp.mol[0].res[0].spin[0].name = 'NH' 53 cdp.mol[0].res[0].spin[0].num = 60 54 cdp.mol[0].res[1].spin[0].name = 'NH' 55 cdp.mol[0].res[1].spin[0].num = 63 56 57 # Add one more residue to the second molecule (and set the residue number of the first). 58 cdp.mol[1].res[0].num = -5 59 cdp.mol[1].res.add_item(res_num=-4) 60 61 # Add a second set of spins to the second molecule (naming the first set first). 62 cdp.mol[1].res[0].spin[0].name = 'C8' 63 cdp.mol[1].res[1].spin[0].name = 'C8' 64 cdp.mol[1].res[0].spin.add_item(spin_name='N5') 65 cdp.mol[1].res[1].spin.add_item(spin_name='N5') 66 cdp.mol[1].res[1].spin.add_item(spin_name='2H', spin_num=132) 67 68 # Deselect a number of spins. 69 cdp.mol[0].res[0].spin[0].select = 0 70 cdp.mol[0].res[2].spin[0].select = 0 71 cdp.mol[1].res[0].spin[0].select = 0 72 cdp.mol[1].res[1].spin[1].select = 0
73 74
76 """Test the Selection object for boolean '&' mol-res-spin selections.""" 77 78 # The Selection object. 79 obj = mol_res_spin.Selection("#Ap4Aase:4 & :Pro@Ca") 80 81 # Test the highest level object. 82 self.assertEqual(obj._union, None) 83 self.assertNotEqual(obj._intersect, None) 84 self.assertEqual(obj.molecules, []) 85 self.assertEqual(obj.residues, []) 86 self.assertEqual(obj.spins, []) 87 88 # Test the first intersection. 89 self.assertEqual(obj._intersect[0]._union, None) 90 self.assertEqual(obj._intersect[0]._intersect, None) 91 self.assertEqual(obj._intersect[0].molecules, ['Ap4Aase']) 92 self.assertEqual(obj._intersect[0].residues, [4]) 93 self.assertEqual(obj._intersect[0].spins, []) 94 95 # Test the second intersection. 96 self.assertEqual(obj._intersect[1]._union, None) 97 self.assertEqual(obj._intersect[1]._intersect, None) 98 self.assertEqual(obj._intersect[1].molecules, []) 99 self.assertEqual(obj._intersect[1].residues, ['Pro']) 100 self.assertEqual(obj._intersect[1].spins, ['Ca'])
101 102
103 - def test_Selection_boolean_or(self):
104 """Test the Selection object for boolean '|' mol-res-spin selections.""" 105 106 # The Selection object. 107 obj = mol_res_spin.Selection("#Ap4Aase:Glu | #RNA@C8") 108 109 # Test the highest level object. 110 self.assertNotEqual(obj._union, None) 111 self.assertEqual(obj._intersect, None) 112 self.assertEqual(obj.molecules, []) 113 self.assertEqual(obj.residues, []) 114 self.assertEqual(obj.spins, []) 115 116 # Test the 1st union. 117 self.assertEqual(obj._union[0]._union, None) 118 self.assertEqual(obj._union[0]._intersect, None) 119 self.assertEqual(obj._union[0].molecules, ['Ap4Aase']) 120 self.assertEqual(obj._union[0].residues, ['Glu']) 121 self.assertEqual(obj._union[0].spins, []) 122 123 # Test the 2nd union. 124 self.assertEqual(obj._union[1]._union, None) 125 self.assertEqual(obj._union[1]._intersect, None) 126 self.assertEqual(obj._union[1].molecules, ['RNA']) 127 self.assertEqual(obj._union[1].residues, []) 128 self.assertEqual(obj._union[1].spins, ['C8'])
129 130
132 """Test the Selection object for complex boolean mol-res-spin selections.""" 133 134 # The Selection object. 135 obj = mol_res_spin.Selection("#Ap4Aase:4 & :Pro | #RNA") 136 137 # Test the highest level object. 138 self.assertNotEqual(obj._union, None) 139 self.assertEqual(obj._intersect, None) 140 self.assertEqual(obj.molecules, []) 141 self.assertEqual(obj.residues, []) 142 self.assertEqual(obj.spins, []) 143 144 # Test the 1st union (this should be an intersection). 145 self.assertEqual(obj._union[0]._union, None) 146 self.assertNotEqual(obj._union[0]._intersect, None) 147 self.assertEqual(obj._union[0].molecules, []) 148 self.assertEqual(obj._union[0].residues, []) 149 self.assertEqual(obj._union[0].spins, []) 150 151 # Test the 2nd union. 152 self.assertEqual(obj._union[1]._union, None) 153 self.assertEqual(obj._union[1]._intersect, None) 154 self.assertEqual(obj._union[1].molecules, ['RNA']) 155 self.assertEqual(obj._union[1].residues, []) 156 self.assertEqual(obj._union[1].spins, []) 157 158 # Test the 1st union, 1st intersection. 159 self.assertEqual(obj._union[0]._intersect[0]._union, None) 160 self.assertEqual(obj._union[0]._intersect[0]._intersect, None) 161 self.assertEqual(obj._union[0]._intersect[0].molecules, ['Ap4Aase']) 162 self.assertEqual(obj._union[0]._intersect[0].residues, [4]) 163 self.assertEqual(obj._union[0]._intersect[0].spins, []) 164 165 # Test the 1st union, 2nd intersection. 166 self.assertEqual(obj._union[0]._intersect[1]._union, None) 167 self.assertEqual(obj._union[0]._intersect[1]._intersect, None) 168 self.assertEqual(obj._union[0]._intersect[1].molecules, []) 169 self.assertEqual(obj._union[0]._intersect[1].residues, ['Pro']) 170 self.assertEqual(obj._union[0]._intersect[1].spins, [])
171 172
174 """The Selection object "#Ap4Aase:Glu | #RNA@C8" contains the molecule 'RNA'.""" 175 176 # The Selection object. 177 obj = mol_res_spin.Selection("#Ap4Aase:Glu | #RNA@C8") 178 179 # Check if the molecule is in the selection. 180 self.assert_(obj.contains_mol('RNA'))
181 182
184 """The Selection object "#Ap4Aase:Glu & #RNA@C8" does not contain the molecule 'RNA'.""" 185 186 # The Selection object. 187 obj = mol_res_spin.Selection("#Ap4Aase:Glu & #RNA@C8") 188 189 # Check if the molecule is in the selection. 190 self.assert_(not obj.contains_mol('RNA'))
191 192
194 """The Selection object "#Ap4Aase:Glu | #RNA@C8" does not contain the molecule 'XXX'.""" 195 196 # The Selection object. 197 obj = mol_res_spin.Selection("#Ap4Aase:Glu | #RNA@C8") 198 199 # Check if the molecule is in the selection. 200 self.assert_(not obj.contains_mol('XXX'))
201 202
204 """The Selection object "#Ap4Aase:Glu | #RNA@C8" does not contain the molecule None.""" 205 206 # The Selection object. 207 obj = mol_res_spin.Selection("#Ap4Aase:Glu | #RNA@C8") 208 209 # Check if the molecule is in the selection. 210 self.assert_(not obj.contains_mol())
211 212
214 """The Selection object ":Glu" does contain the molecule None.""" 215 216 # The Selection object. 217 obj = mol_res_spin.Selection(":Glu") 218 219 # Check if the molecule is in the selection. 220 self.assert_(obj.contains_mol())
221 222
224 """The Selection object "#Ap4Aase:Glu | #RNA@C8" contains the molecule 'R*'.""" 225 226 # The Selection object. 227 obj = mol_res_spin.Selection("#Ap4Aase:Glu | #RNA@C8") 228 229 # Check if the molecule is in the selection. 230 self.assert_(obj.contains_mol('R*'))
231 232
234 """The Selection object "#Ap4Aase:Glu | #RNA@C8" contains the molecule '*R*'.""" 235 236 # The Selection object. 237 obj = mol_res_spin.Selection("#Ap4Aase:Glu | #RNA@C8") 238 239 # Check if the molecule is in the selection. 240 self.assert_(obj.contains_mol('*R*'))
241 242
244 """The Selection object "#Ap4Aase:Glu | #RNA@C8" does not contain the res 'Glu' (without the mol name).""" 245 246 # The Selection object. 247 obj = mol_res_spin.Selection("#Ap4Aase:Glu | #RNA@C8") 248 249 # Check if the molecule is in the selection. 250 self.assert_(not obj.contains_res(res_name='Glu'))
251 252
254 """The Selection object "#Ap4Aase:Glu | #RNA@C8" contains the res 'Glu' of the mol 'Ap4Aase'.""" 255 256 # The Selection object. 257 obj = mol_res_spin.Selection("#Ap4Aase:Glu | #RNA@C8") 258 259 # Check if the molecule is in the selection. 260 self.assert_(obj.contains_res(res_name='Glu', mol='Ap4Aase'))
261 262
264 """The Selection object "#Ap4Aase:Glu & #RNA@C8" does not contain the res 'Glu'.""" 265 266 # The Selection object. 267 obj = mol_res_spin.Selection("#Ap4Aase:Glu & #RNA@C8") 268 269 # Check if the molecule is in the selection. 270 self.assert_(not obj.contains_res(res_name='Glu'))
271 272
274 """The Selection object "#Ap4Aase:Glu | #RNA@C8" does not contain the res 'Ala'.""" 275 276 # The Selection object. 277 obj = mol_res_spin.Selection("#Ap4Aase:Glu | #RNA@C8") 278 279 # Check if the molecule is in the selection. 280 self.assert_(not obj.contains_res(res_name='Ala'))
281 282
284 """The Selection object "#Ap4Aase:Glu | #RNA:14@C8" does not contain the res None.""" 285 286 # The Selection object. 287 obj = mol_res_spin.Selection("#Ap4Aase:Glu | #RNA:14@C8") 288 289 # Check if the molecule is in the selection. 290 self.assert_(not obj.contains_res())
291 292
294 """The Selection object "#Ap4Aase" does contains the res None.""" 295 296 # The Selection object. 297 obj = mol_res_spin.Selection("#Ap4Aase") 298 299 # Check if the molecule is in the selection. 300 self.assert_(obj.contains_res(mol='Ap4Aase'))
301 302
304 """The Selection object "#Ap4Aase" does not contain the res None of the mol 'RNA'.""" 305 306 # The Selection object. 307 obj = mol_res_spin.Selection("#Ap4Aase") 308 309 # Check if the molecule is in the selection. 310 self.assert_(not obj.contains_res(mol='RNA'))
311 312
314 """The Selection object "#Ap4Aase:Glu | #RNA@C8" contains the res 'G*' of the mol 'Ap4Aase'.""" 315 316 # The Selection object. 317 obj = mol_res_spin.Selection("#Ap4Aase:Glu | #RNA@C8") 318 319 # Check if the molecule is in the selection. 320 self.assert_(obj.contains_res(res_name='G*', mol='Ap4Aase'))
321 322
324 """The Selection object "#Ap4Aase:Glu | #RNA@C8" contains the res '*G*' of the mol 'Ap4Aase'.""" 325 326 # The Selection object. 327 obj = mol_res_spin.Selection("#Ap4Aase:Glu | #RNA@C8") 328 329 # Check if the molecule is in the selection. 330 self.assert_(obj.contains_res(res_name='*G*', mol='Ap4Aase'))
331 332
334 """The Selection object "#Ap4Aase:Glu | #RNA@C8" does not contain the spin 'C8' (without the mol name).""" 335 336 # The Selection object. 337 obj = mol_res_spin.Selection("#Ap4Aase:Glu | #RNA@C8") 338 339 # Check if the molecule is in the selection. 340 self.assert_(not obj.contains_spin(spin_name='C8'))
341 342
344 """The Selection object "#Ap4Aase:Glu | #RNA@C8" contains the spin 'C8' of the mol 'RNA'.""" 345 346 # The Selection object. 347 obj = mol_res_spin.Selection("#Ap4Aase:Glu | #RNA@C8") 348 349 # Check if the molecule is in the selection. 350 self.assert_(obj.contains_spin(spin_name='C8', mol='RNA'))
351 352
354 """The Selection object "#Ap4Aase:Glu & #RNA@C8" does not contain the spin 'C8'.""" 355 356 # The Selection object. 357 obj = mol_res_spin.Selection("#Ap4Aase:Glu & #RNA@C8") 358 359 # Check if the molecule is in the selection. 360 self.assert_(not obj.contains_spin(spin_name='C8'))
361 362
364 """The Selection object "#Ap4Aase:Glu | #RNA@C8" does not contain the spin 'N3'.""" 365 366 # The Selection object. 367 obj = mol_res_spin.Selection("#Ap4Aase:Glu | #RNA@C8") 368 369 # Check if the molecule is in the selection. 370 self.assert_(not obj.contains_spin(spin_name='N3'))
371 372
374 """The Selection object "#Ap4Aase:Glu | #RNA:14@C8" does not contain the spin None.""" 375 376 # The Selection object. 377 obj = mol_res_spin.Selection("#Ap4Aase:Glu | #RNA:14@C8") 378 379 # Check if the molecule is in the selection. 380 self.assert_(not obj.contains_spin())
381 382
384 """The Selection object "#Ap4Aase" does contains the spin None.""" 385 386 # The Selection object. 387 obj = mol_res_spin.Selection("#Ap4Aase") 388 389 # Check if the molecule is in the selection. 390 self.assert_(obj.contains_spin(mol='Ap4Aase'))
391 392
394 """The Selection object "#Ap4Aase" does not contain the spin None of the mol 'RNA'.""" 395 396 # The Selection object. 397 obj = mol_res_spin.Selection("#Ap4Aase") 398 399 # Check if the molecule is in the selection. 400 self.assert_(not obj.contains_spin(mol='RNA'))
401 402
404 """The Selection object "#Ap4Aase:Glu | #RNA@C8" contains the spin 'C*' of the mol 'RNA'.""" 405 406 # The Selection object. 407 obj = mol_res_spin.Selection("#Ap4Aase:Glu | #RNA@C8") 408 409 # Check if the molecule is in the selection. 410 self.assert_(obj.contains_spin(spin_name='C*', mol='RNA'))
411 412
414 """The Selection object "#Ap4Aase:Glu | #RNA@C8" contains the spin '*C*' of the mol 'RNA'.""" 415 416 # The Selection object. 417 obj = mol_res_spin.Selection("#Ap4Aase:Glu | #RNA@C8") 418 419 # Check if the molecule is in the selection. 420 self.assert_(obj.contains_spin(spin_name='*C*', mol='RNA'))
421 422
424 """Test the Selection object for the single spin identifier '#Ap4Aase:2&:Glu@63&@NH'.""" 425 426 # The Selection object. 427 obj = mol_res_spin.Selection("#Ap4Aase:2&:Glu@63&@NH") 428 429 # Test if various spins are in the selection. 430 self.assert_((cdp.mol[0], cdp.mol[0].res[0], cdp.mol[0].res[0].spin[0]) not in obj) 431 self.assert_((cdp.mol[0], cdp.mol[0].res[1], cdp.mol[0].res[1].spin[0]) in obj) 432 self.assert_((cdp.mol[0], cdp.mol[0].res[2], cdp.mol[0].res[2].spin[0]) not in obj) 433 self.assert_((cdp.mol[1], cdp.mol[1].res[0], cdp.mol[1].res[0].spin[0]) not in obj) 434 self.assert_((cdp.mol[1], cdp.mol[1].res[0], cdp.mol[1].res[0].spin[1]) not in obj) 435 self.assert_((cdp.mol[1], cdp.mol[1].res[1], cdp.mol[1].res[1].spin[0]) not in obj) 436 self.assert_((cdp.mol[1], cdp.mol[1].res[1], cdp.mol[1].res[1].spin[1]) not in obj)
437 438
439 - def test_Selection_memory(self):
440 """Test that the Selection object has no memory of previous selections.""" 441 442 # The original Selection object. 443 obj = mol_res_spin.Selection(":1&:Glu@16&@N") 444 445 # The new Selection object. 446 obj = mol_res_spin.Selection(":13&:Pro") 447 448 # Test the highest level object. 449 self.assertEqual(obj._union, None) 450 self.assertNotEqual(obj._intersect, None) 451 self.assertEqual(obj.molecules, []) 452 self.assertEqual(obj.residues, []) 453 self.assertEqual(obj.spins, []) 454 455 # Test the 1st intersection. 456 self.assertEqual(obj._intersect[0]._union, None) 457 self.assertEqual(obj._intersect[0]._intersect, None) 458 self.assertEqual(obj._intersect[0].molecules, []) 459 self.assertEqual(obj._intersect[0].residues, [13]) 460 self.assertEqual(obj._intersect[0].spins, []) 461 462 # Test the 2nd intersection. 463 self.assertEqual(obj._intersect[1]._union, None) 464 self.assertEqual(obj._intersect[1]._intersect, None) 465 self.assertEqual(obj._intersect[1].molecules, []) 466 self.assertEqual(obj._intersect[1].residues, ['Pro']) 467 self.assertEqual(obj._intersect[1].spins, [])
468 469
470 - def test_count_spins(self):
471 """Test that the number of spins can be properly counted. 472 473 The function tested is generic_fns.mol_res_spin.count_spins(). 474 """ 475 476 # Test the number of spins counted. 477 self.assertEqual(mol_res_spin.count_spins(), 4) 478 self.assertEqual(mol_res_spin.count_spins(skip_desel=False), 8) 479 self.assertEqual(mol_res_spin.count_spins(selection='@N5'), 1) 480 self.assertEqual(mol_res_spin.count_spins(selection='@N5', skip_desel=False), 2)
481 482
483 - def test_count_no_spins(self):
484 """Test that the number of spins (zero) can be properly counted. 485 486 The function tested is generic_fns.mol_res_spin.count_spins(). 487 """ 488 489 # Reset relax. 490 reset() 491 492 # Add a data pipe to the data store. 493 ds.add(pipe_name='orig', pipe_type='mf') 494 495 # Test the number of spins counted. 496 self.assertEqual(mol_res_spin.count_spins(), 0)
497 498
499 - def test_count_spins_no_pipe(self):
500 """Test that the counting of the number of spins raises an error when no pipe exists. 501 502 The function tested is generic_fns.mol_res_spin.count_spins(). 503 """ 504 505 # Reset relax. 506 reset() 507 508 # Test for the error. 509 self.assertRaises(RelaxNoPipeError, mol_res_spin.count_spins)
510 511
513 """Test the function for determining if molecule-residue-spin data exists. 514 515 The function tested is generic_fns.mol_res_spin.exists_mol_res_spin_data(). 516 """ 517 518 # This should be True. 519 self.failUnless(mol_res_spin.exists_mol_res_spin_data())
520 521
523 """Determine if molecule-residue-spin data exists (with data for a single molecule). 524 525 The function tested is generic_fns.mol_res_spin.exists_mol_res_spin_data(). 526 """ 527 528 # Reset relax. 529 reset() 530 531 # Add a data pipe to the data store. 532 ds.add(pipe_name='orig', pipe_type='mf') 533 dp = pipes.get_pipe('orig') 534 535 # Name the first molecule. 536 dp.mol[0].name = 'TOM40' 537 538 # This should be True. 539 self.failUnless(mol_res_spin.exists_mol_res_spin_data())
540 541
543 """Determine if molecule-residue-spin data exists (when a single residue is named). 544 545 The function tested is generic_fns.mol_res_spin.exists_mol_res_spin_data(). 546 """ 547 548 # Reset relax. 549 reset() 550 551 # Add a data pipe to the data store. 552 ds.add(pipe_name='orig', pipe_type='mf') 553 dp = pipes.get_pipe('orig') 554 555 # Name the first residue. 556 dp.mol[0].res[0].name = 'Lys' 557 558 # This should be True. 559 self.failUnless(mol_res_spin.exists_mol_res_spin_data())
560 561
563 """Determine if molecule-residue-spin data exists (when a single residue is numbered). 564 565 The function tested is generic_fns.mol_res_spin.exists_mol_res_spin_data(). 566 """ 567 568 # Reset relax. 569 reset() 570 571 # Add a data pipe to the data store. 572 ds.add(pipe_name='orig', pipe_type='mf') 573 dp = pipes.get_pipe('orig') 574 575 # Number the first residue. 576 dp.mol[0].res[0].num = 1 577 578 # This should be True. 579 self.failUnless(mol_res_spin.exists_mol_res_spin_data())
580 581
583 """Determine if molecule-residue-spin data exists (when a single spin is named). 584 585 The function tested is generic_fns.mol_res_spin.exists_mol_res_spin_data(). 586 """ 587 588 # Reset relax. 589 reset() 590 591 # Add a data pipe to the data store. 592 ds.add(pipe_name='orig', pipe_type='mf') 593 dp = pipes.get_pipe('orig') 594 595 # Name the first spin. 596 dp.mol[0].res[0].spin[0].name = 'NH' 597 598 # This should be True. 599 self.failUnless(mol_res_spin.exists_mol_res_spin_data())
600 601
603 """Determine if molecule-residue-spin data exists (when a single spin is numbered). 604 605 The function tested is generic_fns.mol_res_spin.exists_mol_res_spin_data(). 606 """ 607 608 # Reset relax. 609 reset() 610 611 # Add a data pipe to the data store. 612 ds.add(pipe_name='orig', pipe_type='mf') 613 dp = pipes.get_pipe('orig') 614 615 # Number the first spin. 616 dp.mol[0].res[0].spin[0].num = 234 617 618 # This should be True. 619 self.failUnless(mol_res_spin.exists_mol_res_spin_data())
620 621
623 """Determine if molecule-residue-spin data exists when no data exists. 624 625 The function tested is generic_fns.mol_res_spin.exists_mol_res_spin_data(). 626 """ 627 628 # Reset relax. 629 reset() 630 631 # Add a data pipe to the data store. 632 ds.add(pipe_name='orig', pipe_type='mf') 633 634 # This should be False. 635 self.failIf(mol_res_spin.exists_mol_res_spin_data())
636 637
639 """Determine if molecule-residue-spin data exists when no data pipe exists. 640 641 The function tested is generic_fns.mol_res_spin.exists_mol_res_spin_data(). 642 """ 643 644 # Reset relax. 645 reset() 646 647 # This should fail. 648 self.assertRaises(RelaxNoPipeError, mol_res_spin.exists_mol_res_spin_data)
649 650
652 """First test of the spin ID generation function. 653 654 The function tested is generic_fns.mol_res_spin.generate_spin_id_data_array(). 655 """ 656 657 # The data. 658 data = ['1', 'GLY'] 659 660 # The ID. 661 id = mol_res_spin.generate_spin_id_data_array(data, res_num_col=1, res_name_col=2) 662 663 # Test the string. 664 self.assertEqual(id, ':1&:GLY')
665 666
668 """Second test of the spin ID generation function. 669 670 The function tested is generic_fns.mol_res_spin.generate_spin_id_data_array(). 671 """ 672 673 # The data. 674 data = ['1', 'GLY', '234', 'NH'] 675 676 # The ID. 677 id = mol_res_spin.generate_spin_id_data_array(data, res_num_col=1, res_name_col=2, spin_num_col=3, spin_name_col=4) 678 679 # Test the string. 680 self.assertEqual(id, ':1&:GLY@234&@NH')
681 682
684 """Third test of the spin ID generation function. 685 686 The function tested is generic_fns.mol_res_spin.generate_spin_id_data_array(). 687 """ 688 689 # The data. 690 data = ['Ap4Aase', '234', 'NH'] 691 692 # The ID. 693 id = mol_res_spin.generate_spin_id_data_array(data, mol_name_col=1, res_num_col=None, res_name_col=None, spin_num_col=2, spin_name_col=3) 694 695 # Test the string. 696 self.assertEqual(id, '#Ap4Aase@234&@NH')
697 698
700 """Fourth test of the spin ID generation function. 701 702 The function tested is generic_fns.mol_res_spin.generate_spin_id_data_array(). 703 """ 704 705 # The data. 706 data = ['Ap4Aase', '1', 'GLY'] 707 708 # The ID. 709 id = mol_res_spin.generate_spin_id_data_array(data, mol_name_col=1, res_num_col=2, res_name_col=3) 710 711 # Test the string. 712 self.assertEqual(id, '#Ap4Aase:1&:GLY')
713 714
716 """Fifth test of the spin ID generation function. 717 718 The function tested is generic_fns.mol_res_spin.generate_spin_id_data_array(). 719 """ 720 721 # The data. 722 data = ['Ap4Aase', '1', 'GLY', '234', 'NH'] 723 724 # The ID. 725 id = mol_res_spin.generate_spin_id_data_array(data, mol_name_col=1, res_num_col=2, res_name_col=3, spin_num_col=4, spin_name_col=5) 726 727 # Test the string. 728 self.assertEqual(id, '#Ap4Aase:1&:GLY@234&@NH')
729 730
732 """Sixth test of the spin ID generation function. 733 734 The function tested is generic_fns.mol_res_spin.generate_spin_id_data_array(). 735 """ 736 737 # The data. 738 data = ['1', 'GLY', None, None] 739 740 # The ID. 741 id = mol_res_spin.generate_spin_id_data_array(data, res_num_col=1, res_name_col=2) 742 743 # Test the string. 744 self.assertEqual(id, ':1&:GLY')
745 746
747 - def test_molecule_loop(self):
748 """Test the proper operation of the molecule loop with molecule selection. 749 750 The function tested is generic_fns.mol_res_spin.molecule_loop(). 751 """ 752 753 # Loop over the molecules. 754 for mol in mol_res_spin.molecule_loop('#RNA'): 755 # Test the molecule name. 756 self.assertEqual(mol.name, 'RNA') 757 758 # Test loop length. 759 self.assertEqual(len(list(mol_res_spin.molecule_loop('#RNA'))), 1)
760 761
762 - def test_molecule_loop_no_data(self):
763 """Test the proper operation of the molecule loop when no data is present. 764 765 The function tested is generic_fns.mol_res_spin.molecule_loop(). 766 """ 767 768 # Reset relax. 769 reset() 770 771 # Add a data pipe to the data store. 772 ds.add(pipe_name='orig', pipe_type='mf') 773 774 # Loop over the molecules. 775 i = 0 776 for molecule in mol_res_spin.molecule_loop(): 777 i = i + 1 778 779 # Test loop length. 780 self.assertEqual(i, 0)
781 782
783 - def test_molecule_loop_no_pipe(self):
784 """Test the proper operation of the molecule loop when no data pipe is present. 785 786 The function tested is generic_fns.mol_res_spin.molecule_loop(). 787 """ 788 789 # Reset relax. 790 reset() 791 792 # Function for the problem of catching an error in a generator function. 793 def fail_test(): 794 for molecule in mol_res_spin.molecule_loop(): 795 pass
796 797 # Test for the no pipe error. 798 self.assertRaises(RelaxNoPipeError, fail_test)
799 800
801 - def test_molecule_loop_no_selection(self):
802 """Test the proper operation of the molecule loop when no selection is present. 803 804 The function tested is generic_fns.mol_res_spin.molecule_loop(). 805 """ 806 807 # Molecule data. 808 name = ['Ap4Aase', 'RNA'] 809 810 # Loop over the molecules. 811 i = 0 812 for mol in mol_res_spin.molecule_loop(): 813 # Test the molecule names. 814 self.assertEqual(mol.name, name[i]) 815 816 # Increment i. 817 i = i + 1 818 819 # Test loop length. 820 self.assertEqual(len(list(mol_res_spin.molecule_loop())), 2)
821 822 823
824 - def test_parse_token_single_element_num(self):
825 """Test the generic_fns.mol_res_spin.parse_token() function on the string '1'.""" 826 827 # Parse the token. 828 list = mol_res_spin.parse_token('1') 829 830 # Check the list elements. 831 self.assertEqual(len(list), 1) 832 self.assertEqual(list[0], 1)
833 834
835 - def test_parse_token_single_element_neg_num(self):
836 """Test the generic_fns.mol_res_spin.parse_token() function on the string '-4'.""" 837 838 # Parse the token. 839 list = mol_res_spin.parse_token('-4') 840 841 # Check the list elements. 842 self.assertEqual(len(list), 1) 843 self.assertEqual(list[0], -4)
844 845
846 - def test_parse_token_single_element_name(self):
847 """Test the generic_fns.mol_res_spin.parse_token() function on the string 'G'.""" 848 849 # Parse the token. 850 list = mol_res_spin.parse_token('G') 851 852 # Check the list elements. 853 self.assertEqual(len(list), 1) 854 self.assertEqual(list[0], 'G')
855 856
857 - def test_parse_token_single_element_wildcard_name(self):
858 """Test the generic_fns.mol_res_spin.parse_token() function on the string 'N*'.""" 859 860 # Parse the token. 861 list = mol_res_spin.parse_token('N*') 862 863 # Check the list elements. 864 self.assertEqual(len(list), 1) 865 self.assertEqual(list[0], 'N*')
866 867
868 - def test_parse_token_single_element_range(self):
869 """Test the generic_fns.mol_res_spin.parse_token() function on the string '1-10'.""" 870 871 # Parse the token. 872 list = mol_res_spin.parse_token('1-10') 873 874 # Check the list elements. 875 self.assertEqual(len(list), 10) 876 for i in range(1, 11): 877 self.assertEqual(list[i-1], i)
878 879
880 - def test_parse_token_single_element_neg_range(self):
881 """Test the generic_fns.mol_res_spin.parse_token() function on the string '-10--1'.""" 882 883 # Parse the token. 884 list = mol_res_spin.parse_token('-10--1') 885 886 # Check the list elements. 887 self.assertEqual(len(list), 10) 888 j = 0 889 for i in range(-10, -2): 890 self.assertEqual(list[j], i) 891 j = j + 1
892 893
894 - def test_parse_token_multi_element_num(self):
895 """Test the generic_fns.mol_res_spin.parse_token() function on the string '-2, 1'.""" 896 897 # Parse the token. 898 list = mol_res_spin.parse_token('-2, 1') 899 900 # Check the list elements. 901 self.assertEqual(len(list), 2) 902 self.assertEqual(list[0], -2) 903 self.assertEqual(list[1], 1)
904 905
906 - def test_parse_token_multi_element_name(self):
907 """Test the generic_fns.mol_res_spin.parse_token() function on the string 'N,CA'.""" 908 909 # Parse the token. 910 list = mol_res_spin.parse_token('N,CA') 911 912 # Check the list elements. 913 self.assertEqual(len(list), 2) 914 self.assertEqual(list[0], 'CA') 915 self.assertEqual(list[1], 'N')
916 917
918 - def test_parse_token_multi_element_num_name(self):
919 """Test the generic_fns.mol_res_spin.parse_token() function on the string '76,Ala'.""" 920 921 # Parse the token. 922 list = mol_res_spin.parse_token('76,Ala') 923 924 # Check the list elements. 925 self.assertEqual(len(list), 2) 926 self.assertEqual(list[0], 76) 927 self.assertEqual(list[1], 'Ala')
928 929
930 - def test_parse_token_multi_element_num_range(self):
931 """Test the generic_fns.mol_res_spin.parse_token() function on the string '1,3-5'.""" 932 933 # Parse the token. 934 list = mol_res_spin.parse_token('1,3-5') 935 936 # Check the list elements. 937 self.assertEqual(len(list), 4) 938 self.assertEqual(list[0], 1) 939 self.assertEqual(list[1], 3) 940 self.assertEqual(list[2], 4) 941 self.assertEqual(list[3], 5)
942 943
944 - def test_parse_token_multi_element_range_name(self):
945 """Test the generic_fns.mol_res_spin.parse_token() function on the string '3-5,NH'.""" 946 947 # Parse the token. 948 list = mol_res_spin.parse_token('3-5,NH') 949 950 # Check the list elements. 951 self.assertEqual(len(list), 4) 952 self.assertEqual(list[0], 3) 953 self.assertEqual(list[1], 4) 954 self.assertEqual(list[2], 5) 955 self.assertEqual(list[3], 'NH')
956 957
958 - def test_parse_token_multi_element_range_num_name(self):
959 """Test the generic_fns.mol_res_spin.parse_token() function on the string '3-6, 8, Gly'.""" 960 961 # Parse the token. 962 list = mol_res_spin.parse_token('3-6, 8, Gly') 963 964 # Check the list elements. 965 self.assertEqual(len(list), 6) 966 self.assertEqual(list[0], 3) 967 self.assertEqual(list[1], 4) 968 self.assertEqual(list[2], 5) 969 self.assertEqual(list[3], 6) 970 self.assertEqual(list[4], 8) 971 self.assertEqual(list[5], 'Gly')
972 973
974 - def test_residue_loop(self):
975 """Test the proper operation of the residue loop with residue selection. 976 977 The function tested is generic_fns.mol_res_spin.residue_loop(). 978 """ 979 980 # Loop over the residues. 981 for res in mol_res_spin.residue_loop('#Ap4Aase:Glu'): 982 # Test the selection. 983 self.assertEqual(res.num, 2) 984 985 # Test loop length. 986 self.assertEqual(len(list(mol_res_spin.residue_loop('#Ap4Aase:Glu'))), 1)
987 988
989 - def test_residue_loop_no_data(self):
990 """Test the proper operation of the residue loop when no data is present. 991 992 The function tested is generic_fns.mol_res_spin.residue_loop(). 993 """ 994 995 # Reset relax. 996 reset() 997 998 # Add a data pipe to the data store. 999 ds.add(pipe_name='orig', pipe_type='mf') 1000 1001 # Loop over the residues. 1002 i = 0 1003 for residue in mol_res_spin.residue_loop(): 1004 i = i + 1 1005 1006 # Test loop length. 1007 self.assertEqual(i, 0)
1008 1009
1010 - def test_residue_loop_no_pipe(self):
1011 """Test the proper operation of the residue loop when no data pipe is present. 1012 1013 The function tested is generic_fns.mol_res_spin.residue_loop(). 1014 """ 1015 1016 # Reset relax. 1017 reset() 1018 1019 # Function for the problem of catching an error in a generator function. 1020 def fail_test(): 1021 for residue in mol_res_spin.residue_loop(): 1022 pass
1023 1024 # Test for the no pipe error. 1025 self.assertRaises(RelaxNoPipeError, fail_test) 1026 1027
1028 - def test_residue_loop_no_selection(self):
1029 """Test the proper operation of the residue loop when no selection is present. 1030 1031 The function tested is generic_fns.mol_res_spin.residue_loop(). 1032 """ 1033 1034 # Spin data. 1035 num = [1, 2, 4, -5, -4] 1036 name = [None, 'Glu', 'Pro', None, None] 1037 1038 # Loop over the residues. 1039 i = 0 1040 for res in mol_res_spin.residue_loop(): 1041 # Test the residue numbers. 1042 self.assertEqual(res.num, num[i]) 1043 1044 # Test the residue names. 1045 self.assertEqual(res.name, name[i]) 1046 1047 # Increment i. 1048 i = i + 1 1049 1050 # Test loop length. 1051 self.assertEqual(i, 5)
1052 1053
1054 - def test_return_molecule(self):
1055 """Test the function for returning the desired molecule data container. 1056 1057 The function tested is generic_fns.mol_res_spin.return_molecule(). 1058 """ 1059 1060 # Ask for a few molecules. 1061 mol1 = mol_res_spin.return_molecule('#Ap4Aase') 1062 mol2 = mol_res_spin.return_molecule(selection='#RNA', pipe='orig') 1063 1064 # Test the data of molecule 1. 1065 self.assertEqual(mol1.name, 'Ap4Aase') 1066 1067 # Test the data of molecule 2. 1068 self.assertEqual(mol2.name, 'RNA')
1069 1070
1071 - def test_return_molecule_pipe_fail(self):
1072 """Test the failure of the function for returning the desired molecule data container. 1073 1074 The function tested is generic_fns.mol_res_spin.return_molecule(). 1075 """ 1076 1077 # Try to get a molecule from a missing data pipe. 1078 self.assertRaises(RelaxNoPipeError, mol_res_spin.return_molecule, selection='#Ap4Aase', pipe='new') 1079 self.assertRaises(RelaxNoPipeError, mol_res_spin.return_molecule, selection='#RNA', pipe='new')
1080 1081
1082 - def test_return_residue(self):
1083 """Test the function for returning the desired residue data container. 1084 1085 The function tested is generic_fns.mol_res_spin.return_residue(). 1086 """ 1087 1088 # Ask for a few residues. 1089 res1 = mol_res_spin.return_residue(':1') 1090 res2 = mol_res_spin.return_residue(selection=':2') 1091 res4 = mol_res_spin.return_residue(selection=':4', pipe='orig') 1092 res5 = mol_res_spin.return_residue(selection='#RNA:-5', pipe='orig') 1093 1094 # Test the data of residue 1. 1095 self.assertEqual(res1.num, 1) 1096 self.assertEqual(res1.name, None) 1097 1098 # Test the data of residue 2. 1099 self.assertEqual(res2.num, 2) 1100 self.assertEqual(res2.name, 'Glu') 1101 1102 # Test the data of residue 4. 1103 self.assertEqual(res4.num, 4) 1104 self.assertEqual(res4.name, 'Pro') 1105 1106 # Test the data of the RNA residue -5. 1107 self.assertEqual(res5.num, -5) 1108 self.assertEqual(res5.name, None) 1109 self.assertEqual(res5.spin[1].name, 'N5')
1110 1111
1112 - def test_return_residue_pipe_fail(self):
1113 """Test the failure of the function for returning the desired residue data container. 1114 1115 The function tested is generic_fns.mol_res_spin.return_residue(). 1116 """ 1117 1118 # Try to get a residue from a missing data pipe. 1119 self.assertRaises(RelaxNoPipeError, mol_res_spin.return_residue, selection=':2', pipe='new')
1120 1121
1122 - def test_return_single_residue_info(self):
1123 """Test the function for returning the desired residue data container. 1124 1125 The function tested is generic_fns.mol_res_spin.return_single_residue_info(). 1126 """ 1127 1128 # Ask for a few residues. 1129 res1 = mol_res_spin.return_single_residue_info('1') 1130 res2 = mol_res_spin.return_single_residue_info('2,Glu') 1131 res4 = mol_res_spin.return_single_residue_info('Pro,4') 1132 res5 = mol_res_spin.return_single_residue_info('-5') 1133 1134 # Test the data of residue 1. 1135 self.assertEqual(res1, (1, None)) 1136 1137 # Test the data of residue 2. 1138 self.assertEqual(res2, (2, 'Glu')) 1139 1140 # Test the data of residue 4. 1141 self.assertEqual(res4, (4, 'Pro')) 1142 1143 # Test the data of the RNA residue -5. 1144 self.assertEqual(res5, (-5, None))
1145 1146
1147 - def test_return_single_residue_info_fail(self):
1148 """Test the failure of the function for returning the desired residue data container. 1149 1150 The function tested is generic_fns.mol_res_spin.return_single_residue_info(). 1151 """ 1152 1153 # Ask for a few residues. 1154 self.assertRaises(RelaxError, mol_res_spin.return_single_residue_info, '1,2') 1155 self.assertRaises(RelaxError, mol_res_spin.return_single_residue_info, '1,Glu,Pro') 1156 self.assertRaises(RelaxError, mol_res_spin.return_single_residue_info, '1,2,Glu,Pro')
1157 1158
1159 - def test_return_spin(self):
1160 """Test the function for returning the desired spin data container. 1161 1162 The function tested is generic_fns.mol_res_spin.return_spin(). 1163 """ 1164 1165 # Ask for a few spins. 1166 spin1 = mol_res_spin.return_spin(':1') 1167 spin2 = mol_res_spin.return_spin(selection=':2&:Glu') 1168 spin3 = mol_res_spin.return_spin(selection=':4&:Pro', pipe='orig') 1169 spin4 = mol_res_spin.return_spin(selection='#RNA:-5@N5', pipe='orig') 1170 spin5 = mol_res_spin.return_spin(selection=':-4@2H', pipe='orig') 1171 1172 # Test the data of spin 1. 1173 self.assertNotEqual(spin1, None) 1174 self.assertEqual(spin1.num, 60) 1175 self.assertEqual(spin1.name, 'NH') 1176 1177 # Test the data of spin 2. 1178 self.assertNotEqual(spin2, None) 1179 self.assertEqual(spin2.num, 63) 1180 self.assertEqual(spin2.name, 'NH') 1181 1182 # Test the data of spin 3. 1183 self.assertNotEqual(spin3, None) 1184 self.assertEqual(spin3.num, None) 1185 self.assertEqual(spin3.name, None) 1186 1187 # Test the data of the RNA res -5, spin N5. 1188 self.assertNotEqual(spin4, None) 1189 self.assertEqual(spin4.num, None) 1190 self.assertEqual(spin4.name, 'N5') 1191 1192 # Test the data of the RNA res -4, spin 2H. 1193 self.assertNotEqual(spin5, None) 1194 self.assertEqual(spin5.num, 132) 1195 self.assertEqual(spin5.name, '2H')
1196 1197
1198 - def test_return_spin_pipe_fail(self):
1199 """Test the failure of the function for returning the desired spin data container. 1200 1201 The function tested is generic_fns.mol_res_spin.return_spin(). 1202 """ 1203 1204 # Try to get a spin from a missing data pipe. 1205 self.assertRaises(RelaxNoPipeError, mol_res_spin.return_spin, selection=':2', pipe='new')
1206 1207
1208 - def test_spin_loop(self):
1209 """Test the proper operation of the spin loop with spin selection. 1210 1211 The function tested is generic_fns.mol_res_spin.spin_loop(). 1212 """ 1213 1214 # Spin data. 1215 select = [1, 0] 1216 1217 # Loop over the spins. 1218 i = 0 1219 for spin in mol_res_spin.spin_loop('@N5'): 1220 # Test the selection. 1221 self.assertEqual(spin.select, select[i]) 1222 1223 # Test the spin names. 1224 self.assertEqual(spin.name, 'N5') 1225 1226 # Increment i. 1227 i = i + 1 1228 1229 # Test loop length. 1230 self.assertEqual(i, 2)
1231 1232
1233 - def test_spin_loop_boolean_or(self):
1234 """Test the operation of the spin loop with the selection "#Ap4Aase:Glu | #RNA@C8". 1235 1236 The function tested is generic_fns.mol_res_spin.spin_loop(). 1237 """ 1238 1239 # Selection, and spin name and number. 1240 select = [1, 0, 1] 1241 name = ['NH', 'C8', 'C8'] 1242 num = [63, None, None] 1243 1244 # Loop over the spins. 1245 i = 0 1246 for spin in mol_res_spin.spin_loop("#Ap4Aase:Glu | #RNA@C8"): 1247 # Test the spin. 1248 self.assertEqual([spin.select, spin.name, spin.num], [select[i], name[i], num[i]]) 1249 1250 # Increment i. 1251 i = i + 1 1252 1253 # Test loop length. 1254 self.assertEqual(i, 3)
1255 1256
1257 - def test_spin_loop_multiatom(self):
1258 """Test the proper operation of the spin loop with spin selection '@NH|@N5'. 1259 1260 The function tested is generic_fns.mol_res_spin.spin_loop(). 1261 """ 1262 1263 # Spin data. 1264 select = [0, 1, 1, 0] 1265 name = ['NH', 'NH', 'N5', 'N5'] 1266 1267 # Loop over the spins. 1268 i = 0 1269 for spin in mol_res_spin.spin_loop('@NH|@N5'): 1270 # Test the selection. 1271 self.assertEqual(spin.select, select[i]) 1272 1273 # Test the spin names. 1274 self.assertEqual(spin.name, name[i]) 1275 1276 # Increment i. 1277 i = i + 1 1278 1279 # Test loop length. 1280 self.assertEqual(i, 4)
1281 1282
1283 - def test_spin_loop_no_data(self):
1284 """Test the proper operation of the spin loop when no data is present. 1285 1286 The function tested is generic_fns.mol_res_spin.spin_loop(). 1287 """ 1288 1289 # Reset relax. 1290 reset() 1291 1292 # Add a data pipe to the data store. 1293 ds.add(pipe_name='orig', pipe_type='mf') 1294 1295 # Loop over the spins. 1296 i = 0 1297 for spin in mol_res_spin.spin_loop(): 1298 i = i + 1 1299 1300 # Test loop length. 1301 self.assertEqual(i, 0)
1302 1303
1304 - def test_spin_loop_no_pipe(self):
1305 """Test the proper operation of the spin loop when no data pipe is present. 1306 1307 The function tested is generic_fns.mol_res_spin.spin_loop(). 1308 """ 1309 1310 # Reset relax. 1311 reset() 1312 1313 # Function for the problem of catching an error in a generator function. 1314 def fail_test(): 1315 for spin in mol_res_spin.spin_loop(): 1316 pass
1317 1318 # Test for the no pipe error. 1319 self.assertRaises(RelaxNoPipeError, fail_test) 1320 1321
1322 - def test_spin_loop_no_selection(self):
1323 """Test the proper operation of the spin loop when no selection is present. 1324 1325 The function tested is generic_fns.mol_res_spin.spin_loop(). 1326 """ 1327 1328 # Spin data. 1329 select = [0, 1, 0, 0, 1, 1, 0, 1] 1330 name = ['NH', 'NH', None, 'C8', 'N5', 'C8', 'N5', '2H'] 1331 1332 # Loop over the spins. 1333 i = 0 1334 for spin in mol_res_spin.spin_loop(): 1335 # Test the selection. 1336 self.assertEqual(spin.select, select[i]) 1337 1338 # Test the spin names. 1339 self.assertEqual(spin.name, name[i]) 1340 1341 # Increment i. 1342 i = i + 1 1343 1344 # Test loop length. 1345 self.assertEqual(i, 8)
1346 1347
1348 - def test_spin_loop_single_spin(self):
1349 """Test the operation of the spin loop with the single spin selection '#Ap4Aase:Glu@63'. 1350 1351 The function tested is generic_fns.mol_res_spin.spin_loop(). 1352 """ 1353 1354 # Loop over the spins. 1355 i = 0 1356 for spin in mol_res_spin.spin_loop('#Ap4Aase:Glu@63'): 1357 # Test the selection. 1358 self.assertEqual(spin.select, 1) 1359 1360 # Test the spin name. 1361 self.assertEqual(spin.name, 'NH') 1362 1363 # Test the spin number. 1364 self.assertEqual(spin.num, 63) 1365 1366 # Increment i. 1367 i = i + 1 1368 1369 # Test loop length. 1370 self.assertEqual(i, 1)
1371 1372
1373 - def test_spin_loop_wildcard(self):
1374 """Test the proper operation of the spin loop with wildcard spin selection '@N*'. 1375 1376 The function tested is generic_fns.mol_res_spin.spin_loop(). 1377 """ 1378 1379 # Spin data. 1380 select = [0, 1, 1, 0] 1381 name = ['NH', 'NH', 'N5', 'N5'] 1382 1383 # Loop over the spins. 1384 i = 0 1385 for spin in mol_res_spin.spin_loop('@N*'): 1386 # Test the selection. 1387 self.assertEqual(spin.select, select[i]) 1388 1389 # Test the spin names. 1390 self.assertEqual(spin.name, name[i]) 1391 1392 # Increment i. 1393 i = i + 1 1394 1395 # Test loop length. 1396 self.assertEqual(i, 4)
1397 1398
1399 - def test_tokenise1(self):
1400 """Test the generic_fns.mol_res_spin.tokenise() function on the string '@1'.""" 1401 1402 # Tokenise. 1403 mol_token, res_token, spin_token = mol_res_spin.tokenise('@1') 1404 1405 # Check the tokens. 1406 self.assertEqual(mol_token, None) 1407 self.assertEqual(res_token, None) 1408 self.assertEqual(spin_token, '1')
1409 1410
1411 - def test_tokenise2(self):
1412 """Test the generic_fns.mol_res_spin.tokenise() function on the string ':-4'.""" 1413 1414 # Tokenise. 1415 mol_token, res_token, spin_token = mol_res_spin.tokenise(':-4') 1416 1417 # Check the tokens. 1418 self.assertEqual(mol_token, None) 1419 self.assertEqual(res_token, '-4') 1420 self.assertEqual(spin_token, None)
1421 1422
1423 - def test_tokenise3(self):
1424 """Test the generic_fns.mol_res_spin.tokenise() function on the string '#CaM'.""" 1425 1426 # Tokenise. 1427 mol_token, res_token, spin_token = mol_res_spin.tokenise('#CaM') 1428 1429 # Check the tokens. 1430 self.assertEqual(mol_token, 'CaM') 1431 self.assertEqual(res_token, None) 1432 self.assertEqual(spin_token, None)
1433 1434
1435 - def test_tokenise4(self):
1436 """Test the generic_fns.mol_res_spin.tokenise() function on the string ':G@N3'.""" 1437 1438 # Tokenise. 1439 mol_token, res_token, spin_token = mol_res_spin.tokenise(':G@N3') 1440 1441 # Check the tokens. 1442 self.assertEqual(mol_token, None) 1443 self.assertEqual(res_token, 'G') 1444 self.assertEqual(spin_token, 'N3')
1445 1446
1447 - def test_tokenise5(self):
1448 """Test the generic_fns.mol_res_spin.tokenise() function on the string '#OMP@NH'.""" 1449 1450 # Tokenise. 1451 mol_token, res_token, spin_token = mol_res_spin.tokenise('#OMP@NH') 1452 1453 # Check the tokens. 1454 self.assertEqual(mol_token, 'OMP') 1455 self.assertEqual(res_token, None) 1456 self.assertEqual(spin_token, 'NH')
1457 1458
1459 - def test_tokenise6(self):
1460 """Test the generic_fns.mol_res_spin.tokenise() function on the string '#Lyso:20-50'.""" 1461 1462 # Tokenise. 1463 mol_token, res_token, spin_token = mol_res_spin.tokenise('#Lyso:20-50') 1464 1465 # Check the tokens. 1466 self.assertEqual(mol_token, 'Lyso') 1467 self.assertEqual(res_token, '20-50') 1468 self.assertEqual(spin_token, None)
1469 1470
1471 - def test_tokenise7(self):
1472 """Test the generic_fns.mol_res_spin.tokenise() function on the string '#Ap4Aase:*@N,CA'.""" 1473 1474 # Tokenise. 1475 mol_token, res_token, spin_token = mol_res_spin.tokenise('#Ap4Aase:*@N,CA') 1476 1477 # Check the tokens. 1478 self.assertEqual(mol_token, 'Ap4Aase') 1479 self.assertEqual(res_token, '*') 1480 self.assertEqual(spin_token, 'N,CA')
1481 1482
1483 - def test_tokenise8(self):
1484 """Test the generic_fns.mol_res_spin.tokenise() function on the string '@N*'.""" 1485 1486 # Tokenise. 1487 mol_token, res_token, spin_token = mol_res_spin.tokenise('@N*') 1488 1489 # Check the tokens. 1490 self.assertEqual(mol_token, None) 1491 self.assertEqual(res_token, None) 1492 self.assertEqual(spin_token, 'N*')
1493 1494
1495 - def test_tokenise_dup_atom_id_fail1(self):
1496 """Test failure of the generic_fns.mol_res_spin.tokenise() function on the string '@N@1'. 1497 1498 This tests for a duplicated atom identifier. 1499 """ 1500 1501 # Tokenise an invalid string. 1502 self.assertRaises(RelaxError, mol_res_spin.tokenise, '@N@1')
1503 1504
1505 - def test_tokenise_dup_atom_id_fail2(self):
1506 """Test failure of the generic_fns.mol_res_spin.tokenise() function on the string ':*@N@1'. 1507 1508 This tests for a duplicated atom identifier. 1509 """ 1510 1511 # Tokenise an invalid string. 1512 self.assertRaises(RelaxError, mol_res_spin.tokenise, ':*@N@1')
1513 1514
1515 - def test_tokenise_dup_atom_id_fail3(self):
1516 """Test failure of the generic_fns.mol_res_spin.tokenise() function on the string '@N:*@1'. 1517 1518 This tests for a duplicated atom identifier. 1519 """ 1520 1521 # Tokenise an invalid string. 1522 self.assertRaises(RelaxError, mol_res_spin.tokenise, '@N:*@1')
1523 1524
1525 - def test_tokenise_dup_res_id_fail1(self):
1526 """Test failure of the generic_fns.mol_res_spin.tokenise() function on the string ':1:2'. 1527 1528 This tests for a duplicated residue identifier. 1529 """ 1530 1531 # Tokenise an invalid string. 1532 self.assertRaises(RelaxError, mol_res_spin.tokenise, ':1:2')
1533 1534
1535 - def test_tokenise_dup_res_id_fail2(self):
1536 """Test failure of the generic_fns.mol_res_spin.tokenise() function on the string '#None:1:Ala'. 1537 1538 This tests for a duplicated residue identifier. 1539 """ 1540 1541 # Tokenise an invalid string. 1542 self.assertRaises(RelaxError, mol_res_spin.tokenise, '#None:1:Ala')
1543 1544
1545 - def test_tokenise_dup_res_id_fail3(self):
1546 """Test failure of the generic_fns.mol_res_spin.tokenise() function on the string ':1:Ala@N'. 1547 1548 This tests for a duplicated residue identifier. 1549 """ 1550 1551 # Tokenise an invalid string. 1552 self.assertRaises(RelaxError, mol_res_spin.tokenise, ':1:Ala@N')
1553 1554
1555 - def test_tokenise_dup_mol_id_fail1(self):
1556 """Test failure of the generic_fns.mol_res_spin.tokenise() function on the string '#A#B'. 1557 1558 This tests for a duplicated molecule identifier. 1559 """ 1560 1561 # Tokenise an invalid string. 1562 self.assertRaises(RelaxError, mol_res_spin.tokenise, '#A#B')
1563 1564
1565 - def test_tokenise_dup_mol_id_fail2(self):
1566 """Test failure of the generic_fns.mol_res_spin.tokenise() function on the string '#A#B:Leu'. 1567 1568 This tests for a duplicated molecule identifier. 1569 """ 1570 1571 # Tokenise an invalid string. 1572 self.assertRaises(RelaxError, mol_res_spin.tokenise, '#A#B:Leu')
1573 1574
1575 - def test_tokenise_dup_mol_id_fail3(self):
1576 """Test failure of the generic_fns.mol_res_spin.tokenise() function on the string '#A#C@CA'. 1577 1578 This tests for a duplicated molecule identifier. 1579 """ 1580 1581 # Tokenise an invalid string. 1582 self.assertRaises(RelaxError, mol_res_spin.tokenise, '#A#C@CA')
1583 1584
1585 - def test_tokenise_out_of_order_atom_id_fail1(self):
1586 """Test failure of the generic_fns.mol_res_spin.tokenise() function on the string '@CA#A'. 1587 1588 This tests for an out of order '@' identifier. 1589 """ 1590 1591 # Tokenise an invalid string. 1592 self.assertRaises(RelaxError, mol_res_spin.tokenise, '@CA#A')
1593 1594
1595 - def test_tokenise_out_of_order_atom_id_fail2(self):
1596 """Test failure of the generic_fns.mol_res_spin.tokenise() function on the string '@CA:Pro'. 1597 1598 This tests for an out of order '@' identifier. 1599 """ 1600 1601 # Tokenise an invalid string. 1602 self.assertRaises(RelaxError, mol_res_spin.tokenise, '@CA:Pro')
1603 1604
1605 - def test_tokenise_out_of_order_atom_id_fail3(self):
1606 """Test failure of the generic_fns.mol_res_spin.tokenise() function on the string '@CA#Z:Pro'. 1607 1608 This tests for an out of order '@' identifier. 1609 """ 1610 1611 # Tokenise an invalid string. 1612 self.assertRaises(RelaxError, mol_res_spin.tokenise, '@CA#Z:Pro')
1613 1614
1615 - def test_tokenise_out_of_order_res_id_fail1(self):
1616 """Test failure of the generic_fns.mol_res_spin.tokenise() function on the string '@CA:Pro'. 1617 1618 This tests for an out of order ':' identifier. 1619 """ 1620 1621 # Tokenise an invalid string. 1622 self.assertRaises(RelaxError, mol_res_spin.tokenise, '@CA:Pro')
1623 1624
1625 - def test_tokenise_out_of_order_res_id_fail2(self):
1626 """Test failure of the generic_fns.mol_res_spin.tokenise() function on the string ':Glu#X'. 1627 1628 This tests for an out of order ':' identifier. 1629 """ 1630 1631 # Tokenise an invalid string. 1632 self.assertRaises(RelaxError, mol_res_spin.tokenise, ':Glu#X')
1633 1634
1635 - def test_tokenise_out_of_order_res_id_fail3(self):
1636 """Test failure of the generic_fns.mol_res_spin.tokenise() function on the string '#1@12423:Glu'. 1637 1638 This tests for an out of order ':' identifier. 1639 """ 1640 1641 # Tokenise an invalid string. 1642 self.assertRaises(RelaxError, mol_res_spin.tokenise, ':Glu#X')
1643 1644
1645 - def test_tokenise_out_of_order_mol_id_fail1(self):
1646 """Test failure of the generic_fns.mol_res_spin.tokenise() function on the string ':1-160#A'. 1647 1648 This tests for an out of order '#' identifier. 1649 """ 1650 1651 # Tokenise an invalid string. 1652 self.assertRaises(RelaxError, mol_res_spin.tokenise, ':1-160#A')
1653 1654
1655 - def test_tokenise_out_of_order_mol_id_fail2(self):
1656 """Test failure of the generic_fns.mol_res_spin.tokenise() function on the string '@N,CA#A'. 1657 1658 This tests for an out of order '#' identifier. 1659 """ 1660 1661 # Tokenise an invalid string. 1662 self.assertRaises(RelaxError, mol_res_spin.tokenise, '@N,CA#A')
1663 1664
1665 - def test_tokenise_out_of_order_mol_id_fail3(self):
1666 """Test failure of the generic_fns.mol_res_spin.tokenise() function on the string '@N:-10#Zip'. 1667 1668 This tests for an out of order '#' identifier. 1669 """ 1670 1671 # Tokenise an invalid string. 1672 self.assertRaises(RelaxError, mol_res_spin.tokenise, '@N:-10#Zip')
1673 1674
1675 - def test_tokenise_bad_string_fail1(self):
1676 """Test failure of the generic_fns.mol_res_spin.tokenise() function on the string '13'. 1677 1678 This tests for an improper selection string. 1679 """ 1680 1681 # Tokenise an invalid string. 1682 self.assertRaises(RelaxError, mol_res_spin.tokenise, '13')
1683 1684
1685 - def test_tokenise_bad_string_fail2(self):
1686 """Test failure of the generic_fns.mol_res_spin.tokenise() function on the string 'XXX'. 1687 1688 This tests for an improper selection string. 1689 """ 1690 1691 # Tokenise an invalid string. 1692 self.assertRaises(RelaxError, mol_res_spin.tokenise, 'XXX')
1693 1694
1695 - def test_tokenise_bad_string_fail3(self):
1696 """Test failure of the generic_fns.mol_res_spin.tokenise() function on the string ''. 1697 1698 This tests for an improper selection string. 1699 """ 1700 1701 # Tokenise an invalid string. 1702 self.assertRaises(RelaxError, mol_res_spin.tokenise, '')
1703 1704
1705 - def test_boolean_and_selection(self):
1706 """Test boolean and in mol-res-spin selections.""" 1707 1708 # The selection loop: 1709 sel = list(mol_res_spin.residue_loop("#Ap4Aase:4 & :Pro")) 1710 1711 # Test: 1712 self.assertEqual(len(sel), 1) 1713 for res in sel: 1714 self.assert_(res.name == "Pro" and res.num == 4)
1715 1716
1717 - def test_boolean_complex_selection(self):
1718 """Test complex boolean mol-res-spin selections.""" 1719 1720 # The residue selection loop. 1721 sel = list(mol_res_spin.residue_loop("#Ap4Aase:4 & :Pro | #RNA")) 1722 1723 # Residue names and numbers. 1724 names = ['Pro', None, None] 1725 numbers = [4, -5, -4] 1726 1727 # The residues. 1728 self.assertEqual(len(sel), 3) 1729 for i in xrange(3): 1730 self.assertEqual(sel[i].name, names[i]) 1731 self.assertEqual(sel[i].num, numbers[i])
1732 1733 1734 ###################################################### 1735 # Test disabled until this functionality is enabled. # 1736 ######################################################
1737 - def xxx_test_boolean_parenthesis_selection(self):
1738 """Test complex boolean mol-res-spin selections with parenthesis.""" 1739 1740 # The selection loop: 1741 sel = list(mol_res_spin.residue_loop("(#Ap4Aase & :Pro) | (#RNA & :-4)")) 1742 1743 # Test: 1744 self.assertEqual(len(sel), 2) 1745 for res in sel: 1746 self.assert_(res.num in [-4, 4])
1747