Author: bugman Date: Sat Jun 28 22:37:39 2008 New Revision: 6534 URL: http://svn.gna.org/viewcvs/relax?rev=6534&view=rev Log: Created the ResidueList.from_xml() method. Modified: 1.3/data/mol_res_spin.py Modified: 1.3/data/mol_res_spin.py URL: http://svn.gna.org/viewcvs/relax/1.3/data/mol_res_spin.py?rev=6534&r1=6533&r2=6534&view=diff ============================================================================== --- 1.3/data/mol_res_spin.py (original) +++ 1.3/data/mol_res_spin.py Sat Jun 28 22:37:39 2008 @@ -405,6 +405,31 @@ return False + def from_xml(self, res_nodes): + """Recreate a residue list data structure from the XML residue nodes. + + @param res_nodes: The residue XML nodes. + @type res_nodes: xml.dom.minicompat.NodeList instance + """ + + # Test if empty. + if not self.is_empty(): + raise RelaxFromXMLNotEmptyError, self.__class__.__name__ + + # Loop over the residues. + for res_node in res_nodes: + # Get the residue details and add the residue to the ResidueList structure. + name = res_node.getAttribute('name') + num = res_node.getAttribute('num') + self.add_item(res_name=name, res_num=num) + + # Get the spin nodes. + spin_nodes = res_node.getElementsByTagName('spin') + + # Recreate the spin data structures for the current residue. + self[-1].spin.from_xml(spin_nodes) + + def xml_create_element(self, doc, element): """Create XML elements for each residue.