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

Source Code for Module test_suite.unit_tests.spin_testing_base

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2007-2011 Edward d'Auvergne                                   # 
  4  #                                                                             # 
  5  # This file is part of the program relax.                                     # 
  6  #                                                                             # 
  7  # relax is free software; you can redistribute it and/or modify               # 
  8  # it under the terms of the GNU General Public License as published by        # 
  9  # the Free Software Foundation; either version 2 of the License, or           # 
 10  # (at your option) any later version.                                         # 
 11  #                                                                             # 
 12  # relax is distributed in the hope that it will be useful,                    # 
 13  # but WITHOUT ANY WARRANTY; without even the implied warranty of              # 
 14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               # 
 15  # GNU General Public License for more details.                                # 
 16  #                                                                             # 
 17  # You should have received a copy of the GNU General Public License           # 
 18  # along with relax; if not, write to the Free Software                        # 
 19  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   # 
 20  #                                                                             # 
 21  ############################################################################### 
 22   
 23  # Python module imports. 
 24  from numpy import array 
 25   
 26  # relax module imports. 
 27  from data import Relax_data_store; ds = Relax_data_store() 
 28  from generic_fns import pipes 
 29  from relax_errors import RelaxError, RelaxNoPipeError 
 30  from test_suite.unit_tests.base_classes import UnitTestCase 
 31   
 32   
