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

Source Code for Module test_suite.unit_tests._generic_fns.test_selection

 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  # relax module imports. 
24  from data import Relax_data_store; ds = Relax_data_store() 
25  from generic_fns 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 'generic_fns.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 generic_fns.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