24 #include <basic/basic.hh>
26 #include <basic/options/option.hh>
28 #include <basic/options/keys/bbg.OptionKeys.gen.hh>
37 #include <utility/exit.hh>
38 #include <basic/Tracer.hh>
39 #include <numeric/random/random.hh>
40 #include <numeric/xyz.functions.hh>
41 #include <numeric/xyzMatrix.hh>
42 #include <numeric/xyzVector.hh>
43 #include <numeric/constants.hh>
44 #include <numeric/internal/RowVectors.hh>
50 #include <utility/vector1.hh>
55 using namespace core::pose;
56 using namespace utility;
57 using namespace numeric;
58 using namespace basic::options;
59 using namespace basic::options::OptionKeys;
61 static basic::Tracer
TR(
"protocols.simple_moves.BBConRotMover");
62 static numeric::random::RandomGenerator
RG(19500606);
65 namespace simple_moves {
82 BBConRotMover::BBConRotMover()
87 using numeric::constants::d::pi;
97 factorA_ = option[ bbg::factorA ]*2.0;
106 return "BBConRotMover";
114 if(iter++ > 100)
break;
116 TR.Debug <<
"apply: iter=" << iter << std::endl;
121 using basic::periodic_range;
122 using basic::unsigned_periodic_range;
123 using numeric::constants::d::pi;
124 using numeric::constants::d::pi_2;
131 TR.Debug <<
"Pick: " << left <<
" <--> " <<
resnum_ << std::endl;
135 TR.Debug <<
"Do random rot ... " << std::endl;
152 Vector p1((r2-r1).length(),0.0,0.0);
153 Vector p2((r3-r2).length(),0.0,0.0);
154 Vector p3((r4-r3).length(),0.0,0.0);
157 TR.Debug <<
"Jac_new0=" << jac_new0 << std::endl;
161 if (jac_new0>0) failed =
false;
172 Real theta1_old = pose.
dof(dih12);
173 Real theta2_old = pose.
dof(dih11);;
174 Real theta3_old = pose.
dof(dih10);
175 Real theta4_old = pose.
dof(dih9);
176 Real alpha1_old = pi - pose.
dof(ang11);
177 Real alpha2_old = pi - pose.
dof(ang10);
178 Real alpha3_old = pi - pose.
dof(ang9);
194 TR.Debug <<
"W_old=" << W_old <<
" W_new=" << W_new << std::endl;
203 Real theta1,theta2,theta3,theta4;
204 Real alpha1,alpha2,alpha3;
212 r0,r1,r2,r3,r4,r5,r6,p1,p2,p3,
214 theta1_old,theta2_old,theta3_old,theta4_old,
215 alpha1_old,alpha2_old,alpha3_old,
217 theta1,theta2,theta3,theta4,
218 alpha1,alpha2,alpha3) )
222 TR.Debug <<
"Jac_new1=" << jac_new1 << std::endl;
234 pose.
set_dof(ang11, pi-alpha1);
235 pose.
set_dof(ang10, pi-alpha2);
240 if (dd.length_squared()<1.0e-6)
243 TR.Debug <<
"Closure Success!" << std::endl;
288 TR.Debug <<
"Closure Failed!" << std::endl;
303 Vector end_xyz = rsd3.atom(
"CA").xyz();
309 rsd0.atom(
"N").xyz(),
310 rsd0.atom(
"CA").xyz(),
314 rsd0.atom(
"CA").xyz(),
315 rsd0.atom(
"C").xyz(),
319 rsd1.atom(
"N").xyz(),
320 rsd1.atom(
"CA").xyz(),
324 rsd1.atom(
"CA").xyz(),
325 rsd1.atom(
"C").xyz(),
329 rsd2.atom(
"N").xyz(),
330 rsd2.atom(
"CA").xyz(),
334 rsd2.atom(
"CA").xyz(),
335 rsd2.atom(
"C").xyz(),
342 rsd0.atom(
"N").xyz(),
343 rsd0.atom(
"CA").xyz(),
344 rsd0.atom(
"C").xyz(),
348 rsd0.atom(
"CA").xyz(),
349 rsd0.atom(
"C").xyz(),
350 rsd1.atom(
"N").xyz(),
354 rsd0.atom(
"C").xyz(),
355 rsd1.atom(
"N").xyz(),
356 rsd1.atom(
"CA").xyz(),
360 rsd1.atom(
"N").xyz(),
361 rsd1.atom(
"CA").xyz(),
362 rsd1.atom(
"C").xyz(),
366 rsd1.atom(
"CA").xyz(),
367 rsd1.atom(
"C").xyz(),
368 rsd2.atom(
"N").xyz(),
372 rsd1.atom(
"C").xyz(),
373 rsd2.atom(
"N").xyz(),
374 rsd2.atom(
"CA").xyz(),
378 rsd2.atom(
"N").xyz(),
379 rsd2.atom(
"CA").xyz(),
380 rsd2.atom(
"C").xyz(),
384 rsd2.atom(
"CA").xyz(),
385 rsd2.atom(
"C").xyz(),
386 rsd3.atom(
"N").xyz(),
390 rsd2.atom(
"C").xyz(),
391 rsd3.atom(
"N").xyz(),
392 rsd3.atom(
"CA").xyz(),
428 using basic::periodic_range;
429 using basic::unsigned_periodic_range;
430 using numeric::constants::d::pi;
431 using numeric::constants::d::pi_2;
449 Real W_old = detL*exp(-d2/2.0);
485 segment.
set_dof(dih0, periodic_range(segment.
dof(dih0)+
dphi[1],pi_2));
486 segment.
set_dof(dih1, periodic_range(segment.
dof(dih1)+
dphi[2],pi_2));
487 segment.
set_dof(dih3, periodic_range(segment.
dof(dih3)+
dphi[3],pi_2));
488 segment.
set_dof(dih4, periodic_range(segment.
dof(dih4)+
dphi[4],pi_2));
489 segment.
set_dof(dih6, periodic_range(segment.
dof(dih6)+
dphi[5],pi_2));
490 segment.
set_dof(dih7, periodic_range(segment.
dof(dih7)+
dphi[6],pi_2));
491 segment.
set_dof(angle1, unsigned_periodic_range(segment.
dof(angle1)+
dphi[7],pi));
492 segment.
set_dof(angle2, unsigned_periodic_range(segment.
dof(angle2)+
dphi[8],pi));
493 segment.
set_dof(angle3, unsigned_periodic_range(segment.
dof(angle3)+
dphi[9],pi));
494 segment.
set_dof(angle4, unsigned_periodic_range(segment.
dof(angle4)+
dphi[10],pi));
495 segment.
set_dof(angle5, unsigned_periodic_range(segment.
dof(angle5)+
dphi[11],pi));
496 segment.
set_dof(angle6, unsigned_periodic_range(segment.
dof(angle6)+
dphi[12],pi));
497 segment.
set_dof(angle7, unsigned_periodic_range(segment.
dof(angle7)+
dphi[13],pi));
498 segment.
set_dof(angle8, unsigned_periodic_range(segment.
dof(angle8)+
dphi[14],pi));
499 segment.
set_dof(angle9, unsigned_periodic_range(segment.
dof(angle9)+
dphi[15],pi));
510 return detL*exp(-d2/2.0);
523 using numeric::x_rotation_matrix_radians;
524 using numeric::z_rotation_matrix_radians;
525 using numeric::constants::d::pi;
526 using namespace core::kinematics;
529 xyzMatrix M(stub.
M * x_rotation_matrix_radians( phi ));
530 M *= z_rotation_matrix_radians( pi - theta );
532 d = stub.
v + distance * M.col_x();
609 jacobian = 1.0 / std::fabs(det);
632 Real const theta1_old,
633 Real const theta2_old,
634 Real const theta3_old,
635 Real const theta4_old,
636 Real const alpha1_old,
637 Real const alpha2_old,
638 Real const alpha3_old,
651 using numeric::x_rotation_matrix_radians;
652 using numeric::z_rotation_matrix_radians;
653 using basic::periodic_range;
654 using numeric::constants::d::pi;
655 using numeric::constants::d::pi_2;
657 Real sinA1, cosA1, sinA2, cosA2;
658 Real sinO1, cosO1, cosO2;
661 Real k_2, j_2, v_2, va;
662 Real w, w_2, h, h_2, g, p1_2, p2_2, p3_2;
667 static Real const MAXDIH2 = 50.0*pi/180.0;
668 static Real const MAXANG2 = 20.0*pi/180.0;
670 bool crfailed =
false;
672 p1_2 = p1.x()*p1.x();
673 p2_2 = p2.x()*p2.x();
674 p3_2 = p3.x()*p3.x();
677 a = (r2 - r1).normalize();
678 b = (r1 - r0).normalize();
681 g = std::sqrt( 1.0 - g*g );
685 T0.col_x(a).col_y(d).col_z(c);
689 k = r4 - r2; k_2 = k.length_squared();
690 j = r4 - r1; j_2 = j.length_squared();
692 cosA2 = (k_2 - p2_2 - p3_2) / (2.0*p2.x()*p3.x());
693 if (std::fabs(cosA2)>1.0)
696 TR.Debug <<
"can't close" << std::endl;
699 sinA2 = -std::sqrt( 1.0 - cosA2*cosA2 );
706 xyzMatrix T2(z_rotation_matrix_radians( std::atan2(sinA2, cosA2) ));
709 cosO2 = cos( theta2_old );
712 xyzMatrix R2(x_rotation_matrix_radians(theta2_old));
714 v_2 = v.length_squared();
716 w = (j_2 - p1_2 - v_2) / (2.0 * p1.x());
718 va = v.x()*v.x() + v.y()*v.y();
723 TR.Debug <<
"h_2=" << h_2 << std::endl;
726 TR.Debug <<
"can't close" << std::endl;
732 cosA1 = ( w * v.x() - v.y() * h ) / va;
733 sinA1 = -( w * v.y() + v.x() * h ) / va;
735 xyzMatrix T1(z_rotation_matrix_radians( std::atan2(sinA1, cosA1) ));
743 cosO1 = ( j.z()*n.z() + j.y()*n.y() ) / (j.y()*j.y() + j.z()*j.z() );
744 sinO1 = ( j.y()*n.z() - j.z()*n.y() ) / (j.y()*j.y() + j.z()*j.z() );
746 alpha1 = std::atan2( sinA1, cosA1 );
747 alpha1 += alpha1<0 ? pi : 0;
748 theta1 = std::atan2( sinO1, cosO1 );
749 alpha2 = std::atan2( sinA2, cosA2 );
750 alpha2 += alpha2<0 ? pi : 0;
753 if (alpha1 != alpha1 || theta1 != theta1)
756 TR.Debug <<
"ERROR COS SIN" << std::endl;
757 TR.Debug <<
"DB: A1 " << sinA1 <<
" " << cosA1 << std::endl;
758 TR.Debug <<
"DB: A2 " << sinA2 <<
" " << cosA2 << std::endl;
759 TR.Debug <<
"DB: O1 " << sinO1 <<
" " << cosO2 << std::endl;
762 TR.Debug <<
"alpha1=" << alpha1*180.0/pi <<
" alpha2=" << alpha2*180.0/pi << std::endl;
764 get_xyz(r0, r1, r2, r3, p2.x(), alpha1, theta1);
765 alpha3 = numeric::angle_radians( r3, r4, r5 );
766 theta3 = numeric::dihedral_radians( r2, r3, r4, r5 );
767 theta4 = numeric::dihedral_radians( r3, r4, r5, r6 );
773 (std::fabs(periodic_range( theta1_old-theta1, pi_2 )) > MAXDIH2) ||
774 (std::fabs(periodic_range( theta2_old-theta2, pi_2 )) > MAXDIH2) ||
775 (std::fabs(periodic_range( theta3_old-theta3, pi_2 )) > MAXDIH2) ||
776 (std::fabs(periodic_range( theta4_old-theta4, pi_2 )) > MAXDIH2) ||
777 (std::fabs(periodic_range( alpha1_old-alpha1, pi_2 )) > MAXANG2) ||
778 (std::fabs(periodic_range( alpha2_old-alpha2, pi_2 )) > MAXANG2) ||
779 (std::fabs(periodic_range( alpha3_old-alpha3, pi_2 )) > MAXANG2) ||
780 alpha1<0.017 || alpha1>3.124
786 cosA1 = ( w * v.x() + v.y() * h ) / va;
787 sinA1 = -( w * v.y() - v.x() * h ) / va;
790 xyzMatrix T1(z_rotation_matrix_radians( std::atan2(sinA1, cosA1) ));
796 cosO1 = ( j.z()*n.z() + j.y()*n.y() ) / (j.y()*j.y() + j.z()*j.z() );
797 sinO1 = ( j.y()*n.z() - j.z()*n.y() ) / (j.y()*j.y() + j.z()*j.z() );
799 alpha1 = std::atan2( sinA1, cosA1 );
800 alpha1 += alpha1<0 ? pi : 0;
801 theta1 = std::atan2( sinO1, cosO1 );
802 alpha2 = std::atan2( sinA2, cosA2 );
803 alpha2 += alpha2<0 ? pi : 0;
806 TR.Debug <<
"alpha1=" << alpha1*180.0/pi <<
" alpha2=" << alpha2*180.0/pi << std::endl;
809 get_xyz(r0, r1, r2, r3, p2.x(), alpha1, theta1);
810 alpha3 = numeric::angle_radians( r3, r4, r5 );
811 theta3 = numeric::dihedral_radians( r2, r3, r4, r5 );
812 theta4 = numeric::dihedral_radians( r3, r4, r5, r6 );
818 (std::fabs(periodic_range( theta1_old-theta1, pi_2 )) > MAXDIH2) ||
819 (std::fabs(periodic_range( theta2_old-theta2, pi_2 )) > MAXDIH2) ||
820 (std::fabs(periodic_range( theta3_old-theta3, pi_2 )) > MAXDIH2) ||
821 (std::fabs(periodic_range( theta4_old-theta4, pi_2 )) > MAXDIH2) ||
822 (std::fabs(periodic_range( alpha1_old-alpha1, pi_2 )) > MAXANG2) ||
823 (std::fabs(periodic_range( alpha2_old-alpha2, pi_2 )) > MAXANG2) ||
824 (std::fabs(periodic_range( alpha3_old-alpha3, pi_2 )) > MAXANG2) ||
825 alpha1<0.017 || alpha1>3.124
839 double big,dum,sum,temp;
847 if ((temp=fabs(a[i][j])) > big) big=temp;
851 TR.Warning <<
"Singular matrix in routine get_determinant" << std::endl;
859 for (k=0;k<i;k++) sum -= a[i][k]*a[k][j];
866 sum -= a[i][k]*a[k][j];
868 if ( (dum=vv[i]*fabs(sum)) >= big) {
883 if (a[j][j] == 0.0) a[j][j]=1.0e-20;
886 for (i=j+1;i<n;i++) a[i][j] *= dum;
890 for ( j = 0; j < n; j++ ) d *= a[j][j];