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-2013 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_store import Relax_data_store; ds = Relax_data_store() 
 27  from pipe_control import pipes 
 28  from pipe_control.mol_res_spin import metadata_update 
 29  from lib.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 'pipe_control.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 pipe_control.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 pipe_control.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 pipe_control.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 pipe_control.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 pipe_control.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 pipe_control.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 pipe_control.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 pipe_control.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 pipe_control.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 pipe_control.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 pipe_control.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 pipe_control.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 name and number). 413 414 The function tested is both pipe_control.mol_res_spin.create_spin() and prompt.spin.create(). 415 """ 416 417 # Create the first spin. 418 self.spin_fns.create(spin_num=1, spin_name='P1', res_num=1, mol_name='Old mol') 419 420 # Assert that a RelaxError occurs when the next added spin has the same number as the first. 421 self.assertRaises(RelaxError, self.spin_fns.create, spin_num=1, spin_name='P1', res_num=1, mol_name='Old mol')
422 423
424 - def test_delete_spin_name(self):
425 """Test spin deletion using spin name identifiers. 426 427 The function tested is both pipe_control.mol_res_spin.delete_spin() and 428 prompt.spin.delete(). 429 """ 430 431 # Delete the first spin. 432 self.spin_fns.delete(spin_id='@C8') 433 434 # Get the data pipe. 435 dp = pipes.get_pipe('orig') 436 437 # Test that the first spin is now 6, C19. 438 self.assertEqual(dp.mol[0].res[0].spin[0].num, 6) 439 self.assertEqual(dp.mol[0].res[0].spin[0].name, 'C19') 440 self.assert_(not hasattr(dp.mol[0].res[0].spin[0], 'x'))
441 442
443 - def test_delete_spin_num(self):
444 """Test spin deletion using spin number identifiers. 445 446 The function tested is both pipe_control.mol_res_spin.delete_spin() and 447 prompt.spin.delete(). 448 """ 449 450 # Delete the first spin. 451 self.spin_fns.delete(spin_id='@C8') 452 453 # Get the data pipe. 454 dp = pipes.get_pipe('orig') 455 456 # Test that the first spin is now 6, C19. 457 self.assertEqual(dp.mol[0].res[0].spin[0].num, 6) 458 self.assertEqual(dp.mol[0].res[0].spin[0].name, 'C19') 459 self.assert_(not hasattr(dp.mol[0].res[0].spin[0], 'x'))
460 461
462 - def test_delete_spin_all(self):
463 """Test the deletion of all spins in one residue. 464 465 The function tested is both pipe_control.mol_res_spin.delete_spin() and 466 prompt.spin.delete(). 467 """ 468 469 # Delete all spins. 470 self.spin_fns.delete(spin_id='@1-200') 471 472 # Get the data pipe. 473 dp = pipes.get_pipe('orig') 474 475 # Test that the first spin defaults back to the empty spin. 476 self.assertEqual(dp.mol[0].res[0].spin[0].num, None) 477 self.assertEqual(dp.mol[0].res[0].spin[0].name, None)
478 479
480 - def test_delete_spin_shift(self):
481 """Test the deletion of multiple spins. 482 483 The function tested is both pipe_control.mol_res_spin.delete_spin() and 484 prompt.spin.delete(). 485 """ 486 487 # Delete the first and third spins. 488 self.spin_fns.delete(spin_id='@C8,7') 489 490 # Get the data pipe. 491 dp = pipes.get_pipe('orig') 492 493 # Test that the remaining spins. 494 self.assertEqual(dp.mol[0].res[0].spin[0].num, 6) 495 self.assertEqual(dp.mol[0].res[0].spin[0].name, 'C19') 496 self.assertEqual(dp.mol[0].res[0].spin[1].num, 8) 497 self.assertEqual(dp.mol[0].res[0].spin[1].name, 'C24') 498 self.assertEqual(dp.mol[0].res[0].spin[2].num, 9) 499 self.assertEqual(dp.mol[0].res[0].spin[2].name, 'C26')
500 501
502 - def test_display_spin(self):
503 """Test the display of spin information. 504 505 The function tested is both pipe_control.mol_res_spin.display_spin() and 506 prompt.spin.display(). 507 """ 508 509 # The following should all work without error. 510 self.spin_fns.display() 511 self.spin_fns.display(':1') 512 self.spin_fns.display('#Old mol:1') 513 self.spin_fns.display('#New mol:5') 514 self.spin_fns.display('#New mol:6@3239')
515 516
517 - def test_name_spin(self):
518 """Test the renaming of a spin. 519 520 The function tested is both pipe_control.mol_res_spin.name_spin() and 521 prompt.spin.name(). 522 """ 523 524 # Rename some spins. 525 self.spin_fns.name(spin_id='@C26', name='C25', force=True) 526 self.spin_fns.name(spin_id=':2@78', name='Ca', force=True) 527 self.spin_fns.name(spin_id='#New mol:6@3239', name='NHe', force=True) 528 529 # Get the data pipe. 530 dp = pipes.get_pipe('orig') 531 532 # Test that the spins have been named (and that the others have not). 533 self.assertEqual(dp.mol[0].res[0].spin[0].name, 'C8') 534 self.assertEqual(dp.mol[0].res[0].spin[1].name, 'C19') 535 self.assertEqual(dp.mol[0].res[0].spin[2].name, 'C21') 536 self.assertEqual(dp.mol[0].res[0].spin[3].name, 'C24') 537 self.assertEqual(dp.mol[0].res[0].spin[4].name, 'C25') 538 self.assertEqual(dp.mol[0].res[1].spin[0].name, 'Ca') 539 self.assertEqual(dp.mol[1].res[0].spin[0].name, 'NH') 540 self.assertEqual(dp.mol[1].res[1].spin[0].name, None) 541 self.assertEqual(dp.mol[1].res[1].spin[1].name, 'NHe')
542 543
544 - def test_name_spin_many(self):
545 """Test the renaming of multiple spins. 546 547 The function tested is both pipe_control.mol_res_spin.name_spin() and 548 prompt.spin.name(). 549 """ 550 551 # Rename all NHs. 552 self.spin_fns.name(spin_id='@NH', name='N', force=True) 553 554 # Get the data pipe. 555 dp = pipes.get_pipe('orig') 556 557 # Test the renaming of the NHs (and that the other spins have not changed). 558 self.assertEqual(dp.mol[0].res[0].spin[0].name, 'C8') 559 self.assertEqual(dp.mol[0].res[0].spin[1].name, 'C19') 560 self.assertEqual(dp.mol[0].res[0].spin[2].name, 'C21') 561 self.assertEqual(dp.mol[0].res[0].spin[3].name, 'C24') 562 self.assertEqual(dp.mol[0].res[0].spin[4].name, 'C26') 563 self.assertEqual(dp.mol[0].res[1].spin[0].name, 'N') 564 self.assertEqual(dp.mol[1].res[0].spin[0].name, 'N') 565 self.assertEqual(dp.mol[1].res[1].spin[0].name, None) 566 self.assertEqual(dp.mol[1].res[1].spin[1].name, 'N')
567 568
569 - def test_number_spin(self):
570 """Test the numbering of a spin. 571 572 The function tested is both pipe_control.mol_res_spin.number_spin() and 573 prompt.spin.number(). 574 """ 575 576 # Rename a few spins. 577 self.spin_fns.number(spin_id='@C8', number=1, force=True) 578 self.spin_fns.number(spin_id='@6', number=2, force=True) 579 self.spin_fns.number(spin_id='@7', number=3, force=True) 580 self.spin_fns.number(spin_id='@8', number=4, force=True) 581 self.spin_fns.number(spin_id='@9', number=5, force=True) 582 self.spin_fns.number(spin_id='@78', number=6, force=True) 583 self.spin_fns.number(spin_id='@239', number=7, force=True) 584 self.spin_fns.number(spin_id='@3239', number=9, force=True) 585 586 # Get the data pipe. 587 dp = pipes.get_pipe('orig') 588 589 # Test that the spins have been numbered. 590 self.assertEqual(dp.mol[0].res[0].spin[0].num, 1) 591 self.assertEqual(dp.mol[0].res[0].spin[1].num, 2) 592 self.assertEqual(dp.mol[0].res[0].spin[2].num, 3) 593 self.assertEqual(dp.mol[0].res[0].spin[3].num, 4) 594 self.assertEqual(dp.mol[0].res[0].spin[4].num, 5) 595 self.assertEqual(dp.mol[0].res[1].spin[0].num, 6) 596 self.assertEqual(dp.mol[1].res[0].spin[0].num, 7) 597 self.assertEqual(dp.mol[1].res[1].spin[1].num, 9)
598 599
601 """Test the renaming of multiple spins. 602 603 The function tested is both pipe_control.mol_res_spin.number_spin() and 604 prompt.spin.number(). 605 """ 606 607 # Try numbering all NHs. 608 self.assertRaises(RelaxError, self.spin_fns.number, spin_id='@NH', number=-6)
609