Author: bugman Date: Sun Jun 22 19:05:09 2008 New Revision: 6429 URL: http://svn.gna.org/viewcvs/relax?rev=6429&view=rev Log: Added the ability to create XML elements for alignment tensors. Modified: 1.3/data/__init__.py 1.3/data/align_tensor.py 1.3/data/diff_tensor.py 1.3/data/pipe_container.py Modified: 1.3/data/__init__.py URL: http://svn.gna.org/viewcvs/relax/1.3/data/__init__.py?rev=6429&r1=6428&r2=6429&view=diff ============================================================================== --- 1.3/data/__init__.py (original) +++ 1.3/data/__init__.py Sun Jun 22 19:05:09 2008 @@ -210,6 +210,6 @@ xml.dom.ext.PrettyPrint(xmldoc, file) # Print out. - print self + print self[self.current_pipe] print "\n\nXML:" xml.dom.ext.PrettyPrint(xmldoc) Modified: 1.3/data/align_tensor.py URL: http://svn.gna.org/viewcvs/relax/1.3/data/align_tensor.py?rev=6429&r1=6428&r2=6429&view=diff ============================================================================== --- 1.3/data/align_tensor.py (original) +++ 1.3/data/align_tensor.py Sun Jun 22 19:05:09 2008 @@ -29,6 +29,7 @@ # relax module imports. from data_classes import Element from relax_errors import RelaxError +from relax_xml import fill_object_contents @@ -558,6 +559,33 @@ self.append(AlignTensorData(name)) + def xml_create_element(self, doc, element): + """Create an XML element for the alignment tensors. + + @param doc: The XML document object. + @type doc: xml.dom.minidom.Document instance + @param element: The element to add the alignment tensors XML element to. + @type element: XML element object + """ + + # Create the alignment tensors element and add it to the higher level element. + tensor_list_element = doc.createElement('align_tensors') + element.appendChild(tensor_list_element) + + # Set the alignment tensor attributes. + tensor_list_element.setAttribute('desc', 'Alignment tensor list') + + # Loop over the tensors. + for i in xrange(len(self)): + # Create an XML element for a single tensor. + tensor_element = doc.createElement('align_tensor') + tensor_list_element.appendChild(tensor_element) + tensor_list_element.setAttribute('index', `i`) + tensor_list_element.setAttribute('desc', 'Alignment tensor') + + # Add all simple python objects within the PipeContainer to the pipe element. + fill_object_contents(doc, tensor_element, object=self[i], blacklist=self[i].__class__.__dict__.keys()) + class AlignTensorData(Element): """An empty data container for the alignment tensor elements.""" Modified: 1.3/data/diff_tensor.py URL: http://svn.gna.org/viewcvs/relax/1.3/data/diff_tensor.py?rev=6429&r1=6428&r2=6429&view=diff ============================================================================== --- 1.3/data/diff_tensor.py (original) +++ 1.3/data/diff_tensor.py Sun Jun 22 19:05:09 2008 @@ -826,13 +826,13 @@ self.__dict__[target+'_sim'] = DiffTensorSimList(target, self) - def xml_create_diff_element(self, doc, element): + def xml_create_element(self, doc, element): """Create an XML element for the diffusion tensor. @param doc: The XML document object. @type doc: xml.dom.minidom.Document instance - @param element: The element to add the diffusion tensor element to. - @type element: XML element object + @param element: The element to add the diffusion tensor element to. + @type element: XML element object """ # Create the diffusion tensor element and add it to the higher level element. Modified: 1.3/data/pipe_container.py URL: http://svn.gna.org/viewcvs/relax/1.3/data/pipe_container.py?rev=6429&r1=6428&r2=6429&view=diff ============================================================================== --- 1.3/data/pipe_container.py (original) +++ 1.3/data/pipe_container.py Sun Jun 22 19:05:09 2008 @@ -169,7 +169,7 @@ global_element = doc.createElement('global') element.appendChild(global_element) global_element.setAttribute('desc', 'Global data located in the top level of the data pipe') - fill_object_contents(doc, global_element, object=self, blacklist=['diff_tensor', 'hybrid_pipes', 'mol', 'pipe_type', 'structure'] + self.__class__.__dict__.keys()) + fill_object_contents(doc, global_element, object=self, blacklist=['align_tensors', 'diff_tensor', 'hybrid_pipes', 'mol', 'pipe_type', 'structure'] + self.__class__.__dict__.keys()) # Hybrid info. self.xml_create_hybrid_element(doc, element) @@ -177,6 +177,10 @@ # Add the diffusion tensor data. if hasattr(self, 'diff_tensor'): self.diff_tensor.xml_create_diff_element(doc, element) + + # Add the alignment tensor data. + if hasattr(self, 'align_tensors'): + self.align_tensors.xml_create_element(doc, element) # Add the structural data, if it exists. if hasattr(self, 'structure'):