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