14 #ifndef INCLUDED_core_pack_dunbrack_SemiRotamericSingleResidueDunbrackLibrary_tmpl_hh
15 #define INCLUDED_core_pack_dunbrack_SemiRotamericSingleResidueDunbrackLibrary_tmpl_hh
17 #if (defined WIN32) && (!defined WIN_PYROSETTA)
18 #define ZLIB_WINAPI // REQUIRED FOR WINDOWS
27 #include <basic/basic.hh>
34 #include <ObjexxFCL/FArray2D.hh>
35 #include <ObjexxFCL/FArray3D.hh>
38 #include <utility/exit.hh>
39 #include <utility/vector1.functions.hh>
42 #include <numeric/random/random.hh>
43 #include <numeric/MathTensor.hh>
44 #include <numeric/interpolation/spline/TricubicSpline.hh>
47 #include <boost/cstdint.hpp>
50 #include <platform/types.hh>
131 #include <utility/Bound.fwd.hh>
132 #include <utility/Bound.hh>
133 #include <utility/LexicographicalIterator.fwd.hh>
134 #include <utility/LexicographicalIterator.hh>
135 #include <utility/assert.hh>
136 #include <utility/down_cast.hh>
137 #include <utility/fixedsizearray1.fwd.hh>
138 #include <utility/fixedsizearray1.hh>
139 #include <utility/stream_util.hh>
140 #include <utility/string_util.hh>
141 #include <utility/vector1.fwd.hh>
142 #include <utility/vector1.hh>
143 #include <utility/vector1_bool.hh>
144 #include <utility/vectorL.fwd.hh>
145 #include <utility/vectorL.hh>
146 #include <utility/vectorL_Selector.hh>
147 #include <utility/vectorL_bool.hh>
148 #include <utility/file/FileName.fwd.hh>
149 #include <utility/file/FileName.hh>
150 #include <utility/file/PathName.fwd.hh>
151 #include <utility/file/PathName.hh>
152 #include <utility/file/gzip_util.hh>
153 #include <utility/io/irstream.fwd.hh>
154 #include <utility/io/irstream.hh>
155 #include <utility/io/izstream.fwd.hh>
156 #include <utility/io/izstream.hh>
157 #include <utility/io/mpistream.hh>
158 #include <utility/io/mpistream.ipp>
159 #include <utility/io/orstream.fwd.hh>
160 #include <utility/io/orstream.hh>
161 #include <utility/io/ozstream.fwd.hh>
162 #include <utility/io/ozstream.hh>
163 #include <utility/io/zipstream.hpp>
164 #include <utility/io/zipstream.ipp>
165 #include <utility/keys/AutoKey.fwd.hh>
166 #include <utility/keys/AutoKey.hh>
167 #include <utility/keys/Key.fwd.hh>
168 #include <utility/keys/Key.hh>
169 #include <utility/keys/Key2Tuple.fwd.hh>
170 #include <utility/keys/Key2Tuple.hh>
171 #include <utility/keys/Key3Tuple.fwd.hh>
172 #include <utility/keys/Key3Tuple.hh>
173 #include <utility/keys/Key4Tuple.fwd.hh>
174 #include <utility/keys/Key4Tuple.hh>
175 #include <utility/keys/KeyLess.fwd.hh>
176 #include <utility/keys/KeyLookup.fwd.hh>
177 #include <utility/keys/KeyLookup.hh>
178 #include <utility/keys/NoClient.fwd.hh>
179 #include <utility/keys/NoClient.hh>
180 #include <utility/keys/SmallKeyVector.fwd.hh>
181 #include <utility/keys/SmallKeyVector.hh>
182 #include <utility/keys/UserKey.fwd.hh>
183 #include <utility/keys/VariantKey.fwd.hh>
184 #include <utility/keys/VariantKey.hh>
185 #include <utility/options/AnyOption.fwd.hh>
186 #include <utility/options/AnyOption.hh>
187 #include <utility/options/AnyVectorOption.fwd.hh>
188 #include <utility/options/AnyVectorOption.hh>
189 #include <utility/options/BooleanOption.fwd.hh>
190 #include <utility/options/BooleanOption.hh>
191 #include <utility/options/BooleanVectorOption.fwd.hh>
192 #include <utility/options/BooleanVectorOption.hh>
193 #include <utility/options/FileOption.fwd.hh>
194 #include <utility/options/FileOption.hh>
195 #include <utility/options/FileVectorOption.fwd.hh>
196 #include <utility/options/FileVectorOption.hh>
197 #include <utility/options/IntegerOption.fwd.hh>
198 #include <utility/options/IntegerOption.hh>
199 #include <utility/options/IntegerVectorOption.fwd.hh>
200 #include <utility/options/IntegerVectorOption.hh>
201 #include <utility/options/Option.fwd.hh>
202 #include <utility/options/Option.hh>
203 #include <utility/options/OptionCollection.fwd.hh>
204 #include <utility/options/OptionCollection.hh>
205 #include <utility/options/PathOption.fwd.hh>
206 #include <utility/options/PathOption.hh>
207 #include <utility/options/PathVectorOption.fwd.hh>
208 #include <utility/options/PathVectorOption.hh>
209 #include <utility/options/RealOption.fwd.hh>
210 #include <utility/options/RealOption.hh>
211 #include <utility/options/RealVectorOption.fwd.hh>
212 #include <utility/options/RealVectorOption.hh>
213 #include <utility/options/ScalarOption.fwd.hh>
214 #include <utility/options/ScalarOption.hh>
215 #include <utility/options/ScalarOption_T_.fwd.hh>
216 #include <utility/options/ScalarOption_T_.hh>
217 #include <utility/options/StringOption.fwd.hh>
218 #include <utility/options/StringOption.hh>
219 #include <utility/options/StringVectorOption.fwd.hh>
220 #include <utility/options/StringVectorOption.hh>
221 #include <utility/options/VariantOption.fwd.hh>
222 #include <utility/options/VariantOption.hh>
223 #include <utility/options/VectorOption.fwd.hh>
224 #include <utility/options/VectorOption.hh>
225 #include <utility/options/VectorOption_T_.fwd.hh>
226 #include <utility/options/VectorOption_T_.hh>
227 #include <utility/options/mpi_stderr.hh>
228 #include <utility/options/keys/AnyOptionKey.fwd.hh>
229 #include <utility/options/keys/AnyOptionKey.hh>
230 #include <utility/options/keys/AnyVectorOptionKey.fwd.hh>
231 #include <utility/options/keys/AnyVectorOptionKey.hh>
232 #include <utility/options/keys/BooleanOptionKey.fwd.hh>
233 #include <utility/options/keys/BooleanOptionKey.hh>
234 #include <utility/options/keys/BooleanVectorOptionKey.fwd.hh>
235 #include <utility/options/keys/BooleanVectorOptionKey.hh>
236 #include <utility/options/keys/FileOptionKey.fwd.hh>
237 #include <utility/options/keys/FileOptionKey.hh>
238 #include <utility/options/keys/FileVectorOptionKey.fwd.hh>
239 #include <utility/options/keys/FileVectorOptionKey.hh>
240 #include <utility/options/keys/IntegerOptionKey.fwd.hh>
241 #include <utility/options/keys/IntegerOptionKey.hh>
242 #include <utility/options/keys/IntegerVectorOptionKey.fwd.hh>
243 #include <utility/options/keys/IntegerVectorOptionKey.hh>
244 #include <utility/options/keys/OptionKey.fwd.hh>
245 #include <utility/options/keys/OptionKey.hh>
246 #include <utility/options/keys/OptionKeys.hh>
247 #include <utility/options/keys/PathOptionKey.fwd.hh>
248 #include <utility/options/keys/PathOptionKey.hh>
249 #include <utility/options/keys/PathVectorOptionKey.fwd.hh>
250 #include <utility/options/keys/PathVectorOptionKey.hh>
251 #include <utility/options/keys/RealOptionKey.fwd.hh>
252 #include <utility/options/keys/RealOptionKey.hh>
253 #include <utility/options/keys/RealVectorOptionKey.fwd.hh>
254 #include <utility/options/keys/RealVectorOptionKey.hh>
255 #include <utility/options/keys/ScalarOptionKey.fwd.hh>
256 #include <utility/options/keys/ScalarOptionKey.hh>
257 #include <utility/options/keys/StringOptionKey.fwd.hh>
258 #include <utility/options/keys/StringOptionKey.hh>
259 #include <utility/options/keys/StringVectorOptionKey.fwd.hh>
260 #include <utility/options/keys/StringVectorOptionKey.hh>
261 #include <utility/options/keys/VectorOptionKey.fwd.hh>
262 #include <utility/options/keys/VectorOptionKey.hh>
263 #include <utility/options/keys/all.hh>
264 #include <utility/pointer/ReferenceCount.fwd.hh>
265 #include <utility/pointer/ReferenceCount.hh>
266 #include <utility/pointer/access_ptr.fwd.hh>
267 #include <utility/pointer/access_ptr.hh>
268 #include <utility/pointer/owning_ptr.functions.hh>
269 #include <utility/pointer/owning_ptr.fwd.hh>
270 #include <utility/pointer/owning_ptr.hh>
271 #include <utility/signals/BufferedSignalHub.fwd.hh>
272 #include <utility/signals/BufferedSignalHub.hh>
273 #include <utility/signals/Link.fwd.hh>
274 #include <utility/signals/Link.hh>
275 #include <utility/signals/LinkUnit.fwd.hh>
276 #include <utility/signals/LinkUnit.hh>
277 #include <utility/signals/SignalHub.fwd.hh>
278 #include <utility/signals/SignalHub.hh>
279 #include <numeric/NumericTraits.hh>
280 #include <numeric/constants.hh>
281 #include <numeric/conversions.hh>
282 #include <numeric/numeric.functions.hh>
283 #include <numeric/sphericalVector.fwd.hh>
284 #include <numeric/sphericalVector.hh>
285 #include <numeric/trig.functions.hh>
286 #include <numeric/types.hh>
287 #include <numeric/xyz.functions.fwd.hh>
288 #include <numeric/xyz.functions.hh>
289 #include <numeric/xyzMatrix.fwd.hh>
290 #include <numeric/xyzMatrix.hh>
291 #include <numeric/xyzVector.fwd.hh>
292 #include <numeric/xyzVector.hh>
293 #include <numeric/internal/ColPointers.hh>
294 #include <numeric/internal/ColVectors.hh>
295 #include <numeric/internal/ColsPointer.hh>
296 #include <numeric/internal/RowPointers.hh>
297 #include <numeric/internal/RowVectors.hh>
298 #include <numeric/internal/RowsPointer.hh>
299 #include <numeric/random/random.fwd.hh>
300 #include <numeric/random/uniform.fwd.hh>
301 #include <numeric/random/uniform.hh>
302 #include <ObjexxFCL/Dimension.fwd.hh>
303 #include <ObjexxFCL/Dimension.hh>
304 #include <ObjexxFCL/DimensionExpression.hh>
305 #include <ObjexxFCL/DynamicIndexRange.fwd.hh>
306 #include <ObjexxFCL/DynamicIndexRange.hh>
307 #include <ObjexxFCL/FArray.all.fwd.hh>
308 #include <ObjexxFCL/FArray.fwd.hh>
309 #include <ObjexxFCL/FArray.hh>
310 #include <ObjexxFCL/FArray1.all.fwd.hh>
311 #include <ObjexxFCL/FArray1.fwd.hh>
312 #include <ObjexxFCL/FArray1A.fwd.hh>
313 #include <ObjexxFCL/FArray1D.fwd.hh>
314 #include <ObjexxFCL/FArray1P.fwd.hh>
315 #include <ObjexxFCL/FArray2.all.fwd.hh>
316 #include <ObjexxFCL/FArray2.fwd.hh>
317 #include <ObjexxFCL/FArray2.hh>
318 #include <ObjexxFCL/FArray2A.fwd.hh>
319 #include <ObjexxFCL/FArray2A.hh>
320 #include <ObjexxFCL/FArray2D.fwd.hh>
321 #include <ObjexxFCL/FArray2P.fwd.hh>
322 #include <ObjexxFCL/FArray2P.hh>
323 #include <ObjexxFCL/FArray3.all.fwd.hh>
324 #include <ObjexxFCL/FArray3.fwd.hh>
325 #include <ObjexxFCL/FArray3.hh>
326 #include <ObjexxFCL/FArray3A.fwd.hh>
327 #include <ObjexxFCL/FArray3D.fwd.hh>
328 #include <ObjexxFCL/FArray3P.fwd.hh>
329 #include <ObjexxFCL/FArray4.all.fwd.hh>
330 #include <ObjexxFCL/FArray4.fwd.hh>
331 #include <ObjexxFCL/FArray4.hh>
332 #include <ObjexxFCL/FArray4A.fwd.hh>
333 #include <ObjexxFCL/FArray4D.fwd.hh>
334 #include <ObjexxFCL/FArray4D.hh>
335 #include <ObjexxFCL/FArray4P.fwd.hh>
336 #include <ObjexxFCL/FArray5.all.fwd.hh>
337 #include <ObjexxFCL/FArray5.fwd.hh>
338 #include <ObjexxFCL/FArray5A.fwd.hh>
339 #include <ObjexxFCL/FArray5D.fwd.hh>
340 #include <ObjexxFCL/FArray5P.fwd.hh>
341 #include <ObjexxFCL/FArray6.all.fwd.hh>
342 #include <ObjexxFCL/FArray6.fwd.hh>
343 #include <ObjexxFCL/FArray6A.fwd.hh>
344 #include <ObjexxFCL/FArray6D.fwd.hh>
345 #include <ObjexxFCL/FArray6P.fwd.hh>
346 #include <ObjexxFCL/FArrayInitializer.fwd.hh>
347 #include <ObjexxFCL/FArrayInitializer.hh>
348 #include <ObjexxFCL/FArraySection.fwd.hh>
349 #include <ObjexxFCL/FArraySection.hh>
350 #include <ObjexxFCL/FArrayTraits.fwd.hh>
351 #include <ObjexxFCL/FArrayTraits.hh>
352 #include <ObjexxFCL/Fmath.hh>
353 #include <ObjexxFCL/IndexRange.fwd.hh>
354 #include <ObjexxFCL/IndexRange.hh>
355 #include <ObjexxFCL/InitializerSentinel.hh>
356 #include <ObjexxFCL/KeyFArray1D.fwd.hh>
357 #include <ObjexxFCL/KeyFArray2D.fwd.hh>
358 #include <ObjexxFCL/KeyFArray3D.fwd.hh>
359 #include <ObjexxFCL/KeyFArray4D.fwd.hh>
360 #include <ObjexxFCL/KeyFArray5D.fwd.hh>
361 #include <ObjexxFCL/KeyFArray6D.fwd.hh>
362 #include <ObjexxFCL/Observer.fwd.hh>
363 #include <ObjexxFCL/Observer.hh>
364 #include <ObjexxFCL/ObserverMulti.hh>
365 #include <ObjexxFCL/ObserverSingle.hh>
366 #include <ObjexxFCL/ProxySentinel.hh>
367 #include <ObjexxFCL/SetWrapper.fwd.hh>
368 #include <ObjexxFCL/Star.fwd.hh>
369 #include <ObjexxFCL/Star.hh>
370 #include <ObjexxFCL/StaticIndexRange.fwd.hh>
371 #include <ObjexxFCL/StaticIndexRange.hh>
372 #include <ObjexxFCL/TypeTraits.hh>
373 #include <ObjexxFCL/char.functions.hh>
374 #include <ObjexxFCL/proxy_const_assert.hh>
375 #include <ObjexxFCL/string.functions.hh>
399 #include <basic/MetricValue.fwd.hh>
400 #include <basic/datacache/BasicDataCache.fwd.hh>
401 #include <basic/interpolate.hh>
402 #include <basic/options/keys/OptionKeys.hh>
403 #include <basic/options/option.hh>
404 #include <boost/algorithm/string/erase.hpp>
405 #include <boost/bind.hpp>
406 #include <boost/config.hpp>
407 #include <boost/function.hpp>
408 #include <boost/pool/detail/mutex.hpp>
409 #include <boost/pool/poolfwd.hpp>
410 #include <zlib/zlib.h>
411 #include <zlib/zutil.h>
417 using namespace ObjexxFCL;
422 bool const backbone_independent_scoring,
423 bool const backbone_independent_rotamer_sampling
426 bbind_nrchi_scoring_( backbone_independent_scoring ),
427 bbind_nrchi_sampling_( backbone_independent_rotamer_sampling ),
428 nrchi_periodicity_( 0.0 ),
429 nrchi_lower_angle_( 0.0 ),
430 bbdep_nrchi_nbins_( 0 ),
431 bbdep_nrchi_binsize_( 0 ),
432 bbind_nrchi_nbins_( 0 ),
433 bbind_nrchi_binsize_( 0 ),
434 n_nrchi_sample_bins_( 0 )
449 if ( bbind_nrchi_scoring_ ) {
450 return rotamer_energy_deriv_bbind( rsd, scratch,
false );
452 return rotamer_energy_deriv_bbdep( rsd, scratch,
false );
464 if ( bbind_nrchi_scoring_ ) {
465 return rotamer_energy_deriv_bbind( rsd, scratch,
true );
467 return rotamer_energy_deriv_bbdep( rsd, scratch,
true );
479 assert( ! bbind_nrchi_scoring_ );
481 parent::eval_rotameric_energy_deriv( rsd, scratch, eval_deriv );
483 Real chidevpen_score( 0.0 );
484 for (
Size ii = 1; ii <=
T; ++ii ) {
485 chidevpen_score += scratch.
chidevpen()[ ii ];
488 Real nrchi_score, dnrchiscore_dchi, dnrchiscore_dphi, dnrchiscore_dpsi;
489 nrchi_score = bbdep_nrchi_score( rsd, scratch,
490 dnrchiscore_dchi, dnrchiscore_dphi, dnrchiscore_dpsi );
492 if ( nrchi_score != nrchi_score ) {
494 std::cerr <<
"NaN in SemiRot: " << rsd.
seqpos() <<
" " << rsd.
name() << std::endl;
497 scratch.
fa_dun_tot() = chidevpen_score + nrchi_score;
506 if ( ! eval_deriv )
return chidevpen_score + nrchi_score;
517 std::fill( dE_dchi.begin(), dE_dchi.end(), 0.0 );
518 std::fill( dE_dchi_dev.begin(), dE_dchi_dev.end(), 0.0 );
519 std::fill( dE_dchi_semi.begin(), dE_dchi_semi.end(), 0.0 );
520 std::fill( dE_dbb.begin(), dE_dbb.end(), 0.0 );
521 std::fill( dE_dbb_dev.begin(), dE_dbb_dev.end(), 0.0 );
522 std::fill( dE_dbb_rot.begin(), dE_dbb_rot.end(), 0.0 );
523 std::fill( dE_dbb_semi.begin(), dE_dbb_semi.end(), 0.0 );
536 for (
Size i=1; i <=
T; ++i ) {
540 dE_dchi[
T + 1 ] = dnrchiscore_dchi;
541 dE_dchi_semi[
T + 1 ] = dnrchiscore_dchi;
543 parent::correct_termini_derivatives( rsd, scratch );
545 return chidevpen_score + nrchi_score;
557 assert( bbind_nrchi_scoring_ );
559 Real rotameric_score = parent::eval_rotameric_energy_deriv( rsd, scratch, eval_deriv );
562 Real nrchi_score, dnrchiscore_dnrchi;
563 nrchi_score = bbind_nrchi_score( rsd, scratch, dnrchiscore_dnrchi );
565 scratch.
fa_dun_tot() = rotameric_score + nrchi_score;
570 if ( ! eval_deriv )
return rotameric_score + nrchi_score;
580 std::fill( dE_dchi.begin(), dE_dchi.end(), 0.0 );
581 std::fill( dE_dchi_dev.begin(), dE_dchi_dev.end(), 0.0 );
582 std::fill( dE_dchi_semi.begin(), dE_dchi_semi.end(), 0.0 );
593 Real const invp( ( rotprob ==
Real( 0.0 ) ) ? 0.0 : -1.0 / rotprob );
601 for (
Size i=1; i<=
T; ++i ) {
605 dE_dchi[
T + 1 ] = dnrchiscore_dnrchi;
606 dE_dchi_semi[
T + 1 ] = dnrchiscore_dnrchi;
608 parent::correct_termini_derivatives( rsd, scratch );
610 return rotameric_score + nrchi_score;
619 Real & dnrchi_score_dnrchi
622 assert( bbind_nrchi_scoring_ );
624 Size const packed_rotno( grandparent::rotwell_2_packed_rotno( scratch.
rotwell() ));
627 Size nrchi_bin, nrchi_bin_next;
630 get_bbind_nrchi_bin( nrchi, nrchi_bin, nrchi_bin_next, nrchi_alpha );
632 Real const nrchi_beta = 1 - nrchi_alpha;
633 Real const score_lower_bin = bbind_non_rotameric_chi_scores_( nrchi_bin, packed_rotno );
634 Real const score_upper_bin = bbind_non_rotameric_chi_scores_( nrchi_bin_next, packed_rotno );
636 dnrchi_score_dnrchi = ( score_upper_bin - score_lower_bin ) / bbind_nrchi_binsize_;
637 return nrchi_beta * score_lower_bin + nrchi_alpha * score_upper_bin;
647 Real & dnrchi_score_dnrchi,
648 Real & dnrchi_score_dphi,
649 Real & dnrchi_score_dpsi
652 assert( ! bbind_nrchi_scoring_ );
654 Size const packed_rotno( parent::rotwell_2_packed_rotno( scratch.
rotwell() ));
657 Size nrchi_bin, nrchi_bin_next;
659 get_bbdep_nrchi_bin( nrchi, nrchi_bin, nrchi_bin_next, nrchi_alpha );
661 Real phi( parent::get_phi_from_rsd( rsd ) );
662 Real psi( parent::get_psi_from_rsd( rsd ) );
665 Size phibin, phibin_next, psibin, psibin_next;
666 Real phi_alpha, psi_alpha;
669 parent::get_phipsi_bins(
670 phi, psi, phibin, psibin,
671 phibin_next, psibin_next,
672 phi_alpha, psi_alpha );
674 assert( phibin >= 1 && phibin <= parent::N_PHIPSI_BINS );
675 assert( psibin >= 1 && psibin <= parent::N_PHIPSI_BINS );
677 BBDepScoreInterpData const & d000( bbdep_nrc_interpdata_[ packed_rotno ]( phibin , psibin , nrchi_bin ));
678 BBDepScoreInterpData const & d001( bbdep_nrc_interpdata_[ packed_rotno ]( phibin , psibin , nrchi_bin_next ));
679 BBDepScoreInterpData const & d010( bbdep_nrc_interpdata_[ packed_rotno ]( phibin , psibin_next, nrchi_bin ));
680 BBDepScoreInterpData const & d011( bbdep_nrc_interpdata_[ packed_rotno ]( phibin , psibin_next, nrchi_bin_next ));
681 BBDepScoreInterpData const & d100( bbdep_nrc_interpdata_[ packed_rotno ]( phibin_next, psibin , nrchi_bin ));
682 BBDepScoreInterpData const & d101( bbdep_nrc_interpdata_[ packed_rotno ]( phibin_next, psibin , nrchi_bin_next ));
683 BBDepScoreInterpData const & d110( bbdep_nrc_interpdata_[ packed_rotno ]( phibin_next, psibin_next, nrchi_bin ));
684 BBDepScoreInterpData const & d111( bbdep_nrc_interpdata_[ packed_rotno ]( phibin_next, psibin_next, nrchi_bin_next ));
686 Real interpolated_energy(0.0);
697 phi_alpha, psi_alpha, nrchi_alpha,
698 10, 10, bbdep_nrchi_binsize_,
702 dnrchi_score_dnrchi );
704 return interpolated_energy;
716 flll( bbdep_non_rotameric_chi_scores_[ packed_rotno ]( phibin , psibin , nrchi_bin )),
717 fllu( bbdep_non_rotameric_chi_scores_[ packed_rotno ]( phibin , psibin , nrchi_bin_next )),
718 flul( bbdep_non_rotameric_chi_scores_[ packed_rotno ]( phibin , psibin_next, nrchi_bin )),
719 fluu( bbdep_non_rotameric_chi_scores_[ packed_rotno ]( phibin , psibin_next, nrchi_bin_next )),
720 full( bbdep_non_rotameric_chi_scores_[ packed_rotno ]( phibin_next, psibin , nrchi_bin )),
721 fulu( bbdep_non_rotameric_chi_scores_[ packed_rotno ]( phibin_next, psibin , nrchi_bin_next )),
722 fuul( bbdep_non_rotameric_chi_scores_[ packed_rotno ]( phibin_next, psibin_next, nrchi_bin )),
723 fuuu( bbdep_non_rotameric_chi_scores_[ packed_rotno ]( phibin_next, psibin_next, nrchi_bin_next ));
725 //if ( flll > 1e16 ) {std::cout << "inf: flll " << phibin << " " << psibin << " " << phibin_next << " " << psibin_next << " " << nrchi_bin << " " << nrchi_bin_next << std::endl; }
726 //if ( fllu > 1e16 ) {std::cout << "inf: fllu " << phibin << " " << psibin << " " << phibin_next << " " << psibin_next << " " << nrchi_bin << " " << nrchi_bin_next << std::endl; }
727 //if ( flul > 1e16 ) {std::cout << "inf: flul " << phibin << " " << psibin << " " << phibin_next << " " << psibin_next << " " << nrchi_bin << " " << nrchi_bin_next << std::endl; }
728 //if ( fluu > 1e16 ) {std::cout << "inf: fluu " << phibin << " " << psibin << " " << phibin_next << " " << psibin_next << " " << nrchi_bin << " " << nrchi_bin_next << std::endl; }
729 //if ( full > 1e16 ) {std::cout << "inf: full " << phibin << " " << psibin << " " << phibin_next << " " << psibin_next << " " << nrchi_bin << " " << nrchi_bin_next << std::endl; }
730 //if ( fulu > 1e16 ) {std::cout << "inf: fulu " << phibin << " " << psibin << " " << phibin_next << " " << psibin_next << " " << nrchi_bin << " " << nrchi_bin_next << std::endl; }
731 //if ( fuul > 1e16 ) {std::cout << "inf: fuul " << phibin << " " << psibin << " " << phibin_next << " " << psibin_next << " " << nrchi_bin << " " << nrchi_bin_next << std::endl; }
732 //if ( fuuu > 1e16 ) {std::cout << "inf: fuuu " << phibin << " " << psibin << " " << phibin_next << " " << psibin_next << " " << nrchi_bin << " " << nrchi_bin_next << std::endl; }
735 Real const a1 = phi_alpha, a2 = psi_alpha, a3 = nrchi_alpha;
736 Real const b1 = 1 - a1, b2 = 1 - a2, b3 = 1 - a3;
738 dnrchi_score_dphi = (
739 ( b2 * b3 * ( full - flll ) ) + ( a2 * b3 * ( fuul - flul ) ) +
740 ( b2 * a3 * ( fulu - fllu ) ) + ( a2 * a3 * ( fuuu - fluu ) ) ) / parent::PHIPSI_BINRANGE;
741 dnrchi_score_dpsi = (
742 ( b1 * b3 * ( flul - flll ) ) + ( a1 * b3 * ( fuul - full ) ) +
743 ( b1 * a3 * ( fluu - fllu ) ) + ( a1 * a3 * ( fuuu - fulu ) ) ) / parent::PHIPSI_BINRANGE;
744 dnrchi_score_dnrchi = (
745 ( b1 * b2 * ( fllu - flll ) ) + ( a1 * b2 * ( fulu - full ) ) +
746 ( b1 * a2 * ( fluu - flul ) ) + ( a1 * a2 * ( fuuu - fuul ) ) ) / bbdep_nrchi_binsize_;
749 ( b1 * b2 * b3 * flll ) +
750 ( a1 * b2 * b3 * full ) +
751 ( b1 * a2 * b3 * flul ) +
752 ( a1 * a2 * b3 * fuul ) +
753 ( b1 * b2 * a3 * fllu ) +
754 ( a1 * b2 * a3 * fulu ) +
755 ( b1 * a2 * a3 * fluu ) +
756 ( a1 * a2 * a3 * fuuu ); */
768 bool curr_rotamer_only,
772 assert( rsd.
nchi() ==
T+1 );
773 Real nrchi_score( 0 );
774 if ( curr_rotamer_only ) {
775 Real dnrchiscore_dchi, dnrchiscore_dphi, dnrchiscore_dpsi;
778 parent::eval_rotameric_energy_deriv( rsd, scratch,
false);
780 nrchi_score = bbdep_nrchi_score( rsd, scratch, dnrchiscore_dchi, dnrchiscore_dphi, dnrchiscore_dpsi );
784 for (
Size jj = 0; jj <= bbdep_nrchi_nbins_; ++jj ) {
785 rsd_chi[rsd_copy.
nchi()]=nrchi_lower_angle_+bbdep_nrchi_binsize_*jj;
786 rsd_copy.
chi(rsd_chi);
787 parent::eval_rotameric_energy_deriv( rsd_copy, scratch,
false);
788 Real tmp_nrchi_score=bbdep_nrchi_score( rsd_copy, scratch, dnrchiscore_dchi, dnrchiscore_dphi, dnrchiscore_dpsi );
789 if ( tmp_nrchi_score < nrchi_score)
790 nrchi_score=tmp_nrchi_score;
797 Real const phi( parent::get_phi_from_rsd( rsd ) );
798 Real const psi( parent::get_psi_from_rsd( rsd ) );
803 Real dnrchiscore_dchi, dnrchiscore_dphi, dnrchiscore_dpsi;
804 parent::eval_rotameric_energy_deriv( rsd, scratch,
false);
805 nrchi_score = bbdep_nrchi_score( rsd, scratch, dnrchiscore_dchi, dnrchiscore_dphi, dnrchiscore_dpsi );
806 Real tmp_nrchi_score;
811 for (
Size jj = 1; jj <= rotamer_samples.size(); ++jj ) {
813 for (
Size ii = 1; ii <=
T; ++ii ) {
814 rsd_chi[ii]=rotamer_samples[jj].chi_mean()[ii];
817 for (
Size kk = 0; kk <= bbdep_nrchi_nbins_; ++kk ) {
818 rsd_chi[rsd_copy.
nchi()]=nrchi_lower_angle_+bbdep_nrchi_binsize_*kk;
819 rsd_copy.
chi(rsd_chi);
820 parent::eval_rotameric_energy_deriv( rsd_copy, scratch,
false);
821 tmp_nrchi_score=bbdep_nrchi_score( rsd_copy, scratch, dnrchiscore_dchi, dnrchiscore_dphi, dnrchiscore_dpsi );
822 if ( tmp_nrchi_score < nrchi_score)
823 nrchi_score=tmp_nrchi_score;
838 numeric::random::RandomGenerator &
RG,
840 bool perturb_from_rotamer_center
843 if ( bbind_nrchi_sampling_ ) {
844 assign_random_rotamer_with_bias_bbind( rsd, scratch, RG, new_chi_angles, perturb_from_rotamer_center );
846 assign_random_rotamer_with_bias_bbdep( rsd, scratch, RG, new_chi_angles, perturb_from_rotamer_center );
856 numeric::random::RandomGenerator &
RG,
858 bool perturb_from_rotamer_center
862 Size packed_rotno( 0 );
863 parent::assign_random_rotamer( rsd, scratch, RG, new_chi_angles, perturb_from_rotamer_center, packed_rotno );
866 Real random_prob = RG.uniform();
867 Size count( 0 ), nrchi_bin( 0 );
868 while ( random_prob > 0 ) {
869 nrchi_bin = bbind_rotamers_sorted_by_probability_( ++count, packed_rotno );
870 random_prob -= bbind_rotamers_to_sample_( nrchi_bin, packed_rotno ).prob_;
871 if ( count == n_nrchi_sample_bins_ )
break;
874 if ( perturb_from_rotamer_center ) {
878 Real nrchi_prob = RG.uniform();
879 Real left( bbind_rotamers_to_sample_( nrchi_bin, packed_rotno ).left_ );
880 Real right( bbind_rotamers_to_sample_( nrchi_bin, packed_rotno ).right_ );
881 assert( left < right );
883 new_chi_angles[
T + 1 ] = left + (left-right) * nrchi_prob;
885 new_chi_angles[
T + 1 ] = bbind_rotamers_to_sample_( nrchi_bin, packed_rotno ).median_;
895 numeric::random::RandomGenerator &
RG,
897 bool perturb_from_rotamer_center
900 Real random_prob = RG.uniform();
902 Real const phi( parent::get_phi_from_rsd( rsd ) );
903 Real const psi( parent::get_psi_from_rsd( rsd ) );
905 Size phibin, psibin, phibin_next, psibin_next;
906 Real phi_alpha, psi_alpha;
907 parent::get_phipsi_bins( phi, psi, phibin, psibin, phibin_next, psibin_next,phi_alpha, psi_alpha );
911 while ( random_prob > 0 ) {
913 bbdep_rotamers_to_sample_( phibin, psibin, ++count ));
915 interpolated_nrchi_sample = interpolate_bbdep_nrchi_sample(
917 phibin, psibin, phibin_next, psibin_next,
921 random_prob -= interpolated_nrchi_sample.
prob_;
922 if ( count == bbdep_rotamers_to_sample_.size3() )
break;
929 phibin, psibin, phibin_next, psibin_next, phi_alpha, psi_alpha,
930 interpolated_rotamer );
932 this->assign_chi_for_interpolated_rotamer( interpolated_rotamer, rsd, RG, new_chi_angles, perturb_from_rotamer_center );
934 if ( ! perturb_from_rotamer_center ) {
935 new_chi_angles[
T + 1 ] = interpolated_nrchi_sample.
nrchi_mean_;
937 new_chi_angles[
T + 1 ] = interpolated_nrchi_sample.
nrchi_mean_ +
938 RG.gaussian() * interpolated_nrchi_sample.
nrchi_sd_;
957 if ( bbind_nrchi_sampling_ ) {
958 fill_rotamer_vector_bbind( pose, scorefxn, task, packer_neighbor_graph,
959 concrete_residue, existing_residue, extra_chi_steps, buried, rotamers );
961 fill_rotamer_vector_bbdep( pose, scorefxn, task, packer_neighbor_graph,
962 concrete_residue, existing_residue, extra_chi_steps, buried, rotamers );
983 Real phi( parent::get_phi_from_rsd( existing_residue ) );
984 Real psi( parent::get_psi_from_rsd( existing_residue ) );
985 Size phibin, psibin, phibin_next, psibin_next;
986 Real phi_alpha, psi_alpha;
987 parent::get_phipsi_bins( phi, psi, phibin, psibin, phibin_next, psibin_next, phi_alpha, psi_alpha );
993 for (
Size ii = 1; ii <= grandparent::n_packed_rots(); ++ii ) {
997 phibin_next, psibin_next,phi_alpha, psi_alpha,
998 interpolated_rotamers[ ii ] );
1000 probs_of_next_rotamers[ ii ] = interpolated_rotamers[ ii ].rotamer_probability() *
1001 bbind_rotamers_to_sample_( bbind_rotamers_sorted_by_probability_( 1, ii ), ii ).prob_;
1004 Size const max_rots_that_can_be_built = grandparent::n_packed_rots() * n_nrchi_sample_bins_;
1006 Real const requisit_probability = buried ? 0.87 : 0.95;
1008 Real accumulated_probability( 0.0 );
1010 Size count_rotamers_built = 0;
1011 while ( accumulated_probability < requisit_probability ) {
1013 Size const which_packedrotno_to_build = utility::arg_max( probs_of_next_rotamers );
1015 Size const count = next_nrchi_rotamer_to_take[ which_packedrotno_to_build ];
1016 Size const next_count = ++next_nrchi_rotamer_to_take[ which_packedrotno_to_build ];
1018 Size const nrchi_rotno = bbind_rotamers_sorted_by_probability_( count, which_packedrotno_to_build );
1019 Size const next_nrchi_rotno = count < n_nrchi_sample_bins_ ?
1020 bbind_rotamers_sorted_by_probability_( next_count, which_packedrotno_to_build ) : 0 ;
1022 accumulated_probability += probs_of_next_rotamers[ which_packedrotno_to_build ];
1023 ++count_rotamers_built;
1025 if ( probs_of_next_rotamers[ which_packedrotno_to_build ] <= 0 )
break;
1027 if ( next_nrchi_rotno == 0 ) {
1028 probs_of_next_rotamers[ which_packedrotno_to_build ] = 0;
1030 probs_of_next_rotamers[ which_packedrotno_to_build ] =
1031 interpolated_rotamers[ which_packedrotno_to_build ].rotamer_probability() *
1032 bbind_rotamers_to_sample_(
1034 which_packedrotno_to_build ).prob_;
1037 build_bbind_rotamers(
1038 pose, scorefxn, task, packer_neighbor_graph,
1039 concrete_residue, existing_residue, extra_chi_steps, buried,
1040 interpolated_rotamers[ which_packedrotno_to_build ], nrchi_rotno,
1041 bbind_rotamers_to_sample_( nrchi_rotno, which_packedrotno_to_build ),
1044 if ( count_rotamers_built == max_rots_that_can_be_built )
break;
1068 Real phi( parent::get_phi_from_rsd( existing_residue ) );
1069 Real psi( parent::get_psi_from_rsd( existing_residue ) );
1070 Size phibin, psibin, phibin_next, psibin_next;
1071 Real phi_alpha, psi_alpha;
1072 parent::get_phipsi_bins( phi, psi, phibin, psibin, phibin_next, psibin_next, phi_alpha, psi_alpha );
1074 Real const requisit_probability = buried ? 0.95 : 0.87;
1076 Real accumulated_probability( 0.0 );
1078 Size const max_rots_that_can_be_built = grandparent::n_packed_rots() * n_nrchi_sample_bins_;
1079 Size count_rotamers_built = 0;
1080 while ( accumulated_probability < requisit_probability ) {
1081 ++count_rotamers_built;
1084 bbdep_rotamers_to_sample_( phibin, psibin, count_rotamers_built ));
1090 ind01( bbdep_rotsample_sorted_order_( phibin , psibin_next, packed_rotno00, nrchi_bin )),
1091 ind10( bbdep_rotsample_sorted_order_( phibin_next, psibin , packed_rotno00, nrchi_bin )),
1092 ind11( bbdep_rotsample_sorted_order_( phibin_next, psibin_next, packed_rotno00, nrchi_bin ));
1094 BBDepNRChiSample<> const & nrchi_sample_01( bbdep_rotamers_to_sample_( phibin , psibin_next, ind01 ));
1095 BBDepNRChiSample<> const & nrchi_sample_10( bbdep_rotamers_to_sample_( phibin_next, psibin , ind10 ));
1096 BBDepNRChiSample<> const & nrchi_sample_11( bbdep_rotamers_to_sample_( phibin_next, psibin_next, ind11 ));
1099 interpolate_bbdep_nrchi_sample(
1100 nrchi_sample_00, nrchi_sample_01,
1101 nrchi_sample_10, nrchi_sample_11,
1102 phi_alpha, psi_alpha
1105 if ( rotamer_has_been_interpolated[ packed_rotno00 ] == 0 ) {
1107 rotamer_has_been_interpolated[ packed_rotno00 ] = 1;
1109 scratch, packed_rotno00,
1111 phibin_next, psibin_next,phi_alpha, psi_alpha,
1112 interpolated_rotamers[ packed_rotno00 ] );
1115 build_bbdep_rotamers(
1116 pose, scorefxn, task, packer_neighbor_graph,
1117 concrete_residue, existing_residue, extra_chi_steps, buried,
1118 interpolated_rotamers[ packed_rotno00 ], interpolated_nrchi_sample,
1121 accumulated_probability += interpolated_nrchi_sample.
prob_;
1123 if ( count_rotamers_built == max_rots_that_can_be_built )
break;
1135 if ( bbind_nrchi_sampling_ ) {
1136 return get_all_rotamer_samples_bbind( phi, psi );
1138 return get_all_rotamer_samples_bbdep( phi, psi );
1151 if ( bbind_nrchi_sampling_ ) {
1152 return get_probability_for_rotamer_bbind( phi, psi, rot_ind );
1154 return get_probability_for_rotamer_bbdep( phi, psi, rot_ind );
1166 if ( bbind_nrchi_sampling_ ) {
1167 return get_rotamer_bbind( phi, psi, rot_ind );
1169 return get_rotamer_bbdep( phi, psi, rot_ind );
1185 return grandparent::n_possible_rots() * n_nrchi_sample_bins_;
1198 Size phibin, psibin, phibin_next, psibin_next;
1199 Real phi_alpha, psi_alpha;
1200 parent::get_phipsi_bins( phi, psi, phibin, psibin, phibin_next, psibin_next, phi_alpha, psi_alpha );
1206 for (
Size ii = 1; ii <= grandparent::n_packed_rots(); ++ii ) {
1210 phibin_next, psibin_next,phi_alpha, psi_alpha,
1211 interpolated_rotamers[ ii ] );
1213 probs_of_next_rotamers[ ii ] = interpolated_rotamers[ ii ].rotamer_probability() *
1214 bbind_rotamers_to_sample_( bbind_rotamers_sorted_by_probability_( 1, ii ), ii ).prob_;
1218 Size const n_rots = grandparent::n_packed_rots() * n_nrchi_sample_bins_;
1220 all_rots.reserve( n_rots );
1222 for (
Size ii = 1; ii <= n_rots; ++ii ) {
1224 Size const which_packedrotno_to_build = utility::arg_max( probs_of_next_rotamers );
1228 Size const count = next_nrchi_rotamer_to_take[ which_packedrotno_to_build ];
1229 Size const next_count = ++next_nrchi_rotamer_to_take[ which_packedrotno_to_build ];
1231 Size const nrchi_rotno = bbind_rotamers_sorted_by_probability_( count, which_packedrotno_to_build );
1232 Size const next_nrchi_rotno = count < n_nrchi_sample_bins_ ?
1233 bbind_rotamers_sorted_by_probability_( next_count, which_packedrotno_to_build ) : 0 ;
1241 sample.
set_chi_mean(
T + 1, bbind_rotamers_to_sample_( nrchi_rotno, which_packedrotno_to_build ).median_ );
1243 sample.
set_prob( probs_of_next_rotamers[ which_packedrotno_to_build ] );
1246 sample.
set_nrchi_probability( bbind_rotamers_to_sample_( nrchi_rotno, which_packedrotno_to_build ).prob_ );
1249 if ( probs_of_next_rotamers[ which_packedrotno_to_build ] <= 0 )
break;
1251 if ( next_nrchi_rotno == 0 ) {
1252 probs_of_next_rotamers[ which_packedrotno_to_build ] = 0;
1254 probs_of_next_rotamers[ which_packedrotno_to_build ] =
1255 interpolated_rotamers[ which_packedrotno_to_build ].rotamer_probability() *
1256 bbind_rotamers_to_sample_( next_nrchi_rotno, which_packedrotno_to_build ).prob_;
1258 all_rots.push_back( sample );
1276 Size phibin, psibin, phibin_next, psibin_next;
1277 Real phi_alpha, psi_alpha;
1278 parent::get_phipsi_bins( phi, psi, phibin, psibin, phibin_next, psibin_next, phi_alpha, psi_alpha );
1280 Size const n_rots = grandparent::n_packed_rots() * n_nrchi_sample_bins_;
1282 all_rots.reserve( n_rots );
1284 for (
Size ii = 1; ii <= n_rots; ++ii ) {
1286 bbdep_rotamers_to_sample_( phibin, psibin, ii ));
1292 ind01( bbdep_rotsample_sorted_order_( phibin , psibin_next, packed_rotno00, nrchi_bin )),
1293 ind10( bbdep_rotsample_sorted_order_( phibin_next, psibin , packed_rotno00, nrchi_bin )),
1294 ind11( bbdep_rotsample_sorted_order_( phibin_next, psibin_next, packed_rotno00, nrchi_bin ));
1296 BBDepNRChiSample<> const & nrchi_sample_01( bbdep_rotamers_to_sample_( phibin , psibin_next, ind01 ));
1297 BBDepNRChiSample<> const & nrchi_sample_10( bbdep_rotamers_to_sample_( phibin_next, psibin , ind10 ));
1298 BBDepNRChiSample<> const & nrchi_sample_11( bbdep_rotamers_to_sample_( phibin_next, psibin_next, ind11 ));
1301 interpolate_bbdep_nrchi_sample(
1302 nrchi_sample_00, nrchi_sample_01,
1303 nrchi_sample_10, nrchi_sample_11,
1304 phi_alpha, psi_alpha
1307 if ( rotamer_has_been_interpolated[ packed_rotno00 ] == 0 ) {
1309 rotamer_has_been_interpolated[ packed_rotno00 ] = 1;
1311 scratch, packed_rotno00,
1313 phibin_next, psibin_next,phi_alpha, psi_alpha,
1314 interpolated_rotamers[ packed_rotno00 ] );
1321 sample.
set_rotwell( parent::packed_rotno_2_rotwell( packed_rotno00 ));
1336 all_rots.push_back( sample );
1351 Size phibin, psibin, phibin_next, psibin_next;
1352 Real phi_alpha, psi_alpha;
1353 parent::get_phipsi_bins( phi, psi, phibin, psibin, phibin_next, psibin_next, phi_alpha, psi_alpha );
1358 for (
Size ii = 1; ii <= grandparent::n_packed_rots(); ++ii ) {
1364 sorted_rotno_01( parent::packed_rotno_2_sorted_rotno()( phibin , psibin_next, packed_rotno )),
1365 sorted_rotno_10( parent::packed_rotno_2_sorted_rotno()( phibin_next, psibin , packed_rotno )),
1366 sorted_rotno_11( parent::packed_rotno_2_sorted_rotno()( phibin_next, psibin_next, packed_rotno ));
1369 rot01( parent::rotamers()( phibin , psibin_next, sorted_rotno_01 ) ),
1370 rot10( parent::rotamers()( phibin_next, psibin , sorted_rotno_10 ) ),
1371 rot11( parent::rotamers()( phibin_next, psibin_next, sorted_rotno_11 ) );
1373 Real interpolated_probability, dummy1, dummy2;
1374 basic::interpolate_bilinear_by_value(
1376 static_cast< Real > ( rot10.rotamer_probability()),
1377 static_cast< Real > ( rot01.rotamer_probability()),
1379 phi_alpha, psi_alpha, parent::PHIPSI_BINRANGE,
false ,
1380 interpolated_probability,
1384 probability_of_rotameric_chi[ ii ] = interpolated_probability;
1385 probs_of_next_rotamers[ ii ] = probability_of_rotameric_chi[ ii ] *
1386 bbind_rotamers_to_sample_( bbind_rotamers_sorted_by_probability_( 1, ii ), ii ).prob_;
1390 Size const n_rots = grandparent::n_packed_rots() * n_nrchi_sample_bins_;
1392 all_rots.reserve( n_rots );
1394 Real last_prob( 0 );
1396 for (
Size ii = 1; ii <= rot_ind; ++ii ) {
1398 Size const which_packedrotno_to_build = utility::arg_max( probs_of_next_rotamers );
1400 Size const count = next_nrchi_rotamer_to_take[ which_packedrotno_to_build ];
1401 Size const next_count = ++next_nrchi_rotamer_to_take[ which_packedrotno_to_build ];
1404 Size const next_nrchi_rotno = count < n_nrchi_sample_bins_ ?
1405 bbind_rotamers_sorted_by_probability_( next_count, which_packedrotno_to_build ) : 0 ;
1407 last_prob = probs_of_next_rotamers[ which_packedrotno_to_build ];
1409 if ( probs_of_next_rotamers[ which_packedrotno_to_build ] <= 0 )
break;
1411 if ( next_nrchi_rotno == 0 ) {
1412 probs_of_next_rotamers[ which_packedrotno_to_build ] = 0;
1414 probs_of_next_rotamers[ which_packedrotno_to_build ] =
1415 probability_of_rotameric_chi[ which_packedrotno_to_build ] *
1416 bbind_rotamers_to_sample_( next_nrchi_rotno, which_packedrotno_to_build ).prob_;
1433 Size phibin, psibin, phibin_next, psibin_next;
1434 Real phi_alpha, psi_alpha;
1435 parent::get_phipsi_bins( phi, psi, phibin, psibin, phibin_next, psibin_next, phi_alpha, psi_alpha );
1438 bbdep_rotamers_to_sample_( phibin, psibin, rot_ind ));
1444 ind01( bbdep_rotsample_sorted_order_( phibin , psibin_next, packed_rotno00, nrchi_bin )),
1445 ind10( bbdep_rotsample_sorted_order_( phibin_next, psibin , packed_rotno00, nrchi_bin )),
1446 ind11( bbdep_rotsample_sorted_order_( phibin_next, psibin_next, packed_rotno00, nrchi_bin ));
1448 BBDepNRChiSample<> const & nrchi_sample_01( bbdep_rotamers_to_sample_( phibin , psibin_next, ind01 ));
1449 BBDepNRChiSample<> const & nrchi_sample_10( bbdep_rotamers_to_sample_( phibin_next, psibin , ind10 ));
1450 BBDepNRChiSample<> const & nrchi_sample_11( bbdep_rotamers_to_sample_( phibin_next, psibin_next, ind11 ));
1452 Real nrchi_prob, dummy_dprob_1, dummy_dprob_2;
1454 basic::interpolate_bilinear_by_value(
1455 static_cast< Real > ( nrchi_sample_00.
prob_),
1456 static_cast< Real > ( nrchi_sample_10.
prob_),
1457 static_cast< Real > ( nrchi_sample_01.
prob_),
1458 static_cast< Real > ( nrchi_sample_11.
prob_),
1459 phi_alpha, psi_alpha, parent::PHIPSI_BINRANGE,
false ,
1461 dummy_dprob_1, dummy_dprob_2
1475 Size phibin, psibin, phibin_next, psibin_next;
1476 Real phi_alpha, psi_alpha;
1477 parent::get_phipsi_bins( phi, psi, phibin, psibin, phibin_next, psibin_next, phi_alpha, psi_alpha );
1482 for (
Size ii = 1; ii <= grandparent::n_packed_rots(); ++ii ) {
1488 sorted_rotno_01( parent::packed_rotno_2_sorted_rotno()( phibin , psibin_next, packed_rotno )),
1489 sorted_rotno_10( parent::packed_rotno_2_sorted_rotno()( phibin_next, psibin , packed_rotno )),
1490 sorted_rotno_11( parent::packed_rotno_2_sorted_rotno()( phibin_next, psibin_next, packed_rotno ));
1493 rot01( parent::rotamers()( phibin , psibin_next, sorted_rotno_01 ) ),
1494 rot10( parent::rotamers()( phibin_next, psibin , sorted_rotno_10 ) ),
1495 rot11( parent::rotamers()( phibin_next, psibin_next, sorted_rotno_11 ) );
1497 Real interpolated_probability, dummy1, dummy2;
1498 basic::interpolate_bilinear_by_value(
1500 static_cast< Real > ( rot10.rotamer_probability()),
1501 static_cast< Real > ( rot01.rotamer_probability()),
1503 phi_alpha, psi_alpha, parent::PHIPSI_BINRANGE,
false ,
1504 interpolated_probability,
1508 probability_of_rotameric_chi[ ii ] = interpolated_probability;
1509 probs_of_next_rotamers[ ii ] = probability_of_rotameric_chi[ ii ] *
1510 bbind_rotamers_to_sample_( bbind_rotamers_sorted_by_probability_( 1, ii ), ii ).prob_;
1514 Size const n_rots = grandparent::n_packed_rots() * n_nrchi_sample_bins_;
1516 all_rots.reserve( n_rots );
1518 Real last_prob( 0 );
1519 Size last_nrchi_rotno( 0 );
1520 Size last_rchi_rotno( 0 );
1522 for (
Size ii = 1; ii <= rot_ind; ++ii ) {
1524 Size const which_packedrotno_to_build = utility::arg_max( probs_of_next_rotamers );
1525 last_prob = probs_of_next_rotamers[ which_packedrotno_to_build ];
1526 last_rchi_rotno = which_packedrotno_to_build;
1528 Size const count = next_nrchi_rotamer_to_take[ which_packedrotno_to_build ];
1529 Size const next_count = ++next_nrchi_rotamer_to_take[ which_packedrotno_to_build ];
1531 Size const nrchi_rotno = bbind_rotamers_sorted_by_probability_( count, which_packedrotno_to_build );
1532 last_nrchi_rotno = nrchi_rotno;
1533 Size const next_nrchi_rotno = count < n_nrchi_sample_bins_ ?
1534 bbind_rotamers_sorted_by_probability_( next_count, which_packedrotno_to_build ) : 0 ;
1536 last_prob = probs_of_next_rotamers[ which_packedrotno_to_build ];
1538 if ( probs_of_next_rotamers[ which_packedrotno_to_build ] <= 0 )
break;
1540 if ( next_nrchi_rotno == 0 ) {
1541 probs_of_next_rotamers[ which_packedrotno_to_build ] = 0;
1543 probs_of_next_rotamers[ which_packedrotno_to_build ] =
1544 probability_of_rotameric_chi[ which_packedrotno_to_build ] *
1545 bbind_rotamers_to_sample_( next_nrchi_rotno, which_packedrotno_to_build ).prob_;
1554 scratch, last_rchi_rotno,
1556 phibin_next, psibin_next,phi_alpha, psi_alpha,
1565 sample.
set_chi_mean(
T + 1, bbind_rotamers_to_sample_( last_nrchi_rotno, last_rchi_rotno ).median_ );
1570 sample.
set_nrchi_probability( bbind_rotamers_to_sample_( last_nrchi_rotno, last_rchi_rotno ).prob_ );
1585 Size phibin, psibin, phibin_next, psibin_next;
1586 Real phi_alpha, psi_alpha;
1587 parent::get_phipsi_bins( phi, psi, phibin, psibin, phibin_next, psibin_next, phi_alpha, psi_alpha );
1590 bbdep_rotamers_to_sample_( phibin, psibin, rot_ind ));
1596 ind01( bbdep_rotsample_sorted_order_( phibin , psibin_next, packed_rotno00, nrchi_bin )),
1597 ind10( bbdep_rotsample_sorted_order_( phibin_next, psibin , packed_rotno00, nrchi_bin )),
1598 ind11( bbdep_rotsample_sorted_order_( phibin_next, psibin_next, packed_rotno00, nrchi_bin ));
1600 BBDepNRChiSample<> const & nrchi_sample_01( bbdep_rotamers_to_sample_( phibin , psibin_next, ind01 ));
1601 BBDepNRChiSample<> const & nrchi_sample_10( bbdep_rotamers_to_sample_( phibin_next, psibin , ind10 ));
1602 BBDepNRChiSample<> const & nrchi_sample_11( bbdep_rotamers_to_sample_( phibin_next, psibin_next, ind11 ));
1605 interpolate_bbdep_nrchi_sample(
1606 nrchi_sample_00, nrchi_sample_01,
1607 nrchi_sample_10, nrchi_sample_11,
1608 phi_alpha, psi_alpha
1613 scratch, packed_rotno00,
1615 phibin_next, psibin_next,phi_alpha, psi_alpha,
1620 sample.
set_rotwell( parent::packed_rotno_2_rotwell( packed_rotno00 ));
1660 parent::enumerate_chi_sets(
1661 *concrete_residue, task, existing_residue.
seqpos(), buried,
1662 bbdep_rotamer_building_data,
1663 extra_chi_steps, chi_set_vector );
1665 parent::create_rotamers_from_chisets(
1666 pose, scorefxn, task,
1667 packer_neighbor_graph, concrete_residue, existing_residue,
1668 chi_set_vector, rotamers );
1683 Size const nrchi_rotno,
1693 parent::enumerate_chi_sets(
1694 *concrete_residue, task, existing_residue.
seqpos(), buried,
1695 bbind_rotamer_building_data,
1696 extra_chi_steps, chi_set_vector );
1698 parent::create_rotamers_from_chisets(
1699 pose, scorefxn, task,
1700 packer_neighbor_graph, concrete_residue, existing_residue,
1701 chi_set_vector, rotamers );
1712 Size const chi_index,
1721 if ( chi_index !=
T + 1 ) {
1722 parent::chisamples_for_rotamer_and_chi( rsd_type, rtask, buried, chi_index, rotamer_data, extra_steps,
1723 total_chi, total_rot, total_ex_steps, rotsample_prob );
1724 }
else if ( bbind_nrchi_sampling_ ) {
1725 bbind_chisamples_for_rotamer_chi( rsd_type, rtask, buried, chi_index, rotamer_data, extra_steps,
1726 total_chi, total_rot, total_ex_steps, rotsample_prob );
1728 bbdep_chisamples_for_rotamer_chi( rsd_type, rtask, buried, chi_index, rotamer_data, extra_steps,
1729 total_chi, total_rot, total_ex_steps, rotsample_prob );
1739 Size const chi_index,
1748 using namespace pack::task;
1749 assert( chi_index ==
T + 1 );
1757 Real const minimum_angular_distance_for_extra_bbind_rotamer_sample( 10.0 );
1759 total_chi.push_back( nrsample.median_ );
1760 total_ex_steps.push_back( 0.0 );
1761 total_rot.push_back( bbind_rotameric_data.
nrchi_bin_id() );
1762 chisample_prob.push_back( nrsample.prob_ );
1770 if ( std::abs( basic::periodic_range( nrsample.median_ - nrsample.left_, nrchi_periodicity_ )) >
1771 minimum_angular_distance_for_extra_bbind_rotamer_sample ) {
1774 total_chi.push_back( nrsample.median_ - 0.5 * ( nrsample.median_ - nrsample.left_ ) );
1775 total_ex_steps.push_back( 1.0 );
1776 total_rot.push_back( bbind_rotameric_data.
nrchi_bin_id() );
1777 chisample_prob.push_back( nrsample.prob_ );
1780 if ( std::abs( basic::periodic_range( nrsample.median_ - nrsample.right_, nrchi_periodicity_ )) >
1781 minimum_angular_distance_for_extra_bbind_rotamer_sample ) {
1784 total_chi.push_back( nrsample.median_ + 0.5 * ( nrsample.right_ - nrsample.median_ ) );
1785 total_ex_steps.push_back( 1.0 );
1786 total_rot.push_back( bbind_rotameric_data.
nrchi_bin_id() );
1787 chisample_prob.push_back( nrsample.prob_ );
1798 Size const chi_index,
1807 using namespace pack::task;
1808 assert( chi_index ==
T + 1 );
1816 total_chi.push_back( nrsample.nrchi_mean_ );
1817 total_ex_steps.push_back( 0. );
1818 total_rot.push_back( nrsample.nrchi_bin_ );
1819 chisample_prob.push_back( nrsample.prob_ );
1825 Real const min_extrachi_sd = 0.0;
1826 if ( nrsample.nrchi_sd_ <= min_extrachi_sd )
return;
1828 for (
Size k=1; k<= extra_steps.size(); ++k ) {
1829 total_chi.push_back( nrsample.nrchi_mean_ + extra_steps[k] * nrsample.nrchi_sd_ );
1830 total_ex_steps.push_back( extra_steps[k] );
1831 total_rot.push_back( nrsample.nrchi_bin_ );
1832 chisample_prob.push_back( nrsample.prob_ );
1852 utility_exit_with_message(
"Unimplemented!");
1859 using namespace boost;
1860 parent::write_to_binary( out );
1866 boost::int32_t bbind_nrchi_scoring = bbind_nrchi_scoring_;
1867 out.write( (
char*) &bbind_nrchi_scoring,
sizeof( boost::int32_t ));
1871 boost::int32_t bbind_nrchi_sampling = bbind_nrchi_sampling_;
1872 out.write( (
char*) &bbind_nrchi_sampling,
sizeof( boost::int32_t ));
1875 if ( ! bbind_nrchi_scoring_ ) {
1877 Size const n_bbdep_scores = grandparent::n_packed_rots() * parent::N_PHIPSI_BINS * parent::N_PHIPSI_BINS * bbdep_nrchi_nbins_;
1880 for (
Size ii = 1; ii <= grandparent::n_packed_rots(); ++ii ) {
1881 for (
Size jj = 1; jj <= bbdep_nrchi_nbins_; ++jj ) {
1882 for (
Size kk = 1; kk <= parent::N_PHIPSI_BINS; ++kk ) {
1883 for (
Size ll = 1; ll <= parent::N_PHIPSI_BINS; ++ll ) {
1884 bbdep_nrc_interpdata[ count ] = bbdep_nrc_interpdata_[ ii ]( ll, kk, jj );
1891 delete [] bbdep_nrc_interpdata;
1894 Size const n_bbind_scores = bbind_non_rotameric_chi_scores_.size();
1895 Real * bbind_non_rotameric_chi_scores =
new Real[ n_bbind_scores ];
1897 for (
Size ii = 1; ii <= grandparent::n_packed_rots(); ++ii ) {
1898 for (
Size jj = 1; jj <= bbind_nrchi_nbins_; ++jj ) {
1899 bbind_non_rotameric_chi_scores[ count ] = bbind_non_rotameric_chi_scores_( jj, ii );
1903 out.write( (
char*) bbind_non_rotameric_chi_scores, n_bbind_scores *
sizeof(
Real ));
1904 delete [] bbind_non_rotameric_chi_scores;
1909 boost::int32_t n_nrchi_sample_bins = n_nrchi_sample_bins_;
1910 out.write( (
char*) & n_nrchi_sample_bins,
sizeof( boost::int32_t ) );
1913 if ( ! bbind_nrchi_sampling_ ) {
1915 Size const n_bbdep_nrchi_samples =
1916 grandparent::n_packed_rots() * parent::N_PHIPSI_BINS * parent::N_PHIPSI_BINS * n_nrchi_sample_bins_;
1918 boost::int32_t * bbdep_nrchi_packed_rotnos =
new boost::int32_t[ n_bbdep_nrchi_samples ];
1919 boost::int32_t * bbdep_nrchi_bin =
new boost::int32_t[ n_bbdep_nrchi_samples ];
1924 boost::int32_t * bbdep_rotsample_sorted_order =
new boost::int32_t[ n_bbdep_nrchi_samples ];
1927 Size count_iijj( 1 );
1928 for (
Size ii = 1; ii <= n_nrchi_sample_bins_; ++ii ) {
1929 for (
Size jj = 1; jj <= grandparent::n_packed_rots(); ++jj ) {
1930 for (
Size kk = 1; kk <= parent::N_PHIPSI_BINS; ++kk ) {
1931 for (
Size ll = 1; ll <= parent::N_PHIPSI_BINS; ++ll ) {
1932 bbdep_nrchi_packed_rotnos[ count ] = bbdep_rotamers_to_sample_( ll, kk, count_iijj ).packed_rotno_;
1933 bbdep_nrchi_bin[ count ] = bbdep_rotamers_to_sample_( ll, kk, count_iijj ).nrchi_bin_;
1934 bbdep_nrchi_means[ count ] = bbdep_rotamers_to_sample_( ll, kk, count_iijj ).nrchi_mean_;
1935 bbdep_nrchi_sdevs[ count ] = bbdep_rotamers_to_sample_( ll, kk, count_iijj ).nrchi_sd_;
1936 bbdep_nrchi_probs[ count ] = bbdep_rotamers_to_sample_( ll, kk, count_iijj ).prob_;
1937 bbdep_rotsample_sorted_order[count]= bbdep_rotsample_sorted_order_( ll, kk, jj, ii );
1944 out.write( (
char*) bbdep_nrchi_packed_rotnos, n_bbdep_nrchi_samples *
sizeof( boost::int32_t ) );
1945 out.write( (
char*) bbdep_nrchi_bin, n_bbdep_nrchi_samples *
sizeof( boost::int32_t ) );
1946 out.write( (
char*) bbdep_nrchi_means, n_bbdep_nrchi_samples *
sizeof(
DunbrackReal ) );
1947 out.write( (
char*) bbdep_nrchi_sdevs, n_bbdep_nrchi_samples *
sizeof(
DunbrackReal ) );
1948 out.write( (
char*) bbdep_nrchi_probs, n_bbdep_nrchi_samples *
sizeof(
DunbrackReal ) );
1949 out.write( (
char*) bbdep_rotsample_sorted_order, n_bbdep_nrchi_samples *
sizeof( boost::int32_t ) );
1951 delete [] bbdep_nrchi_packed_rotnos; bbdep_nrchi_packed_rotnos = 0;
1952 delete [] bbdep_nrchi_bin; bbdep_nrchi_bin = 0;
1953 delete [] bbdep_nrchi_means; bbdep_nrchi_means = 0;
1954 delete [] bbdep_nrchi_sdevs; bbdep_nrchi_sdevs = 0;
1955 delete [] bbdep_nrchi_probs; bbdep_nrchi_probs = 0;
1956 delete [] bbdep_rotsample_sorted_order; bbdep_rotsample_sorted_order = 0;
1963 Size const n_bbind_nrchi_samples = n_nrchi_sample_bins_ * grandparent::n_packed_rots();
1970 boost::int32_t * bbind_rotsample_sorted_order( 0 );
1971 if ( bbind_nrchi_sampling_ ) {
1972 bbind_rotsample_sorted_order =
new boost::int32_t[ n_bbind_nrchi_samples ];
1976 for (
Size ii = 1; ii <= grandparent::n_packed_rots(); ++ii ) {
1977 for (
Size jj = 1; jj <= n_nrchi_sample_bins_; ++jj ) {
1978 bbind_nrchi_lefts[ count ] = bbind_rotamers_to_sample_( jj, ii ).left_;
1979 bbind_nrchi_medians[ count ] = bbind_rotamers_to_sample_( jj, ii ).median_;
1980 bbind_nrchi_rights[ count ] = bbind_rotamers_to_sample_( jj, ii ).right_;
1981 bbind_nrchi_probs[ count ] = bbind_rotamers_to_sample_( jj, ii ).prob_;
1983 if ( bbind_nrchi_sampling_ ) {
1984 bbind_rotsample_sorted_order[ count ] = bbind_rotamers_sorted_by_probability_( jj, ii );
1989 out.write( (
char*) bbind_nrchi_lefts, n_bbind_nrchi_samples *
sizeof(
DunbrackReal ) );
1990 out.write( (
char*) bbind_nrchi_medians, n_bbind_nrchi_samples *
sizeof(
DunbrackReal ) );
1991 out.write( (
char*) bbind_nrchi_rights, n_bbind_nrchi_samples *
sizeof(
DunbrackReal ) );
1992 out.write( (
char*) bbind_nrchi_probs, n_bbind_nrchi_samples *
sizeof(
DunbrackReal ) );
1994 if ( bbind_nrchi_sampling_ ) {
1995 out.write( (
char*) bbind_rotsample_sorted_order, n_bbind_nrchi_samples *
sizeof( boost::int32_t ) );
1998 delete [] bbind_nrchi_lefts;
1999 delete [] bbind_nrchi_medians;
2000 delete [] bbind_nrchi_rights;
2001 delete [] bbind_nrchi_probs;
2002 delete [] bbind_rotsample_sorted_order;
2011 using namespace boost;
2012 parent::read_from_binary( in );
2017 boost::int32_t bbind_nrchi_scoring( 0 );
2018 in.read( (
char*) &bbind_nrchi_scoring,
sizeof( boost::int32_t ));
2019 if ( bbind_nrchi_scoring_ != static_cast< bool > ( bbind_nrchi_scoring ) ) {
2020 if ( bbind_nrchi_scoring ) {
2021 std::cerr <<
"ERROR: binary file description for " << grandparent::aa() <<
" contains data for"
2022 <<
" backbone independent non-rotameric chi scoring,\nbut the instantiated Semirotamer library"
2023 <<
" was created with backbone dependent non-rotameric chi scoring.\nCheck"
2024 <<
" semirotameric parameter definitions in RotamerLibrary::initialize_dun10_aa_parameters.";
2026 std::cerr <<
"ERROR: binary file description for " << grandparent::aa() <<
" contains data for"
2027 <<
" backbone dependent non-rotameric chi scoring,\nbut the instantiated Semirotamer library"
2028 <<
" was created with backbone independent non-rotameric chi scoring.\nCheck"
2029 <<
" semirotameric parameter definitions in RotamerLibrary::initialize_dun10_aa_parameters.";
2037 boost::int32_t bbind_nrchi_sampling( 0 );
2038 in.read( (
char*) &bbind_nrchi_sampling,
sizeof( boost::int32_t ));
2039 if ( bbind_nrchi_sampling_ != static_cast< bool > ( bbind_nrchi_sampling ) ) {
2040 if ( bbind_nrchi_sampling ) {
2041 std::cerr <<
"ERROR: binary file description for " << grandparent::aa() <<
" contains data for"
2042 <<
" backbone independent non-rotameric chi sampling,\nbut the instantiated Semirotamer library"
2043 <<
" was created with backbone dependent non-rotameric chi sampling.\nCheck"
2044 <<
" semirotameric parameter definitions in RotamerLibrary::initialize_dun10_aa_parameters.";
2046 std::cerr <<
"ERROR: binary file description for " << grandparent::aa() <<
" contains data for"
2047 <<
" backbone dependent non-rotameric chi sampling,\nbut the instantiated Semirotamer library"
2048 <<
" was created with backbone independent non-rotameric chi sampling.\nCheck"
2049 <<
" semirotameric parameter definitions in RotamerLibrary::initialize_dun10_aa_parameters.";
2055 if ( ! bbind_nrchi_scoring_ ) {
2057 Size const n_bbdep_scores = grandparent::n_packed_rots() * parent::N_PHIPSI_BINS * parent::N_PHIPSI_BINS * bbdep_nrchi_nbins_;
2062 bbdep_nrc_interpdata_.resize( grandparent::n_packed_rots() );
2063 for (
Size ii = 1; ii <= grandparent::n_packed_rots(); ++ii ) {
2064 bbdep_nrc_interpdata_[ ii ].dimension( parent::N_PHIPSI_BINS, parent::N_PHIPSI_BINS, bbdep_nrchi_nbins_ );
2065 for (
Size jj = 1; jj <= bbdep_nrchi_nbins_; ++jj ) {
2066 for (
Size kk = 1; kk <= parent::N_PHIPSI_BINS; ++kk ) {
2067 for (
Size ll = 1; ll <= parent::N_PHIPSI_BINS; ++ll ) {
2068 bbdep_nrc_interpdata_[ ii ]( ll, kk, jj ) = bbdep_nrc_interpdata[ count ];
2074 delete [] bbdep_nrc_interpdata;
2077 Size const n_bbind_scores = grandparent::n_packed_rots() * bbind_nrchi_nbins_;
2078 Real * bbind_non_rotameric_chi_scores =
new Real[ n_bbind_scores ];
2079 in.read( (
char*) bbind_non_rotameric_chi_scores, n_bbind_scores *
sizeof(
Real ));
2080 bbind_non_rotameric_chi_scores_.dimension( bbind_nrchi_nbins_, grandparent::n_packed_rots() );
2083 for (
Size ii = 1; ii <= grandparent::n_packed_rots(); ++ii ) {
2084 for (
Size jj = 1; jj <= bbind_nrchi_nbins_; ++jj ) {
2085 bbind_non_rotameric_chi_scores_( jj, ii ) = bbind_non_rotameric_chi_scores[ count ];
2089 delete [] bbind_non_rotameric_chi_scores;
2094 boost::int32_t n_nrchi_sample_bins( 0 );
2095 in.read( (
char*) & n_nrchi_sample_bins,
sizeof( boost::int32_t ) );
2096 n_nrchi_sample_bins_ = n_nrchi_sample_bins;
2100 if ( ! bbind_nrchi_sampling_ ) {
2102 Size const n_bbdep_nrchi_samples =
2103 grandparent::n_packed_rots() * parent::N_PHIPSI_BINS * parent::N_PHIPSI_BINS * n_nrchi_sample_bins_;
2105 boost::int32_t * bbdep_nrchi_packed_rotnos =
new boost::int32_t[ n_bbdep_nrchi_samples ];
2106 boost::int32_t * bbdep_nrchi_bin =
new boost::int32_t[ n_bbdep_nrchi_samples ];
2111 boost::int32_t * bbdep_rotsample_sorted_order =
new boost::int32_t[ n_bbdep_nrchi_samples ];
2113 in.read( (
char*) bbdep_nrchi_packed_rotnos, n_bbdep_nrchi_samples *
sizeof( boost::int32_t ) );
2114 in.read( (
char*) bbdep_nrchi_bin, n_bbdep_nrchi_samples *
sizeof( boost::int32_t ) );
2115 in.read( (
char*) bbdep_nrchi_means, n_bbdep_nrchi_samples *
sizeof(
DunbrackReal ) );
2116 in.read( (
char*) bbdep_nrchi_sdevs, n_bbdep_nrchi_samples *
sizeof(
DunbrackReal ) );
2117 in.read( (
char*) bbdep_nrchi_probs, n_bbdep_nrchi_samples *
sizeof(
DunbrackReal ) );
2118 in.read( (
char*) bbdep_rotsample_sorted_order, n_bbdep_nrchi_samples *
sizeof( boost::int32_t ) );
2120 bbdep_rotamers_to_sample_.dimension( parent::N_PHIPSI_BINS, parent::N_PHIPSI_BINS, grandparent::n_packed_rots()*n_nrchi_sample_bins_ );
2121 bbdep_rotsample_sorted_order_.dimension( parent::N_PHIPSI_BINS, parent::N_PHIPSI_BINS, grandparent::n_packed_rots(), n_nrchi_sample_bins_ );
2124 Size count_iijj( 1 );
2125 for (
Size ii = 1; ii <= n_nrchi_sample_bins_; ++ii ) {
2126 for (
Size jj = 1; jj <= grandparent::n_packed_rots(); ++jj ) {
2127 for (
Size kk = 1; kk <= parent::N_PHIPSI_BINS; ++kk ) {
2128 for (
Size ll = 1; ll <= parent::N_PHIPSI_BINS; ++ll ) {
2129 bbdep_rotamers_to_sample_( ll, kk, count_iijj ).packed_rotno_ = bbdep_nrchi_packed_rotnos[ count ];
2130 bbdep_rotamers_to_sample_( ll, kk, count_iijj ).nrchi_bin_ = bbdep_nrchi_bin[ count ];
2131 bbdep_rotamers_to_sample_( ll, kk, count_iijj ).nrchi_mean_ = bbdep_nrchi_means[ count ];
2132 bbdep_rotamers_to_sample_( ll, kk, count_iijj ).nrchi_sd_ = bbdep_nrchi_sdevs[ count ];
2133 bbdep_rotamers_to_sample_( ll, kk, count_iijj ).prob_ = bbdep_nrchi_probs[ count ];
2134 bbdep_rotsample_sorted_order_( ll, kk, jj, ii ) = bbdep_rotsample_sorted_order[count];
2142 delete [] bbdep_nrchi_packed_rotnos; bbdep_nrchi_packed_rotnos = 0;
2143 delete [] bbdep_nrchi_bin; bbdep_nrchi_bin = 0;
2144 delete [] bbdep_nrchi_means; bbdep_nrchi_means = 0;
2145 delete [] bbdep_nrchi_sdevs; bbdep_nrchi_sdevs = 0;
2146 delete [] bbdep_nrchi_probs; bbdep_nrchi_probs = 0;
2147 delete [] bbdep_rotsample_sorted_order; bbdep_rotsample_sorted_order = 0;
2154 Size const n_bbind_nrchi_samples = n_nrchi_sample_bins_ * grandparent::n_packed_rots();
2160 boost::int32_t * bbind_rotsample_sorted_order =
new boost::int32_t[ n_bbind_nrchi_samples ];
2162 in.read( (
char*) bbind_nrchi_lefts, n_bbind_nrchi_samples *
sizeof(
DunbrackReal ) );
2163 in.read( (
char*) bbind_nrchi_medians, n_bbind_nrchi_samples *
sizeof(
DunbrackReal ) );
2164 in.read( (
char*) bbind_nrchi_rights, n_bbind_nrchi_samples *
sizeof(
DunbrackReal ) );
2165 in.read( (
char*) bbind_nrchi_probs, n_bbind_nrchi_samples *
sizeof(
DunbrackReal ) );
2166 if ( bbind_nrchi_sampling_ ) {
2167 in.read( (
char*) bbind_rotsample_sorted_order, n_bbind_nrchi_samples *
sizeof( boost::int32_t ) );
2170 bbind_rotamers_to_sample_.dimension( n_nrchi_sample_bins_, grandparent::n_packed_rots() );
2171 if ( bbind_nrchi_sampling_ ) {
2172 bbind_rotamers_sorted_by_probability_.dimension( n_nrchi_sample_bins_, grandparent::n_packed_rots() );
2176 for (
Size ii = 1; ii <= grandparent::n_packed_rots(); ++ii ) {
2177 for (
Size jj = 1; jj <= n_nrchi_sample_bins_; ++jj ) {
2178 bbind_rotamers_to_sample_( jj, ii ).left_ = bbind_nrchi_lefts[ count ];
2179 bbind_rotamers_to_sample_( jj, ii ).median_ = bbind_nrchi_medians[ count ];
2180 bbind_rotamers_to_sample_( jj, ii ).right_ = bbind_nrchi_rights[ count ];
2181 bbind_rotamers_to_sample_( jj, ii ).prob_ = bbind_nrchi_probs[ count ];
2183 if ( bbind_nrchi_sampling_ ) {
2184 bbind_rotamers_sorted_by_probability_( jj, ii ) = bbind_rotsample_sorted_order[ count ];
2190 delete [] bbind_nrchi_lefts;
2191 delete [] bbind_nrchi_medians;
2192 delete [] bbind_nrchi_rights;
2193 delete [] bbind_nrchi_probs;
2194 delete [] bbind_rotsample_sorted_order;
2207 parent::get_rotamer_from_chi( chi, rot );
2208 Size const packed_rotno( grandparent::rotwell_2_packed_rotno( rot ) );
2209 Real const nrchi = clip_to_nrchi_range( chi[
T + 1 ] );
2211 for (
Size ii = 1; ii <= n_nrchi_sample_bins_; ++ii ) {
2212 Real const left = bbind_rotamers_to_sample_( ii, packed_rotno ).left_;
2213 Real const right = bbind_rotamers_to_sample_( ii, packed_rotno ).right_;
2214 if ( left < nrchi_lower_angle_ ) {
2217 ! ( left <= nrchi && nrchi <= right ) &&
2218 ! ( left + nrchi_periodicity_ <= nrchi && nrchi <= right + nrchi_periodicity_ ) ) {
2221 }
else if ( right > nrchi_lower_angle_ + nrchi_periodicity_ ) {
2223 ! ( left <= nrchi && nrchi <= right ) &&
2224 ! ( left - nrchi_periodicity_ <= nrchi && nrchi <= right - nrchi_periodicity_ ) ) {
2227 }
else if ( left > nrchi ) {
2229 }
else if ( nrchi > right ) {
2237 if ( rot[
T + 1 ] == 0 ) {
2238 std::cerr <<
"Failed to find bracketing bin for : " << nrchi <<
T;
2239 for (
Size ii = 1; ii <= n_nrchi_sample_bins_; ++ii ) {
2240 std::cerr <<
"( " << ii <<
" : " << bbind_rotamers_to_sample_( ii, packed_rotno ).left_ <<
", " << bbind_rotamers_to_sample_(ii, packed_rotno ).right_ <<
") ";
2242 std::cerr << std::endl;
2251 Real angle_in_degrees
2254 nrchi_periodicity_ = angle_in_degrees;
2261 Real angle_in_degrees
2264 nrchi_lower_angle_ = angle_in_degrees;
2271 Real step_size_in_degrees
2274 assert( nrchi_periodicity_ != 0.0 );
2275 assert( step_size_in_degrees != 0.0 );
2276 bbdep_nrchi_binsize_ = step_size_in_degrees;
2277 bbdep_nrchi_nbins_ =
static_cast< Size > (nrchi_periodicity_ / step_size_in_degrees);
2284 Real step_size_in_degrees
2287 assert( nrchi_periodicity_ != 0.0 );
2288 assert( step_size_in_degrees != 0.0 );
2289 bbind_nrchi_binsize_ = step_size_in_degrees;
2290 bbind_nrchi_nbins_ =
static_cast< Size > (nrchi_periodicity_ / step_size_in_degrees);
2298 Size total_memory = parent::memory_usage_dynamic();
2301 for (
Size ii = 1; ii <= bbdep_nrc_interpdata_.size(); ++ii ) {
2304 total_memory += bbdep_nrc_interpdata_.size() *
sizeof( FArray3D< BBDepScoreInterpData > );
2307 total_memory += bbind_non_rotameric_chi_scores_.size() *
sizeof(
Real );
2311 total_memory += bbind_rotamers_sorted_by_probability_.size() *
sizeof(
Size );
2315 total_memory += bbdep_rotsample_sorted_order_.size() *
sizeof(
Size );
2317 total_memory += parent::memory_usage_dynamic();
2319 return total_memory;
2333 utility::io::izstream & in_rotdef,
2334 utility::io::izstream & in_rotameric,
2335 utility::io::izstream & in_continmin_bbdep,
2336 utility::io::izstream & in_continmin_bbind
2339 read_rotamer_definitions( in_rotdef );
2340 read_rotameric_data( in_rotameric );
2341 read_bbdep_continuous_minimization_data( in_continmin_bbdep );
2342 read_bbind_continuous_minimization_data( in_continmin_bbind );
2349 utility::io::izstream & in_rotdef,
2350 utility::io::izstream & in_rotameric,
2351 utility::io::izstream & in_continmin_bbdep
2354 assert( ! bbind_nrchi_scoring_ );
2356 read_rotamer_definitions( in_rotdef );
2357 read_rotameric_data( in_rotameric );
2358 read_bbdep_continuous_minimization_data( in_continmin_bbdep );
2370 utility::io::izstream & in_rotameric
2381 FArray2D< Size > rotameric_count( parent::N_PHIPSI_BINS, parent::N_PHIPSI_BINS,
Size( 0 ) );
2382 FArray2D< Size > semi_rotameric_count( parent::N_PHIPSI_BINS, parent::N_PHIPSI_BINS,
Size( 0 ));
2384 while ( in_rotameric ) {
2386 char first_char = in_rotameric.peek();
2387 if ( first_char ==
'#' ) {
2389 in_rotameric.getline( line );
2403 in_rotameric >> three_letter_code >> phi >> psi >> count;
2404 in_rotameric >> rotwell[ 1 ] >> rotwell[ 2 ] >> rotwell[ 3 ] >> rotwell[ 4 ];
2405 in_rotameric >> prob;
2406 in_rotameric >> mean[ 1 ] >> mean[ 2 ] >> mean[ 3 ] >> mean[ 4 ];
2407 in_rotameric >> stdev[ 1 ] >> stdev[ 2 ] >> stdev[ 3 ] >> stdev[ 4 ];
2409 if ( ! in_rotameric )
break;
2411 if ( phi == 180 || psi == 180 )
continue;
2414 for (
Size ii = 1; ii <=
T; ++ii ) {
2415 if ( stdev[ ii ] == 0.0 ) {
2419 if ( prob == 0.0 ) {
2426 Size phibin, psibin;
2427 parent::get_phipsi_bins( phi, psi, phibin, psibin );
2429 ++semi_rotameric_count( phibin, psibin );
2441 Size const packed_rotno( grandparent::rotwell_2_packed_rotno( rotwell ) );
2442 if ( parent::packed_rotno_2_sorted_rotno()( phibin, psibin, packed_rotno ) == 0 ) {
2444 Size nencountered = ++rotameric_count( phibin, psibin );
2445 parent::packed_rotno_2_sorted_rotno()( phibin, psibin, packed_rotno ) = nencountered;
2446 for (
Size ii = 1; ii <=
T; ++ii ) {
2447 parent::rotamers()( phibin, psibin, nencountered ).chi_mean( ii, mean[ ii ] );
2448 parent::rotamers()( phibin, psibin, nencountered ).chi_sd( ii, stdev[ ii ] );
2450 parent::rotamers()( phibin, psibin, nencountered ).rotamer_probability() = prob;
2451 parent::rotamers()( phibin, psibin, nencountered ).rotE() = 0;
2452 parent::rotamers()( phibin, psibin, nencountered ).rotE_dsecophi() = 0;
2453 parent::rotamers()( phibin, psibin, nencountered ).rotE_dsecopsi() = 0;
2454 parent::rotamers()( phibin, psibin, nencountered ).rotE_dsecophipsi() = 0;
2456 Size const sorted_rotno = parent::packed_rotno_2_sorted_rotno()( phibin, psibin, packed_rotno );
2457 parent::rotamers()( phibin, psibin, sorted_rotno ).rotamer_probability() += prob;
2460 for (
Size ii = 1; ii <=
T; ++ii ) {
2461 if ( std::abs( basic::periodic_range( parent::rotamers()( phibin, psibin, sorted_rotno ).chi_mean( ii ) - mean[ ii ], 360 )) > 1e-5 ) {
2462 std::cerr <<
"ERROR: semi-rotameric input invalid -- chi means differ." << std::endl;
2463 std::cerr <<
"Phi: " << phi <<
" Psi: " << psi <<
" original chi_" << ii <<
": ";
2464 std::cerr << parent::rotamers()( phibin, psibin, sorted_rotno ).chi_mean( ii );
2465 std::cerr <<
" later chi_" << ii <<
": "<< mean[ ii ] << std::endl;
2468 if ( std::abs( parent::rotamers()( phibin, psibin, sorted_rotno ).chi_sd( ii ) - stdev[ ii ]) > 1e-5 ) {
2469 std::cerr <<
"ERROR: semi-rotameric input invalid -- chi stdevs differ." << std::endl;
2470 std::cerr <<
"Phi: " << phi <<
" Psi: " << psi <<
" original chi_" << ii <<
": ";
2471 std::cerr << parent::rotamers()( phibin, psibin, sorted_rotno ).chi_sd( ii );
2472 std::cerr <<
" later chi_" << ii <<
": "<< stdev[ ii ] << std::endl;
2478 if ( ! bbind_nrchi_sampling_ ) {
2479 Size const which_rotamer = semi_rotameric_count( phibin, psibin );
2480 BBDepNRChiSample<> & sample( bbdep_rotamers_to_sample_( phibin, psibin, which_rotamer ) );
2485 sample.
prob_ = prob;
2486 bbdep_rotsample_sorted_order_( phibin, psibin, packed_rotno, rotwell[
T + 1 ]) = which_rotamer;
2490 parent::initialize_bicubic_splines();
2498 utility::io::izstream & in_continmin
2502 if ( bbind_nrchi_scoring_ )
return;
2513 bbdep_non_rotameric_chi_scores.resize( grandparent::n_packed_rots() );
2514 for (
Size ii = 1; ii <= grandparent::n_packed_rots(); ++ii ) {
2515 bbdep_non_rotameric_chi_scores[ ii ].dimension( parent::N_PHIPSI_BINS, parent::N_PHIPSI_BINS, bbdep_nrchi_nbins_ );
2516 bbdep_non_rotameric_chi_scores[ ii ] = 0;
2519 while ( in_continmin ) {
2520 char first_char = in_continmin.peek();
2521 if ( first_char ==
'#' ) {
2536 in_continmin >> three_letter_code >> phi >> psi >> count;
2537 for (
Size ii = 1; ii <=
T; ++ii ) {
2538 in_continmin >> rotwell[ ii ];
2540 in_continmin >> base_prob;
2541 for (
Size ii = 1; ii <=
T; ++ii ) {
2542 in_continmin >> chimean[ ii ];
2544 for (
Size ii = 1; ii <=
T; ++ii ) {
2545 in_continmin >> chisd[ ii ];
2547 for (
Size ii = 1; ii <= bbdep_nrchi_nbins_; ++ii ) {
2548 in_continmin >> nrchi_probs[ ii ];
2551 if ( ! in_continmin )
break;
2552 if ( phi == 180 || psi == 180 )
continue;
2557 if (base_prob == 0.0 ) { base_prob = 1e-4; }
2560 Size phibin, psibin;
2561 parent::get_phipsi_bins( phi, psi, phibin, psibin );
2562 Size const rotno = grandparent::rotwell_2_rotno( rotwell );
2563 for (
Size ii = 1; ii <= bbdep_nrchi_nbins_; ++ii ) {
2569 Real const prob = base_prob * ( nrchi_probs[ ii ] == 0.0 ? 1e-4 : nrchi_probs[ ii ] );
2570 bbdep_non_rotameric_chi_scores[ rotno ]( phibin, psibin, ii ) = -std::log( prob );
2576 std::cout <<
"Creating tricubic splines for the backbone-dependent non-rotameric chi scores" << std::endl;
2577 using namespace numeric;
2578 using namespace numeric::interpolation::spline;
2579 BorderFlag border[3] = { e_Periodic, e_Periodic, e_Periodic};
2580 Real const start[3] = { -180.0, -180.0, nrchi_lower_angle_};
2581 Real const delta[3] = { 10.0, 10.0, bbdep_nrchi_binsize_ };
2582 bool const lin_cont[3] = {
true,
true,
true};
2583 std::pair< double, double>
const first_be[3] =
2585 std::pair< double, double>( 10, 10),
2586 std::pair< double, double>( 10, 10),
2587 std::pair< double, double>( 10, 10)
2590 for (
Size ii = 1; ii <= grandparent::n_packed_rots(); ++ii ) {
2591 MathTensor< Real > data( parent::N_PHIPSI_BINS, parent::N_PHIPSI_BINS, bbdep_nrchi_nbins_ );
2592 for (
Size jj = 1; jj <= parent::N_PHIPSI_BINS; ++jj ) {
2593 for (
Size kk = 1; kk <= parent::N_PHIPSI_BINS; ++kk ) {
2594 for (
Size ll = 1; ll <= bbdep_nrchi_nbins_; ++ll ) {
2595 data( jj-1, kk-1, ll-1 ) = bbdep_non_rotameric_chi_scores[ ii ]( jj, kk, ll );
2599 TricubicSpline spline;
2600 spline.train( border,
start, delta, data, lin_cont, first_be );
2601 for (
Size jj = 1; jj <= parent::N_PHIPSI_BINS; ++jj ) {
2602 for (
Size kk = 1; kk <= parent::N_PHIPSI_BINS; ++kk ) {
2603 for (
Size ll = 1; ll <= bbdep_nrchi_nbins_; ++ll ) {
2604 bbdep_nrc_interpdata_[ ii ]( jj, kk, ll ).value_ = (
DunbrackReal) data( jj-1, kk-1, ll-1 );
2605 bbdep_nrc_interpdata_[ ii ]( jj, kk, ll ).dsecox_ = (
DunbrackReal) spline.get_dsecox()( jj-1, kk-1, ll-1 );
2606 bbdep_nrc_interpdata_[ ii ]( jj, kk, ll ).dsecoy_ = (
DunbrackReal) spline.get_dsecoy()( jj-1, kk-1, ll-1 );
2607 bbdep_nrc_interpdata_[ ii ]( jj, kk, ll ).dsecoz_ = (
DunbrackReal) spline.get_dsecoz()( jj-1, kk-1, ll-1 );
2608 bbdep_nrc_interpdata_[ ii ]( jj, kk, ll ).dsecoxy_ = (
DunbrackReal) spline.get_dsecoxy()( jj-1, kk-1, ll-1 );
2609 bbdep_nrc_interpdata_[ ii ]( jj, kk, ll ).dsecoxz_ = (
DunbrackReal) spline.get_dsecoxz()( jj-1, kk-1, ll-1 );
2610 bbdep_nrc_interpdata_[ ii ]( jj, kk, ll ).dsecoyz_ = (
DunbrackReal) spline.get_dsecoyz()( jj-1, kk-1, ll-1 );
2611 bbdep_nrc_interpdata_[ ii ]( jj, kk, ll ).dsecoxyz_ = (
DunbrackReal) spline.get_dsecoxyz()( jj-1, kk-1, ll-1 );
2617 std::cout <<
"Finished creating tricubic splines" << std::endl;
2624 utility::io::izstream & in_continmin
2628 if ( ! bbind_nrchi_scoring_ )
return;
2632 Real nrchi_val, rho, prob, neglnprob;
2634 while ( in_continmin ) {
2635 char first_char = in_continmin.peek();
2636 if ( first_char ==
'#' ) {
2648 in_continmin >> three_letter_code >> rotwell[ 1 ] >> rotwell[ 2 ] >> rotwell[ 3 ] >> rotwell[ 4 ];
2649 in_continmin >> nrchi_val >> rho >> prob >> neglnprob;
2651 if ( ! in_continmin )
break;
2653 Size const packed_rotno( grandparent::rotwell_2_packed_rotno( rotwell ) );
2654 Size bbind_nrchi_bin, dummy;
Real dummy_alpha;
2655 get_bbind_nrchi_bin( nrchi_val, bbind_nrchi_bin, dummy, dummy_alpha );
2656 bbind_non_rotameric_chi_scores_( bbind_nrchi_bin, packed_rotno ) = neglnprob;
2667 utility::io::izstream & in_rotdef
2671 Real prob, lnprob,
left, median, right;
2678 while ( in_rotdef ) {
2679 char first_char = in_rotdef.peek();
2680 if ( first_char ==
'#' ) {
2692 in_rotdef >> rotwell[ 1 ] >> rotwell[ 2 ] >> rotwell[ 3 ] >> rotwell[ 4 ];
2693 in_rotdef >> prob >> lnprob >> left >> median >> right;
2695 if ( ! in_rotdef )
break;
2697 Size const rotno( grandparent::rotwell_2_rotno( rotwell ) );
2698 if ( rotwell[
T + 1 ] == 1 ) {
2699 grandparent::mark_rotwell_exists( rotwell );
2701 lefts[ rotno ].push_back( left );
2702 medians[ rotno ].push_back( median );
2703 rights[ rotno ].push_back( right );
2704 probs[ rotno ].push_back( prob );
2707 for (
Size ii = 1; ii <= grandparent::n_possible_rots(); ++ii ) {
2709 if ( lefts[ ii ].
size() != 0 ) {
2711 for (
Size jj = ii+1; jj <= grandparent::n_possible_rots(); ++jj ) {
2712 if ( lefts[ jj ].
size() != 0 && lefts[ jj ].size() != lefts[ ii ].size() ) {
2713 std::cerr <<
"ERROR: Error in reading rotamer definition file" << std::endl;
2714 std::cerr <<
"ERROR: rotno's " << ii <<
" and " << jj;
2715 std::cerr <<
" have each defined a different number of pseudorots: ";
2716 std::cerr << lefts[ ii ].size() <<
" != " << lefts[ jj ].size();
2717 std::cerr << std::endl;
2722 n_nrchi_sample_bins_ = lefts[ ii ].size();
2733 grandparent::declare_all_existing_rotwells_encountered();
2736 parent::rotamers().dimension( parent::N_PHIPSI_BINS, parent::N_PHIPSI_BINS, grandparent::n_packed_rots() );
2737 parent::packed_rotno_2_sorted_rotno().dimension( parent::N_PHIPSI_BINS, parent::N_PHIPSI_BINS, grandparent::n_packed_rots() );
2738 parent::packed_rotno_2_sorted_rotno() = 0;
2742 bbind_rotamers_to_sample_.dimension( n_nrchi_sample_bins_, grandparent::n_packed_rots() );
2745 Size count_packed_rots( 0 );
2746 for (
Size ii = 1; ii <= grandparent::n_possible_rots(); ++ii ) {
2747 if ( lefts[ ii ].
size() == 0 )
continue;
2748 ++count_packed_rots;
2749 for (
Size jj = 1; jj <= n_nrchi_sample_bins_; ++jj ) {
2750 bbind_rotamers_to_sample_( jj, count_packed_rots ).left_ = lefts[ ii ][ jj ];
2751 bbind_rotamers_to_sample_( jj, count_packed_rots ).median_ = medians[ ii ][ jj ];
2752 bbind_rotamers_to_sample_( jj, count_packed_rots ).right_ = rights[ ii ][ jj ];
2753 bbind_rotamers_to_sample_( jj, count_packed_rots ).prob_ = probs[ ii ][ jj ];
2756 if ( ! bbind_nrchi_sampling_ ) {
2758 bbdep_rotamers_to_sample_.dimension(
2759 parent::N_PHIPSI_BINS,
2760 parent::N_PHIPSI_BINS,
2761 grandparent::n_packed_rots() * n_nrchi_sample_bins_ );
2762 bbdep_rotsample_sorted_order_.dimension(
2763 parent::N_PHIPSI_BINS,
2764 parent::N_PHIPSI_BINS,
2765 grandparent::n_packed_rots(),
2766 n_nrchi_sample_bins_ );
2767 bbdep_rotsample_sorted_order_ = 0;
2770 if ( bbind_nrchi_scoring_ ) {
2771 assert( bbind_nrchi_nbins_ != 0 );
2772 bbind_non_rotameric_chi_scores_.dimension( bbind_nrchi_nbins_, grandparent::n_packed_rots() );
2773 bbind_non_rotameric_chi_scores_ = 0;
2775 assert( bbdep_nrchi_nbins_ != 0 );
2776 bbdep_nrc_interpdata_.resize( grandparent::n_packed_rots() );
2777 for (
Size ii = 1; ii <= grandparent::n_packed_rots(); ++ii ) {
2778 bbdep_nrc_interpdata_[ ii ].dimension( parent::N_PHIPSI_BINS, parent::N_PHIPSI_BINS, bbdep_nrchi_nbins_ );
2782 if ( bbind_nrchi_sampling_ ) {
2783 bbind_rotamers_sorted_by_probability_.dimension( n_nrchi_sample_bins_, grandparent::n_packed_rots() );
2785 for (
Size ii = 1; ii <= grandparent::n_packed_rots(); ++ii ) {
2786 for (
Size jj = 1; jj <= n_nrchi_sample_bins_; ++jj ) {
2787 rot_probs_and_inds[ jj ].probability_ = bbind_rotamers_to_sample_( jj, ii ).prob_;
2788 rot_probs_and_inds[ jj ].index_ = jj;
2791 std::sort( rot_probs_and_inds.begin(), rot_probs_and_inds.end(),
psc_compare );
2792 for (
Size jj = 1, jj_down = n_nrchi_sample_bins_; jj_down >= 1; --jj_down, ++jj ) {
2794 bbind_rotamers_sorted_by_probability_( jj, ii ) = rot_probs_and_inds[ jj_down ].index_;
2806 Real chip = basic::periodic_range( chi, nrchi_periodicity_ );
2808 if ( chip >= nrchi_lower_angle_ + nrchi_periodicity_ ) {
2809 while ( chip >= nrchi_lower_angle_ + nrchi_periodicity_ ) {
2810 chip -= nrchi_periodicity_;
2812 }
else if ( chip < nrchi_lower_angle_ ) {
2813 while ( chip < nrchi_lower_angle_ ) {
2814 chip += nrchi_periodicity_;
2829 Real clipped_nrchi( clip_to_nrchi_range( nrchi ));
2830 grandparent::bin_angle(
2831 nrchi_lower_angle_, bbdep_nrchi_binsize_, nrchi_periodicity_, bbdep_nrchi_nbins_,
2832 clipped_nrchi, bin_lower, bin_upper, nrchi_alpha
2845 Real clipped_nrchi( clip_to_nrchi_range( nrchi ));
2846 grandparent::bin_angle(
2847 nrchi_lower_angle_, bbind_nrchi_binsize_, nrchi_periodicity_, bbind_nrchi_nbins_,
2848 clipped_nrchi, bin_lower, bin_upper, nrchi_alpha
2856 Size const packed_rotno,
2857 Size const nrchi_bin,
2860 Size const phibin_next,
2861 Size const psibin_next,
2862 Real const phi_alpha,
2863 Real const psi_alpha
2867 ind00( bbdep_rotsample_sorted_order_( phibin , psibin , packed_rotno, nrchi_bin )),
2868 ind01( bbdep_rotsample_sorted_order_( phibin , psibin_next, packed_rotno, nrchi_bin )),
2869 ind10( bbdep_rotsample_sorted_order_( phibin_next, psibin , packed_rotno, nrchi_bin )),
2870 ind11( bbdep_rotsample_sorted_order_( phibin_next, psibin_next, packed_rotno, nrchi_bin ));
2872 BBDepNRChiSample<> const & nrchi_sample_00( bbdep_rotamers_to_sample_( phibin , psibin , ind00 ));
2873 BBDepNRChiSample<> const & nrchi_sample_01( bbdep_rotamers_to_sample_( phibin , psibin_next, ind01 ));
2874 BBDepNRChiSample<> const & nrchi_sample_10( bbdep_rotamers_to_sample_( phibin_next, psibin , ind10 ));
2875 BBDepNRChiSample<> const & nrchi_sample_11( bbdep_rotamers_to_sample_( phibin_next, psibin_next, ind11 ));
2877 return interpolate_bbdep_nrchi_sample(
2878 nrchi_sample_00, nrchi_sample_01,
2879 nrchi_sample_10, nrchi_sample_11,
2880 phi_alpha, psi_alpha
2891 Real const phi_alpha,
2892 Real const psi_alpha
2899 Real dummy_dprob_1, dummy_dprob_2;
2900 basic::interpolate_bilinear_by_value(
2901 static_cast< Real > ( nrchi_sample_00.
prob_),
2902 static_cast< Real > ( nrchi_sample_10.
prob_),
2903 static_cast< Real > ( nrchi_sample_01.
prob_),
2904 static_cast< Real > ( nrchi_sample_11.
prob_),
2905 phi_alpha, psi_alpha, parent::PHIPSI_BINRANGE,
false ,
2906 interpolated_sample.
prob_,
2907 dummy_dprob_1, dummy_dprob_2
2909 Real dummy_dmean_1, dummy_dmean_2;
2910 basic::interpolate_bilinear_by_value(
2911 static_cast< Real > ( nrchi_sample_00.
nrchi_mean_),
2912 static_cast< Real > ( nrchi_sample_10.
nrchi_mean_),
2913 static_cast< Real > ( nrchi_sample_01.
nrchi_mean_),
2914 static_cast< Real > ( nrchi_sample_11.
nrchi_mean_),
2915 phi_alpha, psi_alpha, parent::PHIPSI_BINRANGE,
true ,
2917 dummy_dmean_1, dummy_dmean_2
2919 Real dummy_dsd_1, dummy_dsd_2;
2920 basic::interpolate_bilinear_by_value(
2921 static_cast< Real > ( nrchi_sample_00.
nrchi_sd_),
2922 static_cast< Real > ( nrchi_sample_10.
nrchi_sd_),
2923 static_cast< Real > ( nrchi_sample_01.
nrchi_sd_),
2924 static_cast< Real > ( nrchi_sample_11.
nrchi_sd_),
2925 phi_alpha, psi_alpha, parent::PHIPSI_BINRANGE,
false ,
2927 dummy_dsd_1, dummy_dsd_2
2929 return interpolated_sample;
2946 #endif // INCLUDED_core_pack_dunbrack_SemiRotamericSingleResidueDunbrackLibrary_TMPL_HH