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-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  # relax module imports. 
23  from data_store import Relax_data_store; ds = Relax_data_store() 
24  from pipe_control import selection 
25  from test_suite.unit_tests.base_classes import UnitTestCase 
26   
27   
28 -class Test_selection(UnitTestCase):
29 """Unit tests for the functions of the 'pipe_control.selection' module.""" 30
31 - def setUp(self):
32 """Set up some residues and spins for testing their selection and deselection.""" 33 34 # Add a data pipe to the data store. 35 ds.add(pipe_name='orig', pipe_type='mf') 36 37 # Name the first molecule. 38 cdp.mol[0].name = 'Ap4Aase' 39 40 # Add a second molecule to the system. 41 cdp.mol.add_item(mol_name='RNA') 42 43 # Add two more residues to the first molecule (and set the residue number of the first). 44 cdp.mol[0].res[0].num = 1 45 cdp.mol[0].res.add_item(res_num=2, res_name='Glu') 46 cdp.mol[0].res.add_item(res_num=4, res_name='Pro') 47 48 # Add some spin info to this molecule. 49 cdp.mol[0].res[0].spin[0].name = 'NH' 50 cdp.mol[0].res[0].spin[0].num = 60 51 cdp.mol[0].res[1].spin[0].name = 'NH' 52 cdp.mol[0].res[1].spin[0].num = 63 53 54 # Add one more residue to the second molecule (and set the residue number of the first). 55 cdp.mol[1].res[0].num = -5 56 cdp.mol[1].res.add_item(res_num=-4) 57 58 # Add a second set of spins to the second molecule (naming the first set first). 59 cdp.mol[1].res[0].spin[0].name = 'C8' 60 cdp.mol[1].res[1].spin[0].name = 'C8' 61 cdp.mol[1].res[0].spin.add_item(spin_name='N5') 62 cdp.mol[1].res[1].spin.add_item(spin_name='N5') 63 64 # Deselect a number of spins. 65 cdp.mol[0].res[0].spin[0].select = 0 66 cdp.mol[0].res[2].spin[0].select = 0 67 cdp.mol[1].res[0].spin[0].select = 0 68 cdp.mol[1].res[1].spin[1].select = 0
69 70
71 - def test_reverse(self):
72 """Test spin system selection reversal. 73 74 The function tested is pipe_control.selection.reverse(). 75 """ 76 77 # Reverse the selection. 78 selection.reverse() 79 80 # Test the selection status. 81 self.assertEqual(cdp.mol[0].res[0].spin[0].select, 1) 82 self.assertEqual(cdp.mol[0].res[1].spin[0].select, 0) 83 self.assertEqual(cdp.mol[0].res[2].spin[0].select, 1) 84 self.assertEqual(cdp.mol[1].res[0].spin[0].select, 1) 85 self.assertEqual(cdp.mol[1].res[0].spin[1].select, 0) 86 self.assertEqual(cdp.mol[1].res[1].spin[0].select, 0) 87 self.assertEqual(cdp.mol[1].res[1].spin[1].select, 1)
88