mailr4465 - /branches/consistency_tests_1.3/test_suite/system_tests/consistency_tests.py


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

Header


Content

Posted by sebastien . morin . 1 on January 07, 2008 - 19:41:
Author: semor
Date: Mon Jan  7 19:41:25 2008
New Revision: 4465

URL: http://svn.gna.org/viewcvs/relax?rev=4465&view=rev
Log:
Updated the consistency_tests code in the test suite mainly by mimicking the 
jw_mapping code.

Jw mapping and consistency testing are performed in the same way so their 
code should be similar.


Modified:
    
branches/consistency_tests_1.3/test_suite/system_tests/consistency_tests.py

Modified: 
branches/consistency_tests_1.3/test_suite/system_tests/consistency_tests.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/consistency_tests_1.3/test_suite/system_tests/consistency_tests.py?rev=4465&r1=4464&r2=4465&view=diff
==============================================================================
--- 
branches/consistency_tests_1.3/test_suite/system_tests/consistency_tests.py 
(original)
+++ 
branches/consistency_tests_1.3/test_suite/system_tests/consistency_tests.py 
Mon Jan  7 19:41:25 2008
@@ -23,108 +23,50 @@
 
 # Python module imports.
 import sys
+from unittest import TestCase
 
 # relax module imports.
 from data import Data as relax_data_store
 from generic_fns.selection import residue_loop
 from physical_constants import N15_CSA, NH_BOND_LENGTH
 
-# The relax data storage object.
+
+class Ct(TestCase):
+    """Class for testing various aspects specific to consistency testing."""
+
+    def setUp(self):
+        """Set up for all the functional tests."""
+
+        # Create the data pipe.
+        self.relax.interpreter._Pipe.create('ct', 'ct')
 
 
+    def tearDown(self):
+        """Reset the relax data storage object."""
+
+        relax_data_store.__reset__()
 
 
-class Ct:
-    def __init__(self, relax, test_name):
-        """Class for testing various aspects specific to consistency 
testing."""
+    def test_calc(self):
+        """The consistency testing calculation test."""
 
-        self.relax = relax
+        # Data directory.
+        dir = sys.path[-1] + '/test_suite/system_tests/data/jw_mapping/'
 
-        # Results reading test.
-        if test_name == 'set':
+        # Data paths.
+        dataPaths = [dir + 'noe.dat',
+                     dir + 'R1.dat',
+                     dir + 'R2.dat']
 
-            # The name of the test.
-            self.name = "The user function value.set()"
-
-            # The test.
-            self.test = self.set_value
-
-        # Consistency tests calculation test.
-        if test_name == 'calc':
-
-            # The name of the test.
-            self.name = "Consistency tests calculation"
-
-            # The test.
-            self.test = self.calc
-
-
-    def calc(self, pipe):
-        """The consistency tests calculation test."""
-
-        # Arguments.
-        self.pipe = pipe
-
-        # Setup.
-        self.calc_setup()
-
-        # Try the consistency testing.
-        self.relax.interpreter._Minimisation.calc()
-
-        # Success.
-        return self.calc_integrity()
-
-
-    def calc_integrity(self):
+        # Data types.
+        dataTypes = [('NOE', '600', 600.0e6),
+                     ('R1', '600', 600.0e6),
+                     ('R2', '600', 600.0e6)]
 
         # Correct consistency functions values:
         j0 = [4.0703318681008998e-09, 3.7739393907014834e-09]
         f_eta = [0.35164988964635652, 0.32556427866911447]
         f_r2 = [2.0611470814962761e-09, 1.9117396355237641e-09]
