Exemplo n.º 1
0
    def from_xml(self, pipe_node, file_version=None, dir=None):
        """Read a pipe container XML element and place the contents into this pipe.

        @param pipe_node:       The data pipe XML node.
        @type pipe_node:        xml.dom.minidom.Element instance
        @keyword file_version:  The relax XML version of the XML file.
        @type file_version:     int
        @keyword dir:           The name of the directory containing the results file (needed for loading external files).
        @type dir:              str
        """

        # Test if empty.
        if not self.is_empty():
            raise RelaxFromXMLNotEmptyError(self.__class__.__name__)

        # Get the global data node, and fill the contents of the pipe.
        global_node = pipe_node.getElementsByTagName('global')[0]
        xml_to_object(global_node, self, file_version=file_version)

        # Backwards compatibility transformations.
        self._back_compat_hook(file_version)

        # Get the hybrid node (and its sub-node), and recreate the hybrid object.
        hybrid_node = pipe_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 experimental information data nodes and, if they exist, fill the contents.
        exp_info_nodes = pipe_node.getElementsByTagName('exp_info')
        if exp_info_nodes:
            # Create the data container.
            self.exp_info = ExpInfo()

            # Fill its contents.
            self.exp_info.from_xml(exp_info_nodes[0],
                                   file_version=file_version)

        # Get the diffusion tensor data nodes and, if they exist, fill the contents.
        diff_tensor_nodes = pipe_node.getElementsByTagName('diff_tensor')
        if diff_tensor_nodes:
            # Create the diffusion tensor object.
            self.diff_tensor = DiffTensorData()

            # Fill its contents.
            self.diff_tensor.from_xml(diff_tensor_nodes[0],
                                      file_version=file_version)

        # Get the alignment tensor data nodes and, if they exist, fill the contents.
        align_tensor_nodes = pipe_node.getElementsByTagName('align_tensors')
        if align_tensor_nodes:
            # Create the alignment tensor object.
            self.align_tensors = AlignTensorList()

            # Fill its contents.
            self.align_tensors.from_xml(align_tensor_nodes[0],
                                        file_version=file_version)

        # Recreate the interatomic data structure (this needs to be before the 'mol' structure as the backward compatibility hooks can create interatomic data containers!).
        interatom_nodes = pipe_node.getElementsByTagName('interatomic')
        self.interatomic.from_xml(interatom_nodes, file_version=file_version)

        # Recreate the molecule, residue, and spin data structure.
        mol_nodes = pipe_node.getElementsByTagName('mol')
        self.mol.from_xml(mol_nodes, file_version=file_version)

        # Get the structural object nodes and, if they exist, fill the contents.
        str_nodes = pipe_node.getElementsByTagName('structure')
        if str_nodes:
            # Create the structural object.
            fail = False
            self.structure = Internal()

            # Fill its contents.
            if not fail:
                self.structure.from_xml(str_nodes[0],
                                        dir=dir,
                                        file_version=file_version)
Exemplo n.º 2
0
    def setUp(self):
        """Set 'self.diff_data' to an empty instance of the DiffTensorData class."""

        self.diff_data = DiffTensorData()