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.model_free import Model_free
29 from specific_fns.jw_mapping import Jw_mapping
30 from specific_fns.noe import Noe
31
32
35
36 self.__relax_help__ = \
37 """Class for interfacing with Grace."""
38
39
40 self.__relax_help__ = self.__relax_help__ + "\n" + help.relax_class_help
41
42
43 self.__relax__ = relax
44
45
46 - def view(self, file=None, dir='grace', grace_exe='xmgrace'):
47 """Function for running Grace.
48
49 Keyword Arguments
50 ~~~~~~~~~~~~~~~~~
51
52 file: The name of the file.
53
54 dir: The directory name.
55
56 grace_exe: The Grace executable file.
57
58
59 Description
60 ~~~~~~~~~~~
61
62 This function can be used to execute Grace to view the specified file the Grace '.agr' file
63 and the execute Grace. If the directory name is set to None, the file will be assumed to be
64 in the current working directory.
65
66
67 Examples
68 ~~~~~~~~
69
70 To view the file 's2.agr' in the directory 'grace', type:
71
72 relax> grace.view(file='s2.agr')
73 relax> grace.view(file='s2.agr', dir='grace')
74 """
75
76
77 if self.__relax__.interpreter.intro:
78 text = sys.ps3 + "grace.view("
79 text = text + "file=" + `file`
80 text = text + ", dir=" + `dir`
81 text = text + ", grace_exe=" + `grace_exe` + ")"
82 print text
83
84
85 if type(file) != str:
86 raise RelaxStrError, ('file name', file)
87
88
89 if dir != None and type(dir) != str:
90 raise RelaxNoneStrError, ('directory name', dir)
91
92
93 if type(grace_exe) != str:
94 raise RelaxStrError, ('Grace executable file', grace_exe)
95
96
97 self.__relax__.generic.grace.view(file=file, dir=dir, grace_exe=grace_exe)
98
99
100 - def write(self, run=None, x_data_type='res', y_data_type=None, res_num=None, res_name=None, plot_data='value', file=None, dir='grace', force=0):
101 """Function for creating a grace '.agr' file.
102
103 Keyword Arguments
104 ~~~~~~~~~~~~~~~~~
105
106 run: The name of the run.
107
108 x_data_type: The data type for the X-axis (no regular expression is allowed).
109
110 y_data_type: The data type for the Y-axis (no regular expression is allowed).
111
112 res_num: The residue number (regular expression is allowed).
113
114 res_name: The residue name (regular expression is allowed).
115
116 plot_data: The data to use for the plot.
117
118 file: The name of the file.
119
120 dir: The directory name.
121
122 force: A flag which, if set to 1, will cause the file to be overwritten.
123
124
125 Description
126 ~~~~~~~~~~~
127
128 This function is designed to be as flexible as possible so that any combination of data can
129 be plotted. The output is in the format of a Grace plot (also known as ACE/gr, Xmgr, and
130 xmgrace) which only supports two dimensional plots. Three types of keyword arguments can
131 be used to create various types of plot. These include the X-axis and Y-axis data types,
132 the residue number and name selection arguments, and an argument for selecting what to
133 actually plot.
134
135 The X-axis and Y-axis data type arguments should be plain strings, regular expression is not
136 allowed. If the X-axis data type argument is not given, the plot will default to having the
137 residue number along the x-axis. The two axes of the Grace plot can be absolutely any of
138 the data types listed in the tables below. The only limitation, currently anyway, is that
139 the data must belong to the same run.
140
141 The residue number and name arguments can be used to limit the residues used in the plot.
142 The default is that all residues will be used, however, these arguments can be used to
143 select a subset of all residues, or a single residue for plots of Monte Carlo simulations,
144 etc. Regular expression is allowed for both the residue number and name, and the number can
145 either be an integer or a string.
146
147 The property which is actually plotted can be controlled by the 'plot_data' argument. It
148 can be one of the following:
149 'value': Plot values (with errors if they exist).
150 'error': Plot errors.
151 'sims': Plot the simulation values.
152
153
154 Examples
155 ~~~~~~~~
156
157 To write the NOE values for all residues from the run 'noe' to the Grace file 'noe.agr',
158 type:
159
160 relax> grace.write('noe', 'res', 'noe', file='noe.agr')
161 relax> grace.write('noe', y_data_type='noe', file='noe.agr')
162 relax> grace.write('noe', x_data_type='res', y_data_type='noe', file='noe.agr')
163 relax> grace.write(run='noe', y_data_type='noe', file='noe.agr', force=1)
164
165
166 To create a Grace file of 'S2' vs. 'te' for all residues, type:
167
168 relax> grace.write('m2', 'S2', 'te', file='s2_te.agr')
169 relax> grace.write('m2', x_data_type='S2', y_data_type='te', file='s2_te.agr')
170 relax> grace.write(run='m2', x_data_type='S2', y_data_type='te', file='s2_te.agr', force=1)
171
172
173 To create a Grace file of the Monte Carlo simulation values of 'Rex' vs. 'te' for residue
174 123, type:
175
176 relax> grace.write('m4', 'Rex', 'te', res_num=123, plot_data='sims', file='s2_te.agr')
177 relax> grace.write(run='m4', x_data_type='Rex', y_data_type='te', res_num=123,
178 plot_data='sims', file='s2_te.agr')
179 """
180
181
182 if self.__relax__.interpreter.intro:
183 text = sys.ps3 + "grace.write("
184 text = text + "run=" + `run`
185 text = text + ", x_data_type=" + `x_data_type`
186 text = text + ", y_data_type=" + `y_data_type`
187 text = text + ", res_num=" + `res_num`
188 text = text + ", res_name=" + `res_name`
189 text = text + ", plot_data=" + `plot_data`
190 text = text + ", file=" + `file`
191 text = text + ", dir=" + `dir`
192 text = text + ", force=" + `force` + ")"
193 print text
194
195
196 if type(run) != str:
197 raise RelaxStrError, ('run', run)
198
199
200 if type(x_data_type) != str:
201 raise RelaxStrError, ('x data type', x_data_type)
202
203
204 if type(y_data_type) != str:
205 raise RelaxStrError, ('y data type', y_data_type)
206
207
208 if res_num != None and type(res_num) != int and type(res_num) != str:
209 raise RelaxNoneIntStrError, ('residue number', res_num)
210
211
212 if res_name != None and type(res_name) != str:
213 raise RelaxNoneStrError, ('residue name', res_name)
214
215
216 if type(plot_data) != str:
217 raise RelaxStrError, ('plot data', plot_data)
218
219
220 if type(file) != str:
221 raise RelaxStrError, ('file name', file)
222
223
224 if dir != None and type(dir) != str:
225 raise RelaxNoneStrError, ('directory name', dir)
226
227
228 if type(force) != int or (force != 0 and force != 1):
229 raise RelaxBinError, ('force flag', force)
230
231
232 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, file=file, dir=dir, force=force)
233
234
235
236
237
238
239
240 write.__doc__ = write.__doc__ + "\n\n" + regexp_doc() + "\n"
241 write.__doc__ = write.__doc__ + Minimise.return_data_name.__doc__ + "\n\n"
242 write.__doc__ = write.__doc__ + Model_free.return_data_name.__doc__ + "\n\n"
243 write.__doc__ = write.__doc__ + Jw_mapping.return_data_name.__doc__ + "\n\n"
244 write.__doc__ = write.__doc__ + Noe.return_data_name.__doc__ + "\n"
245