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