Package data_store :: Module gui
[hide private]
[frames] | no frames]

Source Code for Module data_store.gui

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2010-2014 Edward d'Auvergne                                   # 
  4  #                                                                             # 
  5  # This file is part of the program relax (http://www.nmr-relax.com).          # 
  6  #                                                                             # 
  7  # This program is free software: you can redistribute it and/or modify        # 
  8  # it under the terms of the GNU General Public License as published by        # 
  9  # the Free Software Foundation, either version 3 of the License, or           # 
 10  # (at your option) any later version.                                         # 
 11  #                                                                             # 
 12  # This program is distributed in the hope that it will be useful,             # 
 13  # but WITHOUT ANY WARRANTY; without even the implied warranty of              # 
 14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               # 
 15  # GNU General Public License for more details.                                # 
 16  #                                                                             # 
 17  # You should have received a copy of the GNU General Public License           # 
 18  # along with this program.  If not, see <http://www.gnu.org/licenses/>.       # 
 19  #                                                                             # 
 20  ############################################################################### 
 21   
 22  # Module docstring. 
 23  """The GUI data objects of the relax data store.""" 
 24   
 25  # relax module imports. 
 26  from data_store.data_classes import Element, RelaxListType 
 27  from lib.xml import xml_to_object 
 28   
 29   
30 -class Gui(Element):
31 """Container for the global GUI data structures.""" 32
33 - def __init__(self):
34 """Initialise the container info.""" 35 36 # Execute the base class __init__() method. 37 super(Gui, self).__init__() 38 39 # Add the analysis list object. 40 self.analyses = Analyses() 41 42 # The free format file settings. 43 self.free_file_format = Free_file_format() 44 45 # Set the name and description. 46 self.name = 'relax_gui' 47 self.desc = 'The relax GUI information store.'
48 49
50 - def from_xml(self, gui_node, file_version=1):
51 """Recreate the gui data structure from the XML gui node. 52 53 @param gui_node: The gui XML node. 54 @type gui_node: xml.dom.minicompat.Element instance 55 @keyword file_version: The relax XML version of the XML file. 56 @type file_version: int 57 """ 58 59 # Init. 60 self.analyses = Analyses() 61 self.free_file_format = Free_file_format() 62 63 # Get the analyses node and recreate the analyses structure. 64 analyses_nodes = gui_node.getElementsByTagName('analyses') 65 self.analyses.from_xml(analyses_nodes[0], file_version=file_version) 66 67 # Get the file settings node and recreate the structure. 68 format_nodes = gui_node.getElementsByTagName('free_file_format') 69 if format_nodes: 70 self.free_file_format.from_xml(format_nodes[0], file_version=file_version) 71 72 # Recreate all the other data structures. 73 xml_to_object(gui_node, self, file_version=file_version, blacklist=['analyses', 'free_file_format'])
74 75 76
77 -class Analyses(RelaxListType):
78 """A list object for holding all the GUI info specific to a certain analysis type.""" 79
80 - def __init__(self):
81 """Initialise some class variables.""" 82 83 # Execute the base class __init__() method. 84 super(Analyses, self).__init__() 85 86 # Some generic initial names. 87 self.list_name = 'analyses' 88 self.list_desc = 'GUI information specific to relax analysis types'
89 90
91 - def add(self, type=None):
92 """Add a new analysis type. 93 94 @keyword type: The analysis type. This can be currently one of 'noe', 'r1', 'r2', or 'model-free'. 95 @type type: str 96 @return: The index of the data container added to the list. 97 @rtype: int 98 """ 99 100 # Append an empty element. 101 self.append(Element(name='analysis', desc='GUI information for a relax analysis')) 102 103 # Set the analysis type. 104 self[-1].analysis_type = type 105 106 # Return the index of the container. 107 return len(self)-1
108 109
110 - def from_xml(self, analyses_node, file_version=1):
111 """Recreate the analyses data structure from the XML analyses node. 112 113 @param analyses_node: The analyses XML node. 114 @type analyses_node: xml.dom.minicompat.Element instance 115 @keyword file_version: The relax XML version of the XML file. 116 @type file_version: int 117 """ 118 119 # Get all the analysis nodes. 120 analysis_nodes = analyses_node.getElementsByTagName('analysis') 121 122 # Loop over the nodes. 123 for node in analysis_nodes: 124 # Add a blank analysis container. 125 index = self.add() 126 127 # Recreate the analysis container. 128 self[index].from_xml(node, file_version=file_version)
129 130
131 -class Free_file_format(Element):
132 """Container for the free format file settings (column numbers, column separators, etc.).""" 133
134 - def __init__(self):
135 """Set up the initial values.""" 136 137 # Execute the base class __init__() method. 138 super(Free_file_format, self).__init__(name='free_file_format', desc='The column numbers and separator for the free format file.') 139 140 # Reset. 141 self.reset()
142 143
144 - def reset(self):
145 """Reset all variables to the initial values.""" 146 147 # The default column numbers. 148 self.spin_id_col = None 149 self.mol_name_col = 1 150 self.res_num_col = 2 151 self.res_name_col = 3 152 self.spin_num_col = 4 153 self.spin_name_col = 5 154 self.data_col = 6 155 self.error_col = 7 156 157 # The column separator (set to None for white space). 158 self.sep = None
159