-
-        # Loop over residues.
-        for res in residue_loop:
-            # Residues -2 and -1 have data.
-            if res.num == -2 or res.num == -1:
-                if not res.spin[0].select:
-                    print 'Residue', res.num, 'unexpectedly not selected'
-                    return
-
-                if abs(res.spin[0].j0 - j0[index]) > j0[index]/1e6:
-                    print 'Error in residue', res.num, 'j0 calculated value'
-                    return
-                if abs(res.spin[0].f_eta - f_eta[index]) > f_eta[index]/1e6:
-                    print 'Error in residue', res.num, 'f_eta calculated 
value'
-                    return
-                if abs(res.spin[0].f_r2 - f_r2[index]) > f_r2[index]/1e6:
-                    print 'Error in residue', res.num, 'f_r2 calculated 
value'
-                    return
-
-            # Other residues have insufficient data.
-            else:
-                if res.spin[0].select:
-                    print 'Residue', res.num, 'unexpectedly selected'
-                    return
-
-        # Success.
-        return 1
-
-
-    def calc_setup(self):
-        """Setup for the calculation test."""
-
-        dir = sys.path[-1] + '/test_suite/system_tests/data/jw_mapping/'
-
-        dataPaths = [dir + 'noe.dat',
-                     dir + 'R1.dat',
-                     dir + 'R2.dat']
-
-        dataTypes = [('NOE', '600', 600.0e6),
-                     ('R1', '600', 600.0e6),
-                     ('R2', '600', 600.0e6)]
-
-        # Create the data pipe.
-        self.relax.interpreter._Pipe.create(self.pipe, 'ct')
 
         # Read the sequence.
         self.relax.interpreter._Sequence.read(file='test_seq', 
dir=sys.path[-1] + '/test_suite/system_tests/data')
@@ -133,22 +75,33 @@
         for dataSet in xrange(len(dataPaths)):
             self.relax.interpreter._Relax_data.read(dataTypes[dataSet][0], 
dataTypes[dataSet][1], dataTypes[dataSet][2], dataPaths[dataSet])
 
-        # Nuclei type.
-        self.relax.interpreter._Nuclei.nuclei('N')
-
-        # Set r and csa.
+        # Set r, csa, and the nucleus type.
         self.relax.interpreter._Value.set(NH_BOND_LENGTH, 'bond_length')
         self.relax.interpreter._Value.set(N15_CSA, 'csa')
+        self.relax.interpreter._Value.set('N', 'nucleus')
 
         # Select the frequency.
         self.relax.interpreter._Consistency_tests.set_frq(frq=600.0 * 1e6)
 
+        # Try the consistency testing.
+        self.relax.interpreter._Minimisation.calc()
 
-    def set_value(self, pipe):
-        """The value.set test."""
+        # Loop over residues.
+        for res in residue_loop():
+            # Residues -2 and -1 have data.
+            if res.num == -2 or res.num == -1:
+                self.assert_(res.spin[0].select)
+                self.assertAlmostEqual(res.spin[0].j0, j0[index])
+                self.assertAlmostEqual(res.spin[0].f_eta, f_eta[index])
+                self.assertAlmostEqual(res.spin[0].f_r2, f_r2[index])
 
-        # Create the data pipe.
-        self.relax.interpreter._Pipe.create(pipe, 'ct')
+            # Other residues have insufficient data.
+            else:
+                self.assert_(not res.spin[0].select)
+
+
+    def test_set_value(self):
+        """The user function value.set()."""
 
         # Read the sequence.
         self.relax.interpreter._Sequence.read(file='test_seq', 
dir=sys.path[-1] + '/test_suite/system_tests/data')
@@ -159,15 +112,7 @@
         self.relax.interpreter._Value.set(bond_length, 'bond_length')
         self.relax.interpreter._Value.set(csa, 'csa')
 
-        # Test values.
-        for i in xrange(len(relax_data_store[pipe].mol[0].res)):
-            if relax_data_store[pipe].mol[0].res[i].spin[0].r != bond_length:
-                print 'Value of bond_length has not been set correctly'
-                return
-            if relax_data_store[pipe].mol[0].res[i].spin[0].csa != csa:
-                print 'Value of csa has not been set correctly'
-                return
-
-        # Success.
-        return 1
-
+        # Loop over residues.
+        for res in residue_loop():
+            self.assertEqual(res.spin[0].r, NH_BOND_LENGTH)
+            self.assertEqual(res.spin[0].csa, N15_CSA)




Related Messages


Powered by MHonArc, Updated Mon Jan 07 20:20:24 2008