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-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  # Python module imports. 
 23  from numpy import array 
 24   
 25  # relax module imports. 
 26  from data import Relax_data_store; ds = Relax_data_store() 
 27  from generic_fns import pipes 
 28  from generic_fns.mol_res_spin import metadata_update 
 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 # Update the metadata. 109 metadata_update()
110 111
112 - def test_copy_spin(self):
113 """Test the copying of the spin data within the same residue. 114 115 The function tested is both generic_fns.mol_res_spin.copy_spin() and 116 prompt.spin.copy(). 117 """ 118 119 # Copy the spin from the 3rd molecule. 120 self.spin_fns.copy(spin_from='#3rd:13', spin_to='#3rd:13@NE') 121 122 # Get the data pipe. 123 dp = pipes.get_pipe('orig') 124 125 # Test the original spin. 126 self.assertEqual(dp.mol[2].res[0].num, 13) 127 self.assertEqual(dp.mol[2].res[0].name, 'Gly') 128 self.assertEqual(dp.mol[2].res[0].spin[0].num, None) 129 self.assertEqual(dp.mol[2].res[0].spin[0].name, None) 130 self.assertEqual(dp.mol[2].res[0].spin[0].x, 'hello') 131 132 # Test the new spin. 133 self.assertEqual(dp.mol[2].res[0].spin[1].num, None) 134 self.assertEqual(dp.mol[2].res[0].spin[1].name, 'NE') 135 self.assertEqual(dp.mol[2].res[0].spin[1].x, 'hello')
136 137
139 """Test the copying of the spin data between different molecules. 140 141 The function tested is both generic_fns.mol_res_spin.copy_spin() and 142 prompt.spin.copy(). 143 """ 144 145 # Copy the spin 'C8' from the first molecule, first residue to the second molecule, fifth residue. 146 self.spin_fns.copy(spin_from='#Old mol:1@C8', spin_to='#New mol:5@334') 147 148 # Get the data pipe. 149 dp = pipes.get_pipe('orig') 150 151 # Test the original spin. 152 self.assertEqual(dp.mol[0].res[0].num, 1) 153 self.assertEqual(dp.mol[0].res[0].name, 'Ala') 154 self.assertEqual(dp.mol[0].res[0].spin[0].num, 111) 155 self.assertEqual(dp.mol[0].res[0].spin[0].name, 'C8') 156 self.assertEqual(dp.mol[0].res[0].spin[0].x, 1) 157 158 # Test the new spin. 159 self.assertEqual(dp.mol[1].res[0].num, 5) 160 self.assertEqual(dp.mol[1].res[0].name, 'Lys') 161 self.assertEqual(dp.mol[1].res[0].spin[0].num, 239) 162 self.assertEqual(dp.mol[1].res[0].spin[0].name, 'NH') 163 self.assertEqual(dp.mol[1].res[0].spin[1].num, 334) 164 self.assertEqual(dp.mol[1].res[0].spin[1].name, 'C8') 165 self.assertEqual(dp.mol[1].res[0].spin[1].x, 1)
166 167
169 """Test the copying of the spin data between different residues. 170 171 The function tested is both generic_fns.mol_res_spin.copy_spin() and 172 prompt.spin.copy(). 173 """ 174 175 # Copy the spin 'C8' from the first residue to the third residue. 176 self.spin_fns.copy(spin_from='#Old mol:1@C8', spin_to='#Old mol:2') 177 178 # Get the data pipe. 179 dp = pipes.get_pipe('orig') 180 181 # Test the original spin. 182 self.assertEqual(dp.mol[0].res[0].num, 1) 183 self.assertEqual(dp.mol[0].res[0].name, 'Ala') 184 self.assertEqual(dp.mol[0].res[0].spin[0].num, 111) 185 self.assertEqual(dp.mol[0].res[0].spin[0].name, 'C8') 186 self.assertEqual(dp.mol[0].res[0].spin[0].x, 1) 187 188 # Test the new spin. 189 self.assertEqual(dp.mol[0].res[1].num, 2) 190 self.assertEqual(dp.mol[0].res[1].name, 'Arg') 191 self.assertEqual(dp.mol[0].res[1].spin[0].num, 78) 192 self.assertEqual(dp.mol[0].res[1].spin[0].name, 'NH') 193 self.assertEqual(dp.mol[0].res[1].spin[1].num, 111) 194 self.assertEqual(dp.mol[0].res[1].spin[1].name, 'C8') 195 self.assertEqual(dp.mol[0].res[1].spin[1].x, 1)
196 197
199 """Test the copying of the spin data between different data pipes. 200 201 The function tested is both generic_fns.mol_res_spin.copy_spin() and 202 prompt.spin.copy(). 203 """ 204 205 # Copy the spin data. 206 self.spin_fns.copy(spin_from='#Old mol:1@C8', pipe_to='test') 207 208 # Get the data pipes. 209 dp = pipes.get_pipe('orig') 210 dp_test = pipes.get_pipe('test') 211 212 # Change the first spin's data. 213 dp.mol[0].res[0].spin[0].num = 222 214 dp.mol[0].res[0].spin[0].x = 2 215 216 # Update the metadata. 217 metadata_update() 218 219 # Test the original spin. 220 self.assertEqual(dp.mol[0].res[0].spin[0].num, 222) 221 self.assertEqual(dp.mol[0].res[0].spin[0].x, 2) 222 223 # Test the new spin. 224 self.assertEqual(dp_test.mol[0].res[0].spin[0].num, 111) 225 self.assertEqual(dp_test.mol[0].res[0].spin[0].x, 1)
226 227
229 """Test the copying of the spin data between different data pipes. 230 231 The function tested is both generic_fns.mol_res_spin.copy_spin() and 232 prompt.spin.copy(). 233 """ 234 235 # Copy the spin to the second data pipe. 236 self.assertRaises(RelaxNoPipeError, self.spin_fns.copy, spin_from='#Old mol:1@C8', pipe_to='test2')
237 238 239
240 - def test_copy_spin_fail1(self):
241 """Test the failure of the copying of the spin data of a non-existent residue. 242 243 The function tested is both generic_fns.mol_res_spin.copy_spin() and 244 prompt.spin.copy(). 245 """ 246 247 # Copy a non-existent residue (1 Met, @C8). 248 self.assertRaises(RelaxError, self.spin_fns.copy, spin_from=':Met@C8', spin_to=':2,Gly')
249 250
251 - def test_copy_spin_fail2(self):
252 """Test the failure of the copying of the spin data of a non-existent spin. 253 254 The function tested is both generic_fns.mol_res_spin.copy_spin() and 255 prompt.spin.copy(). 256 """ 257 258 # Copy a non-existent spin (1 Ala, @234). 259 self.assertRaises(RelaxError, self.spin_fns.copy, spin_from=':Ala@234', spin_to=':2,Gly')
260 261
262 - def test_copy_spin_fail3(self):
263 """Test the failure of the copying of the spin data to a non-existent residue. 264 265 The function tested is both generic_fns.mol_res_spin.copy_spin() and 266 prompt.spin.copy(). 267 """ 268 269 # Copy to a non-existent residue (3). 270 self.assertRaises(RelaxError, self.spin_fns.copy, spin_from='#Old mol:1@C8', spin_to='#Old mol:3')
271 272
273 - def test_copy_spin_fail4(self):
274 """Test the failure of the copying of the spin data to a number which already exists. 275 276 The function tested is both generic_fns.mol_res_spin.copy_spin() and 277 prompt.spin.copy(). 278 """ 279 280 # Copy a spin to a number which already exists. 281 self.assertRaises(RelaxError, self.spin_fns.copy, spin_from=':1', spin_to=':2@78')
282 283
284 - def test_create_pseudo_spin(self):
285 """Test the creation of a pseudo-atom. 286 287 The function tested is both generic_fns.mol_res_spin.create_pseudo_spin() and 288 prompt.spin.create_pseudo(). 289 """ 290 291 # Create a few new protons. 292 self.spin_fns.create(spin_num=100, spin_name='H13', res_num=1, mol_name='Old mol') 293 self.spin_fns.create(spin_num=101, spin_name='H14', res_num=1, mol_name='Old mol') 294 self.spin_fns.create(spin_num=102, spin_name='H15', res_num=1, mol_name='Old mol') 295 296 # Get the data pipe. 297 dp = pipes.get_pipe('orig') 298 299 # Set some atomic positions. 300 dp.mol[0].res[0].spin[5].pos = [array([3.0, 0.0, 0.0])] 301 dp.mol[0].res[0].spin[6].pos = [array([0.0, 3.0, 0.0])] 302 dp.mol[0].res[0].spin[7].pos = [array([0.0, 0.0, 3.0])] 303 304 # Create a pseudo-spin. 305 self.spin_fns.create_pseudo(spin_name='Q3', spin_num=105, members=['#Old mol:1@H13', '#Old mol:1@H14', '#Old mol:1@H15'], averaging='linear') 306 307 # Test that the spin numbers are correct. 308 self.assertEqual(dp.mol[0].res[0].spin[5].num, 100) 309 self.assertEqual(dp.mol[0].res[0].spin[6].num, 101) 310 self.assertEqual(dp.mol[0].res[0].spin[7].num, 102) 311 self.assertEqual(dp.mol[0].res[0].spin[8].num, 105) 312 313 # Test that the spin names are correct. 314 self.assertEqual(dp.mol[0].res[0].spin[5].name, 'H13') 315 self.assertEqual(dp.mol[0].res[0].spin[6].name, 'H14') 316 self.assertEqual(dp.mol[0].res[0].spin[7].name, 'H15') 317 self.assertEqual(dp.mol[0].res[0].spin[8].name, 'Q3') 318 319 # Test the averaged position. 320 self.assertEqual(len(dp.mol[0].res[0].spin[8].pos), 1) 321 self.assertEqual(dp.mol[0].res[0].spin[8].pos[0][0], 1.0) 322 self.assertEqual(dp.mol[0].res[0].spin[8].pos[0][1], 1.0) 323 self.assertEqual(dp.mol[0].res[0].spin[8].pos[0][2], 1.0) 324 325 # Test the pseudo-spin info. 326 self.assertEqual(dp.mol[0].res[0].spin[5].pseudo_name, '@Q3') 327 self.assertEqual(dp.mol[0].res[0].spin[5].pseudo_num, 105) 328 self.assertEqual(dp.mol[0].res[0].spin[6].pseudo_name, '@Q3') 329 self.assertEqual(dp.mol[0].res[0].spin[6].pseudo_num, 105) 330 self.assertEqual(dp.mol[0].res[0].spin[7].pseudo_name, '@Q3') 331 self.assertEqual(dp.mol[0].res[0].spin[7].pseudo_num, 105) 332 self.assertEqual(dp.mol[0].res[0].spin[8].members, ['#Old mol:1@H13', '#Old mol:1@H14', '#Old mol:1@H15']) 333 self.assertEqual(dp.mol[0].res[0].spin[8].averaging, 'linear')
334 335
336 - def test_create_pseudo_spin2(self):
337 """Test the creation of a pseudo-atom (test 2). 338 339 The function tested is both generic_fns.mol_res_spin.create_pseudo_spin() and 340 prompt.spin.create_pseudo(). 341 """ 342 343 # Create a few new protons. 344 self.spin_fns.create(spin_num=100, spin_name='H93', res_num=1, mol_name='Old mol') 345 self.spin_fns.create(spin_num=101, spin_name='H94', res_num=1, mol_name='Old mol') 346 347 # Get the data pipe. 348 dp = pipes.get_pipe('orig') 349 350 # Set some atomic positions. 351 dp.mol[0].res[0].spin[5].pos = [array([2.0, 0.0, 0.0]), array([-2.0, 0.0, 0.0])] 352 dp.mol[0].res[0].spin[6].pos = [array([0.0, 2.0, 0.0]), array([0.0, -2.0, 0.0])] 353 354 # Create a pseudo-spin. 355 self.spin_fns.create_pseudo(spin_name='Q10', spin_num=105, members=['#Old mol:1@H93', '#Old mol:1@H94'], averaging='linear') 356 357 # Test that the spin numbers are correct. 358 self.assertEqual(dp.mol[0].res[0].spin[5].num, 100) 359 self.assertEqual(dp.mol[0].res[0].spin[6].num, 101) 360 self.assertEqual(dp.mol[0].res[0].spin[7].num, 105) 361 362 # Test that the spin names are correct. 363 self.assertEqual(dp.mol[0].res[0].spin[5].name, 'H93') 364 self.assertEqual(dp.mol[0].res[0].spin[6].name, 'H94') 365 self.assertEqual(dp.mol[0].res[0].spin[7].name, 'Q10') 366 367 # Test the averaged position. 368 self.assertEqual(len(dp.mol[0].res[0].spin[7].pos), 2) 369 self.assertEqual(dp.mol[0].res[0].spin[7].pos[0][0], 1.0) 370 self.assertEqual(dp.mol[0].res[0].spin[7].pos[0][1], 1.0) 371 self.assertEqual(dp.mol[0].res[0].spin[7].pos[0][2], 0.0) 372 self.assertEqual(dp.mol[0].res[0].spin[7].pos[1][0], -1.0) 373 self.assertEqual(dp.mol[0].res[0].spin[7].pos[1][1], -1.0) 374 self.assertEqual(dp.mol[0].res[0].spin[7].pos[1][2], 0.0) 375 376 # Test the pseudo-spin info. 377 self.assertEqual(dp.mol[0].res[0].spin[5].pseudo_name, '@Q10') 378 self.assertEqual(dp.mol[0].res[0].spin[5].pseudo_num, 105) 379 self.assertEqual(dp.mol[0].res[0].spin[6].pseudo_name, '@Q10') 380 self.assertEqual(dp.mol[0].res[0].spin[6].pseudo_num, 105) 381 self.assertEqual(dp.mol[0].res[0].spin[7].members, ['#Old mol:1@H93', '#Old mol:1@H94']) 382 self.assertEqual(dp.mol[0].res[0].spin[7].averaging, 'linear')
383 384
385 - def test_create_spin(self):
386 """Test the creation of a spin. 387 388 The function tested is both generic_fns.mol_res_spin.create_spin() and 389 prompt.spin.create(). 390 """ 391 392 # Create a few new spins. 393 self.spin_fns.create(spin_num=1, spin_name='C3', res_num=1, mol_name='Old mol') 394 self.spin_fns.create(spin_num=2, spin_name='C17', res_num=1, mol_name='Old mol') 395 self.spin_fns.create(spin_num=-3, spin_name='N7', res_num=6, mol_name='New mol') 396 397 # Get the data pipe. 398 dp = pipes.get_pipe('orig') 399 400 # Test that the spin numbers are correct. 401 self.assertEqual(dp.mol[0].res[0].spin[5].num, 1) 402 self.assertEqual(dp.mol[0].res[0].spin[6].num, 2) 403 self.assertEqual(dp.mol[1].res[1].spin[2].num, -3) 404 405 # Test that the spin names are correct. 406 self.assertEqual(dp.mol[0].res[0].spin[5].name, 'C3') 407 self.assertEqual(dp.mol[0].res[0].spin[6].name, 'C17') 408 self.assertEqual(dp.mol[1].res[1].spin[2].name, 'N7')
409 410
411 - def test_create_spin_fail(self):
412 """Test the failure of spin creation (by supplying two spins with the same number). 413 414 The function tested is both generic_fns.mol_res_spin.create_spin() and 415 prompt.spin.create(). 416 """ 417 418 # Create the first spin. 419 self.spin_fns.create(spin_num=1, spin_name='P1', res_num=1, mol_name='Old mol') 420 421 # Assert that a RelaxError occurs when the next added spin has the same number as the first. 422 self.assertRaises(RelaxError, self.spin_fns.create, spin_num=1, spin_name='P3', res_num=1, mol_name='Old mol')
423 424
425 - def test_delete_spin_name(self):
426 """Test spin deletion using spin name identifiers. 427 428 The function tested is both generic_fns.mol_res_spin.delete_spin() and 429 prompt.spin.delete(). 430 """ 431 432 # Delete the first spin. 433 self.spin_fns.delete(spin_id='@C8') 434 435 # Get the data pipe. 436 dp = pipes.get_pipe('orig') 437 438 # Test that the first spin is now 6, C19. 439 self.assertEqual(dp.mol[0].res[0].spin[0].num, 6) 440 self.assertEqual(dp.mol[0].res[0].spin[0].name, 'C19') 441 self.assert_(not hasattr(dp.mol[0].res[0].spin[0], 'x'))
442 443
444 - def test_delete_spin_num(self):
445 """Test spin deletion using spin number identifiers. 446 447 The function tested is both generic_fns.mol_res_spin.delete_spin() and 448 prompt.spin.delete(). 449 """ 450 451 # Delete the first spin. 452 self.spin_fns.delete(spin_id='@C8') 453 454 # Get the data pipe. 455 dp = pipes.get_pipe('orig') 456 457 # Test that the first spin is now 6, C19. 458 self.assertEqual(dp.mol[0].res[0].spin[0].num, 6) 459 self.assertEqual(dp.mol[0].res[0].spin[0].name, 'C19') 460 self.assert_(not hasattr(dp.mol[0].res[0].spin[0], 'x'))
461 462
463 - def test_delete_spin_all(self):
464 """Test the deletion of all spins in one residue. 465 466 The function tested is both generic_fns.mol_res_spin.delete_spin() and 467 prompt.spin.delete(). 468 """ 469 470 # Delete all spins. 471 self.spin_fns.delete(spin_id='@1-200') 472 473 # Get the data pipe. 474 dp = pipes.get_pipe('orig') 475 476 # Test that the first spin defaults back to the empty spin. 477 self.assertEqual(dp.mol[0].res[0].spin[0].num, None) 478 self.assertEqual(dp.mol[0].res[0].spin[0].name, None)
479 480
481 - def test_delete_spin_shift(self):
482 """Test the deletion of multiple spins. 483 484 The function tested is both generic_fns.mol_res_spin.delete_spin() and 485 prompt.spin.delete(). 486 """ 487 488 # Delete the first and third spins. 489 self.spin_fns.delete(spin_id='@C8,7') 490 491 # Get the data pipe. 492 dp = pipes.get_pipe('orig') 493 494 # Test that the remaining spins. 495 self.assertEqual(dp.mol[0].res[0].spin[0].num, 6) 496 self.assertEqual(dp.mol[0].res[0].spin[0].name, 'C19') 497 self.assertEqual(dp.mol[0].res[0].spin[1].num, 8) 498 self.assertEqual(dp.mol[0].res[0].spin[1].name, 'C24') 499 self.assertEqual(dp.mol[0].res[0].spin[2].num, 9) 500 self.assertEqual(dp.mol[0].res[0].spin[2].name, 'C26')
501 502
503 - def test_display_spin(self):
504 """Test the display of spin information. 505 506 The function tested is both generic_fns.mol_res_spin.display_spin() and 507 prompt.spin.display(). 508 """ 509 510 # The following should all work without error. 511 self.spin_fns.display() 512 self.spin_fns.display(':1') 513 self.spin_fns.display('#Old mol:1') 514 self.spin_fns.display('#New mol:5') 515 self.spin_fns.display('#New mol:6@3239')
516 517
518 - def test_name_spin(self):
519 """Test the renaming of a spin. 520 521 The function tested is both generic_fns.mol_res_spin.name_spin() and 522 prompt.spin.name(). 523 """ 524 525 # Rename some spins. 526 self.spin_fns.name(spin_id='@C26', name='C25', force=True) 527 self.spin_fns.name(spin_id=':2@78', name='Ca', force=True) 528 self.spin_fns.name(spin_id='#New mol:6@3239', name='NHe', force=True) 529 530 # Get the data pipe. 531 dp = pipes.get_pipe('orig') 532 533 # Test that the spins have been named (and that the others have not). 534 self.assertEqual(dp.mol[0].res[0].spin[0].name, 'C8') 535 self.assertEqual(dp.mol[0].res[0].spin[1].name, 'C19') 536 self.assertEqual(dp.mol[0].res[0].spin[2].name, 'C21') 537 self.assertEqual(dp.mol[0].res[0].spin[3].name, 'C24') 538 self.assertEqual(dp.mol[0].res[0].spin[4].name, 'C25') 539 self.assertEqual(dp.mol[0].res[1].spin[0].name, 'Ca') 540 self.assertEqual(dp.mol[1].res[0].spin[0].name, 'NH') 541 self.assertEqual(dp.mol[1].res[1].spin[0].name, None) 542 self.assertEqual(dp.mol[1].res[1].spin[1].name, 'NHe')
543 544
545 - def test_name_spin_many(self):
546 """Test the renaming of multiple spins. 547 548 The function tested is both generic_fns.mol_res_spin.name_spin() and 549 prompt.spin.name(). 550 """ 551 552 # Rename all NHs. 553 self.spin_fns.name(spin_id='@NH', name='N', force=True) 554 555 # Get the data pipe. 556 dp = pipes.get_pipe('orig') 557 558 # Test the renaming of the NHs (and that the other spins have not changed). 559 self.assertEqual(dp.mol[0].res[0].spin[0].name, 'C8') 560 self.assertEqual(dp.mol[0].res[0].spin[1].name, 'C19') 561 self.assertEqual(dp.mol[0].res[0].spin[2].name, 'C21') 562 self.assertEqual(dp.mol[0].res[0].spin[3].name, 'C24') 563 self.assertEqual(dp.mol[0].res[0].spin[4].name, 'C26') 564 self.assertEqual(dp.mol[0].res[1].spin[0].name, 'N') 565 self.assertEqual(dp.mol[1].res[0].spin[0].name, 'N') 566 self.assertEqual(dp.mol[1].res[1].spin[0].name, None) 567 self.assertEqual(dp.mol[1].res[1].spin[1].name, 'N')
568 569
570 - def test_number_spin(self):
571 """Test the numbering of a spin. 572 573 The function tested is both generic_fns.mol_res_spin.number_spin() and 574 prompt.spin.number(). 575 """ 576 577 # Rename a few spins. 578 self.spin_fns.number(spin_id='@C8', number=1, force=True) 579 self.spin_fns.number(spin_id='@6', number=2, force=True) 580 self.spin_fns.number(spin_id='@7', number=3, force=True) 581 self.spin_fns.number(spin_id='@8', number=4, force=True) 582 self.spin_fns.number(spin_id='@9', number=5, force=True) 583 self.spin_fns.number(spin_id='@78', number=6, force=True) 584 self.spin_fns.number(spin_id='@239', number=7, force=True) 585 self.spin_fns.number(spin_id='@3239', number=9, force=True) 586 587 # Get the data pipe. 588 dp = pipes.get_pipe('orig') 589 590 # Test that the spins have been numbered. 591 self.assertEqual(dp.mol[0].res[0].spin[0].num, 1) 592 self.assertEqual(dp.mol[0].res[0].spin[1].num, 2) 593 self.assertEqual(dp.mol[0].res[0].spin[2].num, 3) 594 self.assertEqual(dp.mol[0].res[0].spin[3].num, 4) 595 self.assertEqual(dp.mol[0].res[0].spin[4].num, 5) 596 self.assertEqual(dp.mol[0].res[1].spin[0].num, 6) 597 self.assertEqual(dp.mol[1].res[0].spin[0].num, 7) 598 self.assertEqual(dp.mol[1].res[1].spin[1].num, 9)
599 600
602 """Test the renaming of multiple spins. 603 604 The function tested is both generic_fns.mol_res_spin.number_spin() and 605 prompt.spin.number(). 606 """ 607 608 # Try numbering all NHs. 609 self.assertRaises(RelaxError, self.spin_fns.number, spin_id='@NH', number=-6)
610