1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 import sys
24
25 from doc_string import regexp_doc
26 import help
27 from generic_fns.minimise import Minimise
28 from specific_fns.consistency_tests import Consistency_tests
29 from specific_fns.model_free import Model_free
30 from specific_fns.jw_mapping import Jw_mapping
31 from specific_fns.noe import Noe
32 from specific_fns.relax_fit import Relax_fit
33
34
37
38 self.__relax_help__ = \
39 """Class for interfacing with Grace."""
40
41
42 self.__relax_help__ = self.__relax_help__ + "\n" + help.relax_class_help
43
44
45 self.__relax__ = relax
46
47
48 - def view(self, file=None, dir='grace', grace_exe='xmgrace'):
49 """Function for running Grace.
50
51 Keyword Arguments
52 ~~~~~~~~~~~~~~~~~
53
54 file: The name of the file.
55
56 dir: The directory name.
57
58 grace_exe: The Grace executable file.
59
60
61 Description
62 ~~~~~~~~~~~
63
64 This function can be used to execute Grace to view the specified file the Grace '.agr' file
65 and the execute Grace. If the directory name is set to None, the file will be assumed to be
66 in the current working directory.
67
68
69 Examples
70 ~~~~~~~~
71
72 To view the file 's2.agr' in the directory 'grace', type:
73
74 relax> grace.view(file='s2.agr')
75 relax> grace.view(file='s2.agr', dir='grace')
76 """
77
78
79 if self.__relax__.interpreter.intro:
80 text = sys.ps3 + "grace.view("
81 text = text + "file=" + `file`
82 text = text + ", dir=" + `dir`
83 text = text + ", grace_exe=" + `grace_exe` + ")"
84 print text
85
86
87 if type(file) != str:
88 raise RelaxStrError, ('file name', file)
89
90
91 if dir != None and type(dir) != str:
92 raise RelaxNoneStrError, ('directory name', dir)
93
94
95 if type(grace_exe) != str:
96 raise RelaxStrError, ('Grace executable file', grace_exe)
97
98
99 self.__relax__.generic.grace.view(file=file, dir=dir, grace_exe=grace_exe)
100
101
102 - def write(self, run=None, x_data_type='res', y_data_type=None, res_num=None, res_name=None, plot_data='value', norm=0, file=None, dir='grace', force=0):
103 """Function for creating a grace '.agr' file.
104
105 Keyword Arguments
106 ~~~~~~~~~~~~~~~~~
107
108 run: The name of the run.
109
110 x_data_type: The data type for the X-axis (no regular expression is allowed).
111
112 y_data_type: The data type for the Y-axis (no regular expression is allowed).
113
114 res_num: The residue number (regular expression is allowed).
115
116 res_name: The residue name (regular expression is allowed).
117
118 plot_data: The data to use for the plot.
119
120 norm: Flag for the normalisation of series type data.
121
122 file: The name of the file.
123
124 dir: The directory name.
125
126 force: A flag which, if set to 1, will cause the file to be overwritten.
127
128
129 Description
130 ~~~~~~~~~~~
131
132 This function is designed to be as flexible as possible so that any combination of data can
133 be plotted. The output is in the format of a Grace plot (also known as ACE/gr, Xmgr, and
134 xmgrace) which only supports two dimensional plots. Three types of keyword arguments can
135 be used to create various types of plot. These include the X-axis and Y-axis data types,
136 the residue number and name selection arguments, and an argument for selecting what to
137 actually plot.
138
139 The X-axis and Y-axis data type arguments should be plain strings, regular expression is not
140 allowed. If the X-axis data type argument is not given, the plot will default to having the
141 residue number along the x-axis. The two axes of the Grace plot can be absolutely any of
142 the data types listed in the tables below. The only limitation, currently anyway, is that
143 the data must belong to the same run.
144
145 The residue number and name arguments can be used to limit the residues used in the plot.
146 The default is that all residues will be used, however, these arguments can be used to
147 select a subset of all residues, or a single residue for plots of Monte Carlo simulations,
148 etc. Regular expression is allowed for both the residue number and name, and the number can
149 either be an integer or a string.
150
151 The property which is actually plotted can be controlled by the 'plot_data' argument. It
152 can be one of the following:
153 'value': Plot values (with errors if they exist).
154 'error': Plot errors.
155 'sims': Plot the simulation values.
156
157 Normalisation is only allowed for series type data, for example the R2 exponential curves,
158 and will be ignored for all other data types. If the norm flag is set to one then the
159 y-value of the first point of the series will be set to 1. This normalisation is useful for
160 emphasising errors in the data sets.
161
162
163 Examples
164 ~~~~~~~~
165
166 To write the NOE values for all residues from the run 'noe' to the Grace file 'noe.agr',
167 type:
168
169 relax> grace.write('noe', 'res', 'noe', file='noe.agr')
170 relax> grace.write('noe', y_data_type='noe', file='noe.agr')
171 relax> grace.write('noe', x_data_type='res', y_data_type='noe', file='noe.agr')
172 relax> grace.write(run='noe', y_data_type='noe', file='noe.agr', force=1)
173
174
175 To create a Grace file of 'S2' vs. 'te' for all residues, type:
176
177 relax> grace.write('m2', 'S2', 'te', file='s2_te.agr')
178 relax> grace.write('m2', x_data_type='S2', y_data_type='te', file='s2_te.agr')
179 relax> grace.write(run='m2', x_data_type='S2', y_data_type='te', file='s2_te.agr', force=1)
180
181
182 To create a Grace file of the Monte Carlo simulation values of 'Rex' vs. 'te' for residue
183 123, type:
184
185 relax> grace.write('m4', 'Rex', 'te', res_num=123, plot_data='sims', file='s2_te.agr')
186 relax> grace.write(run='m4', x_data_type='Rex', y_data_type='te', res_num=123,
187 plot_data='sims', file='s2_te.agr')
188
189
190 By plotting the peak intensities, the integrity of exponential relaxation curves can be
191 checked and anomalies searched for prior to model-free analysis or reduced spectral density
192 mapping. For example the normalised average peak intensities can be plotted verses the
193 relaxation time periods for the relaxation curves of all residues of a protein. The
194 normalisation, whereby the initial peak intensity of each residue I(0) is set to 1,
195 emphasises any problems. To produce this Grace file, type:
196
197 relax> grace.write(name, x_data_type='relax_times', y_data_type='ave_int',
198 norm=1, file='intensities_norm.agr', force=1)
199 """
200
201
202 if self.__relax__.interpreter.intro:
203 text = sys.ps3 + "grace.write("
204 text = text + "run=" + `run`
205 text = text + ", x_data_type=" + `x_data_type`
206 text = text + ", y_data_type=" + `y_data_type`
207 text = text + ", res_num=" + `res_num`
208 text = text + ", res_name=" + `res_name`
209 text = text + ", plot_data=" + `plot_data`
210 text = text + ", norm=" + `norm`
211 text = text + ", file=" + `file`
212 text = text + ", dir=" + `dir`
213 text = text + ", force=" + `force` + ")"
214 print text
215
216
217 if type(run) != str:
218 raise RelaxStrError, ('run', run)
219
220
221 if type(x_data_type) != str:
222 raise RelaxStrError, ('x data type', x_data_type)
223
224
225 if type(y_data_type) != str:
226 raise RelaxStrError, ('y data type', y_data_type)
227
228
229 if res_num != None and type(res_num) != int and type(res_num) != str:
230 raise RelaxNoneIntStrError, ('residue number', res_num)
231
232
233 if res_name != None and type(res_name) != str:
234 raise RelaxNoneStrError, ('residue name', res_name)
235
236
237 if type(plot_data) != str:
238 raise RelaxStrError, ('plot data', plot_data)
239
240
241 if type(file) != str:
242 raise RelaxStrError, ('file name', file)
243
244
245 if dir != None and type(dir) != str:
246 raise RelaxNoneStrError, ('directory name', dir)
247
248
249 if type(force) != int or (force != 0 and force != 1):
250 raise RelaxBinError, ('force flag', force)
251
252
253 self.__relax__.generic.grace.write(run=run, x_data_type=x_data_type, y_data_type=y_data_type, res_num=res_num, res_name=res_name, plot_data=plot_data, norm=norm, file=file, dir=dir, force=force)
254
255
256
257
258
259
260
261 write.__doc__ = write.__doc__ + "\n\n" + regexp_doc() + "\n"
262 write.__doc__ = write.__doc__ + Consistency_tests.return_data_name.__doc__ + "\n\n"
263 write.__doc__ = write.__doc__ + Minimise.return_data_name.__doc__ + "\n\n"
264 write.__doc__ = write.__doc__ + Noe.return_data_name.__doc__ + "\n"
265 write.__doc__ = write.__doc__ + Relax_fit.return_data_name.__doc__ + "\n"
266 write.__doc__ = write.__doc__ + Jw_mapping.return_data_name.__doc__ + "\n\n"
267 write.__doc__ = write.__doc__ + Model_free.return_data_name.__doc__ + "\n\n"
268