19 #include <basic/datacache/BasicDataCache.hh>
98 #include <utility/excn/Exceptions.hh>
99 #include <utility/file/file_sys_util.hh>
101 #include <numeric/random/random.hh>
102 #include <numeric/xyzVector.hh>
103 #include <numeric/xyz.functions.hh>
104 #include <numeric/model_quality/rms.hh>
106 #include <basic/options/option.hh>
107 #include <basic/options/option_macros.hh>
108 #include <basic/options/keys/OptionKeys.hh>
109 #include <basic/options/keys/in.OptionKeys.gen.hh>
110 #include <basic/options/keys/cm.OptionKeys.gen.hh>
112 #include <basic/Tracer.hh>
113 #include <boost/unordered/unordered_map.hpp>
115 namespace protocols {
117 namespace hybridization {
121 static basic::Tracer
TR(
"protocols.hybridization.CartesianHybridize");
157 for(
core::Size tmpl = 1; tmpl <= ntempls; ++tmpl) {
159 for (
int i=1; i<=(
int)ncontigs; ++i) {
161 bool spilt_chunk=
false;
164 for (
int j=2; j<=(
int)template_chunks_in[tmpl].
size(); ++j) {
165 core::Size j0start = template_chunks_in[tmpl][j-1].start(), j0stop = template_chunks_in[tmpl][j-1].stop();
166 core::Size j1start = template_chunks_in[tmpl][j].start(), j1stop = template_chunks_in[tmpl][j].stop();
168 bool j0incontig = ((j0start>=cstart) && (j0stop<=cstop));
169 bool j1incontig = ((j1start>=cstart) && (j1stop<=cstop));
171 if (j0incontig && j1incontig) {
175 TR.Debug <<
"Make subfrag " << cstart <<
" , " << cutpoint-1 << std::endl;
177 }
else if(spilt_chunk && j0incontig && !j1incontig) {
180 TR.Debug <<
"Make subfrag " << cstart <<
" , " << cstop << std::endl;
186 TR.Debug <<
"template_contigs:" << std::endl;
194 using namespace basic::options;
195 using namespace basic::options::OptionKeys;
230 R.xx() = R.yy() = R.zz() = 1;
231 R.xy() = R.yx() = R.zx() = R.zy() = R.yz() = R.xz() = 0;
240 ObjexxFCL::FArray2D< core::Real > final_coords( 3, 4*aln_len );
241 ObjexxFCL::FArray2D< core::Real > init_coords( 3, 4*aln_len );
243 for (
int ii=0; ii<(
int)aln_len; ++ii) {
249 preT += x_1+x_2+x_3+x_4;
255 postT += y_1+y_2+y_3+y_4;
257 for (
int j=0; j<3; ++j) {
258 init_coords(j+1,4*ii+1) = x_1[j];
259 init_coords(j+1,4*ii+2) = x_2[j];
260 init_coords(j+1,4*ii+3) = x_3[j];
261 init_coords(j+1,4*ii+4) = x_4[j];
262 final_coords(j+1,4*ii+1) = y_1[j];
263 final_coords(j+1,4*ii+2) = y_2[j];
264 final_coords(j+1,4*ii+3) = y_3[j];
265 final_coords(j+1,4*ii+4) = y_4[j];
270 for (
int i=1; i<=4*(
int)len; ++i) {
271 for (
int j=0; j<3; ++j ) {
272 init_coords(j+1,i) -= preT[j];
273 final_coords(j+1,i) -= postT[j];
279 ObjexxFCL::FArray1D< numeric::Real > ww( 4*len, 1.0 );
280 ObjexxFCL::FArray2D< numeric::Real > uu( 3, 3, 0.0 );
283 numeric::model_quality::findUU( init_coords, final_coords, ww, 4*len, uu, ctx );
284 R.xx( uu(1,1) ); R.xy( uu(2,1) ); R.xz( uu(3,1) );
285 R.yx( uu(1,2) ); R.yy( uu(2,2) ); R.yz( uu(3,2) );
286 R.zx( uu(1,3) ); R.zy( uu(2,3) ); R.zz( uu(3,3) );
291 for (
int i=(
int)frag.
start(); i<=(
int)frag.
stop(); ++i) {
294 pose.
set_xyz( tgt, postT + (R*(templ.
xyz( src )-preT)) );
316 dynamic_cast<core::conformation::symmetry::SymmetricConformation &> ( pose.
conformation()) );
318 nres = symm_info->num_independent_residues();
322 bool nterm = (start == 1);
323 bool cterm = (start == nres-8);
328 ObjexxFCL::FArray1D< numeric::Real > ww( 2*4*aln_len, 1.0 );
329 ObjexxFCL::FArray2D< numeric::Real > uu( 3, 3, 0.0 );
332 for (
int i=0; i<(
int)len; ++i) {
335 for (
int tries = 0; tries<80; ++tries) {
342 ObjexxFCL::FArray2D< core::Real > init_coords( 3, 2*4*aln_len );
343 for (
int ii=-aln_len; ii<aln_len; ++ii) {
344 int i = (ii>=0) ? (nterm?len-ii-1:ii) : (cterm?-ii-1:len+ii);
349 com1 += x_1+x_2+x_3+x_4;
350 for (
int j=0; j<3; ++j) {
351 init_coords(j+1,4*(ii+aln_len)+1) = x_1[j];
352 init_coords(j+1,4*(ii+aln_len)+2) = x_2[j];
353 init_coords(j+1,4*(ii+aln_len)+3) = x_3[j];
354 init_coords(j+1,4*(ii+aln_len)+4) = x_4[j];
357 com1 /= 2.0*4.0*aln_len;
358 for (
int ii=0; ii<2*4*aln_len; ++ii) {
359 for (
int j=0; j<3; ++j ) init_coords(j+1,ii+1) -= com1[j];
363 frame.
apply( toget, pose_copy );
366 ObjexxFCL::FArray2D< core::Real > final_coords( 3, 2*4*aln_len );
367 for (
int ii=-aln_len; ii<aln_len; ++ii) {
368 int i = (ii>=0) ? (nterm?len-ii-1:ii) : (cterm?-ii-1:len+ii);
373 com2 += x_1+x_2+x_3+x_4;
374 for (
int j=0; j<3; ++j) {
375 final_coords(j+1,4*(ii+aln_len)+1) = x_1[j];
376 final_coords(j+1,4*(ii+aln_len)+2) = x_2[j];
377 final_coords(j+1,4*(ii+aln_len)+3) = x_3[j];
378 final_coords(j+1,4*(ii+aln_len)+4) = x_4[j];
381 com2 /= 2.0*4.0*aln_len;
382 for (
int ii=0; ii<2*4*aln_len; ++ii) {
383 for (
int j=0; j<3; ++j ) final_coords(j+1,ii+1) -= com2[j];
389 numeric::model_quality::findUU( final_coords, init_coords, ww, 2*4*aln_len, uu, ctx );
390 numeric::model_quality::calc_rms_fast( rms, final_coords, init_coords, ww, 2*4*aln_len, ctx );
393 if (rms < 0.5)
break;
394 if (tries >= 20 && rms < 1)
break;
395 if (tries >= 40 && rms < 2)
break;
396 if (tries >= 60 && rms < 4)
break;
399 R.xx( uu(1,1) ); R.xy( uu(2,1) ); R.xz( uu(3,1) );
400 R.yx( uu(1,2) ); R.yy( uu(2,2) ); R.yz( uu(3,2) );
401 R.zx( uu(1,3) ); R.zy( uu(2,3) ); R.zz( uu(3,3) );
405 for (
Size i = 0; i < len; ++i ) {
408 pose.
set_xyz(
id, R * ( pose_copy.
xyz(
id) - com2) + com1 );
416 using namespace basic::options;
417 using namespace basic::options::OptionKeys;
418 using namespace core::pose::datacache;
423 tocen->apply( pose );
451 TR <<
"RUNNING FOR " << NMACROCYCLES <<
" MACROCYCLES" << std::endl;
461 mm.set_bb (ires,
false);
462 mm.set_chi(ires,
false);
471 if ( ires == jres && iatom >= jatom)
continue;
473 if ( dist <= MAXDIST ) {
492 if (m==1) bonded_weight = 0.0*max_cart;
493 if (m==2) bonded_weight = 0.01*max_cart;
494 if (m==3) bonded_weight = 0.1*max_cart;
496 core::Real bonded_weight_angle = max_cart_angle;
497 if (m==1) bonded_weight_angle = 0.0*max_cart_angle;
498 if (m==2) bonded_weight_angle = 0.01*max_cart_angle;
499 if (m==3) bonded_weight_angle = 0.1*max_cart_angle;
501 core::Real bonded_weight_length = max_cart_length;
502 if (m==1) bonded_weight_length = 0.0*max_cart_length;
503 if (m==2) bonded_weight_length = 0.01*max_cart_length;
504 if (m==3) bonded_weight_length = 0.1*max_cart_length;
506 core::Real bonded_weight_torsion = max_cart_torsion;
507 if (m==1) bonded_weight_torsion = 0.0*max_cart_torsion;
508 if (m==2) bonded_weight_torsion = 0.01*max_cart_torsion;
509 if (m==3) bonded_weight_torsion = 0.1*max_cart_torsion;
512 if (m==1) cst_weight = 2*max_cst;
513 if (m==2) cst_weight = 2*max_cst;
514 if (m==3) cst_weight = 2*max_cst;
517 if (m==1) vdw_weight = 0.1*max_vdw;
518 if (m==2) vdw_weight = 0.1*max_vdw;
519 if (m==3) vdw_weight = 0.1*max_vdw;
521 TR <<
"CYCLE " << m << std::endl;
522 TR <<
" setting bonded weight = " << bonded_weight << std::endl;
523 TR <<
" setting bonded angle weight = " << bonded_weight_angle << std::endl;
524 TR <<
" setting bonded length weight = " << bonded_weight_length << std::endl;
525 TR <<
" setting bonded torsion weight = " << bonded_weight_torsion << std::endl;
526 TR <<
" setting cst weight = " << cst_weight << std::endl;
527 TR <<
" setting vdw weight = " << vdw_weight << std::endl;
536 (*lowres_scorefxn_)(pose);
540 if (m==4) neffcycles /=2;
541 for (
int n=1; n<=(
int)neffcycles; ++n) {
546 core::Real action_picker = numeric::random::uniform();
549 action = no_ns_moves?2:1;
550 if (action_picker < 0.2) action = 3;
553 if (action_picker < 0.2) action = 3;
556 if (action_picker < 0.2) action = 3;
562 if (action == 1) action_string =
"fragNS";
563 if (action == 2) action_string =
"frag";
564 if (action == 3) action_string =
"picker";
566 if (action == 1 || action == 2) {
575 core::Size frag_id = numeric::random::random_range( 1, nfrags );
578 if (frag->size() > 14)
579 action_string = action_string+
"_15+";
580 else if (frag->size() <= 4)
581 action_string = action_string+
"_0-4";
583 action_string = action_string+
"_5-14";
589 runtime_assert( pose.
data().has( CacheableDataType::TEMPLATE_HYBRIDIZATION_HISTORY ) );
591 *(
static_cast< TemplateHistory*
>( pose.
data().get_ptr( CacheableDataType::TEMPLATE_HYBRIDIZATION_HISTORY )() ));
592 history.
set( frag->start(), frag->stop(), templ_id );
601 for (
int i=1; i<(
int)n_prot_res; ++i) {
612 residuals[i] = (d2-1.328685)*(d2-1.328685);
613 if ( residuals[i] > max_residuals[1]) {
614 max_residuals[3] = max_residuals[2]; max_residuals[2] = max_residuals[1]; max_residuals[1] = residuals[i];
615 max_poses[3] = max_poses[2]; max_poses[2] = max_poses[1]; max_poses[1] = i;
616 }
else if ( residuals[i] > max_residuals[2]) {
617 max_residuals[3] = max_residuals[2]; max_residuals[2] = residuals[i];
618 max_poses[3] = max_poses[2]; max_poses[2] = i;
619 }
else if ( residuals[i] > max_residuals[3]) {
620 max_residuals[3] = residuals[i];
627 max_poses[ 4 ] = numeric::random::random_range(1,n_prot_res);
628 int select_position = numeric::random::random_range(1,4);
629 if (select_position == 4)
630 action_string = action_string+
"_rand";
631 core::Size max_pos = max_poses[ select_position ];
634 core::Size insert_pos = max_pos - numeric::random::random_range(3,5);
635 insert_pos = std::min( insert_pos, n_prot_res-8);
636 insert_pos = std::max( (
int)insert_pos, 1);
644 (*min_scorefxn_)(pose);
648 minimizer.run( pose, mm, *
min_scorefxn_, options_minilbfgs );
650 mc->boltzmann( pose , action_string );
651 }
catch( utility::excn::EXCN_Base& excn ) {
658 TR <<
"Step " << n << std::endl;
664 mc->recover_low(pose);
675 (*min_scorefxn_)(pose); minimizer.run( pose, mm, *
min_scorefxn_, options_lbfgs );
676 (*nocst_scorefxn_)(pose); minimizer.run( pose, mm, *
nocst_scorefxn_, options_lbfgs );
677 (*bonds_scorefxn_)(pose); minimizer.run( pose, mm, *
bonds_scorefxn_, options_lbfgs );
678 (*nocst_scorefxn_)(pose); minimizer.run( pose, mm, *
nocst_scorefxn_, options_lbfgs );
679 }
catch( utility::excn::EXCN_Base& excn ) {
691 (*lowres_scorefxn_)(pose);