Author: bugman Date: Fri Oct 9 20:24:11 2009 New Revision: 9711 URL: http://svn.gna.org/viewcvs/relax?rev=9711&view=rev Log: Created a data container for storing experimental details. This will be used extensively for the BMRB file generation. Added: branches/bmrb/data/exp_info.py Modified: branches/bmrb/data/data_classes.py branches/bmrb/data/pipe_container.py Modified: branches/bmrb/data/data_classes.py URL: http://svn.gna.org/viewcvs/relax/branches/bmrb/data/data_classes.py?rev=9711&r1=9710&r2=9711&view=diff ============================================================================== --- branches/bmrb/data/data_classes.py (original) +++ branches/bmrb/data/data_classes.py Fri Oct 9 20:24:11 2009 @@ -22,6 +22,9 @@ # Python module imports. from re import search + +# relax module imports. +from relax_xml import fill_object_contents, xml_to_object # Empty data container. @@ -51,6 +54,17 @@ return text + def from_xml(self, exp_info_node): + """Recreate the container data structure from the XML container node. + + @param exp_info_node: The container XML node. + @type exp_info_node: xml.dom.minicompat.Element instance + """ + + # Recreate all the data structures. + xml_to_object(exp_info_node, self) + + def is_empty(self): """Method for testing if the Element container is empty. @@ -73,3 +87,26 @@ # The Element container is empty. return True + + + def to_xml(self, doc, element): + """Create an XML element for the container. + + The variables self.name and self.desc must exist. + + + @param doc: The XML document object. + @type doc: xml.dom.minidom.Document instance + @param element: The element to add the container element to. + @type element: XML element object + """ + + # Create the container element and add it to the higher level element. + tensor_element = doc.createElement(self.name) + element.appendChild(tensor_element) + + # Set the container attributes. + tensor_element.setAttribute('desc', self.desc) + + # Add all simple python objects within the PipeContainer to the pipe element. + fill_object_contents(doc, tensor_element, object=self, blacklist=['type'] + list(self.__class__.__dict__.keys())) Added: branches/bmrb/data/exp_info.py URL: http://svn.gna.org/viewcvs/relax/branches/bmrb/data/exp_info.py?rev=9711&view=auto ============================================================================== --- branches/bmrb/data/exp_info.py (added) +++ branches/bmrb/data/exp_info.py Fri Oct 9 20:24:11 2009 @@ -1,0 +1,40 @@ +############################################################################### +# # +# Copyright (C) 2009 Edward d'Auvergne # +# # +# This file is part of the program relax. # +# # +# relax is free software; you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation; either version 2 of the License, or # +# (at your option) any later version. # +# # +# relax is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with relax; if not, write to the Free Software # +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # +# # +############################################################################### + +# Module docstring. +"""Module holding the experimental information data container.""" + +# relax module imports. +from data_classes import Element + + +class ExpInfo(Element): + """The experimental information data container.""" + + def __init__(self): + """Initialise the data container.""" + + # The name of the container. + self.name = 'exp_info' + + # The description of the container. + self.desc = 'Experimental information' Modified: branches/bmrb/data/pipe_container.py URL: http://svn.gna.org/viewcvs/relax/branches/bmrb/data/pipe_container.py?rev=9711&r1=9710&r2=9711&view=diff ============================================================================== --- branches/bmrb/data/pipe_container.py (original) +++ branches/bmrb/data/pipe_container.py Fri Oct 9 20:24:11 2009 @@ -1,6 +1,6 @@ ############################################################################### # # -# Copyright (C) 2007-2008 Edward d'Auvergne # +# Copyright (C) 2007-2009 Edward d'Auvergne # # # # This file is part of the program relax. # # # @@ -27,6 +27,7 @@ # relax module imports. from align_tensor import AlignTensorList from diff_tensor import DiffTensorData +from exp_info import ExpInfo import generic_fns from mol_res_spin import MoleculeList from prototype import Prototype @@ -62,7 +63,7 @@ text = "The data pipe storage object.\n" # Special objects/methods (to avoid the getattr() function call on). - spec_obj = ['mol', 'diff_tensor', 'structure'] + spec_obj = ['exp_info', 'mol', 'diff_tensor', 'structure'] # Objects. text = text + "\n" @@ -80,6 +81,10 @@ if name == 'structure': text = text + " structure: The 3D molecular data object\n" + # The experimental info data container. + if name == 'exp_info': + text = text + " exp_info: The data container for experimental information\n" + # Skip the PipeContainer methods. if name in list(self.__class__.__dict__.keys()): continue @@ -117,6 +122,15 @@ 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 experimental information data nodes and, if they exist, fill the contents. + exp_info_nodes = relax_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]) # Get the diffusion tensor data nodes and, if they exist, fill the contents. diff_tensor_nodes = relax_node.getElementsByTagName('diff_tensor') @@ -214,10 +228,14 @@ 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=['align_tensors', 'diff_tensor', 'hybrid_pipes', 'mol', 'pipe_type', 'structure'] + list(self.__class__.__dict__.keys())) + fill_object_contents(doc, global_element, object=self, blacklist=['align_tensors', 'diff_tensor', 'exp_info', 'hybrid_pipes', 'mol', 'pipe_type', 'structure'] + list(self.__class__.__dict__.keys())) # Hybrid info. self.xml_create_hybrid_element(doc, element) + + # Add the experimental information. + if hasattr(self, 'exp_info'): + self.exp_info.to_xml(doc, element) # Add the diffusion tensor data. if hasattr(self, 'diff_tensor'):