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