Package user_functions :: Module results
[hide private]
[frames] | no frames]

Source Code for Module user_functions.results

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2003-2012 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 results user function definitions.""" 
 24   
 25  # Python module imports. 
 26  import dep_check 
 27  if dep_check.wx_module: 
 28      from wx import FD_OPEN, FD_SAVE 
 29  else: 
 30      FD_OPEN = -1 
 31      FD_SAVE = -1 
 32   
 33  # relax module imports. 
 34  from generic_fns import results 
 35  from graphics import WIZARD_IMAGE_PATH 
 36  from user_functions.data import Uf_info; uf_info = Uf_info() 
 37  from user_functions.objects import Desc_container 
 38   
 39   
 40  # The user function class. 
 41  uf_class = uf_info.add_class('results') 
 42  uf_class.title = "Class for manipulating results." 
 43  uf_class.menu_text = "&results" 
 44  uf_class.gui_icon = "relax.relax" 
 45   
 46   
 47  # The results.display user function. 
 48  uf = uf_info.add_uf('results.display') 
 49  uf.title = "Display the results." 
 50  uf.title_short = "Results display." 
 51  uf.display = True 
 52  # Description. 
 53  uf.desc.append(Desc_container()) 
 54  uf.desc[-1].add_paragraph("This will print to screen (STDOUT) the results contained within the current data pipe.") 
 55  uf.backend = results.display 
 56  uf.menu_text = "&display" 
 57  uf.gui_icon = "oxygen.actions.document-preview" 
 58  uf.wizard_size = (600, 300) 
 59  uf.wizard_apply_button = False 
 60   
 61   
 62  # The results.read user function. 
 63  uf = uf_info.add_uf('results.read') 
 64  uf.title = "Read the contents of a relax results file into the relax data store." 
 65  uf.title_short = "Results reading." 
 66  uf.add_keyarg( 
 67      name = "file", 
 68      default = "results", 
 69      py_type = "str", 
 70      arg_type = "file sel", 
 71      desc_short = "file name", 
 72      desc = "The name of the file to read results from.", 
 73      wiz_filesel_wildcard = "relax results files (*.bz2)|*.bz2|relax results files (*.gz)|*.gz|relax results files (*.*)|*.*", 
 74      wiz_filesel_style = FD_OPEN 
 75  ) 
 76  uf.add_keyarg( 
 77      name = "dir", 
 78      py_type = "str", 
 79      arg_type = "dir", 
 80      desc_short = "directory name", 
 81      desc = "The directory where the file is located.", 
 82      can_be_none = True 
 83  ) 
 84  # Description. 
 85  uf.desc.append(Desc_container()) 
 86  uf.desc[-1].add_paragraph("This is able to handle uncompressed, bzip2 compressed files, or gzip compressed files automatically.  The full file name including extension can be supplied, however, if the file cannot be found the file with '.bz2' appended followed by the file name with '.gz' appended will be searched for.") 
 87  uf.backend = results.read 
 88  uf.menu_text = "&read" 
 89  uf.gui_icon = "oxygen.actions.document-open" 
 90  uf.wizard_size = (700, 500) 
 91  uf.wizard_apply_button = False 
 92   
 93   
 94  # The results.write user function. 
 95  uf = uf_info.add_uf('results.write') 
 96  uf.title = "Write the results to a file." 
 97  uf.title_short = "Results writing." 
 98  uf.add_keyarg( 
 99      name = "file", 
100      default = "results", 
101      py_type = "str_or_inst", 
102      arg_type = "file sel", 
103      desc_short = "file name", 
104      desc = "The name of the file to output results to.  The default is 'results'.  Optionally this can be a file object, or any object with a write() method.", 
105      wiz_filesel_wildcard = "relax results files (*.bz2)|*.bz2|relax results files (*.gz)|*.gz|relax results files (*.*)|*.*", 
106      wiz_filesel_style = FD_SAVE 
107  ) 
108  uf.add_keyarg( 
109      name = "dir", 
110      default = "pipe_name", 
111      py_type = "str", 
112      arg_type = "dir", 
113      desc_short = "directory name", 
114      desc = "The directory name.", 
115      can_be_none = True 
116  ) 
117  uf.add_keyarg( 
118      name = "compress_type", 
119      default = 1, 
120      py_type = "int", 
121      desc_short = "compression type", 
122      desc = "The type of compression to use when creating the file.", 
123      wiz_element_type = "combo", 
124      wiz_combo_choices = [ 
125          "No compression", 
126          "bzip2 compression", 
127          "gzip compression" 
128      ], 
129      wiz_combo_data = [ 
130          0, 
131          1, 
132          2 
133      ], 
134      wiz_read_only = True, 
135  ) 
136  uf.add_keyarg( 
137      name = "force", 
138      default = False, 
139      py_type = "bool", 
140      desc_short = "force flag", 
141      desc = "A flag which if True will cause the results file to be overwritten." 
142  ) 
143  # Description. 
144  uf.desc.append(Desc_container()) 
145  uf.desc[-1].add_paragraph("This will write the entire contents of the current data pipe into an XML formatted file.  This results file can then be read back into relax at a later point in time, or transfered to another machine.  This is in contrast to the state.save user function whereby the entire data store, including all data pipes, are saved into a similarly XML formatted file.") 
146  uf.desc[-1].add_paragraph("To place the results file in the current working directory in the prompt and scripting modes, leave the directory unset.  If the directory is set to the special name 'pipe_name', then the results file will be placed into a directory with the same name as the current data pipe.") 
147  uf.desc[-1].add_paragraph("The default behaviour of this function is to compress the file using bzip2 compression.  If the extension '.bz2' is not included in the file name, it will be added.  The compression can, however, be changed to either no compression or gzip compression.  This is controlled by the compression type which can be set to") 
148  uf.desc[-1].add_item_list_element("0", "No compression (no file extension),") 
149  uf.desc[-1].add_item_list_element("1", "bzip2 compression ('.bz2' file extension),") 
150  uf.desc[-1].add_item_list_element("2", "gzip compression ('.gz' file extension).") 
151  uf.desc[-1].add_paragraph("The complementary read function will automatically handle the compressed files.") 
152  uf.backend = results.write 
153  uf.menu_text = "&write" 
154  uf.gui_icon = "oxygen.actions.document-save" 
155  uf.wizard_height_desc = 450 
156  uf.wizard_size = (1000, 750) 
157  uf.wizard_apply_button = False 
158