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

Source Code for Module user_functions.grace

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2004-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 grace user function definitions for controlling the Grace data viewing software.""" 
 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 grace, minimise 
 35  from graphics import WIZARD_IMAGE_PATH 
 36  from prompt.doc_string import regexp_doc 
 37  from specific_fns.consistency_tests import Consistency_tests 
 38  from specific_fns.jw_mapping import Jw_mapping 
 39  from specific_fns.model_free import Model_free 
 40  from specific_fns.noe import Noe 
 41  from specific_fns.relax_fit import Relax_fit 
 42  from user_functions.data import Uf_info; uf_info = Uf_info() 
 43  from user_functions.objects import Desc_container 
 44   
 45   
 46  # The user function class. 
 47  uf_class = uf_info.add_class('grace') 
 48  uf_class.title = "Class for interfacing with Grace." 
 49  uf_class.menu_text = "&grace" 
 50  uf_class.gui_icon = "relax.grace_icon" 
 51   
 52   
 53  # The grace.view user function. 
 54  uf = uf_info.add_uf('grace.view') 
 55  uf.title = "Visualise the file within Grace." 
 56  uf.title_short = "Grace execution." 
 57  uf.add_keyarg( 
 58      name = "file", 
 59      py_type = "str", 
 60      arg_type = "file sel", 
 61      desc_short = "file name", 
 62      desc = "The name of the file.", 
 63      wiz_filesel_wildcard = "Grace files (*.agr)|*.agr;*.AGR", 
 64      wiz_filesel_style = FD_OPEN 
 65  ) 
 66  uf.add_keyarg( 
 67      name = "dir", 
 68      default = "grace", 
 69      py_type = "str", 
 70      arg_type = "dir", 
 71      desc_short = "directory name", 
 72      desc = "The directory name.", 
 73      can_be_none = True 
 74  ) 
 75  uf.add_keyarg( 
 76      name = "grace_exe", 
 77      default = "xmgrace", 
 78      py_type = "str", 
 79      desc_short = "Grace executable file", 
 80      desc = "The Grace executable file." 
 81  ) 
 82  # Description. 
 83  uf.desc.append(Desc_container()) 
 84  uf.desc[-1].add_paragraph("This can be used to view the specified Grace '*.agr' file by opening it with the Grace program.") 
 85  # Prompt examples. 
 86  uf.desc.append(Desc_container("Prompt examples")) 
 87  uf.desc[-1].add_paragraph("To view the file 's2.agr' in the directory 'grace', type:") 
 88  uf.desc[-1].add_prompt("relax> grace.view(file='s2.agr')") 
 89  uf.desc[-1].add_prompt("relax> grace.view(file='s2.agr', dir='grace')") 
 90  uf.backend = grace.view 
 91  uf.menu_text = "&view" 
 92  uf.gui_icon = "relax.grace_icon" 
 93  uf.wizard_size = (900, 500) 
 94  uf.wizard_image = WIZARD_IMAGE_PATH + 'grace.png' 
 95   
 96   
 97  # The grace.write user function. 
 98  uf = uf_info.add_uf('grace.write') 
 99  uf.title = "Create a grace '.agr' file to visualise the 2D data." 
100  uf.title_short = "Grace file creation." 
101  uf.add_keyarg( 
102      name = "x_data_type", 
103      default = "spin", 
104      py_type = "str", 
105      desc_short = "x data type", 
106      desc = "The data type for the X-axis (no regular expression is allowed).", 
107      wiz_element_type = 'combo', 
108      wiz_combo_iter = grace.get_data_types 
109  ) 
110  uf.add_keyarg( 
111      name = "y_data_type", 
112      py_type = "str", 
113      desc_short = "y data type", 
114      desc = "The data type for the Y-axis (no regular expression is allowed).", 
115      wiz_element_type = 'combo', 
116      wiz_combo_iter = grace.get_data_types 
117  ) 
118  uf.add_keyarg( 
119      name = "spin_id", 
120      py_type = "str", 
121      desc_short = "spin ID string", 
122      desc = "The spin identification string.", 
123      can_be_none = True 
124  ) 
125  uf.add_keyarg( 
126      name = "plot_data", 
127      default = "value", 
128      py_type = "str", 
129      desc_short = "plot data", 
130      desc = "The data to use for the plot.", 
131      wiz_element_type = "combo", 
132      wiz_combo_choices = [ 
133          "Values", 
134          "Errors", 
135          "Simulation values" 
136      ], 
137      wiz_combo_data = [ 
138          "value", 
139          "error", 
140          "sims" 
141      ], 
142      wiz_read_only = True 
143  ) 
144  uf.add_keyarg( 
145      name = "file", 
146      py_type = "str", 
147      arg_type = "file sel", 
148      desc_short = "file name", 
149      desc = "The name of the file.", 
150      wiz_filesel_wildcard = "Grace files (*.agr)|*.agr;*.AGR", 
151      wiz_filesel_style = FD_SAVE 
152  ) 
153  uf.add_keyarg( 
154      name = "dir", 
155      default = "grace", 
156      py_type = "str", 
157      arg_type = "dir", 
158      desc_short = "directory name", 
159      desc = "The directory name.", 
160      can_be_none = True 
161  ) 
162  uf.add_keyarg( 
163      name = "force", 
164      default = False, 
165      py_type = "bool", 
166      desc_short = "force flag", 
167      desc = "A flag which, if set to True, will cause the file to be overwritten." 
168  ) 
169  uf.add_keyarg( 
170      name = "norm", 
171      default = False, 
172      py_type = "bool", 
173      desc_short = "normalisation flag", 
174      desc = "A flag which, if set to True, will cause all graphs to be normalised to a starting value of 1.  This is for the normalisation of series type data." 
175  ) 
176  # Description. 
177  uf.desc.append(Desc_container()) 
178  uf.desc[-1].add_paragraph("This is designed to be as flexible as possible so that any combination of data can be plotted.  The output is in the format of a Grace plot (also known as ACE/gr, Xmgr, and xmgrace) which only supports two dimensional plots.  Three types of information can be used to create various types of plot.  These include the x-axis and y-axis data types, the spin identification string, and the type of data plot.") 
179  uf.desc[-1].add_paragraph("The x-axis and y-axis data types should be plain strings, regular expression is not allowed.  If the x-axis data type is not given, the plot will default to having the spin sequence along the x-axis.  The two axes of the Grace plot can be absolutely any of the data types listed in the tables below.  The only limitation, currently anyway, is that the data must belong to the same data pipe.") 
180  uf.desc[-1].add_paragraph("The spin identification string can be used to limit which spins are used in the plot.  The default is that all spins will be used, however, the ID string can be used to select a subset of all spins, or a single spin for plots of Monte Carlo simulations, etc.") 
181  uf.desc[-1].add_paragraph("The property which is actually plotted can be controlled by the plot data setting.  This can be one of the following:") 
182  uf.desc[-1].add_item_list_element("'value'", "Plot values (with errors if they exist).") 
183  uf.desc[-1].add_item_list_element("'error'", "Plot errors.") 
184  uf.desc[-1].add_item_list_element("'sims'", "Plot the simulation values.") 
185  uf.desc[-1].add_paragraph("Normalisation is only allowed for series type data, for example the R2 exponential curves, and will be ignored for all other data types.  If the norm flag is set to True then the y-value of the first point of the series will be set to 1.  This normalisation is useful for highlighting errors in the data sets.") 
186  uf.desc.append(regexp_doc) 
187  uf.desc.append(minimise.return_data_name_doc) 
188  uf.desc.append(Noe.return_data_name_doc) 
189  uf.desc.append(Relax_fit.return_data_name_doc) 
190  uf.desc.append(Jw_mapping.return_data_name_doc) 
191  uf.desc.append(Consistency_tests.return_data_name_doc) 
192  uf.desc.append(Model_free.return_data_name_doc) 
193  # Prompt examples. 
194  uf.desc.append(Desc_container("Prompt examples")) 
195  uf.desc[-1].add_paragraph("To write the NOE values for all spins to the Grace file 'noe.agr', type one of:") 
196  uf.desc[-1].add_prompt("relax> grace.write('spin', 'noe', file='noe.agr')") 
197  uf.desc[-1].add_prompt("relax> grace.write(y_data_type='noe', file='noe.agr')") 
198  uf.desc[-1].add_prompt("relax> grace.write(x_data_type='spin', y_data_type='noe', file='noe.agr')") 
199  uf.desc[-1].add_prompt("relax> grace.write(y_data_type='noe', file='noe.agr', force=True)") 
200  uf.desc[-1].add_paragraph("To create a Grace file of 's2' vs. 'te' for all spins, type one of:") 
201  uf.desc[-1].add_prompt("relax> grace.write('s2', 'te', file='s2_te.agr')") 
202  uf.desc[-1].add_prompt("relax> grace.write(x_data_type='s2', y_data_type='te', file='s2_te.agr')") 
203  uf.desc[-1].add_prompt("relax> grace.write(x_data_type='s2', y_data_type='te', file='s2_te.agr', force=True)") 
204  uf.desc[-1].add_paragraph("To create a Grace file of the Monte Carlo simulation values of 'rex' vs. 'te' for residue 123, type one of:") 
205  uf.desc[-1].add_prompt("relax> grace.write('rex', 'te', spin_id=':123', plot_data='sims', file='s2_te.agr')") 
206  uf.desc[-1].add_prompt("relax> grace.write(x_data_type='rex', y_data_type='te', spin_id=':123', plot_data='sims', file='s2_te.agr')") 
207  uf.desc[-1].add_paragraph("By plotting the peak intensities, the integrity of exponential relaxation curves can be checked and anomalies searched for prior to model-free analysis or reduced spectral density mapping.  For example the normalised average peak intensities can be plotted verses the relaxation time periods for the relaxation curves of all residues of a protein.  The normalisation, whereby the initial peak intensity of each residue I(0) is set to 1, emphasises any problems.  To produce this Grace file, type:") 
208  uf.desc[-1].add_prompt("relax> grace.write(x_data_type='relax_times', y_data_type='ave_int', file='intensities_norm.agr', force=True, norm=True)") 
209  uf.backend = grace.write 
210  uf.menu_text = "&write" 
211  uf.gui_icon = "oxygen.actions.document-save" 
212  uf.wizard_size = (1000, 700) 
213  uf.wizard_image = WIZARD_IMAGE_PATH + 'grace.png' 
214