mailr18898 - in /branches/frame_order_testing: ./ generic_fns/structure/api_base.py test_suite/system_tests/structure.py


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

Header


Content

Posted by edward on March 19, 2013 - 18:34:
Author: bugman
Date: Tue Mar 19 18:34:18 2013
New Revision: 18898

URL: http://svn.gna.org/viewcvs/relax?rev=18898&view=rev
Log:
Merged revisions 18896-18897 via svnmerge from 
svn+ssh://bugman@xxxxxxxxxxx/svn/relax/trunk

........
  r18896 | bugman | 2013-03-19 18:14:13 +0100 (Tue, 19 Mar 2013) | 6 lines
  
  Created the Structure.test_metadata_xml system test.
  
  This is used to check that the structural metadata (currently helices and 
sheets) are stored in the
  relax XML save files and then can be read back into relax again.
........
  r18897 | bugman | 2013-03-19 18:31:39 +0100 (Tue, 19 Mar 2013) | 3 lines
  
  The helix and sheet metadata is now stored in and read from relax XML state 
files.
........

Modified:
    branches/frame_order_testing/   (props changed)
    branches/frame_order_testing/generic_fns/structure/api_base.py
    branches/frame_order_testing/test_suite/system_tests/structure.py

Propchange: branches/frame_order_testing/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Tue Mar 19 18:34:18 2013
@@ -1,1 +1,1 @@
-/trunk:1-18894
+/trunk:1-18897

Modified: branches/frame_order_testing/generic_fns/structure/api_base.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/frame_order_testing/generic_fns/structure/api_base.py?rev=18898&r1=18897&r2=18898&view=diff
==============================================================================
--- branches/frame_order_testing/generic_fns/structure/api_base.py (original)
+++ branches/frame_order_testing/generic_fns/structure/api_base.py Tue Mar 19 
18:34:18 2013
@@ -289,6 +289,9 @@
         @type file_version:     int
         """
 
+        # Recreate all base objects (i.e. metadata).
+        xml_to_object(str_node, self, file_version=file_version, 
blacklist=['model', 'displacements'])
+
         # Recreate the model / molecule data structure.
         model_nodes = str_node.getElementsByTagName('model')
         self.structural_data.from_xml(model_nodes, id=id, 
file_version=file_version)
@@ -664,6 +667,23 @@
         if not self.structural_data.is_empty():
             self.structural_data.to_xml(doc, str_element)
 
+        # The structural metadata.
+        metadata = ['helices', 'sheets']
+        for name in metadata:
+            # The metadata does not exist.
+            if not hasattr(self, name):
+                continue
+
+            # Get the object.
+            obj = getattr(self, name)
+
+            # Create a new element for this object, and add it to the main 
element.
+            sub_elem = doc.createElement(name)
+            str_element.appendChild(sub_elem)
+
+            # Add the value to the sub element.
+            object_to_xml(doc, sub_elem, value=obj)
+
         # The displacement structure.
         if hasattr(self, 'displacements'):
             # Create an XML element.

Modified: branches/frame_order_testing/test_suite/system_tests/structure.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/frame_order_testing/test_suite/system_tests/structure.py?rev=18898&r1=18897&r2=18898&view=diff
==============================================================================
--- branches/frame_order_testing/test_suite/system_tests/structure.py 
(original)
+++ branches/frame_order_testing/test_suite/system_tests/structure.py Tue Mar 
19 18:34:18 2013
@@ -335,6 +335,48 @@
 
             # Increment the residue counter.
             i = i + 1
+
+
+    def test_metadata_xml(self):
+        """Test the storage and loading of metadata into an XML state 
file."""
+
+        # Load the file.
+        path = status.install_path + 
sep+'test_suite'+sep+'shared_data'+sep+'structures'
+        self.interpreter.structure.read_pdb('1UBQ.pdb', dir=path)
+
+        # Delete a big chunk of the molecule.
+        self.interpreter.structure.delete(":35-76")
+
+        # Delete all waters.
+        self.interpreter.structure.delete(":HOH")
+
+        # Write out the results file.
+        self.tmpfile = mktemp() + '.bz2'
+        self.interpreter.results.write(self.tmpfile, dir=None)
+
+        # Create a new data pipe and load the results.
+        self.interpreter.pipe.create('xml text', 'mf')
+        self.interpreter.results.read(self.tmpfile)
+
+        # What the data should look like.
+        helices = [
+            ['H1', 'A', 'ILE', 23, 'A', 'GLU', 34, 1, 12]
+        ]
+        sheets = [
+            [1, 'BET', 5, 'GLY', 'A', 10, None, 'VAL', 'A', 17, None, 0, 
None, None, None, None, None, None, None, None, None, None],
+            [2, 'BET', 5, 'MET', 'A', 1, None, 'THR', 'A', 7, None, -1, 
None, None, None, None, None, None, None, None, None, None]
+        ]
+
+        # Check the helix data.
+        self.assert_(hasattr(cdp.structure, 'helices'))
+        self.assertEqual(len(cdp.structure.helices), 1)
+        self.assertEqual(cdp.structure.helices[0], helices[0])
+
+        # Check the sheet data.
+        self.assert_(hasattr(cdp.structure, 'sheets'))
+        self.assertEqual(len(cdp.structure.sheets), 2)
+        self.assertEqual(cdp.structure.sheets[0], sheets[0])
+        self.assertEqual(cdp.structure.sheets[1], sheets[1])
 
 
     def test_read_merge(self):




Related Messages


Powered by MHonArc, Updated Tue Mar 19 18:40:02 2013