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.                                     # 
   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@63'.""" 425 426 # The Selection object. 427 obj = mol_res_spin.Selection("#Ap4Aase:2@63") 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@16") 444 445 # The new Selection object. 446 obj = mol_res_spin.Selection(":13") 447 448 # Test the highest level object. 449 self.assertEqual(obj._union, None) 450 self.assertEqual(obj._intersect, None) 451 self.assertEqual(obj.molecules, []) 452 self.assertEqual(obj.residues, [13]) 453 self.assertEqual(obj.spins, [])
454 455
456 - def test_count_spins(self):
457 """Test that the number of spins can be properly counted. 458 459 The function tested is generic_fns.mol_res_spin.count_spins(). 460 """ 461 462 # Test the number of spins counted. 463 self.assertEqual(mol_res_spin.count_spins(), 4) 464 self.assertEqual(mol_res_spin.count_spins(skip_desel=False), 8) 465 self.assertEqual(mol_res_spin.count_spins(selection='@N5'), 1) 466 self.assertEqual(mol_res_spin.count_spins(selection='@N5', skip_desel=False), 2)
467 468
469 - def test_count_no_spins(self):
470 """Test that the number of spins (zero) can be properly counted. 471 472 The function tested is generic_fns.mol_res_spin.count_spins(). 473 """ 474 475 # Reset relax. 476 reset() 477 478 # Add a data pipe to the data store. 479 ds.add(pipe_name='orig', pipe_type='mf') 480 481 # Test the number of spins counted. 482 self.assertEqual(mol_res_spin.count_spins(), 0)
483 484
485 - def test_count_spins_no_pipe(self):
486 """Test that the counting of the number of spins raises an error when no pipe exists. 487 488 The function tested is generic_fns.mol_res_spin.count_spins(). 489 """ 490 491 # Reset relax. 492 reset() 493 494 # Test for the error. 495 self.assertRaises(RelaxNoPipeError, mol_res_spin.count_spins)
496 497
499 """Test the function for determining if molecule-residue-spin data exists. 500 501 The function tested is generic_fns.mol_res_spin.exists_mol_res_spin_data(). 502 """ 503 504 # This should be True. 505 self.failUnless(mol_res_spin.exists_mol_res_spin_data())
506 507
509 """Determine if molecule-residue-spin data exists (with data for a single molecule). 510 511 The function tested is generic_fns.mol_res_spin.exists_mol_res_spin_data(). 512 """ 513 514 # Reset relax. 515 reset() 516 517 # Add a data pipe to the data store. 518 ds.add(pipe_name='orig', pipe_type='mf') 519 dp = pipes.get_pipe('orig') 520 521 # Name the first molecule. 522 dp.mol[0].name = 'TOM40' 523 524 # This should be True. 525 self.failUnless(mol_res_spin.exists_mol_res_spin_data())
526 527
529 """Determine if molecule-residue-spin data exists (when a single residue is named). 530 531 The function tested is generic_fns.mol_res_spin.exists_mol_res_spin_data(). 532 """ 533 534 # Reset relax. 535 reset() 536 537 # Add a data pipe to the data store. 538 ds.add(pipe_name='orig', pipe_type='mf') 539 dp = pipes.get_pipe('orig') 540 541 # Name the first residue. 542 dp.mol[0].res[0].name = 'Lys' 543 544 # This should be True. 545 self.failUnless(mol_res_spin.exists_mol_res_spin_data())
546 547
549 """Determine if molecule-residue-spin data exists (when a single residue is numbered). 550 551 The function tested is generic_fns.mol_res_spin.exists_mol_res_spin_data(). 552 """ 553 554 # Reset relax. 555 reset() 556 557 # Add a data pipe to the data store. 558 ds.add(pipe_name='orig', pipe_type='mf') 559 dp = pipes.get_pipe('orig') 560 561 # Number the first residue. 562 dp.mol[0].res[0].num = 1 563 564 # This should be True. 565 self.failUnless(mol_res_spin.exists_mol_res_spin_data())
566 567
569 """Determine if molecule-residue-spin data exists (when a single spin is named). 570 571 The function tested is generic_fns.mol_res_spin.exists_mol_res_spin_data(). 572 """ 573 574 # Reset relax. 575 reset() 576 577 # Add a data pipe to the data store. 578 ds.add(pipe_name='orig', pipe_type='mf') 579 dp = pipes.get_pipe('orig') 580 581 # Name the first spin. 582 dp.mol[0].res[0].spin[0].name = 'NH' 583 584 # This should be True. 585 self.failUnless(mol_res_spin.exists_mol_res_spin_data())
586 587
589 """Determine if molecule-residue-spin data exists (when a single spin is numbered). 590 591 The function tested is generic_fns.mol_res_spin.exists_mol_res_spin_data(). 592 """ 593 594 # Reset relax. 595 reset() 596 597 # Add a data pipe to the data store. 598 ds.add(pipe_name='orig', pipe_type='mf') 599 dp = pipes.get_pipe('orig') 600 601 # Number the first spin. 602 dp.mol[0].res[0].spin[0].num = 234 603 604 # This should be True. 605 self.failUnless(mol_res_spin.exists_mol_res_spin_data())
606 607
609 """Determine if molecule-residue-spin data exists when no data exists. 610 611 The function tested is generic_fns.mol_res_spin.exists_mol_res_spin_data(). 612 """ 613 614 # Reset relax. 615 reset() 616 617 # Add a data pipe to the data store. 618 ds.add(pipe_name='orig', pipe_type='mf') 619 620 # This should be False. 621 self.failIf(mol_res_spin.exists_mol_res_spin_data())
622 623
625 """Determine if molecule-residue-spin data exists when no data pipe exists. 626 627 The function tested is generic_fns.mol_res_spin.exists_mol_res_spin_data(). 628 """ 629 630 # Reset relax. 631 reset() 632 633 # This should fail. 634 self.assertRaises(RelaxNoPipeError, mol_res_spin.exists_mol_res_spin_data)
635 636
638 """First test of the spin ID generation function. 639 640 The function tested is generic_fns.mol_res_spin.generate_spin_id_data_array(). 641 """ 642 643 # The data. 644 data = ['1', 'GLY'] 645 646 # The ID. 647 id = mol_res_spin.generate_spin_id_data_array(data, res_num_col=1, res_name_col=2) 648 649 # Test the string. 650 self.assertEqual(id, ':1')
651 652
654 """Second test of the spin ID generation function. 655 656 The function tested is generic_fns.mol_res_spin.generate_spin_id_data_array(). 657 """ 658 659 # The data. 660 data = ['1', 'GLY', '234', 'NH'] 661 662 # The ID. 663 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) 664 665 # Test the string. 666 self.assertEqual(id, ':1@234')
667 668
670 """Third test of the spin ID generation function. 671 672 The function tested is generic_fns.mol_res_spin.generate_spin_id_data_array(). 673 """ 674 675 # The data. 676 data = ['Ap4Aase', '234', 'NH'] 677 678 # The ID. 679 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) 680 681 # Test the string. 682 self.assertEqual(id, '#Ap4Aase@234')
683 684
686 """Fourth test of the spin ID generation function. 687 688 The function tested is generic_fns.mol_res_spin.generate_spin_id_data_array(). 689 """ 690 691 # The data. 692 data = ['Ap4Aase', '1', 'GLY'] 693 694 # The ID. 695 id = mol_res_spin.generate_spin_id_data_array(data, mol_name_col=1, res_num_col=2, res_name_col=3) 696 697 # Test the string. 698 self.assertEqual(id, '#Ap4Aase:1')
699 700
702 """Fifth test of the spin ID generation function. 703 704 The function tested is generic_fns.mol_res_spin.generate_spin_id_data_array(). 705 """ 706 707 # The data. 708 data = ['Ap4Aase', '1', 'GLY', '234', 'NH'] 709 710 # The ID. 711 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) 712 713 # Test the string. 714 self.assertEqual(id, '#Ap4Aase:1@234')
715 716
718 """Sixth test of the spin ID generation function. 719 720 The function tested is generic_fns.mol_res_spin.generate_spin_id_data_array(). 721 """ 722 723 # The data. 724 data = ['1', 'GLY', None, None] 725 726 # The ID. 727 id = mol_res_spin.generate_spin_id_data_array(data, res_num_col=1, res_name_col=2) 728 729 # Test the string. 730 self.assertEqual(id, ':1')
731 732
733 - def test_molecule_loop(self):
734 """Test the proper operation of the molecule loop with molecule selection. 735 736 The function tested is generic_fns.mol_res_spin.molecule_loop(). 737 """ 738 739 # Loop over the molecules. 740 for mol in mol_res_spin.molecule_loop('#RNA'): 741 # Test the molecule name. 742 self.assertEqual(mol.name, 'RNA') 743 744 # Test loop length. 745 self.assertEqual(len(list(mol_res_spin.molecule_loop('#RNA'))), 1)
746 747
748 - def test_molecule_loop_no_data(self):
749 """Test the proper operation of the molecule loop when no data is present. 750 751 The function tested is generic_fns.mol_res_spin.molecule_loop(). 752 """ 753 754 # Reset relax. 755 reset() 756 757 # Add a data pipe to the data store. 758 ds.add(pipe_name='orig', pipe_type='mf') 759 760 # Loop over the molecules. 761 i = 0 762 for molecule in mol_res_spin.molecule_loop(): 763 i = i + 1 764 765 # Test loop length. 766 self.assertEqual(i, 0)
767 768
769 - def test_molecule_loop_no_pipe(self):
770 """Test the proper operation of the molecule loop when no data pipe is present. 771 772 The function tested is generic_fns.mol_res_spin.molecule_loop(). 773 """ 774 775 # Reset relax. 776 reset() 777 778 # Function for the problem of catching an error in a generator function. 779 def fail_test(): 780 for molecule in mol_res_spin.molecule_loop(): 781 pass
782 783 # Test for the no pipe error. 784 self.assertRaises(RelaxNoPipeError, fail_test)
785 786
787 - def test_molecule_loop_no_selection(self):
788 """Test the proper operation of the molecule loop when no selection is present. 789 790 The function tested is generic_fns.mol_res_spin.molecule_loop(). 791 """ 792 793 # Molecule data. 794 name = ['Ap4Aase', 'RNA'] 795 796 # Loop over the molecules. 797 i = 0 798 for mol in mol_res_spin.molecule_loop(): 799 # Test the molecule names. 800 self.assertEqual(mol.name, name[i]) 801 802 # Increment i. 803 i = i + 1 804 805 # Test loop length. 806 self.assertEqual(len(list(mol_res_spin.molecule_loop())), 2)
807 808 809
810 - def test_parse_token_single_element_num(self):
811 """Test the generic_fns.mol_res_spin.parse_token() function on the string '1'.""" 812 813 # Parse the token. 814 list = mol_res_spin.parse_token('1') 815 816 # Check the list elements. 817 self.assertEqual(len(list), 1) 818 self.assertEqual(list[0], 1)
819 820
821 - def test_parse_token_single_element_neg_num(self):
822 """Test the generic_fns.mol_res_spin.parse_token() function on the string '-4'.""" 823 824 # Parse the token. 825 list = mol_res_spin.parse_token('-4') 826 827 # Check the list elements. 828 self.assertEqual(len(list), 1) 829 self.assertEqual(list[0], -4)
830 831
832 - def test_parse_token_single_element_name(self):
833 """Test the generic_fns.mol_res_spin.parse_token() function on the string 'G'.""" 834 835 # Parse the token. 836 list = mol_res_spin.parse_token('G') 837 838 # Check the list elements. 839 self.assertEqual(len(list), 1) 840 self.assertEqual(list[0], 'G')
841 842
843 - def test_parse_token_single_element_wildcard_name(self):
844 """Test the generic_fns.mol_res_spin.parse_token() function on the string 'N*'.""" 845 846 # Parse the token. 847 list = mol_res_spin.parse_token('N*') 848 849 # Check the list elements. 850 self.assertEqual(len(list), 1) 851 self.assertEqual(list[0], 'N*')
852 853
854 - def test_parse_token_single_element_range(self):
855 """Test the generic_fns.mol_res_spin.parse_token() function on the string '1-10'.""" 856 857 # Parse the token. 858 list = mol_res_spin.parse_token('1-10') 859 860 # Check the list elements. 861 self.assertEqual(len(list), 10) 862 for i in range(1, 11): 863 self.assertEqual(list[i-1], i)
864 865
866 - def test_parse_token_single_element_neg_range(self):
867 """Test the generic_fns.mol_res_spin.parse_token() function on the string '-10--1'.""" 868 869 # Parse the token. 870 list = mol_res_spin.parse_token('-10--1') 871 872 # Check the list elements. 873 self.assertEqual(len(list), 10) 874 j = 0 875 for i in range(-10, -2): 876 self.assertEqual(list[j], i) 877 j = j + 1
878 879
880 - def test_parse_token_multi_element_num(self):
881 """Test the generic_fns.mol_res_spin.parse_token() function on the string '-2, 1'.""" 882 883 # Parse the token. 884 list = mol_res_spin.parse_token('-2, 1') 885 886 # Check the list elements. 887 self.assertEqual(len(list), 2) 888 self.assertEqual(list[0], -2) 889 self.assertEqual(list[1], 1)
890 891
892 - def test_parse_token_multi_element_name(self):
893 """Test the generic_fns.mol_res_spin.parse_token() function on the string 'N,CA'.""" 894 895 # Parse the token. 896 list = mol_res_spin.parse_token('N,CA') 897 898 # Check the list elements. 899 self.assertEqual(len(list), 2) 900 self.assertEqual(list[0], 'CA') 901 self.assertEqual(list[1], 'N')
902 903
904 - def test_parse_token_multi_element_num_name(self):
905 """Test the generic_fns.mol_res_spin.parse_token() function on the string '76,Ala'.""" 906 907 # Parse the token. 908 list = mol_res_spin.parse_token('76,Ala') 909 910 # Check the list elements. 911 self.assertEqual(len(list), 2) 912 self.assertEqual(list[0], 76) 913 self.assertEqual(list[1], 'Ala')
914 915
916 - def test_parse_token_multi_element_num_range(self):
917 """Test the generic_fns.mol_res_spin.parse_token() function on the string '1,3-5'.""" 918 919 # Parse the token. 920 list = mol_res_spin.parse_token('1,3-5') 921 922 # Check the list elements. 923 self.assertEqual(len(list), 4) 924 self.assertEqual(list[0], 1) 925 self.assertEqual(list[1], 3) 926 self.assertEqual(list[2], 4) 927 self.assertEqual(list[3], 5)
928 929
930 - def test_parse_token_multi_element_range_name(self):
931 """Test the generic_fns.mol_res_spin.parse_token() function on the string '3-5,NH'.""" 932 933 # Parse the token. 934 list = mol_res_spin.parse_token('3-5,NH') 935 936 # Check the list elements. 937 self.assertEqual(len(list), 4) 938 self.assertEqual(list[0], 3) 939 self.assertEqual(list[1], 4) 940 self.assertEqual(list[2], 5) 941 self.assertEqual(list[3], 'NH')
942 943
944 - def test_parse_token_multi_element_range_num_name(self):
945 """Test the generic_fns.mol_res_spin.parse_token() function on the string '3-6, 8, Gly'.""" 946 947 # Parse the token. 948 list = mol_res_spin.parse_token('3-6, 8, Gly') 949 950 # Check the list elements. 951 self.assertEqual(len(list), 6) 952 self.assertEqual(list[0], 3) 953 self.assertEqual(list[1], 4) 954 self.assertEqual(list[2], 5) 955 self.assertEqual(list[3], 6) 956 self.assertEqual(list[4], 8) 957 self.assertEqual(list[5], 'Gly')
958 959
960 - def test_residue_loop(self):
961 """Test the proper operation of the residue loop with residue selection. 962 963 The function tested is generic_fns.mol_res_spin.residue_loop(). 964 """ 965 966 # Loop over the residues. 967 for res in mol_res_spin.residue_loop('#Ap4Aase:Glu'): 968 # Test the selection. 969 self.assertEqual(res.num, 2) 970 971 # Test loop length. 972 self.assertEqual(len(list(mol_res_spin.residue_loop('#Ap4Aase:Glu'))), 1)
973 974
975 - def test_residue_loop_no_data(self):
976 """Test the proper operation of the residue loop when no data is present. 977 978 The function tested is generic_fns.mol_res_spin.residue_loop(). 979 """ 980 981 # Reset relax. 982 reset() 983 984 # Add a data pipe to the data store. 985 ds.add(pipe_name='orig', pipe_type='mf') 986 987 # Loop over the residues. 988 i = 0 989 for residue in mol_res_spin.residue_loop(): 990 i = i + 1 991 992 # Test loop length. 993 self.assertEqual(i, 0)
994 995
996 - def test_residue_loop_no_pipe(self):
997 """Test the proper operation of the residue loop when no data pipe is present. 998 999 The function tested is generic_fns.mol_res_spin.residue_loop(). 1000 """ 1001 1002 # Reset relax. 1003 reset() 1004 1005 # Function for the problem of catching an error in a generator function. 1006 def fail_test(): 1007 for residue in mol_res_spin.residue_loop(): 1008 pass
1009 1010 # Test for the no pipe error. 1011 self.assertRaises(RelaxNoPipeError, fail_test) 1012 1013
1014 - def test_residue_loop_no_selection(self):
1015 """Test the proper operation of the residue loop when no selection is present. 1016 1017 The function tested is generic_fns.mol_res_spin.residue_loop(). 1018 """ 1019 1020 # Spin data. 1021 num = [1, 2, 4, -5, -4] 1022 name = [None, 'Glu', 'Pro', None, None] 1023 1024 # Loop over the residues. 1025 i = 0 1026 for res in mol_res_spin.residue_loop(): 1027 # Test the residue numbers. 1028 self.assertEqual(res.num, num[i]) 1029 1030 # Test the residue names. 1031 self.assertEqual(res.name, name[i]) 1032 1033 # Increment i. 1034 i = i + 1 1035 1036 # Test loop length. 1037 self.assertEqual(i, 5)
1038 1039
1040 - def test_return_molecule(self):
1041 """Test the function for returning the desired molecule data container. 1042 1043 The function tested is generic_fns.mol_res_spin.return_molecule(). 1044 """ 1045 1046 # Ask for a few molecules. 1047 mol1 = mol_res_spin.return_molecule('#Ap4Aase') 1048 mol2 = mol_res_spin.return_molecule(selection='#RNA', pipe='orig') 1049 1050 # Test the data of molecule 1. 1051 self.assertEqual(mol1.name, 'Ap4Aase') 1052 1053 # Test the data of molecule 2. 1054 self.assertEqual(mol2.name, 'RNA')
1055 1056
1057 - def test_return_molecule_pipe_fail(self):
1058 """Test the failure of the function for returning the desired molecule data container. 1059 1060 The function tested is generic_fns.mol_res_spin.return_molecule(). 1061 """ 1062 1063 # Try to get a molecule from a missing data pipe. 1064 self.assertRaises(RelaxNoPipeError, mol_res_spin.return_molecule, selection='#Ap4Aase', pipe='new') 1065 self.assertRaises(RelaxNoPipeError, mol_res_spin.return_molecule, selection='#RNA', pipe='new')
1066 1067
1068 - def test_return_residue(self):
1069 """Test the function for returning the desired residue data container. 1070 1071 The function tested is generic_fns.mol_res_spin.return_residue(). 1072 """ 1073 1074 # Ask for a few residues. 1075 res1 = mol_res_spin.return_residue(':1') 1076 res2 = mol_res_spin.return_residue(selection=':2') 1077 res4 = mol_res_spin.return_residue(selection=':4', pipe='orig') 1078 res5 = mol_res_spin.return_residue(selection='#RNA:-5', pipe='orig') 1079 1080 # Test the data of residue 1. 1081 self.assertEqual(res1.num, 1) 1082 self.assertEqual(res1.name, None) 1083 1084 # Test the data of residue 2. 1085 self.assertEqual(res2.num, 2) 1086 self.assertEqual(res2.name, 'Glu') 1087 1088 # Test the data of residue 4. 1089 self.assertEqual(res4.num, 4) 1090 self.assertEqual(res4.name, 'Pro') 1091 1092 # Test the data of the RNA residue -5. 1093 self.assertEqual(res5.num, -5) 1094 self.assertEqual(res5.name, None) 1095 self.assertEqual(res5.spin[1].name, 'N5')
1096 1097
1098 - def test_return_residue_pipe_fail(self):
1099 """Test the failure of the function for returning the desired residue data container. 1100 1101 The function tested is generic_fns.mol_res_spin.return_residue(). 1102 """ 1103 1104 # Try to get a residue from a missing data pipe. 1105 self.assertRaises(RelaxNoPipeError, mol_res_spin.return_residue, selection=':2', pipe='new')
1106 1107
1108 - def test_return_single_residue_info(self):
1109 """Test the function for returning the desired residue data container. 1110 1111 The function tested is generic_fns.mol_res_spin.return_single_residue_info(). 1112 """ 1113 1114 # Ask for a few residues. 1115 res1 = mol_res_spin.return_single_residue_info('1') 1116 res2 = mol_res_spin.return_single_residue_info('2,Glu') 1117 res4 = mol_res_spin.return_single_residue_info('Pro,4') 1118 res5 = mol_res_spin.return_single_residue_info('-5') 1119 1120 # Test the data of residue 1. 1121 self.assertEqual(res1, (1, None)) 1122 1123 # Test the data of residue 2. 1124 self.assertEqual(res2, (2, 'Glu')) 1125 1126 # Test the data of residue 4. 1127 self.assertEqual(res4, (4, 'Pro')) 1128 1129 # Test the data of the RNA residue -5. 1130 self.assertEqual(res5, (-5, None))
1131 1132
1133 - def test_return_single_residue_info_fail(self):
1134 """Test the failure of the function for returning the desired residue data container. 1135 1136 The function tested is generic_fns.mol_res_spin.return_single_residue_info(). 1137 """ 1138 1139 # Ask for a few residues. 1140 self.assertRaises(RelaxError, mol_res_spin.return_single_residue_info, '1,2') 1141 self.assertRaises(RelaxError, mol_res_spin.return_single_residue_info, '1,Glu,Pro') 1142 self.assertRaises(RelaxError, mol_res_spin.return_single_residue_info, '1,2,Glu,Pro')
1143 1144
1145 - def test_return_spin(self):
1146 """Test the function for returning the desired spin data container. 1147 1148 The function tested is generic_fns.mol_res_spin.return_spin(). 1149 """ 1150 1151 # Ask for a few spins. 1152 spin1 = mol_res_spin.return_spin(':1') 1153 spin2 = mol_res_spin.return_spin(selection=':2') 1154 spin3 = mol_res_spin.return_spin(selection=':4', pipe='orig') 1155 spin4 = mol_res_spin.return_spin(selection='#RNA:-5@N5', pipe='orig') 1156 spin5 = mol_res_spin.return_spin(selection=':-4@2H', pipe='orig') 1157 1158 # Test the data of spin 1. 1159 self.assertNotEqual(spin1, None) 1160 self.assertEqual(spin1.num, 60) 1161 self.assertEqual(spin1.name, 'NH') 1162 1163 # Test the data of spin 2. 1164 self.assertNotEqual(spin2, None) 1165 self.assertEqual(spin2.num, 63) 1166 self.assertEqual(spin2.name, 'NH') 1167 1168 # Test the data of spin 3. 1169 self.assertNotEqual(spin3, None) 1170 self.assertEqual(spin3.num, None) 1171 self.assertEqual(spin3.name, None) 1172 1173 # Test the data of the RNA res -5, spin N5. 1174 self.assertNotEqual(spin4, None) 1175 self.assertEqual(spin4.num, None) 1176 self.assertEqual(spin4.name, 'N5') 1177 1178 # Test the data of the RNA res -4, spin 2H. 1179 self.assertNotEqual(spin5, None) 1180 self.assertEqual(spin5.num, 132) 1181 self.assertEqual(spin5.name, '2H')
1182 1183
1184 - def test_return_spin_pipe_fail(self):
1185 """Test the failure of the function for returning the desired spin data container. 1186 1187 The function tested is generic_fns.mol_res_spin.return_spin(). 1188 """ 1189 1190 # Try to get a spin from a missing data pipe. 1191 self.assertRaises(RelaxNoPipeError, mol_res_spin.return_spin, selection=':2', pipe='new')
1192 1193
1194 - def test_spin_loop(self):
1195 """Test the proper operation of the spin loop with spin selection. 1196 1197 The function tested is generic_fns.mol_res_spin.spin_loop(). 1198 """ 1199 1200 # Spin data. 1201 select = [1, 0] 1202 1203 # Loop over the spins. 1204 i = 0 1205 for spin in mol_res_spin.spin_loop('@N5'): 1206 # Test the selection. 1207 self.assertEqual(spin.select, select[i]) 1208 1209 # Test the spin names. 1210 self.assertEqual(spin.name, 'N5') 1211 1212 # Increment i. 1213 i = i + 1 1214 1215 # Test loop length. 1216 self.assertEqual(i, 2)
1217 1218
1219 - def test_spin_loop_boolean_or(self):
1220 """Test the operation of the spin loop with the selection "#Ap4Aase:Glu | #RNA@C8". 1221 1222 The function tested is generic_fns.mol_res_spin.spin_loop(). 1223 """ 1224 1225 # Selection, and spin name and number. 1226 select = [1, 0, 1] 1227 name = ['NH', 'C8', 'C8'] 1228 num = [63, None, None] 1229 1230 # Loop over the spins. 1231 i = 0 1232 for spin in mol_res_spin.spin_loop("#Ap4Aase:Glu | #RNA@C8"): 1233 # Test the spin. 1234 self.assertEqual([spin.select, spin.name, spin.num], [select[i], name[i], num[i]]) 1235 1236 # Increment i. 1237 i = i + 1 1238 1239 # Test loop length. 1240 self.assertEqual(i, 3)
1241 1242
1243 - def test_spin_loop_multiatom(self):
1244 """Test the proper operation of the spin loop with spin selection '@NH|@N5'. 1245 1246 The function tested is generic_fns.mol_res_spin.spin_loop(). 1247 """ 1248 1249 # Spin data. 1250 select = [0, 1, 1, 0] 1251 name = ['NH', 'NH', 'N5', 'N5'] 1252 1253 # Loop over the spins. 1254 i = 0 1255 for spin in mol_res_spin.spin_loop('@NH|@N5'): 1256 # Test the selection. 1257 self.assertEqual(spin.select, select[i]) 1258 1259 # Test the spin names. 1260 self.assertEqual(spin.name, name[i]) 1261 1262 # Increment i. 1263 i = i + 1 1264 1265 # Test loop length. 1266 self.assertEqual(i, 4)
1267 1268
1269 - def test_spin_loop_no_data(self):
1270 """Test the proper operation of the spin loop when no data is present. 1271 1272 The function tested is generic_fns.mol_res_spin.spin_loop(). 1273 """ 1274 1275 # Reset relax. 1276 reset() 1277 1278 # Add a data pipe to the data store. 1279 ds.add(pipe_name='orig', pipe_type='mf') 1280 1281 # Loop over the spins. 1282 i = 0 1283 for spin in mol_res_spin.spin_loop(): 1284 i = i + 1 1285 1286 # Test loop length. 1287 self.assertEqual(i, 0)
1288 1289
1290 - def test_spin_loop_no_pipe(self):
1291 """Test the proper operation of the spin loop when no data pipe is present. 1292 1293 The function tested is generic_fns.mol_res_spin.spin_loop(). 1294 """ 1295 1296 # Reset relax. 1297 reset() 1298 1299 # Function for the problem of catching an error in a generator function. 1300 def fail_test(): 1301 for spin in mol_res_spin.spin_loop(): 1302 pass
1303 1304 # Test for the no pipe error. 1305 self.assertRaises(RelaxNoPipeError, fail_test) 1306 1307
1308 - def test_spin_loop_no_selection(self):
1309 """Test the proper operation of the spin loop when no selection is present. 1310 1311 The function tested is generic_fns.mol_res_spin.spin_loop(). 1312 """ 1313 1314 # Spin data. 1315 select = [0, 1, 0, 0, 1, 1, 0, 1] 1316 name = ['NH', 'NH', None, 'C8', 'N5', 'C8', 'N5', '2H'] 1317 1318 # Loop over the spins. 1319 i = 0 1320 for spin in mol_res_spin.spin_loop(): 1321 # Test the selection. 1322 self.assertEqual(spin.select, select[i]) 1323 1324 # Test the spin names. 1325 self.assertEqual(spin.name, name[i]) 1326 1327 # Increment i. 1328 i = i + 1 1329 1330 # Test loop length. 1331 self.assertEqual(i, 8)
1332 1333
1334 - def test_spin_loop_single_spin(self):
1335 """Test the operation of the spin loop with the single spin selection '#Ap4Aase:Glu@63'. 1336 1337 The function tested is generic_fns.mol_res_spin.spin_loop(). 1338 """ 1339 1340 # Loop over the spins. 1341 i = 0 1342 for spin in mol_res_spin.spin_loop('#Ap4Aase:Glu@63'): 1343 # Test the selection. 1344 self.assertEqual(spin.select, 1) 1345 1346 # Test the spin name. 1347 self.assertEqual(spin.name, 'NH') 1348 1349 # Test the spin number. 1350 self.assertEqual(spin.num, 63) 1351 1352 # Increment i. 1353 i = i + 1 1354 1355 # Test loop length. 1356 self.assertEqual(i, 1)
1357 1358
1359 - def test_spin_loop_wildcard(self):
1360 """Test the proper operation of the spin loop with wildcard spin selection '@N*'. 1361 1362 The function tested is generic_fns.mol_res_spin.spin_loop(). 1363 """ 1364 1365 # Spin data. 1366 select = [0, 1, 1, 0] 1367 name = ['NH', 'NH', 'N5', 'N5'] 1368 1369 # Loop over the spins. 1370 i = 0 1371 for spin in mol_res_spin.spin_loop('@N*'): 1372 # Test the selection. 1373 self.assertEqual(spin.select, select[i]) 1374 1375 # Test the spin names. 1376 self.assertEqual(spin.name, name[i]) 1377 1378 # Increment i. 1379 i = i + 1 1380 1381 # Test loop length. 1382 self.assertEqual(i, 4)
1383 1384
1385 - def test_tokenise1(self):
1386 """Test the generic_fns.mol_res_spin.tokenise() function on the string '@1'.""" 1387 1388 # Tokenise. 1389 mol_token, res_token, spin_token = mol_res_spin.tokenise('@1') 1390 1391 # Check the tokens. 1392 self.assertEqual(mol_token, None) 1393 self.assertEqual(res_token, None) 1394 self.assertEqual(spin_token, '1')
1395 1396
1397 - def test_tokenise2(self):
1398 """Test the generic_fns.mol_res_spin.tokenise() function on the string ':-4'.""" 1399 1400 # Tokenise. 1401 mol_token, res_token, spin_token = mol_res_spin.tokenise(':-4') 1402 1403 # Check the tokens. 1404 self.assertEqual(mol_token, None) 1405 self.assertEqual(res_token, '-4') 1406 self.assertEqual(spin_token, None)
1407 1408
1409 - def test_tokenise3(self):
1410 """Test the generic_fns.mol_res_spin.tokenise() function on the string '#CaM'.""" 1411 1412 # Tokenise. 1413 mol_token, res_token, spin_token = mol_res_spin.tokenise('#CaM') 1414 1415 # Check the tokens. 1416 self.assertEqual(mol_token, 'CaM') 1417 self.assertEqual(res_token, None) 1418 self.assertEqual(spin_token, None)
1419 1420
1421 - def test_tokenise4(self):
1422 """Test the generic_fns.mol_res_spin.tokenise() function on the string ':G@N3'.""" 1423 1424 # Tokenise. 1425 mol_token, res_token, spin_token = mol_res_spin.tokenise(':G@N3') 1426 1427 # Check the tokens. 1428 self.assertEqual(mol_token, None) 1429 self.assertEqual(res_token, 'G') 1430 self.assertEqual(spin_token, 'N3')
1431 1432
1433 - def test_tokenise5(self):
1434 """Test the generic_fns.mol_res_spin.tokenise() function on the string '#OMP@NH'.""" 1435 1436 # Tokenise. 1437 mol_token, res_token, spin_token = mol_res_spin.tokenise('#OMP@NH') 1438 1439 # Check the tokens. 1440 self.assertEqual(mol_token, 'OMP') 1441 self.assertEqual(res_token, None) 1442 self.assertEqual(spin_token, 'NH')
1443 1444
1445 - def test_tokenise6(self):
1446 """Test the generic_fns.mol_res_spin.tokenise() function on the string '#Lyso:20-50'.""" 1447 1448 # Tokenise. 1449 mol_token, res_token, spin_token = mol_res_spin.tokenise('#Lyso:20-50') 1450 1451 # Check the tokens. 1452 self.assertEqual(mol_token, 'Lyso') 1453 self.assertEqual(res_token, '20-50') 1454 self.assertEqual(spin_token, None)
1455 1456
1457 - def test_tokenise7(self):
1458 """Test the generic_fns.mol_res_spin.tokenise() function on the string '#Ap4Aase:*@N,CA'.""" 1459 1460 # Tokenise. 1461 mol_token, res_token, spin_token = mol_res_spin.tokenise('#Ap4Aase:*@N,CA') 1462 1463 # Check the tokens. 1464 self.assertEqual(mol_token, 'Ap4Aase') 1465 self.assertEqual(res_token, '*') 1466 self.assertEqual(spin_token, 'N,CA')
1467 1468
1469 - def test_tokenise8(self):
1470 """Test the generic_fns.mol_res_spin.tokenise() function on the string '@N*'.""" 1471 1472 # Tokenise. 1473 mol_token, res_token, spin_token = mol_res_spin.tokenise('@N*') 1474 1475 # Check the tokens. 1476 self.assertEqual(mol_token, None) 1477 self.assertEqual(res_token, None) 1478 self.assertEqual(spin_token, 'N*')
1479 1480
1481 - def test_tokenise_dup_atom_id_fail1(self):
1482 """Test failure of the generic_fns.mol_res_spin.tokenise() function on the string '@N@1'. 1483 1484 This tests for a duplicated atom identifier. 1485 """ 1486 1487 # Tokenise an invalid string. 1488 self.assertRaises(RelaxError, mol_res_spin.tokenise, '@N@1')
1489 1490
1491 - def test_tokenise_dup_atom_id_fail2(self):
1492 """Test failure of the generic_fns.mol_res_spin.tokenise() function on the string ':*@N@1'. 1493 1494 This tests for a duplicated atom identifier. 1495 """ 1496 1497 # Tokenise an invalid string. 1498 self.assertRaises(RelaxError, mol_res_spin.tokenise, ':*@N@1')
1499 1500
1501 - def test_tokenise_dup_atom_id_fail3(self):
1502 """Test failure of the generic_fns.mol_res_spin.tokenise() function on the string '@N:*@1'. 1503 1504 This tests for a duplicated atom identifier. 1505 """ 1506 1507 # Tokenise an invalid string. 1508 self.assertRaises(RelaxError, mol_res_spin.tokenise, '@N:*@1')
1509 1510
1511 - def test_tokenise_dup_res_id_fail1(self):
1512 """Test failure of the generic_fns.mol_res_spin.tokenise() function on the string ':1:2'. 1513 1514 This tests for a duplicated residue identifier. 1515 """ 1516 1517 # Tokenise an invalid string. 1518 self.assertRaises(RelaxError, mol_res_spin.tokenise, ':1:2')
1519 1520
1521 - def test_tokenise_dup_res_id_fail2(self):
1522 """Test failure of the generic_fns.mol_res_spin.tokenise() function on the string '#None:1:Ala'. 1523 1524 This tests for a duplicated residue identifier. 1525 """ 1526 1527 # Tokenise an invalid string. 1528 self.assertRaises(RelaxError, mol_res_spin.tokenise, '#None:1:Ala')
1529 1530
1531 - def test_tokenise_dup_res_id_fail3(self):
1532 """Test failure of the generic_fns.mol_res_spin.tokenise() function on the string ':1:Ala@N'. 1533 1534 This tests for a duplicated residue identifier. 1535 """ 1536 1537 # Tokenise an invalid string. 1538 self.assertRaises(RelaxError, mol_res_spin.tokenise, ':1:Ala@N')
1539 1540
1541 - def test_tokenise_dup_mol_id_fail1(self):
1542 """Test failure of the generic_fns.mol_res_spin.tokenise() function on the string '#A#B'. 1543 1544 This tests for a duplicated molecule identifier. 1545 """ 1546 1547 # Tokenise an invalid string. 1548 self.assertRaises(RelaxError, mol_res_spin.tokenise, '#A#B')
1549 1550
1551 - def test_tokenise_dup_mol_id_fail2(self):
1552 """Test failure of the generic_fns.mol_res_spin.tokenise() function on the string '#A#B:Leu'. 1553 1554 This tests for a duplicated molecule identifier. 1555 """ 1556 1557 # Tokenise an invalid string. 1558 self.assertRaises(RelaxError, mol_res_spin.tokenise, '#A#B:Leu')
1559 1560
1561 - def test_tokenise_dup_mol_id_fail3(self):
1562 """Test failure of the generic_fns.mol_res_spin.tokenise() function on the string '#A#C@CA'. 1563 1564 This tests for a duplicated molecule identifier. 1565 """ 1566 1567 # Tokenise an invalid string. 1568 self.assertRaises(RelaxError, mol_res_spin.tokenise, '#A#C@CA')
1569 1570
1571 - def test_tokenise_out_of_order_atom_id_fail1(self):
1572 """Test failure of the generic_fns.mol_res_spin.tokenise() function on the string '@CA#A'. 1573 1574 This tests for an out of order '@' identifier. 1575 """ 1576 1577 # Tokenise an invalid string. 1578 self.assertRaises(RelaxError, mol_res_spin.tokenise, '@CA#A')
1579 1580
1581 - def test_tokenise_out_of_order_atom_id_fail2(self):
1582 """Test failure of the generic_fns.mol_res_spin.tokenise() function on the string '@CA:Pro'. 1583 1584 This tests for an out of order '@' identifier. 1585 """ 1586 1587 # Tokenise an invalid string. 1588 self.assertRaises(RelaxError, mol_res_spin.tokenise, '@CA:Pro')
1589 1590
1591 - def test_tokenise_out_of_order_atom_id_fail3(self):
1592 """Test failure of the generic_fns.mol_res_spin.tokenise() function on the string '@CA#Z:Pro'. 1593 1594 This tests for an out of order '@' identifier. 1595 """ 1596 1597 # Tokenise an invalid string. 1598 self.assertRaises(RelaxError, mol_res_spin.tokenise, '@CA#Z:Pro')
1599 1600
1601 - def test_tokenise_out_of_order_res_id_fail1(self):
1602 """Test failure of the generic_fns.mol_res_spin.tokenise() function on the string '@CA:Pro'. 1603 1604 This tests for an out of order ':' identifier. 1605 """ 1606 1607 # Tokenise an invalid string. 1608 self.assertRaises(RelaxError, mol_res_spin.tokenise, '@CA:Pro')
1609 1610
1611 - def test_tokenise_out_of_order_res_id_fail2(self):
1612 """Test failure of the generic_fns.mol_res_spin.tokenise() function on the string ':Glu#X'. 1613 1614 This tests for an out of order ':' identifier. 1615 """ 1616 1617 # Tokenise an invalid string. 1618 self.assertRaises(RelaxError, mol_res_spin.tokenise, ':Glu#X')
1619 1620
1621 - def test_tokenise_out_of_order_res_id_fail3(self):
1622 """Test failure of the generic_fns.mol_res_spin.tokenise() function on the string '#1@12423:Glu'. 1623 1624 This tests for an out of order ':' identifier. 1625 """ 1626 1627 # Tokenise an invalid string. 1628 self.assertRaises(RelaxError, mol_res_spin.tokenise, ':Glu#X')
1629 1630
1631 - def test_tokenise_out_of_order_mol_id_fail1(self):
1632 """Test failure of the generic_fns.mol_res_spin.tokenise() function on the string ':1-160#A'. 1633 1634 This tests for an out of order '#' identifier. 1635 """ 1636 1637 # Tokenise an invalid string. 1638 self.assertRaises(RelaxError, mol_res_spin.tokenise, ':1-160#A')
1639 1640
1641 - def test_tokenise_out_of_order_mol_id_fail2(self):
1642 """Test failure of the generic_fns.mol_res_spin.tokenise() function on the string '@N,CA#A'. 1643 1644 This tests for an out of order '#' identifier. 1645 """ 1646 1647 # Tokenise an invalid string. 1648 self.assertRaises(RelaxError, mol_res_spin.tokenise, '@N,CA#A')
1649 1650
1651 - def test_tokenise_out_of_order_mol_id_fail3(self):
1652 """Test failure of the generic_fns.mol_res_spin.tokenise() function on the string '@N:-10#Zip'. 1653 1654 This tests for an out of order '#' identifier. 1655 """ 1656 1657 # Tokenise an invalid string. 1658 self.assertRaises(RelaxError, mol_res_spin.tokenise, '@N:-10#Zip')
1659 1660
1661 - def test_tokenise_bad_string_fail1(self):
1662 """Test failure of the generic_fns.mol_res_spin.tokenise() function on the string '13'. 1663 1664 This tests for an improper selection string. 1665 """ 1666 1667 # Tokenise an invalid string. 1668 self.assertRaises(RelaxError, mol_res_spin.tokenise, '13')
1669 1670
1671 - def test_tokenise_bad_string_fail2(self):
1672 """Test failure of the generic_fns.mol_res_spin.tokenise() function on the string 'XXX'. 1673 1674 This tests for an improper selection string. 1675 """ 1676 1677 # Tokenise an invalid string. 1678 self.assertRaises(RelaxError, mol_res_spin.tokenise, 'XXX')
1679 1680
1681 - def test_tokenise_bad_string_fail3(self):
1682 """Test failure of the generic_fns.mol_res_spin.tokenise() function on the string ''. 1683 1684 This tests for an improper selection string. 1685 """ 1686 1687 # Tokenise an invalid string. 1688 self.assertRaises(RelaxError, mol_res_spin.tokenise, '')
1689 1690
1691 - def test_boolean_and_selection(self):
1692 """Test boolean and in mol-res-spin selections.""" 1693 1694 # The selection loop: 1695 sel = list(mol_res_spin.residue_loop("#Ap4Aase:4 & :Pro")) 1696 1697 # Test: 1698 self.assertEqual(len(sel), 1) 1699 for res in sel: 1700 self.assert_(res.name == "Pro" and res.num == 4)
1701 1702
1703 - def test_boolean_complex_selection(self):
1704 """Test complex boolean mol-res-spin selections.""" 1705 1706 # The residue selection loop. 1707 sel = list(mol_res_spin.residue_loop("#Ap4Aase:4 & :Pro | #RNA")) 1708 1709 # Residue names and numbers. 1710 names = ['Pro', None, None] 1711 numbers = [4, -5, -4] 1712 1713 # The residues. 1714 self.assertEqual(len(sel), 3) 1715 for i in xrange(3): 1716 self.assertEqual(sel[i].name, names[i]) 1717 self.assertEqual(sel[i].num, numbers[i])
1718 1719 1720 ###################################################### 1721 # Test disabled until this functionality is enabled. # 1722 ######################################################
1723 - def xxx_test_boolean_parenthesis_selection(self):
1724 """Test complex boolean mol-res-spin selections with parenthesis.""" 1725 1726 # The selection loop: 1727 sel = list(mol_res_spin.residue_loop("(#Ap4Aase & :Pro) | (#RNA & :-4)")) 1728 1729 # Test: 1730 self.assertEqual(len(sel), 2) 1731 for res in sel: 1732 self.assert_(res.num in [-4, 4])
1733