Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
util.cc
Go to the documentation of this file.
1 // -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
2 // vi: set ts=2 noet:
3 //
4 // (c) Copyright Rosetta Commons Member Institutions.
5 // (c) This file is part of the Rosetta software suite and is made available under license.
6 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
7 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
8 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
9 
10 /// @file
11 /// @brief
12 /// @author Nobuyasu Koga ( nobuyasu@u.washington.edu )
13 
15 #include <core/pose/Pose.hh>
16 // AUTO-REMOVED #include <core/conformation/Conformation.hh>
17 
18 // numeric headers
19 #include <numeric/conversions.hh>
20 #include <numeric/trig.functions.hh>
21 #include <numeric/xyzVector.hh>
22 
23 #include <utility/vector1.hh>
24 
25 //Auto Headers
28 #include <core/kinematics/Jump.hh>
29 
30 
31 
32 namespace protocols {
33 namespace fldsgn {
34 namespace potentials {
35 namespace sspot {
36 
37 typedef core::Size Size;
38 typedef core::Real Real;
41 
42 /// @details define a coordinate system with Z axis along cen1->a2 (v1),
43 /// xz plane defined by cen1->a2 and v21. and origin at cen1.
44 /// Find the spherical coordinates phi,and theta of point a4 if
45 /// vector cen2->a4 was moved such that cen2=cen1
46 /// @param[out] v21 vector connecting midpoints
47 void
49  Vector const & a2,
50  Vector const & a4,
51  Real & phi,
52  Real & theta,
53  Vector const & cen1,
54  Vector const & cen2,
55  Vector const & v21
56 )
57 {
58  using numeric::conversions::degrees;
59  using numeric::sin_cos_range;
60 
61  Vector v1( a2 - cen1 ); // v1 vector from center to end of dimer1 vector
62  Vector v2( a4 - cen2 ); // v2 vector from center to end of dimer2 vector
63 
64  Vector const uz( v1.normalized_or_zero() ); // unit vector along v1 = uz
65  Vector const uy( uz.cross( v21 ).normalized_or_zero() ); // unit vector perpendicular v21 v1 plane
66  Vector const ux( uy.cross( uz ).normalized_or_zero() ); // unit vector to define coordinate system
67 
68  Real const v2x = v2.dot( ux ); //v2(1)*ux(1) + v2(2)*ux(2) + v2(3)*ux(3); // v2x=v2.ux
69  Real const v2y = v2.dot( uy ); //v2(1)*uy(1) + v2(2)*uy(2) + v2(3)*uy(3); // v2y=v2.uy
70  Real const v2z = v2.dot( uz ); //v2(1)*uz(1) + v2(2)*uz(2) + v2(3)*uz(3); // v2z=v2.uz
71 
72  Vector const u21( v21.normalized_or_zero() ); // unit vector along v21
73 
74  phi = 200.0; // why set to 200?
75  // if v2y = 0, v2 lies in xz plane and phi is zero; if v2x=0, v2 lies in yz plane and phi is 90 or -90
76  if ( v2y != 0.0 && v2x != 0.0 ) {
77  phi = degrees( std::atan2( v2y, v2x ) );
78  }
79  if ( phi > 180.0 ) {
80  phi -= 360.0f;
81  } else if ( phi < -180.0 ) {
82  phi += 360.0f;
83  }
84 
85  Real r1 = v2.length();
86  Real const v2z_r1 = v2z/r1;
87  if ( r1 != 0.0 && std::abs( v2z_r1 ) <= 1.0 ) {
88  theta = degrees( numeric::arccos( v2z_r1 ) ); // std::acos( sin_cos_range( v2z_r1 ) ) );
89  } else if ( v2z_r1 > 1.0 ) {
90  theta = 0.0;
91  } else {
92  theta = 180.0;
93  }
94 
95 }
96 
97 
98 /// @brief identifies the sequence separation along the fold tree
99 /// lin the old way to calculate the sequence separation takes an asumption of no-break chain
100 /// lin when there is chain break between pos1 and pos2, we add a gap to make a correct calculation in ss energy
101 Size
102 get_foldtree_seqsep( Pose const & pose, Size pos1, Size pos2, Size gap_size )
103 {
104  if( pose.fold_tree().is_simple_tree() ) return std::abs( int( pos1 ) - int( pos2 ) );
105 
106  Size begin ( std::min(pos1,pos2) );
107  Size end ( std::max(pos1,pos2) );
108  bool is_break ( false );
109 
110  for ( Size i = begin; i < end; ++i ) {
111  //if( pose.fold_tree().is_cutpoint(i) ) { is_break=true; break; }
112  if( pose.residue_type(i).is_terminus() ) { is_break=true; break; }
113  }
114  if( is_break ) {
115  return end - begin + gap_size;
116  } else {
117  return end - begin;
118  }
119 }
120 
121 
122 } // ns sspot
123 } // ns potentials
124 } // ns fldsgn
125 } // ns protocols
126