34 #include <basic/Tracer.hh>
38 #include <numeric/xyz.functions.hh>
39 #include <numeric/random/random.hh>
46 #include <utility/vector1.hh>
50 namespace rbsegment_relax {
54 static numeric::random::RandomGenerator
rbseg_RG(18632);
55 static basic::Tracer
TR(
"protocols::moves::RBSegmentMover");
59 return "RBSegmentMover";
78 xDir.project_normal(zDir);
81 yDir = zDir.cross(xDir);
94 for (
Size i=1; i<=segment_.nContinuousSegments(); ++i) {
99 for (
Size j = i_start; j <= i_end; ++j ) {
117 getCoordinateTransformation( pose, origin, local2global);
118 global2local = numeric::inverse( local2global );
124 for (
Size i=1; i<=segment_.nContinuousSegments(); ++i) {
129 for (
Size j = i_start; j <= i_end; ++j ) {
132 localX = global2local * ( pose.
xyz(
id) - origin );
133 localRX = rotation * localX;
134 globalRX = local2global * localRX + origin;
137 atm_ids.push_back(
id );
138 atm_xyzs.push_back( globalRX );
151 getCoordinateTransformation( pose, origin, local2global);
157 for (
Size i=1; i<=segment_.nContinuousSegments(); ++i) {
162 for (
Size j = i_start; j <= i_end; ++j ) {
165 globalRX = pose.
xyz(
id) + local2global * translation;
168 atm_ids.push_back(
id );
169 atm_xyzs.push_back( globalRX );
182 getCoordinateTransformation( pose, origin, local2global);
183 global2local = numeric::inverse( local2global );
189 for (
Size i=1; i<=segment_.nContinuousSegments(); ++i) {
194 for (
Size j = i_start; j <= i_end; ++j ) {
197 localX = global2local * ( pose.
xyz(
id) - origin );
198 localRX = rotation * localX + translation;
199 globalRX = local2global * localRX + origin;
202 atm_ids.push_back(
id );
203 atm_xyzs.push_back( globalRX );
213 applyRotation( pose, rotation );
232 applyRotation( pose , sigma_rot*
rbseg_RG.gaussian() , sigma_rot*
rbseg_RG.gaussian() , sigma_rot*
rbseg_RG.gaussian() );
236 applyTranslation( pose ,
trans );
241 return "GaussianRBSegmentMover";
253 rotationCenter = getCoM( pose );
256 coordinateTransform.clear();
257 coordinateTransform.xx(1);
258 coordinateTransform.yy(1);
259 coordinateTransform.zz(1);
269 if (!segment_.isSimple()) {
270 TR <<
"[ ERROR ] SequenceShiftMover::apply() called on compound segment!" << std::endl;
275 int dir = (
rbseg_RG.random_range(0,1))? -1 : 1;
276 int mag =
rbseg_RG.random_range(1,magnitude_);
278 TR.Debug <<
"SequenceShiftMover::apply() [" << dir*mag <<
"]" << std::endl;
283 Size nres = i_end - i_start + 1;
289 R.xx(0.0);R.xy(0.0);R.xz(0.0);
290 R.yx(0.0);R.yy(0.0);R.yz(0.0);
291 R.zx(0.0);R.zy(0.0);R.zz(0.0);
296 for (
Size i = 0; i < nres-mag; ++i ) {
298 Size r_i = (dir==1)? i_start+i : i_end-i;
299 Size r_j = r_i+dir*mag;
309 R = numeric::alignVectorSets( C1,N1, C2,N2 );
317 atm_ids.push_back(
id );
318 atm_xyzs.push_back( newX );
324 for (
Size i = 0; i < (
Size)mag; ++i ) {
325 Size r_i = (dir==1)? i_end-i : i_start+i;
331 atm_ids.push_back(
id );
332 atm_xyzs.push_back( newX );
341 return "SequenceShiftMover";
351 Real displacement_X( sigOffAxisT_*
rbseg_RG.gaussian() );
352 Real displacement_Y( sigOffAxisT_*
rbseg_RG.gaussian() );
354 Real displacement_alpha( sigAxisR_*
rbseg_RG.gaussian() );
355 Real displacement_beta ( sigOffAxisR_*
rbseg_RG.gaussian() );
356 Real displacement_gamma( sigOffAxisR_*
rbseg_RG.gaussian() );
358 TR.Debug <<
"HelicalGaussianMover::apply() ["
359 << displacement_X <<
"," << displacement_Y <<
"," << displacement_Z <<
","
360 << displacement_alpha <<
"," << displacement_beta <<
"," << displacement_gamma <<
"]" << std::endl;
362 << sigAxisT_ <<
"," << sigOffAxisT_ <<
"," << sigAxisR_ <<
"," << sigOffAxisR_ <<
"]" << std::endl;
365 if ( sigAxisT_ > 1e-6 || sigOffAxisT_ > 1e-6 ) {
370 applyTranslation( pose, trans );
373 if ( sigAxisR_ > 1e-6 || sigOffAxisR_ > 1e-6 ) {
377 applyRotation( pose, displacement_alpha, displacement_beta, displacement_gamma );
383 return "HelicalGaussianMover";
393 if (!segment_.isSimple()) {
394 TR <<
"[ ERROR ] HelicalGaussianMover::getCoordinateTransformationy() called on compound segment!" << std::endl;
402 Vector helixAxisNterm(0,0,0), helixAxisCterm(0,0,0);
403 int startRes = segment_[1].start();
404 int endRes = segment_[1].end();
405 int nres = endRes - startRes + 1;
408 TR <<
"[WARNING] Helical axis of helices less than four residues is not correctly computed" << std::endl;
409 rotationCenter = getCoM( pose );
411 coordinateTransform.clear();
412 coordinateTransform.xx(1);
413 coordinateTransform.yy(1);
414 coordinateTransform.zz(1);
417 int midRes = startRes + (nres-1)/2;
418 helixAxisNterm += ( 0.6/3.6 ) * pose.
residue( midRes ).
xyz(
"CA" );
419 helixAxisNterm += ( 1.0/3.6 ) * pose.
residue( midRes - 1 ).
xyz(
"CA" );
420 helixAxisNterm += ( 1.0/3.6 ) * pose.
residue( midRes - 2 ).
xyz(
"CA" );
421 helixAxisNterm += ( 1.0/3.6 ) * pose.
residue( midRes - 3 ).
xyz(
"CA" );
422 helixAxisCterm += ( 0.6/3.6 ) * pose.
residue( midRes ).
xyz(
"CA" );
423 helixAxisCterm += ( 1.0/3.6 ) * pose.
residue( midRes + 1 ).
xyz(
"CA" );
424 helixAxisCterm += ( 1.0/3.6 ) * pose.
residue( midRes + 2 ).
xyz(
"CA" );
425 helixAxisCterm += ( 1.0/3.6 ) * pose.
residue( midRes + 3 ).
xyz(
"CA" );
427 helixAxisNterm += (1.0/3.6) * pose.
residue(startRes).
xyz(
"CA");
428 helixAxisNterm += (1.0/3.6) * pose.
residue(startRes+1).
xyz(
"CA");
429 helixAxisNterm += (1.0/3.6) * pose.
residue(startRes+2).
xyz(
"CA");
430 helixAxisNterm += (0.6/3.6) * pose.
residue(startRes+3).
xyz(
"CA");
431 helixAxisCterm += (1.0/3.6) * pose.
residue(endRes).
xyz(
"CA");
432 helixAxisCterm += (1.0/3.6) * pose.
residue(endRes-1).
xyz(
"CA");
433 helixAxisCterm += (1.0/3.6) * pose.
residue(endRes-2).
xyz(
"CA");
434 helixAxisCterm += (0.6/3.6) * pose.
residue(endRes-3).
xyz(
"CA");
437 rotationCenter = 0.5 * helixAxisNterm + 0.5 * helixAxisCterm;
438 coordinateTransform = coordTransformFromThreePoints(
451 Real displacement_X( sigOffAxisT_*
rbseg_RG.gaussian() );
452 Real displacement_Y( sigOffAxisT_*
rbseg_RG.gaussian() );
454 Real displacement_alpha( sigAxisR_*
rbseg_RG.gaussian() );
455 Real displacement_beta ( sigOffAxisR_*
rbseg_RG.gaussian() );
456 Real displacement_gamma( sigOffAxisR_*
rbseg_RG.gaussian() );
458 TR.Debug <<
"StrandTwistingMover::apply() ["
459 << displacement_X <<
"," << displacement_Y <<
"," << displacement_Z <<
","
460 << displacement_alpha <<
"," << displacement_beta <<
"," << displacement_gamma <<
"]" << std::endl;
462 if ( sigAxisT_ > 1e-6 || sigOffAxisT_ > 1e-6 ) {
464 applyTranslation( pose, trans );
467 if ( sigAxisR_ > 1e-6 || sigOffAxisR_ > 1e-6 ) {
468 applyRotation( pose, displacement_alpha, displacement_beta, displacement_gamma );
474 return "StrandTwistingMover";
484 if (!segment_.isSimple()) {
485 TR <<
"[ ERROR ] HelicalGaussianMover::getCoordinateTransformationy() called on compound segment!" << std::endl;
490 Vector sAxisNterm(0,0,0), sAxisCterm(0,0,0);
491 int startRes = segment_[1].start();
492 int endRes = segment_[1].end();
493 int nres = endRes - startRes + 1;
496 TR <<
"[WARNING] Strand axis of less than three residues is not correctly computed" << std::endl;
497 rotationCenter = getCoM( pose );
499 coordinateTransform.clear();
500 coordinateTransform.xx(1);
501 coordinateTransform.yy(1);
502 coordinateTransform.zz(1);
504 sAxisNterm += (0.5) * pose.
residue(startRes).
xyz(
"CA");
505 sAxisNterm += (0.5) * pose.
residue(startRes+1).
xyz(
"CA");
506 sAxisCterm += (0.5) * pose.
residue(endRes).
xyz(
"CA");
507 sAxisCterm += (0.5) * pose.
residue(endRes-1).
xyz(
"CA");
509 rotationCenter = 0.5 * sAxisNterm + 0.5 * sAxisCterm;
510 coordinateTransform = coordTransformFromThreePoints(