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

Source Code for Module data.gui

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