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 import help
26 from specific_fns.model_free import Model_free
27 from specific_fns.jw_mapping import Jw_mapping
28 from specific_fns.noe import Noe
29
30
33
34 self.__relax_help__ = \
35 """Class for interfacing with Grace."""
36
37
38 self.__relax_help__ = self.__relax_help__ + "\n" + help.relax_class_help
39
40
41 self.__relax__ = relax
42
43
44 - def view(self, run=None, data_type=None, file=None, dir='grace', grace_exe='xmgrace', force=0):
45 """Function for running Grace.
46
47 Keyword Arguments
48 ~~~~~~~~~~~~~~~~~
49
50 run: The name of the run.
51
52 data_type: The data type.
53
54 file: The name of the file.
55
56 dir: The directory name.
57
58 grace_exe: The Grace executable file.
59
60 force: A flag which, if set to 1, will cause the file to be overwritten.
61
62
63 Description
64 ~~~~~~~~~~~
65
66 This function can be used either to execute grace, opening the specified file, or to create
67 the grace '.agr' file and the execute grace. If the run and data_type arguments are
68 supplied, the second of these two options is pursued. To simply execute grace, leave the
69 run and data_type arguments as None.
70
71 If the directory name is set to None, the file will be placed in the current working
72 directory.
73
74 The force flag will only have an effect if the run argument is not None.
75
76
77 Examples
78 ~~~~~~~~
79
80 To view the file 's2.agr' in the directory 'grace', type:
81
82 relax> grace.view(file='s2.agr')
83 relax> grace.view(file='s2.agr', dir='grace')
84
85
86 To write the NOE values from the run 'noe' to the grace file 'noe.agr' and then view the
87 file, type:
88
89 relax> grace.view('noe', 'noe', 'noe.agr')
90 relax> grace.view('noe', data_type='noe', file='noe.agr')
91 relax> grace.view(run='noe', data_type='noe', file='noe.agr', dir='grace')
92 """
93
94
95 if self.__relax__.interpreter.intro:
96 text = sys.ps3 + "grace.view("
97 text = text + "run=" + `run`
98 text = text + ", data_type=" + `data_type`
99 text = text + ", file=" + `file`
100 text = text + ", dir=" + `dir`
101 text = text + ", grace_exe=" + `grace_exe` + ")"
102 print text
103
104
105 if run != None and type(run) != str:
106 raise RelaxNoneStrError, ('run', run)
107
108
109 if data_type != None and type(data_type) != str:
110 raise RelaxNoneStrError, ('data type', data_type)
111
112
113 if type(file) != str:
114 raise RelaxStrError, ('file name', file)
115
116
117 if dir != None and type(dir) != str:
118 raise RelaxNoneStrError, ('directory name', dir)
119
120
121 if type(grace_exe) != str:
122 raise RelaxStrError, ('Grace executable file', grace_exe)
123
124
125 if type(force) != int or (force != 0 and force != 1):
126 raise RelaxBinError, ('force flag', force)
127
128
129 self.__relax__.generic.grace.view(run=run, data_type=data_type, file=file, dir=dir, grace_exe=grace_exe, force=force)
130
131
132 - def write(self, run=None, data_type=None, file=None, dir='grace', force=0):
133 """Function for creating a grace '.agr' file.
134
135 Keyword Arguments
136 ~~~~~~~~~~~~~~~~~
137
138 run: The name of the run.
139
140 data_type: The data type.
141
142 file: The name of the file.
143
144 dir: The directory name.
145
146 force: A flag which, if set to 1, will cause the file to be overwritten.
147
148
149 Description
150 ~~~~~~~~~~~
151
152 If no directory name is given, the file will be placed in the current working directory.
153
154 The data type argument should be a string.
155
156
157 Examples
158 ~~~~~~~~
159
160 To write the NOE values from the run 'noe' to the grace file 'noe.agr', type:
161
162 relax> grace.write('noe', 'noe', 'noe.agr')
163 relax> grace.write('noe', data_type='noe', file='noe.agr')
164 relax> grace.write(run='noe', data_type='noe', file='noe.agr', dir='grace')
165 """
166
167
168 if self.__relax__.interpreter.intro:
169 text = sys.ps3 + "grace.write("
170 text = text + "run=" + `run`
171 text = text + ", data_type=" + `data_type`
172 text = text + ", file=" + `file`
173 text = text + ", dir=" + `dir`
174 text = text + ", force=" + `force` + ")"
175 print text
176
177
178 if type(run) != str:
179 raise RelaxStrError, ('run', run)
180
181
182 if type(data_type) != str:
183 raise RelaxStrError, ('data type', data_type)
184
185
186 if type(file) != str:
187 raise RelaxStrError, ('file name', file)
188
189
190 if dir != None and type(dir) != str:
191 raise RelaxNoneStrError, ('directory name', dir)
192
193
194 if type(force) != int or (force != 0 and force != 1):
195 raise RelaxBinError, ('force flag', force)
196
197
198 self.__relax__.generic.grace.write(run=run, data_type=data_type, file=file, dir=dir, force=force)
199
200
201
202
203
204 __re_doc__ = """
205
206 Regular expression
207 ~~~~~~~~~~~~~~~~~~
208
209 The python function 'match', which uses regular expression, is used to determine which data
210 type to set values to, therefore various data_type strings can be used to select the same
211 data type. Patterns used for matching for specific data types are listed below. Regular
212 expression is also used in residue name and number selections, except this time the user
213 supplies the regular expression string.
214
215 This is a short description of python regular expression, for more information, see the
216 regular expression syntax section of the Python Library Reference. Some of the regular
217 expression syntax used in this function is:
218
219 [] - A sequence or set of characters to match to a single character. For example,
220 '[Ss]2' will match both 'S2' and 's2'.
221
222 ^ - Match the start of the string.
223
224 $ - Match the end of the string. For example, '^[Ss]2$' will match 's2' but not 'S2f'
225 or 's2s'.
226
227 """
228
229
230 view.__doc__ = view.__doc__ + "\n\n" + __re_doc__ + "\n"
231 view.__doc__ = view.__doc__ + Model_free.get_data_name.__doc__ + "\n\n"
232 view.__doc__ = view.__doc__ + Jw_mapping.get_data_name.__doc__ + "\n\n"
233 view.__doc__ = view.__doc__ + Noe.get_data_name.__doc__ + "\n"
234
235
236 write.__doc__ = write.__doc__ + "\n\n" + __re_doc__ + "\n"
237 write.__doc__ = write.__doc__ + Model_free.get_data_name.__doc__ + "\n\n"
238 write.__doc__ = write.__doc__ + Jw_mapping.get_data_name.__doc__ + "\n\n"
239 write.__doc__ = write.__doc__ + Noe.get_data_name.__doc__ + "\n"
240