mailr3225 - /1.3/test_suite/unit_tests/generic_fns/test_selection.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by edward on March 19, 2007 - 06:22:
Author: bugman
Date: Mon Mar 19 06:21:47 2007
New Revision: 3225

URL: http://svn.gna.org/viewcvs/relax?rev=3225&view=rev
Log:
Multiple unit tests for the spin_loop(), residue_loop(), and molecule_loop() 
generator functions.

These generator functions belong to the 'generic_fns.selection' module.

Modified:
    1.3/test_suite/unit_tests/generic_fns/test_selection.py

Modified: 1.3/test_suite/unit_tests/generic_fns/test_selection.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/test_suite/unit_tests/generic_fns/test_selection.py?rev=3225&r1=3224&r2=3225&view=diff
==============================================================================
--- 1.3/test_suite/unit_tests/generic_fns/test_selection.py (original)
+++ 1.3/test_suite/unit_tests/generic_fns/test_selection.py Mon Mar 19 
06:21:47 2007
@@ -41,12 +41,15 @@
         cdp = relax_data_store[relax_data_store.current_pipe]
 
         # Add a second molecule to the system.
-        cdp.mol.add_item()
+        cdp.mol.add_item(mol_name='RNA')
+
+        # Rename the first molecule.
+        cdp.mol[0].name = 'Ap4Aase'
 
         # Add two more residues to the first molecule (and set the residue 
number of the first).
         cdp.mol[0].res[0].num = 1
-        cdp.mol[0].res.add_item(res_num=2)
-        cdp.mol[0].res.add_item(res_num=4)
+        cdp.mol[0].res.add_item(res_num=2, res_name='Glu')
+        cdp.mol[0].res.add_item(res_num=4, res_name='Pro')
 
         # Add one more residue to the second molecule (and set the residue 
number of the first).
         cdp.mol[1].res[0].num = -5
@@ -69,7 +72,73 @@
         # Reset.
         relax_data_store.__reset__()
 
-        
+
+    def test_molecule_loop(self):
+        """Test the proper operation of the molecule loop with molecule 
selection.
+
+        The function tested is generic_fns.selection.molecule_loop().
+        """
+
+        # Loop over the molecules.
+        for mol in selection.molecule_loop('#RNA'):
+            # Test the molecule name.
+            self.assertEqual(mol.name, 'RNA')
+
+
+    def test_molecule_loop_no_selection(self):
+        """Test the proper operation of the molecule loop when no selection 
is present.
+
+        The function tested is generic_fns.selection.molecule_loop().
+        """
+
+        # Molecule data.
+        name = [None, 'RNA']
+
+        # Loop over the molecules.
+        i = 0
+        for mol in selection.molecule_loop():
+            # Test the molecule names.
+            self.assertEqual(mol.name, name[i])
+
+            # Increment i.
+            i = i + 1
+
+
+    def test_residue_loop(self):
+        """Test the proper operation of the residue loop with residue 
selection.
+
+        The function tested is generic_fns.selection.residue_loop().
+        """
+
+        # Loop over the residues.
+        for res in selection.residue_loop('#Ap4Aase:Glu'):
+            # Test the selection.
+            self.assertEqual(res.num, 2)
+
+
+    def test_residue_loop_no_selection(self):
+        """Test the proper operation of the residue loop when no selection 
is present.
+
+        The function tested is generic_fns.selection.residue_loop().
+        """
+
+        # Spin data.
+        num = [1, 2, 4, -5, -4]
+        name = [None, 'Glu', 'Pro', None, None]
+
+        # Loop over the residues.
+        i = 0
+        for res in selection.residue_loop():
+            # Test the residue numbers.
+            self.assertEqual(res.select, num[i])
+
+            # Test the residue names.
+            self.assertEqual(res.name, name[i])
+
+            # Increment i.
+            i = i + 1
+
+
     def test_reverse(self):
         """Test spin system selection reversal.
 
@@ -90,3 +159,48 @@
         self.assertEqual(cdp.mol[1].res[0].spin[1].select, 0)
         self.assertEqual(cdp.mol[1].res[1].spin[0].select, 0)
         self.assertEqual(cdp.mol[1].res[1].spin[1].select, 1)
+
+
+    def test_spin_loop(self):
+        """Test the proper operation of the spin loop with spin selection.
+
+        The function tested is generic_fns.selection.spin_loop().
+        """
+
+        # Spin data.
+        select = [1, 0]
+
+        # Loop over the spins.
+        i = 0
+        for spin in selection.spin_loop('@N5'):
+            # Test the selection.
+            self.assertEqual(spin.select, select[i])
+
+            # Test the spin names.
+            self.assertEqual(spin.name, 'N5')
+
+            # Increment i.
+            i = i + 1
+
+
+    def test_spin_loop_no_selection(self):
+        """Test the proper operation of the spin loop when no selection is 
present.
+
+        The function tested is generic_fns.selection.spin_loop().
+        """
+
+        # Spin data.
+        select = [0, 1, 0, 0, 1, 1, 0]
+        name = [None, None, None, None, 'N5', None, 'N5']
+
+        # Loop over the spins.
+        i = 0
+        for spin in selection.spin_loop():
+            # Test the selection.
+            self.assertEqual(spin.select, select[i])
+
+            # Test the spin names.
+            self.assertEqual(spin.name, name[i])
+
+            # Increment i.
+            i = i + 1




Related Messages


Powered by MHonArc, Updated Mon Mar 19 06:40:17 2007