1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 """Analysis specific code for the hybridisation of different data pipes."""
24
25
26 from lib.errors import RelaxError, RelaxNoSequenceError, RelaxPipeError, RelaxSequenceError
27 from pipe_control import pipes
28 from pipe_control.mol_res_spin import exists_mol_res_spin_data
29 from pipe_control.sequence import compare_sequence
30
31
33 """Class containing function specific to hybrid models."""
34
35 - def _hybridise(self, hybrid=None, pipe_list=None):
74
75
76 - def data_names(self, set='all', scope=None, error_names=False, sim_names=False):
77 """Return a list of nothing.
78
79 @keyword set: The set of object names to return. This can be set to 'all' for all names, to 'generic' for generic object names, 'params' for analysis specific parameter names, or to 'min' for minimisation specific object names.
80 @type set: str
81 @keyword scope: The scope of the parameter to return. If not set, then all will be returned. If set to 'global' or 'spin', then only the parameters within that scope will be returned.
82 @type scope: str or None
83 @keyword error_names: A flag which if True will add the error object names as well.
84 @type error_names: bool
85 @keyword sim_names: A flag which if True will add the Monte Carlo simulation object names as well.
86 @type sim_names: bool
87 @return: The list of object names.
88 @rtype: list of str
89 """
90
91
92 return []
93
94
95 - def duplicate_data(self, pipe_from=None, pipe_to=None, model_info=None, global_stats=False, verbose=True):
96 """Duplicate the data specific to a single hybrid data pipe.
97
98 @keyword pipe_from: The data pipe to copy the data from.
99 @type pipe_from: str
100 @keyword pipe_to: The data pipe to copy the data to.
101 @type pipe_to: str
102 @keyword model_info: The model information from model_info().
103 @type model_info: int
104 @keyword global_stats: The global statistics flag.
105 @type global_stats: bool
106 @keyword verbose: A flag which if True will cause info to be printed out.
107 @type verbose: bool
108 """
109
110
111 if not pipes.has_pipe(pipe_to):
112 pipes.create(pipe_to, pipe_type='hybrid', switch=False)
113
114
115 dp_from = pipes.get_pipe(pipe_from)
116 dp_to = pipes.get_pipe(pipe_to)
117
118
119 if not exists_mol_res_spin_data(pipe_to):
120 raise RelaxSequenceError(pipe_to)
121
122
123 dp_to.hybrid_pipes = dp_from.hybrid_pipes
124
125
127 """Return a description of the model.
128
129 @param model_info: The model information from the model_loop(). This is unused.
130 @type model_info: int
131 @return: The model description.
132 @rtype: str
133 """
134
135 return "hybrid model"
136
137
139 """Dummy generator method - this should be a global model!"""
140
141 yield 0
142
143
145 """Method stating that this is a global model."""
146
147 return 'global'
148
149
151 """Return the k, n, and chi2 model statistics of the hybrid.
152
153 k - number of parameters.
154 n - number of data points.
155 chi2 - the chi-squared value.
156
157
158 @keyword model_index: The model index. This is zero for the global models or equal to the
159 global spin index (which covers the molecule, residue, and spin
160 indices). This originates from the model_loop().
161 @type model_index: int
162 @keyword spin_id: The spin identification string. Either this or the instance keyword
163 argument must be supplied.
164 @type spin_id: None or str
165 @keyword global_stats: A parameter which determines if global or local statistics are
166 returned. If None, then the appropriateness of global or local
167 statistics is automatically determined.
168 @type global_stats: None or bool
169 @return: The optimisation statistics, in tuple format, of the number of
170 parameters (k), the number of data points (n), and the chi-squared
171 value (chi2).
172 @rtype: tuple of int, int, float
173 """
174
175
176 if model_info == None and spin_id == None:
177 raise RelaxError("Either the model_info or spin_id argument must be supplied.")
178 elif model_info != None and spin_id != None:
179 raise RelaxError("The model_info arg " + repr(model_info) + " and spin_id arg " + repr(spin_id) + " clash. Only one should be supplied.")
180
181
182 k_total = 0
183 n_total = 0
184 chi2_total = 0.0
185
186
187 for pipe in cdp.hybrid_pipes:
188
189 pipes.switch(pipe)
190
191
192 model_statistics = setup.get_specific_fn('model_stats', pipes.get_type(pipe))
193
194
195
196
197 k, n, chi2 = model_statistics(model_info=model_info, spin_id=spin_id, global_stats=global_stats)
198
199
200 if k == None or n == None or chi2 == None:
201 continue
202
203
204 k_total = k_total + k
205 n_total = n_total + n
206 chi2_total = chi2_total + chi2
207
208
209 return k_total, n_total, chi2_total
210
211
213 """Return the number of instances, which for hybrids is always 1.
214
215 @return: The number of instances.
216 @rtype: int
217 """
218
219 return 1
220
221
223 """Dummy function.
224
225 @param model_info: The model index from model_loop().
226 @type model_info: int
227 @return: True if the data should be skipped, False otherwise.
228 @rtype: bool
229 """
230
231
232 return False
233