1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 """The grace user function definitions for controlling the Grace data viewing software."""
24
25
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
34 from graphics import WIZARD_IMAGE_PATH
35 from pipe_control import grace, minimise
36 from prompt.doc_string import regexp_doc
37 from specific_analyses.consistency_tests import Consistency_tests
38 from specific_analyses.jw_mapping import Jw_mapping
39 from specific_analyses.model_free import Model_free
40 from specific_analyses.noe import Noe
41 from specific_analyses.relax_disp.api import Relax_disp
42 from specific_analyses.relax_fit import Relax_fit
43 from user_functions.data import Uf_info; uf_info = Uf_info()
44 from user_functions.objects import Desc_container
45
46
47
48 uf_class = uf_info.add_class('grace')
49 uf_class.title = "Class for interfacing with Grace."
50 uf_class.menu_text = "&grace"
51 uf_class.gui_icon = "relax.grace_icon"
52
53
54
55 uf = uf_info.add_uf('grace.view')
56 uf.title = "Visualise the file within Grace."
57 uf.title_short = "Grace execution."
58 uf.add_keyarg(
59 name = "file",
60 py_type = "str",
61 arg_type = "file sel",
62 desc_short = "file name",
63 desc = "The name of the file.",
64 wiz_filesel_wildcard = "Grace files (*.agr)|*.agr;*.AGR",
65 wiz_filesel_style = FD_OPEN
66 )
67 uf.add_keyarg(
68 name = "dir",
69 default = "grace",
70 py_type = "str",
71 arg_type = "dir",
72 desc_short = "directory name",
73 desc = "The directory name.",
74 can_be_none = True
75 )
76 uf.add_keyarg(
77 name = "grace_exe",
78 default = "xmgrace",
79 py_type = "str",
80 arg_type = "file sel",
81 desc_short = "Grace executable file",
82 desc = "The Grace executable file.",
83 wiz_filesel_style = FD_OPEN,
84 wiz_filesel_preview = False
85 )
86
87 uf.desc.append(Desc_container())
88 uf.desc[-1].add_paragraph("This can be used to view the specified Grace '*.agr' file by opening it with the Grace program.")
89
90 uf.desc.append(Desc_container("Prompt examples"))
91 uf.desc[-1].add_paragraph("To view the file 's2.agr' in the directory 'grace', type:")
92 uf.desc[-1].add_prompt("relax> grace.view(file='s2.agr')")
93 uf.desc[-1].add_prompt("relax> grace.view(file='s2.agr', dir='grace')")
94 uf.backend = grace.view
95 uf.menu_text = "&view"
96 uf.gui_icon = "relax.grace_icon"
97 uf.wizard_size = (900, 500)
98 uf.wizard_image = WIZARD_IMAGE_PATH + 'grace.png'
99
100
101
102 uf = uf_info.add_uf('grace.write')
103 uf.title = "Create a grace '.agr' file to visualise the 2D data."
104 uf.title_short = "Grace file creation."
105 uf.add_keyarg(
106 name = "x_data_type",
107 default = "res_num",
108 py_type = "str",
109 desc_short = "x data type",
110 desc = "The data type for the X-axis (no regular expression is allowed).",
111 wiz_element_type = 'combo',
112 wiz_combo_iter = grace.get_data_types
113 )
114 uf.add_keyarg(
115 name = "y_data_type",
116 py_type = "str",
117 desc_short = "y data type",
118 desc = "The data type for the Y-axis (no regular expression is allowed).",
119 wiz_element_type = 'combo',
120 wiz_combo_iter = grace.get_data_types
121 )
122 uf.add_keyarg(
123 name = "spin_id",
124 py_type = "str",
125 desc_short = "spin ID string",
126 desc = "The spin ID string.",
127 can_be_none = True
128 )
129 uf.add_keyarg(
130 name = "plot_data",
131 default = "value",
132 py_type = "str",
133 desc_short = "plot data",
134 desc = "The data to use for the plot.",
135 wiz_element_type = "combo",
136 wiz_combo_choices = [
137 "Values",
138 "Errors",
139 "Simulation values"
140 ],
141 wiz_combo_data = [
142 "value",
143 "error",
144 "sims"
145 ],
146 wiz_read_only = True
147 )
148 uf.add_keyarg(
149 name = "file",
150 py_type = "str",
151 arg_type = "file sel",
152 desc_short = "file name",
153 desc = "The name of the file.",
154 wiz_filesel_wildcard = "Grace files (*.agr)|*.agr;*.AGR",
155 wiz_filesel_style = FD_SAVE
156 )
157 uf.add_keyarg(
158 name = "dir",
159 default = "grace",
160 py_type = "str",
161 arg_type = "dir",
162 desc_short = "directory name",
163 desc = "The directory name.",
164 can_be_none = True
165 )
166 uf.add_keyarg(
167 name = "force",
168 default = False,
169 py_type = "bool",
170 desc_short = "force flag",
171 desc = "A flag which, if set to True, will cause the file to be overwritten."
172 )
173 uf.add_keyarg(
174 name = "norm",
175 default = False,
176 py_type = "bool",
177 desc_short = "normalisation flag",
178 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."
179 )
180
181 uf.desc.append(Desc_container())
182 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 ID string, and the type of data plot.")
183 uf.desc[-1].add_paragraph("The x-axis and y-axis data types should be plain strings, regular expression is not allowed. The two axes of the Grace plot can be any of the data types listed in the tables below. The only limitation is that the data must belong to the same data pipe.")
184 uf.desc[-1].add_paragraph("If the x-axis data type is not given, the plot will default to having the residue numbering along the x-axis.Two special data types for the axes are:")
185 uf.desc[-1].add_item_list_element("'res_num'", "The axis will consist of the residue numbering.")
186 uf.desc[-1].add_item_list_element("'spin_num'", "The axis will consist of the spin numbering.")
187 uf.desc[-1].add_paragraph("The spin ID 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.")
188 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:")
189 uf.desc[-1].add_item_list_element("'value'", "Plot values (with errors if they exist).")
190 uf.desc[-1].add_item_list_element("'error'", "Plot errors.")
191 uf.desc[-1].add_item_list_element("'sims'", "Plot the simulation values.")
192 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.")
193 uf.desc.append(regexp_doc)
194 uf.desc.append(minimise.return_data_name_doc)
195 uf.desc.append(Noe.return_data_name_doc)
196 uf.desc.append(Relax_disp.return_data_name_doc)
197 uf.desc.append(Relax_fit.return_data_name_doc)
198 uf.desc.append(Jw_mapping.return_data_name_doc)
199 uf.desc.append(Consistency_tests.return_data_name_doc)
200 uf.desc.append(Model_free.return_data_name_doc)
201
202 uf.desc.append(Desc_container("Prompt examples"))
203 uf.desc[-1].add_paragraph("To write the NOE values for all spins to the Grace file 'noe.agr', type one of:")
204 uf.desc[-1].add_prompt("relax> grace.write('res_num', 'noe', file='noe.agr')")
205 uf.desc[-1].add_prompt("relax> grace.write(y_data_type='noe', file='noe.agr')")
206 uf.desc[-1].add_prompt("relax> grace.write(x_data_type='res_num', y_data_type='noe', file='noe.agr')")
207 uf.desc[-1].add_prompt("relax> grace.write(y_data_type='noe', file='noe.agr', force=True)")
208 uf.desc[-1].add_paragraph("To create a Grace file of 's2' vs. 'te' for all spins, type one of:")
209 uf.desc[-1].add_prompt("relax> grace.write('s2', 'te', file='s2_te.agr')")
210 uf.desc[-1].add_prompt("relax> grace.write(x_data_type='s2', y_data_type='te', file='s2_te.agr')")
211 uf.desc[-1].add_prompt("relax> grace.write(x_data_type='s2', y_data_type='te', file='s2_te.agr', force=True)")
212 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:")
213 uf.desc[-1].add_prompt("relax> grace.write('rex', 'te', spin_id=':123', plot_data='sims', file='s2_te.agr')")
214 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')")
215 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:")
216 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)")
217 uf.backend = grace.write
218 uf.menu_text = "&write"
219 uf.gui_icon = "oxygen.actions.document-save"
220 uf.wizard_size = (1000, 700)
221 uf.wizard_image = WIZARD_IMAGE_PATH + 'grace.png'
222