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