1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 """The model-free analysis parameter functions."""
26
27
28 from lib.errors import RelaxError, RelaxNoSequenceError, RelaxNoTensorError
29 from pipe_control import diffusion_tensor
30 from pipe_control.mol_res_spin import exists_mol_res_spin_data, spin_loop
31
32
34 """Determine the global model type.
35
36 @return: The name of the model type, which will be one of 'all', 'diff', 'mf', or 'local_tm'. If all parameters are fixed (and no spins selected), None is returned.
37 @rtype: str or None
38 """
39
40
41 if not exists_mol_res_spin_data():
42 raise RelaxNoSequenceError
43
44
45 local_tm = False
46 for spin in spin_loop():
47
48 if not spin.select:
49 continue
50
51
52 if not hasattr(spin, 'params') or not spin.params:
53 continue
54
55
56 if not local_tm and 'local_tm' in spin.params:
57 local_tm = True
58
59
60 elif local_tm and not 'local_tm' in spin.params:
61 raise RelaxError("All spins must either have a local tm parameter or not.")
62
63
64 mf_all_fixed = True
65 mf_all_deselected = True
66 for spin in spin_loop():
67
68 if not spin.select:
69 continue
70
71
72 mf_all_deselected = False
73
74
75 if not hasattr(spin, 'fixed'):
76 mf_all_fixed = False
77 break
78 if not spin.fixed:
79 mf_all_fixed = False
80 break
81
82
83 if mf_all_deselected:
84
85 if not hasattr(cdp, 'diff_tensor') or cdp.diff_tensor.fixed:
86 return None
87
88 return 'diff'
89
90
91 if local_tm:
92 return 'local_tm'
93
94
95 if not diffusion_tensor.diff_data_exists():
96
97 for spin in spin_loop():
98 if hasattr(spin, 'local_tm') and spin.local_tm != None and not 'local_tm' in spin.params:
99 raise RelaxError("The local tm value is set but not located in the model parameter list.")
100
101
102 raise RelaxNoTensorError('diffusion')
103
104
105 if mf_all_fixed:
106
107 if cdp.diff_tensor.fixed:
108 return None
109
110 return 'diff'
111
112
113 if cdp.diff_tensor.fixed:
114 return 'mf'
115
116
117 else:
118 return 'all'
119
120
122 """Return the equation name and parameter list corresponding to the given model.
123
124 @param model: The model-free model.
125 @type model: str
126 @return: The equation type (either 'mf_orig' or 'mf_ext') and the model-free parameter list corresponding to the model.
127 @rtype: str, list
128 """
129
130
131 if model == 'm0':
132 equation = 'mf_orig'
133 params = []
134 elif model == 'm1':
135 equation = 'mf_orig'
136 params = ['s2']
137 elif model == 'm2':
138 equation = 'mf_orig'
139 params = ['s2', 'te']
140 elif model == 'm3':
141 equation = 'mf_orig'
142 params = ['s2', 'rex']
143 elif model == 'm4':
144 equation = 'mf_orig'
145 params = ['s2', 'te', 'rex']
146 elif model == 'm5':
147 equation = 'mf_ext'
148 params = ['s2f', 's2', 'ts']
149 elif model == 'm6':
150 equation = 'mf_ext'
151 params = ['s2f', 'tf', 's2', 'ts']
152 elif model == 'm7':
153 equation = 'mf_ext'
154 params = ['s2f', 's2', 'ts', 'rex']
155 elif model == 'm8':
156 equation = 'mf_ext'
157 params = ['s2f', 'tf', 's2', 'ts', 'rex']
158 elif model == 'm9':
159 equation = 'mf_orig'
160 params = ['rex']
161
162
163 elif model == 'm10':
164 equation = 'mf_orig'
165 params = ['csa']
166 elif model == 'm11':
167 equation = 'mf_orig'
168 params = ['csa', 's2']
169 elif model == 'm12':
170 equation = 'mf_orig'
171 params = ['csa', 's2', 'te']
172 elif model == 'm13':
173 equation = 'mf_orig'
174 params = ['csa', 's2', 'rex']
175 elif model == 'm14':
176 equation = 'mf_orig'
177 params = ['csa', 's2', 'te', 'rex']
178 elif model == 'm15':
179 equation = 'mf_ext'
180 params = ['csa', 's2f', 's2', 'ts']
181 elif model == 'm16':
182 equation = 'mf_ext'
183 params = ['csa', 's2f', 'tf', 's2', 'ts']
184 elif model == 'm17':
185 equation = 'mf_ext'
186 params = ['csa', 's2f', 's2', 'ts', 'rex']
187 elif model == 'm18':
188 equation = 'mf_ext'
189 params = ['csa', 's2f', 'tf', 's2', 'ts', 'rex']
190 elif model == 'm19':
191 equation = 'mf_orig'
192 params = ['csa', 'rex']
193
194
195 elif model == 'm20':
196 equation = 'mf_orig'
197 params = ['r']
198 elif model == 'm21':
199 equation = 'mf_orig'
200 params = ['r', 's2']
201 elif model == 'm22':
202 equation = 'mf_orig'
203 params = ['r', 's2', 'te']
204 elif model == 'm23':
205 equation = 'mf_orig'
206 params = ['r', 's2', 'rex']
207 elif model == 'm24':
208 equation = 'mf_orig'
209 params = ['r', 's2', 'te', 'rex']
210 elif model == 'm25':
211 equation = 'mf_ext'
212 params = ['r', 's2f', 's2', 'ts']
213 elif model == 'm26':
214 equation = 'mf_ext'
215 params = ['r', 's2f', 'tf', 's2', 'ts']
216 elif model == 'm27':
217 equation = 'mf_ext'
218 params = ['r', 's2f', 's2', 'ts', 'rex']
219 elif model == 'm28':
220 equation = 'mf_ext'
221 params = ['r', 's2f', 'tf', 's2', 'ts', 'rex']
222 elif model == 'm29':
223 equation = 'mf_orig'
224 params = ['r', 'rex']
225
226
227 elif model == 'm30':
228 equation = 'mf_orig'
229 params = ['r', 'csa']
230 elif model == 'm31':
231 equation = 'mf_orig'
232 params = ['r', 'csa', 's2']
233 elif model == 'm32':
234 equation = 'mf_orig'
235 params = ['r', 'csa', 's2', 'te']
236 elif model == 'm33':
237 equation = 'mf_orig'
238 params = ['r', 'csa', 's2', 'rex']
239 elif model == 'm34':
240 equation = 'mf_orig'
241 params = ['r', 'csa', 's2', 'te', 'rex']
242 elif model == 'm35':
243 equation = 'mf_ext'
244 params = ['r', 'csa', 's2f', 's2', 'ts']
245 elif model == 'm36':
246 equation = 'mf_ext'
247 params = ['r', 'csa', 's2f', 'tf', 's2', 'ts']
248 elif model == 'm37':
249 equation = 'mf_ext'
250 params = ['r', 'csa', 's2f', 's2', 'ts', 'rex']
251 elif model == 'm38':
252 equation = 'mf_ext'
253 params = ['r', 'csa', 's2f', 'tf', 's2', 'ts', 'rex']
254 elif model == 'm39':
255 equation = 'mf_orig'
256 params = ['r', 'csa', 'rex']
257
258
259
260
261
262
263 elif model == 'tm0':
264 equation = 'mf_orig'
265 params = ['local_tm']
266 elif model == 'tm1':
267 equation = 'mf_orig'
268 params = ['local_tm', 's2']
269 elif model == 'tm2':
270 equation = 'mf_orig'
271 params = ['local_tm', 's2', 'te']
272 elif model == 'tm3':
273 equation = 'mf_orig'
274 params = ['local_tm', 's2', 'rex']
275 elif model == 'tm4':
276 equation = 'mf_orig'
277 params = ['local_tm', 's2', 'te', 'rex']
278 elif model == 'tm5':
279 equation = 'mf_ext'
280 params = ['local_tm', 's2f', 's2', 'ts']
281 elif model == 'tm6':
282 equation = 'mf_ext'
283 params = ['local_tm', 's2f', 'tf', 's2', 'ts']
284 elif model == 'tm7':
285 equation = 'mf_ext'
286 params = ['local_tm', 's2f', 's2', 'ts', 'rex']
287 elif model == 'tm8':
288 equation = 'mf_ext'
289 params = ['local_tm', 's2f', 'tf', 's2', 'ts', 'rex']
290 elif model == 'tm9':
291 equation = 'mf_orig'
292 params = ['local_tm', 'rex']
293
294
295 elif model == 'tm10':
296 equation = 'mf_orig'
297 params = ['local_tm', 'csa']
298 elif model == 'tm11':
299 equation = 'mf_orig'
300 params = ['local_tm', 'csa', 's2']
301 elif model == 'tm12':
302 equation = 'mf_orig'
303 params = ['local_tm', 'csa', 's2', 'te']
304 elif model == 'tm13':
305 equation = 'mf_orig'
306 params = ['local_tm', 'csa', 's2', 'rex']
307 elif model == 'tm14':
308 equation = 'mf_orig'
309 params = ['local_tm', 'csa', 's2', 'te', 'rex']
310 elif model == 'tm15':
311 equation = 'mf_ext'
312 params = ['local_tm', 'csa', 's2f', 's2', 'ts']
313 elif model == 'tm16':
314 equation = 'mf_ext'
315 params = ['local_tm', 'csa', 's2f', 'tf', 's2', 'ts']
316 elif model == 'tm17':
317 equation = 'mf_ext'
318 params = ['local_tm', 'csa', 's2f', 's2', 'ts', 'rex']
319 elif model == 'tm18':
320 equation = 'mf_ext'
321 params = ['local_tm', 'csa', 's2f', 'tf', 's2', 'ts', 'rex']
322 elif model == 'tm19':
323 equation = 'mf_orig'
324 params = ['local_tm', 'csa', 'rex']
325
326
327 elif model == 'tm20':
328 equation = 'mf_orig'
329 params = ['local_tm', 'r']
330 elif model == 'tm21':
331 equation = 'mf_orig'
332 params = ['local_tm', 'r', 's2']
333 elif model == 'tm22':
334 equation = 'mf_orig'
335 params = ['local_tm', 'r', 's2', 'te']
336 elif model == 'tm23':
337 equation = 'mf_orig'
338 params = ['local_tm', 'r', 's2', 'rex']
339 elif model == 'tm24':
340 equation = 'mf_orig'
341 params = ['local_tm', 'r', 's2', 'te', 'rex']
342 elif model == 'tm25':
343 equation = 'mf_ext'
344 params = ['local_tm', 'r', 's2f', 's2', 'ts']
345 elif model == 'tm26':
346 equation = 'mf_ext'
347 params = ['local_tm', 'r', 's2f', 'tf', 's2', 'ts']
348 elif model == 'tm27':
349 equation = 'mf_ext'
350 params = ['local_tm', 'r', 's2f', 's2', 'ts', 'rex']
351 elif model == 'tm28':
352 equation = 'mf_ext'
353 params = ['local_tm', 'r', 's2f', 'tf', 's2', 'ts', 'rex']
354 elif model == 'tm29':
355 equation = 'mf_orig'
356 params = ['local_tm', 'r', 'rex']
357
358
359 elif model == 'tm30':
360 equation = 'mf_orig'
361 params = ['local_tm', 'r', 'csa']
362 elif model == 'tm31':
363 equation = 'mf_orig'
364 params = ['local_tm', 'r', 'csa', 's2']
365 elif model == 'tm32':
366 equation = 'mf_orig'
367 params = ['local_tm', 'r', 'csa', 's2', 'te']
368 elif model == 'tm33':
369 equation = 'mf_orig'
370 params = ['local_tm', 'r', 'csa', 's2', 'rex']
371 elif model == 'tm34':
372 equation = 'mf_orig'
373 params = ['local_tm', 'r', 'csa', 's2', 'te', 'rex']
374 elif model == 'tm35':
375 equation = 'mf_ext'
376 params = ['local_tm', 'r', 'csa', 's2f', 's2', 'ts']
377 elif model == 'tm36':
378 equation = 'mf_ext'
379 params = ['local_tm', 'r', 'csa', 's2f', 'tf', 's2', 'ts']
380 elif model == 'tm37':
381 equation = 'mf_ext'
382 params = ['local_tm', 'r', 'csa', 's2f', 's2', 'ts', 'rex']
383 elif model == 'tm38':
384 equation = 'mf_ext'
385 params = ['local_tm', 'r', 'csa', 's2f', 'tf', 's2', 'ts', 'rex']
386 elif model == 'tm39':
387 equation = 'mf_orig'
388 params = ['local_tm', 'r', 'csa', 'rex']
389
390
391 else:
392 raise RelaxError("The model '%s' is invalid." % model)
393
394
395 return equation, params
396