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

Source Code for Module test_suite.unit_tests._pipe_control.test_selection

 1  ############################################################################### 
 2  #                                                                             # 
 3  # Copyright (C) 2007-2008 Edward d'Auvergne                                   # 
 4  # Copyright (C) 2007 Chris MacRaild                                           # 
 5  #                                                                             # 
 6  # This file is part of the program relax (http://www.nmr-relax.com).          # 
 7  #                                                                             # 
 8  # This program is free software: you can redistribute it and/or modify        # 
 9  # it under the terms of the GNU General Public License as published by        # 
10  # the Free Software Foundation, either version 3 of the License, or           # 
11  # (at your option) any later version.                                         # 
12  #                                                                             # 
13  # This program is distributed in the hope that it will be useful,             # 
14  # but WITHOUT ANY WARRANTY; without even the implied warranty of              # 
15  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               # 
16  # GNU General Public License for more details.                                # 
17  #                                                                             # 
18  # You should have received a copy of the GNU General Public License           # 
19  # along with this program.  If not, see <http://www.gnu.org/licenses/>.       # 
20  #                                                                             # 
21  ############################################################################### 
22   
23  # relax module imports. 
24  from data_store import Relax_data_store; ds = Relax_data_store() 
25  from pipe_control import selection 
26  from test_suite.unit_tests.base_classes import UnitTestCase 
27   
28   
29 -class Test_selection(UnitTestCase):
30 """Unit tests for the functions of the 'pipe_control.selection' module.""" 31
32 - def setUp(self):
33 """Set up some residues and spins for testing their selection and deselection.""" 34 35 # Add a data pipe to the data store. 36 ds.add(pipe_name='orig', pipe_type='mf') 37 38 # Name the first molecule. 39 cdp.mol[0].name = 'Ap4Aase' 40 41 # Add a second molecule to the system. 42 cdp.mol.add_item(mol_name='RNA') 43 44 # Add two more residues to the first molecule (and set the residue number of the first). 45 cdp.mol[0].res[0].num = 1 46 cdp.mol[0].res.add_item(res_num=2, res_name='Glu') 47 cdp.mol[0].res.add_item(res_num=4, res_name='Pro') 48 49 # Add some spin info to this molecule. 50 cdp.mol[0].res[0].spin[0].name = 'NH' 51 cdp.mol[0].res[0].spin[0].num = 60 52 cdp.mol[0].res[1].spin[0].name = 'NH' 53 cdp.mol[0].res[1].spin[0].num = 63 54 55 # Add one more residue to the second molecule (and set the residue number of the first). 56 cdp.mol[1].res[0].num = -5 57 cdp.mol[1].res.add_item(res_num=-4) 58 59 # Add a second set of spins to the second molecule (naming the first set first). 60 cdp.mol[1].res[0].spin[0].name = 'C8' 61 cdp.mol[1].res[1].spin[0].name = 'C8' 62 cdp.mol[1].res[0].spin.add_item(spin_name='N5') 63 cdp.mol[1].res[1].spin.add_item(spin_name='N5') 64 65 # Deselect a number of spins. 66 cdp.mol[0].res[0].spin[0].select = 0 67 cdp.mol[0].res[2].spin[0].select = 0 68 cdp.mol[1].res[0].spin[0].select = 0 69 cdp.mol[1].res[1].spin[1].select = 0
70 71
72 - def test_reverse(self):
73 """Test spin system selection reversal. 74 75 The function tested is pipe_control.selection.reverse(). 76 """ 77 78 # Reverse the selection. 79 selection.reverse() 80 81 # Test the selection status. 82 self.assertEqual(cdp.mol[0].res[0].spin[0].select, 1) 83 self.assertEqual(cdp.mol[0].res[1].spin[0].select, 0) 84 self.assertEqual(cdp.mol[0].res[2].spin[0].select, 1) 85 self.assertEqual(cdp.mol[1].res[0].spin[0].select, 1) 86 self.assertEqual(cdp.mol[1].res[0].spin[1].select, 0) 87 self.assertEqual(cdp.mol[1].res[1].spin[0].select, 0) 88 self.assertEqual(cdp.mol[1].res[1].spin[1].select, 1)
89