33 -class Spin_base_class(UnitTestCase):
34 """Testing base class for 'prompt.spin' and corresponding 'generic_fns.mol_res_spin' fns. 35 36 This base class also contains many shared unit tests. 37 """ 38
39 - def setUp(self):
40 """Set up for all the spin unit tests. 41 42 The data contained within the 'orig' data pipe is: 43 44 ID Molecule Res number Res name Spin number Spin name 45 0,0,0 Old mol 1 Ala 111 C8 46 0,0,1 Old mol 1 Ala 6 C19 47 0,0,2 Old mol 1 Ala 7 C21 48 0,0,3 Old mol 1 Ala 8 C24 49 0,0,4 Old mol 1 Ala 9 C26 50 0,1,0 Old mol 2 Arg 78 NH 51 1,0,0 New mol 5 Lys 239 NH 52 1,1,0 New mol 6 Thr None None 53 1,1,1 New mol 6 Thr 3239 NH 54 55 The IDs correspond to the molecule, residue and spin indices. 56 """ 57 58 # Add a data pipe to the data store. 59 ds.add(pipe_name='orig', pipe_type='mf') 60 61 # Add a second data pipe for copying tests. 62 ds.add(pipe_name='test', pipe_type='mf') 63 64 # Set the current data pipe to 'orig'. 65 pipes.switch('orig') 66 67 # Name the first molecule. 68 cdp.mol[0].name = 'Old mol' 69 70 # Create the first residue and add some data to its spin container. 71 cdp.mol[0].res[0].num = 1 72 cdp.mol[0].res[0].name = 'Ala' 73 cdp.mol[0].res[0].spin[0].num = 111 74 cdp.mol[0].res[0].spin[0].name = 'C8' 75 cdp.mol[0].res[0].spin[0].x = 1 76 77 # Add some more spins. 78 cdp.mol[0].res[0].spin.add_item('C19', 6) 79 cdp.mol[0].res[0].spin.add_item('C21', 7) 80 cdp.mol[0].res[0].spin.add_item('C24', 8) 81 cdp.mol[0].res[0].spin.add_item('C26', 9) 82 83 # Create a second residue. 84 cdp.mol[0].res.add_item('Arg', 2) 85 cdp.mol[0].res[1].spin[0].num = 78 86 cdp.mol[0].res[1].spin[0].name = 'NH' 87 88 # Create a second molecule. 89 cdp.mol.add_item('New mol') 90 91 # Create the first and second residue of the second molecule and add some data to its spin container. 92 cdp.mol[1].res[0].num = 5 93 cdp.mol[1].res[0].name = 'Lys' 94 cdp.mol[1].res[0].spin[0].num = 239 95 cdp.mol[1].res[0].spin[0].name = 'NH' 96 cdp.mol[1].res.add_item('Thr', 6) 97 cdp.mol[1].res[1].spin.add_item(None, 1433) 98 cdp.mol[1].res[1].spin.add_item('NH', 3239) 99 100 # Create a third molecule. 101 cdp.mol.add_item('3rd') 102 103 # Create the first residue of the 3rd molecule and add some data to its spin container. 104 cdp.mol[2].res[0].num = 13 105 cdp.mol[2].res[0].name = 'Gly' 106 cdp.mol[2].res[0].spin[0].x = 'hello'
107 108
109 - def test_copy_spin(self):
110 """Test the copying of the spin data within the same residue. 111 112 The function tested is both generic_fns.mol_res_spin.copy_spin() and 113 prompt.spin.copy(). 114 """ 115 116 # Copy the spin from the 3rd molecule. 117 self.spin_fns.copy(spin_from='#3rd:13', spin_to='#3rd:13@NE') 118 119 # Get the data pipe. 120 dp = pipes.get_pipe('orig') 121 122 # Test the original spin. 123 self.assertEqual(dp.mol[2].res[0].num, 13) 124 self.assertEqual(dp.mol[2].res[0].name, 'Gly') 125 self.assertEqual(dp.mol[2].res[0].spin[0].num, None) 126 self.assertEqual(dp.mol[2].res[0].spin[0].name, None) 127 self.assertEqual(dp.mol[2].res[0].spin[0].x, 'hello') 128 129 # Test the new spin. 130 self.assertEqual(dp.mol[2].res[0].spin[1].num, None) 131 self.assertEqual(dp.mol[2].res[0].spin[1].name, 'NE') 132 self.assertEqual(dp.mol[2].res[0].spin[1].x, 'hello')
133 134
136 """Test the copying of the spin data between different molecules. 137 138 The function tested is both generic_fns.mol_res_spin.copy_spin() and 139 prompt.spin.copy(). 140 """ 141 142 # Copy the spin '111' from the first molecule, first residue to the second molecule, fifth residue. 143 self.spin_fns.copy(spin_from='#Old mol:1@111', spin_to='#New mol:5@334') 144 145 # Get the data pipe. 146 dp = pipes.get_pipe('orig') 147 148 # Test the original spin. 149 self.assertEqual(dp.mol[0].res[0].num, 1) 150 self.assertEqual(dp.mol[0].res[0].name, 'Ala') 151 self.assertEqual(dp.mol[0].res[0].spin[0].num, 111) 152 self.assertEqual(dp.mol[0].res[0].spin[0].name, 'C8') 153 self.assertEqual(dp.mol[0].res[0].spin[0].x, 1) 154 155 # Test the new spin. 156 self.assertEqual(dp.mol[1].res[0].num, 5) 157 self.assertEqual(dp.mol[1].res[0].name, 'Lys') 158 self.assertEqual(dp.mol[1].res[0].spin[0].num, 239) 159 self.assertEqual(dp.mol[1].res[0].spin[0].name, 'NH') 160 self.assertEqual(dp.mol[1].res[0].spin[1].num, 334) 161 self.assertEqual(dp.mol[1].res[0].spin[1].name, 'C8') 162 self.assertEqual(dp.mol[1].res[0].spin[1].x, 1)
163 164
166 """Test the copying of the spin data between different residues. 167 168 The function tested is both generic_fns.mol_res_spin.copy_spin() and 169 prompt.spin.copy(). 170 """ 171 172 # Copy the spin '111' from the first residue to the third residue. 173 self.spin_fns.copy(spin_from='#Old mol:1@111', spin_to='#Old mol:2') 174 175 # Get the data pipe. 176 dp = pipes.get_pipe('orig') 177 178 # Test the original spin. 179 self.assertEqual(dp.mol[0].res[0].num, 1) 180 self.assertEqual(dp.mol[0].res[0].name, 'Ala') 181 self.assertEqual(dp.mol[0].res[0].spin[0].num, 111) 182 self.assertEqual(dp.mol[0].res[0].spin[0].name, 'C8') 183 self.assertEqual(dp.mol[0].res[0].spin[0].x, 1) 184 185 # Test the new spin. 186 self.assertEqual(dp.mol[0].res[1].num, 2) 187 self.assertEqual(dp.mol[0].res[1].name, 'Arg') 188 self.assertEqual(dp.mol[0].res[1].spin[0].num, 78) 189 self.assertEqual(dp.mol[0].res[1].spin[0].name, 'NH') 190 self.assertEqual(dp.mol[0].res[1].spin[1].num, 111) 191 self.assertEqual(dp.mol[0].res[1].spin[1].name, 'C8') 192 self.assertEqual(dp.mol[0].res[1].spin[1].x, 1)
193 194
196 """Test the copying of the spin data between different data pipes. 197 198 The function tested is both generic_fns.mol_res_spin.copy_spin() and 199 prompt.spin.copy(). 200 """ 201 202 # Copy the spin data. 203 self.spin_fns.copy(spin_from='#Old mol:1@111', pipe_to='test') 204 205 # Get the data pipes. 206 dp = pipes.get_pipe('orig') 207 dp_test = pipes.get_pipe('test') 208 209 # Change the first spin's data. 210 dp.mol[0].res[0].spin[0].num = 222 211 dp.mol[0].res[0].spin[0].x = 2 212 213 # Test the original spin. 214 self.assertEqual(dp.mol[0].res[0].spin[0].num, 222) 215 self.assertEqual(dp.mol[0].res[0].spin[0].x, 2) 216 217 # Test the new spin. 218 self.assertEqual(dp_test.mol[0].res[0].spin[0].num, 111) 219 self.assertEqual(dp_test.mol[0].res[0].spin[0].x, 1)
220 221
223 """Test the copying of the spin data between different data pipes. 224 225 The function tested is both generic_fns.mol_res_spin.copy_spin() and 226 prompt.spin.copy(). 227 """ 228 229 # Copy the spin to the second data pipe. 230 self.assertRaises(RelaxNoPipeError, self.spin_fns.copy, spin_from='#Old mol:1@111', pipe_to='test2')
231 232 233
234 - def test_copy_spin_fail1(self):
235 """Test the failure of the copying of the spin data of a non-existent residue. 236 237 The function tested is both generic_fns.mol_res_spin.copy_spin() and 238 prompt.spin.copy(). 239 """ 240 241 # Copy a non-existent residue (1 Met, @111). 242 self.assertRaises(RelaxError, self.spin_fns.copy, spin_from=':Met@111', spin_to=':2,Gly')
243 244
245 - def test_copy_spin_fail2(self):
246 """Test the failure of the copying of the spin data of a non-existent spin. 247 248 The function tested is both generic_fns.mol_res_spin.copy_spin() and 249 prompt.spin.copy(). 250 """ 251 252 # Copy a non-existent spin (1 Ala, @234). 253 self.assertRaises(RelaxError, self.spin_fns.copy, spin_from=':Ala@234', spin_to=':2,Gly')
254 255
256 - def test_copy_spin_fail3(self):
257 """Test the failure of the copying of the spin data to a non-existent residue. 258 259 The function tested is both generic_fns.mol_res_spin.copy_spin() and 260 prompt.spin.copy(). 261 """ 262 263 # Copy to a non-existent residue (3). 264 self.assertRaises(RelaxError, self.spin_fns.copy, spin_from='#Old mol:1@111', spin_to='#Old mol:3')
265 266
267 - def test_copy_spin_fail4(self):
268 """Test the failure of the copying of the spin data to a number which already exists. 269 270 The function tested is both generic_fns.mol_res_spin.copy_spin() and 271 prompt.spin.copy(). 272 """ 273 274 # Copy a spin to a number which already exists. 275 self.assertRaises(RelaxError, self.spin_fns.copy, spin_from=':1', spin_to=':2@78')
276 277
278 - def test_create_pseudo_spin(self):
279 """Test the creation of a pseudo-atom. 280 281 The function tested is both generic_fns.mol_res_spin.create_pseudo_spin() and 282 prompt.spin.create_pseudo(). 283 """ 284 285 # Create a few new protons. 286 self.spin_fns.create(100, 'H13', res_num=1, mol_name='Old mol') 287 self.spin_fns.create(101, 'H14', res_num=1, mol_name='Old mol') 288 self.spin_fns.create(102, 'H15', res_num=1, mol_name='Old mol') 289 290 # Get the data pipe. 291 dp = pipes.get_pipe('orig') 292 293 # Set some atomic positions. 294 dp.mol[0].res[0].spin[5].pos = [array([3.0, 0.0, 0.0])] 295 dp.mol[0].res[0].spin[6].pos = [array([0.0, 3.0, 0.0])] 296 dp.mol[0].res[0].spin[7].pos = [array([0.0, 0.0, 3.0])] 297 298 # Create a pseudo-spin. 299 self.spin_fns.create_pseudo('Q3', spin_num=105, members=['@H13', '@H14', '@H15'], averaging='linear') 300 301 # Test that the spin numbers are correct. 302 self.assertEqual(dp.mol[0].res[0].spin[5].num, 100) 303 self.assertEqual(dp.mol[0].res[0].spin[6].num, 101) 304 self.assertEqual(dp.mol[0].res[0].spin[7].num, 102) 305 self.assertEqual(dp.mol[0].res[0].spin[8].num, 105) 306 307 # Test that the spin names are correct. 308 self.assertEqual(dp.mol[0].res[0].spin[5].name, 'H13') 309 self.assertEqual(dp.mol[0].res[0].spin[6].name, 'H14') 310 self.assertEqual(dp.mol[0].res[0].spin[7].name, 'H15') 311 self.assertEqual(dp.mol[0].res[0].spin[8].name, 'Q3') 312 313 # Test the averaged position. 314 self.assertEqual(len(dp.mol[0].res[0].spin[8].pos), 1) 315 self.assertEqual(dp.mol[0].res[0].spin[8].pos[0][0], 1.0) 316 self.assertEqual(dp.mol[0].res[0].spin[8].pos[0][1], 1.0) 317 self.assertEqual(dp.mol[0].res[0].spin[8].pos[0][2], 1.0) 318 319 # Test the pseudo-spin info. 320 self.assertEqual(dp.mol[0].res[0].spin[5].pseudo_name, '@Q3') 321 self.assertEqual(dp.mol[0].res[0].spin[5].pseudo_num, 105) 322 self.assertEqual(dp.mol[0].res[0].spin[6].pseudo_name, '@Q3') 323 self.assertEqual(dp.mol[0].res[0].spin[6].pseudo_num, 105) 324 self.assertEqual(dp.mol[0].res[0].spin[7].pseudo_name, '@Q3') 325 self.assertEqual(dp.mol[0].res[0].spin[7].pseudo_num, 105) 326 self.assertEqual(dp.mol[0].res[0].spin[8].members, ['@H13', '@H14', '@H15']) 327 self.assertEqual(dp.mol[0].res[0].spin[8].averaging, 'linear')
328 329
330 - def test_create_pseudo_spin2(self):
331 """Test the creation of a pseudo-atom (test 2). 332 333 The function tested is both generic_fns.mol_res_spin.create_pseudo_spin() and 334 prompt.spin.create_pseudo(). 335 """ 336 337 # Create a few new protons. 338 self.spin_fns.create(100, 'H93', res_num=1, mol_name='Old mol') 339 self.spin_fns.create(101, 'H94', res_num=1, mol_name='Old mol') 340 341 # Get the data pipe. 342 dp = pipes.get_pipe('orig') 343 344 # Set some atomic positions. 345 dp.mol[0].res[0].spin[5].pos = [array([2.0, 0.0, 0.0]), array([-2.0, 0.0, 0.0])] 346 dp.mol[0].res[0].spin[6].pos = [array([0.0, 2.0, 0.0]), array([0.0, -2.0, 0.0])] 347 348 # Create a pseudo-spin. 349 self.spin_fns.create_pseudo('Q10', spin_num=105, members=['@H93', '@H94'], averaging='linear') 350 351 # Test that the spin numbers are correct. 352 self.assertEqual(dp.mol[0].res[0].spin[5].num, 100) 353 self.assertEqual(dp.mol[0].res[0].spin[6].num, 101) 354 self.assertEqual(dp.mol[0].res[0].spin[7].num, 105) 355 356 # Test that the spin names are correct. 357 self.assertEqual(dp.mol[0].res[0].spin[5].name, 'H93') 358 self.assertEqual(dp.mol[0].res[0].spin[6].name, 'H94') 359 self.assertEqual(dp.mol[0].res[0].spin[7].name, 'Q10') 360 361 # Test the averaged position. 362 self.assertEqual(len(dp.mol[0].res[0].spin[7].pos), 2) 363 self.assertEqual(dp.mol[0].res[0].spin[7].pos[0][0], 1.0) 364 self.assertEqual(dp.mol[0].res[0].spin[7].pos[0][1], 1.0) 365 self.assertEqual(dp.mol[0].res[0].spin[7].pos[0][2], 0.0) 366 self.assertEqual(dp.mol[0].res[0].spin[7].pos[1][0], -1.0) 367 self.assertEqual(dp.mol[0].res[0].spin[7].pos[1][1], -1.0) 368 self.assertEqual(dp.mol[0].res[0].spin[7].pos[1][2], 0.0) 369 370 # Test the pseudo-spin info. 371 self.assertEqual(dp.mol[0].res[0].spin[5].pseudo_name, '@Q10') 372 self.assertEqual(dp.mol[0].res[0].spin[5].pseudo_num, 105) 373 self.assertEqual(dp.mol[0].res[0].spin[6].pseudo_name, '@Q10') 374 self.assertEqual(dp.mol[0].res[0].spin[6].pseudo_num, 105) 375 self.assertEqual(dp.mol[0].res[0].spin[7].members, ['@H93', '@H94']) 376 self.assertEqual(dp.mol[0].res[0].spin[7].averaging, 'linear')
377 378
379 - def test_create_spin(self):
380 """Test the creation of a spin. 381 382 The function tested is both generic_fns.mol_res_spin.create_spin() and 383 prompt.spin.create(). 384 """ 385 386 # Create a few new spins. 387 self.spin_fns.create(1, 'C3', res_num=1, mol_name='Old mol') 388 self.spin_fns.create(2, 'C17', res_num=1, mol_name='Old mol') 389 self.spin_fns.create(-3, 'N7', res_num=6, mol_name='New mol') 390 391 # Get the data pipe. 392 dp = pipes.get_pipe('orig') 393 394 # Test that the spin numbers are correct. 395 self.assertEqual(dp.mol[0].res[0].spin[5].num, 1) 396 self.assertEqual(dp.mol[0].res[0].spin[6].num, 2) 397 self.assertEqual(dp.mol[1].res[1].spin[2].num, -3) 398 399 # Test that the spin names are correct. 400 self.assertEqual(dp.mol[0].res[0].spin[5].name, 'C3') 401 self.assertEqual(dp.mol[0].res[0].spin[6].name, 'C17') 402 self.assertEqual(dp.mol[1].res[1].spin[2].name, 'N7')
403 404
405 - def test_create_spin_fail(self):
406 """Test the failure of spin creation (by supplying two spins with the same number). 407 408 The function tested is both generic_fns.mol_res_spin.create_spin() and 409 prompt.spin.create(). 410 """ 411 412 # Create the first spin. 413 self.spin_fns.create(1, 'P1', res_num=1, mol_name='Old mol') 414 415 # Assert that a RelaxError occurs when the next added spin has the same number as the first. 416 self.assertRaises(RelaxError, self.spin_fns.create, 1, 'P3', res_num=1, mol_name='Old mol')
417 418
419 - def test_delete_spin_name(self):
420 """Test spin deletion using spin name identifiers. 421 422 The function tested is both generic_fns.mol_res_spin.delete_spin() and 423 prompt.spin.delete(). 424 """ 425 426 # Delete the first spin. 427 self.spin_fns.delete(spin_id='@C8') 428 429 # Get the data pipe. 430 dp = pipes.get_pipe('orig') 431 432 # Test that the first spin is now 6, C19. 433 self.assertEqual(dp.mol[0].res[0].spin[0].num, 6) 434 self.assertEqual(dp.mol[0].res[0].spin[0].name, 'C19') 435 self.assert_(not hasattr(dp.mol[0].res[0].spin[0], 'x'))
436 437
438 - def test_delete_spin_num(self):
439 """Test spin deletion using spin number identifiers. 440 441 The function tested is both generic_fns.mol_res_spin.delete_spin() and 442 prompt.spin.delete(). 443 """ 444 445 # Delete the first spin. 446 self.spin_fns.delete(spin_id='@111') 447 448 # Get the data pipe. 449 dp = pipes.get_pipe('orig') 450 451 # Test that the first spin is now 6, C19. 452 self.assertEqual(dp.mol[0].res[0].spin[0].num, 6) 453 self.assertEqual(dp.mol[0].res[0].spin[0].name, 'C19') 454 self.assert_(not hasattr(dp.mol[0].res[0].spin[0], 'x'))
455 456
457 - def test_delete_spin_all(self):
458 """Test the deletion of all spins in one residue. 459 460 The function tested is both generic_fns.mol_res_spin.delete_spin() and 461 prompt.spin.delete(). 462 """ 463 464 # Delete all spins. 465 self.spin_fns.delete(spin_id='@1-200') 466 467 # Get the data pipe. 468 dp = pipes.get_pipe('orig') 469 470 # Test that the first spin defaults back to the empty spin. 471 self.assertEqual(dp.mol[0].res[0].spin[0].num, None) 472 self.assertEqual(dp.mol[0].res[0].spin[0].name, None)
473 474
475 - def test_delete_spin_shift(self):
476 """Test the deletion of multiple spins. 477 478 The function tested is both generic_fns.mol_res_spin.delete_spin() and 479 prompt.spin.delete(). 480 """ 481 482 # Delete the first and third spins. 483 self.spin_fns.delete(spin_id='@111,7') 484 485 # Get the data pipe. 486 dp = pipes.get_pipe('orig') 487 488 # Test that the remaining spins. 489 self.assertEqual(dp.mol[0].res[0].spin[0].num, 6) 490 self.assertEqual(dp.mol[0].res[0].spin[0].name, 'C19') 491 self.assertEqual(dp.mol[0].res[0].spin[1].num, 8) 492 self.assertEqual(dp.mol[0].res[0].spin[1].name, 'C24') 493 self.assertEqual(dp.mol[0].res[0].spin[2].num, 9) 494 self.assertEqual(dp.mol[0].res[0].spin[2].name, 'C26')
495 496
497 - def test_display_spin(self):
498 """Test the display of spin information. 499 500 The function tested is both generic_fns.mol_res_spin.display_spin() and 501 prompt.spin.display(). 502 """ 503 504 # The following should all work without error. 505 self.spin_fns.display() 506 self.spin_fns.display(':1') 507 self.spin_fns.display('#Old mol:1') 508 self.spin_fns.display('#New mol:5') 509 self.spin_fns.display('#New mol:6@3239')
510 511
512 - def test_name_spin(self):
513 """Test the renaming of a spin. 514 515 The function tested is both generic_fns.mol_res_spin.name_spin() and 516 prompt.spin.name(). 517 """ 518 519 # Rename some spins. 520 self.spin_fns.name(spin_id='@C26', name='C25', force=True) 521 self.spin_fns.name(spin_id=':2@78', name='Ca', force=True) 522 self.spin_fns.name(spin_id='#New mol:6@3239', name='NHe', force=True) 523 524 # Get the data pipe. 525 dp = pipes.get_pipe('orig') 526 527 # Test that the spins have been named (and that the others have not). 528 self.assertEqual(dp.mol[0].res[0].spin[0].name, 'C8') 529 self.assertEqual(dp.mol[0].res[0].spin[1].name, 'C19') 530 self.assertEqual(dp.mol[0].res[0].spin[2].name, 'C21') 531 self.assertEqual(dp.mol[0].res[0].spin[3].name, 'C24') 532 self.assertEqual(dp.mol[0].res[0].spin[4].name, 'C25') 533 self.assertEqual(dp.mol[0].res[1].spin[0].name, 'Ca') 534 self.assertEqual(dp.mol[1].res[0].spin[0].name, 'NH') 535 self.assertEqual(dp.mol[1].res[1].spin[0].name, None) 536 self.assertEqual(dp.mol[1].res[1].spin[1].name, 'NHe')
537 538
539 - def test_name_spin_many(self):
540 """Test the renaming of multiple spins. 541 542 The function tested is both generic_fns.mol_res_spin.name_spin() and 543 prompt.spin.name(). 544 """ 545 546 # Rename all NHs. 547 self.spin_fns.name(spin_id='@NH', name='N', force=True) 548 549 # Get the data pipe. 550 dp = pipes.get_pipe('orig') 551 552 # Test the renaming of the NHs (and that the other spins have not changed). 553 self.assertEqual(dp.mol[0].res[0].spin[0].name, 'C8') 554 self.assertEqual(dp.mol[0].res[0].spin[1].name, 'C19') 555 self.assertEqual(dp.mol[0].res[0].spin[2].name, 'C21') 556 self.assertEqual(dp.mol[0].res[0].spin[3].name, 'C24') 557 self.assertEqual(dp.mol[0].res[0].spin[4].name, 'C26') 558 self.assertEqual(dp.mol[0].res[1].spin[0].name, 'N') 559 self.assertEqual(dp.mol[1].res[0].spin[0].name, 'N') 560 self.assertEqual(dp.mol[1].res[1].spin[0].name, None) 561 self.assertEqual(dp.mol[1].res[1].spin[1].name, 'N')
562 563
564 - def test_number_spin(self):
565 """Test the numbering of a spin. 566 567 The function tested is both generic_fns.mol_res_spin.number_spin() and 568 prompt.spin.number(). 569 """ 570 571 # Rename a few spins. 572 self.spin_fns.number(spin_id='@111', number=1, force=True) 573 self.spin_fns.number(spin_id='@6', number=2, force=True) 574 self.spin_fns.number(spin_id='@7', number=3, force=True) 575 self.spin_fns.number(spin_id='@8', number=4, force=True) 576 self.spin_fns.number(spin_id='@9', number=5, force=True) 577 self.spin_fns.number(spin_id='@78', number=6, force=True) 578 self.spin_fns.number(spin_id='@239', number=7, force=True) 579 self.spin_fns.number(spin_id='@3239', number=9, force=True) 580 581 # Get the data pipe. 582 dp = pipes.get_pipe('orig') 583 584 # Test that the spins have been numbered. 585 self.assertEqual(dp.mol[0].res[0].spin[0].num, 1) 586 self.assertEqual(dp.mol[0].res[0].spin[1].num, 2) 587 self.assertEqual(dp.mol[0].res[0].spin[2].num, 3) 588 self.assertEqual(dp.mol[0].res[0].spin[3].num, 4) 589 self.assertEqual(dp.mol[0].res[0].spin[4].num, 5) 590 self.assertEqual(dp.mol[0].res[1].spin[0].num, 6) 591 self.assertEqual(dp.mol[1].res[0].spin[0].num, 7) 592 self.assertEqual(dp.mol[1].res[1].spin[1].num, 9)
593 594
596 """Test the renaming of multiple spins. 597 598 The function tested is both generic_fns.mol_res_spin.number_spin() and 599 prompt.spin.number(). 600 """ 601 602 # Try numbering all NHs. 603 self.assertRaises(RelaxError, self.spin_fns.number, spin_id='@NH', number=-6)
604