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