19 #include <basic/datacache/BasicDataCache.hh>
96 #include <utility/excn/Exceptions.hh>
97 #include <utility/file/file_sys_util.hh>
99 #include <numeric/random/random.hh>
100 #include <numeric/xyzVector.hh>
101 #include <numeric/xyz.functions.hh>
102 #include <numeric/model_quality/rms.hh>
103 #include <numeric/random/WeightedSampler.hh>
105 #include <basic/options/option.hh>
106 #include <basic/options/option_macros.hh>
107 #include <basic/options/keys/OptionKeys.hh>
108 #include <basic/options/keys/in.OptionKeys.gen.hh>
109 #include <basic/options/keys/cm.OptionKeys.gen.hh>
111 #include <utility/tag/Tag.hh>
112 #include <utility/string_util.hh>
113 #include <basic/Tracer.hh>
115 #include <boost/unordered/unordered_map.hpp>
117 namespace protocols {
119 namespace hybridization {
121 static basic::Tracer
TR(
"protocols.hybridization.CartesianSampler");
122 static numeric::random::RandomGenerator
RG(8403155);
138 return "CartesianSampler";
157 using namespace basic::options;
158 using namespace basic::options::OptionKeys;
175 for (
int i=1; i<=(
int)nfragsets; ++i) {
199 dynamic_cast<core::conformation::symmetry::SymmetricConformation &> ( pose.
conformation()) );
201 nres = symm_info->num_independent_residues();
211 ObjexxFCL::FArray1D< numeric::Real > ww( 2*4*aln_len, 1.0 );
212 ObjexxFCL::FArray2D< numeric::Real > uu( 3, 3, 0.0 );
215 for (
int i=0; i<(
int)len; ++i) {
219 int maxtries = frame.
nr_frags() / 2;
220 for (
int tries = 0; tries<maxtries; ++tries) {
227 ObjexxFCL::FArray2D< core::Real > init_coords( 3, 2*4*aln_len );
228 for (
int ii=-aln_len; ii<aln_len; ++ii) {
229 int i = (ii>=0) ? (nterm?len-ii-1:ii) : (cterm?-ii-1:len+ii);
234 com1 += x_1+x_2+x_3+x_4;
235 for (
int j=0; j<3; ++j) {
236 init_coords(j+1,4*(ii+aln_len)+1) = x_1[j];
237 init_coords(j+1,4*(ii+aln_len)+2) = x_2[j];
238 init_coords(j+1,4*(ii+aln_len)+3) = x_3[j];
239 init_coords(j+1,4*(ii+aln_len)+4) = x_4[j];
242 com1 /= 2.0*4.0*aln_len;
243 for (
int ii=0; ii<2*4*aln_len; ++ii) {
244 for (
int j=0; j<3; ++j ) init_coords(j+1,ii+1) -= com1[j];
248 frame.
apply( toget, pose_copy );
251 ObjexxFCL::FArray2D< core::Real > final_coords( 3, 2*4*aln_len );
252 for (
int ii=-aln_len; ii<aln_len; ++ii) {
253 int i = (ii>=0) ? (nterm?len-ii-1:ii) : (cterm?-ii-1:len+ii);
258 com2 += x_1+x_2+x_3+x_4;
259 for (
int j=0; j<3; ++j) {
260 final_coords(j+1,4*(ii+aln_len)+1) = x_1[j];
261 final_coords(j+1,4*(ii+aln_len)+2) = x_2[j];
262 final_coords(j+1,4*(ii+aln_len)+3) = x_3[j];
263 final_coords(j+1,4*(ii+aln_len)+4) = x_4[j];
266 com2 /= 2.0*4.0*aln_len;
267 for (
int ii=0; ii<2*4*aln_len; ++ii) {
268 for (
int j=0; j<3; ++j ) final_coords(j+1,ii+1) -= com2[j];
272 numeric::model_quality::findUU( final_coords, init_coords, ww, 2*4*aln_len, uu, ctx );
273 numeric::model_quality::calc_rms_fast( rms, final_coords, init_coords, ww, 2*4*aln_len, ctx );
275 if (rms < 0.5)
break;
276 if (tries >= maxtries/4 && rms < 1)
break;
277 if (tries >= maxtries/2 && rms < 1.5)
break;
281 R.xx( uu(1,1) ); R.xy( uu(2,1) ); R.xz( uu(3,1) );
282 R.yx( uu(1,2) ); R.yy( uu(2,2) ); R.yz( uu(3,2) );
283 R.zx( uu(1,3) ); R.zy( uu(2,3) ); R.zz( uu(3,3) );
287 for (
Size i = 0; i < len; ++i ) {
290 pose.
set_xyz(
id, R * ( pose_copy.
xyz(
id) - com2) + com1 );
297 using namespace core::scoring;
307 dynamic_cast<core::conformation::symmetry::SymmetricConformation const &> ( pose.
conformation()) );
309 nres = symminfo->num_independent_residues();
332 per_resCC.resize(nres);
333 fragmentProbs.resize(nres);
337 for (
int r=1; r<=(
int)nres; ++r) {
339 CCsum += per_resCC[r];
340 CCsum2 += per_resCC[r]*per_resCC[r];
343 CCsum2 = sqrt( CCsum2/nres-CCsum*CCsum );
345 for (
int r=1; r<=(
int)nres; ++r) {
346 fragmentProbs[r] = exp( (CCsum-per_resCC[r])/CCsum2 );
347 TR <<
"Prob_dens_density( " << r <<
" ) = " << fragmentProbs[r] <<
" ; CC=" << per_resCC[r] <<
" (Z=" << (CCsum-per_resCC[r])/CCsum2 <<
")" << std::endl;
351 fragmentProbs.resize(nres);
356 for (
int r=1; r<=(
int)nres; ++r) {
360 Bsum += pose.
pdb_info()->temperature( r, atm );
363 fragmentProbs[r] = exp( Bsum/Btemp );
364 TR <<
"Prob_dens_bfact( " << r <<
" ) = " << fragmentProbs[r] <<
" ; B=" << Bsum << std::endl;
380 for (
int r=1; r<=(
int)nres; ++r) {
381 EnergyMap & emap( energies.onebody_energies( r ) );
384 fragmentProbs[r] = exp( ramaScore / Rtemp );
385 TR <<
"Prob_dens_rama( " << r <<
" ) = " << fragmentProbs[r] <<
" ; rama=" << ramaScore << std::endl;
391 for (
int r=1; r<=(
int)nres; ++r) {
392 fragmentProbs[r] = 0.0;
394 TR <<
"Prob_dens_user( " << r <<
" ) = " << fragmentProbs[r] << std::endl;
398 for (
int r=1; r<=(
int)nres; ++r) {
399 fragmentProbs[r] = 1.0;
400 TR <<
"Prob_dens_uniform( " << r <<
" ) = " << 1.0 << std::endl;
407 for (
Size i_frag_set = 1; i_frag_set<=
fragments_.size(); ++i_frag_set) {
409 for (
Size i_frame = 1; i_frame <=
fragments_[i_frag_set]->nr_frames(); ++i_frame) {
411 advance(frame_it, i_frame-1);
412 core::Size seqpos_start = (*frame_it)->start();
415 frame_weights[i_frame] = 0;
416 for(
int i_pos = (
int)seqpos_start; i_pos<=(
int)seqpos_end; ++i_pos)
417 frame_weights[i_frame] += fragmentProbs[i_pos];
418 frame_weights[i_frame] /= (seqpos_end-seqpos_start+1);
420 frag_bias_[i_frag_set].weights(frame_weights);
426 using namespace basic::options;
427 using namespace basic::options::OptionKeys;
428 using namespace core::pose::datacache;
443 if (fullatom_input) {
446 tocen->apply( pose );
489 minimizer.run( pose, mm, *
scorefxn_, options_minilbfgs );
490 mc->boltzmann( pose );
492 mc->recover_low(pose);
495 (*scorefxn_)(pose); minimizer.run( pose, mm, *
scorefxn_, options_lbfgs );
498 if (fullatom_input) {
501 restore_sc->apply( pose );
511 using namespace core::scoring;
514 if( tag->hasOption(
"scorefxn" ) ) {
520 if( tag->hasOption(
"overlap" ) ) {
523 if( tag->hasOption(
"ncycles" ) ) {
526 if( tag->hasOption(
"strategy" ) ) {
530 if( tag->hasOption(
"residues" ) ) {
537 for (tag_it = branch_tags.begin(); tag_it != branch_tags.end(); ++tag_it) {
538 if ( (*tag_it)->getName() ==
"Fragments" ) {
539 using namespace core::fragment;
547 if( tag->hasOption(
"fraglens" ) ) {
549 for (
core::Size i=1; i<=fraglens.size(); ++i) {