Author: bugman Date: Sat Jun 28 22:35:10 2008 New Revision: 6533 URL: http://svn.gna.org/viewcvs/relax?rev=6533&view=rev Log: Created the MoleculeList.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=6533&r1=6532&r2=6533&view=diff ============================================================================== --- 1.3/data/mol_res_spin.py (original) +++ 1.3/data/mol_res_spin.py Sat Jun 28 22:35:10 2008 @@ -30,7 +30,7 @@ # relax module imports. import data from prototype import Prototype -from relax_errors import RelaxError +from relax_errors import RelaxError, RelaxFromXMLNotEmptyError from relax_xml import fill_object_contents import specific_fns @@ -578,6 +578,30 @@ return False + def from_xml(self, mol_nodes): + """Recreate a molecule list data structure from the XML molecule nodes. + + @param mol_nodes: The molecule XML nodes. + @type mol_nodes: xml.dom.minicompat.NodeList instance + """ + + # Test if empty. + if not self.is_empty(): + raise RelaxFromXMLNotEmptyError, self.__class__.__name__ + + # Loop over the molecules. + for mol_node in mol_nodes: + # Get the molecule details and add the molecule to the MoleculeList structure. + name = mol_node.getAttribute('name') + self.add_item(mol_name=name) + + # Get the residue nodes. + res_nodes = mol_node.getElementsByTagName('res') + + # Recreate the residue data structures for the current molecule. + self[-1].res.from_xml(res_nodes) + + def xml_create_element(self, doc, element): """Create XML elements for each molecule.