mailr6529 - in /1.3/data: pipe_container.py relax_xml.py


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

Header


Content

Posted by edward on June 28, 2008 - 22:10:
Author: bugman
Date: Sat Jun 28 22:10:46 2008
New Revision: 6529

URL: http://svn.gna.org/viewcvs/relax?rev=6529&view=rev
Log:
Wrote the PipeContainer.xml_read_element() method.


Modified:
    1.3/data/pipe_container.py
    1.3/data/relax_xml.py

Modified: 1.3/data/pipe_container.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/data/pipe_container.py?rev=6529&r1=6528&r2=6529&view=diff
==============================================================================
--- 1.3/data/pipe_container.py (original)
+++ 1.3/data/pipe_container.py Sat Jun 28 22:10:46 2008
@@ -26,9 +26,10 @@
 # relax module imports.
 from data_classes import Element
 from diff_tensor import DiffTensorData
+import generic_fns
 from mol_res_spin import MoleculeList
 from prototype import Prototype
-from relax_xml import fill_object_contents
+from relax_xml import fill_object_contents, node_value_to_python, 
xml_to_object
 
 
 class PipeContainer(Prototype):
@@ -206,3 +207,34 @@
         # Set the structural attributes.
         str_element.setAttribute('desc', 'Structural information')
         str_element.setAttribute('id', ds[ds.current_pipe].structure.id)
+
+
+    def xml_read_element(self, relax_node):
+        """Read a pipe container XML element and place the contents into 
this pipe.
+
+        @param relax_node:  The relax XML node.
+        @type relax_node:   xml.dom.minidom.Element instance
+        """
+
+        # Get the global data node, and fill the contents of the pipe.
+        global_node = relax_node.getElementsByTagName('global')[0]
+        xml_to_object(global_node, self)
+
+        # Get the hybrid node (and its sub-node), and recreate the hybrid 
object.
+        hybrid_node = relax_node.getElementsByTagName('hybrid')[0]
+        pipes_node = hybrid_node.getElementsByTagName('pipes')[0]
+        setattr(self, 'hybrid_pipes', 
node_value_to_python(pipes_node.childNodes[0]))
+
+        # Get the diffusion tensor data node and, if it exists, fill the 
contents.
+        diff_tensor_node = relax_node.getElementsByTagName('diff_tensor')[0]
+        if diff_tensor_node:
+            # Create the diffusion tensor object.
+            self.diff_tensor = DiffTensorData()
+
+            # Fill its contents.
+            xml_to_object(diff_tensor_node, self.diff_tensor, 
set_fn=generic_fns.diffusion_tensor.set)
+            self.diff_tensor.tm = 1.0
+
+        # Recreate the molecule, residue, and spin data structure.
+        mol_nodes = relax_node.getElementsByTagName('mol')
+        self.mol.xml_read_element(mol_nodes)

Modified: 1.3/data/relax_xml.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/data/relax_xml.py?rev=6529&r1=6528&r2=6529&view=diff
==============================================================================
--- 1.3/data/relax_xml.py (original)
+++ 1.3/data/relax_xml.py Sat Jun 28 22:10:46 2008
@@ -78,13 +78,16 @@
     return eval(val)
 
 
-def xml_to_object(elem, base_object=None):
+def xml_to_object(elem, base_object=None, set_fn=None):
     """Convert the XML elements into python objects, and place these into 
the base object.
 
     @param elem:        The element to extract all python objects from.
     @type elem:         xml.dom.minidom.Element instance
     @param base_object: The python class instance to place the objects into.
     @type  base_bject:  instance
+    @param set_fn:      A function used to replace setattr for placing the 
object into the base
+                        object.
+    @type set_fn:       function
     """
 
     # Loop over the nodes of the element




Related Messages


Powered by MHonArc, Updated Sat Jun 28 22:20:13 2008