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