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 /// @detailed
13 /// @author Oliver Lange
14 ///
15 
16 
17 // Unit Headers
19 
20 // Project Headers
21 #include <core/pose/Pose.hh>
22 // AUTO-REMOVED #include <core/pose/util.hh>
23 
24 // AUTO-REMOVED #include <core/kinematics/FoldTree.hh>
25 // AUTO-REMOVED #include <core/kinematics/util.hh>
26 // AUTO-REMOVED #include <core/fragment/JumpingFrame.hh>
27 // AUTO-REMOVED #include <core/fragment/Frame.hh>
28 // AUTO-REMOVED #include <core/fragment/BBTorsionSRFD.hh>
29 // AUTO-REMOVED #include <core/fragment/JumpSRFD.hh>
30 // AUTO-REMOVED #include <core/conformation/util.hh>
31 
32 
33 //
34 
35 // ObjexxFCL Headers
36 
37 // Utility headers
38 #include <basic/Tracer.hh>
39 
40 //numeric headers
41 
42 //// C++ headers
43 // #include <string>
44 // AUTO-REMOVED #include <list>
45 
47 #include <core/id/AtomID.hh>
48 #include <utility/vector1.hh>
49 
50 
51 namespace core {
52 namespace scoring {
53 namespace dssp {
54 
55 using namespace core;
56 using namespace pose;
57 using namespace kinematics;
58 
59 static basic::Tracer tr("core.scoring.dssp");
60 
61 void
63  PointList const & ca1, // pass by reference, so no tricks:: 3x3
64  PointList const & ca2, // pass by reference, so no tricks:: 3x3
65  Vector & a,
66  Vector & b,
67  Vector & c
68 )
69 {
70  /* a goes from c-alpha #1 to c-alpha #3 */
71  a = ca1[3]-ca1[1];
72  a.normalize();
73 
74  /* b gives direction of pleat for ca1 c-alphas */
75  Vector b1 = ca1[2] - ca1[1];
76  Vector b2 = ca1[2] - ca1[3];
77  b = b1 + b2 ;
78  b.normalize();
79 
80  /* c goes from ca1 triple to ca2 triple (central alpha-carbons) */
81  c = ca2[2] - ca1[2];
82  c.normalize();
83 }
84 
85 
86 void
88  pose::Pose const& pose,
89  Size const res1,
90  Size const res2,
91  Real& orientation,
92  Real& pleating1,
93  Real& pleating2
94 )
95 {
96  runtime_assert( res1>1 && res1 < pose.total_residue() &&
97  res2 > res1 && res2 < pose.total_residue() );
98 
99  chemical::ResidueType const& rt1 ( pose.residue_type ( res1 ) );
100  chemical::ResidueType const& rt2 ( pose.residue_type ( res2 ) );
101 
102  PointList pCA1(3); //space for 3 CAs positions
103  PointList pCA2(3);
104 
105 // read CAs of 3 consecutive residues
106  for ( int i = -1 ; i<=1 ; i++ ) {
107  id::AtomID CA1( rt1.atom_index ("CA") , res1+i );
108  id::AtomID CA2( rt2.atom_index ("CA") , res2+i );
109  pCA1[ i+2 ] = pose.xyz( CA1 );
110  pCA2[ i+2 ] = pose.xyz( CA2 );
111  };
112 
113  Vector dCaCa = pCA1[ 2 ] - pCA2[ 2 ];
114  if ( dCaCa.length() > 10.5 ) {
115  tr.Warning << "the CA-CA distance for pairing " << res1 << " " << res2 << " is " << dCaCa.length() << std::endl;
116  // I put this in because I had this case once, and such an exit would have saved me time.
117  //If you have longer distances you probably don't want to choose pleating and orientation based on the native structure
118  // --- which is a temporary convenience hack anyway.
119  // utility_exit_with_message(" the CA-CA distance for the chosen pairing is more than 10.5 A check your pairings!!! ");
120  }
121 
122 
123  Vector a1,b1,c1;
124  Vector a2,b2,c2;
125  get_CA_vectors( pCA1, pCA2, a1,b1,c1 );
126  get_CA_vectors( pCA2, pCA1, a2,b2,c2 );
127 
128  orientation = dot_product( a1, a2 );
129 
130  Vector ab1,ab2;
131  cross(a1,b1,ab1);
132  cross(a2,b2,ab2);
133 
134  Real const d1 = dot_product(ab1,c1);
135  Real const d2 = dot_product(ab2,c2);
136 
137  pleating1 = d1;
138 
139  if ( orientation < 0 ) {
140  pleating2 = d2; // antiparallel
141  } else {
142  pleating2 = -d2;
143  }
144 }
145 
146 
147 
148 void
150  pose::Pose const& pose,
151  Size const pos1,
152  Size const pos2,
153  Size &orientation,
154  Size &pleating
155 )
156 {
157 
158  //Why did this have to get so complicated?
159  // Its actually a pretty simple concept!
160  //
161  // For some reasons, get_pairing_geometry flips
162  // pleating2 depending on the orientation --
163  // in ideal strand pairs, pleating1 and pleating2 then have the same sign.
164  //
165  // But for some twisted strand pairs (see, e.g, 22,48 in 1brs.pdb),
166  // the numbers get a little crazy...
167  //
168 
169  Real forientation, pleating1, pleating2;
170  if ( pos1 < pos2 ) {
171  get_pairing_geometry( pose, pos1, pos2, forientation,pleating1,pleating2);
172 
173  //This isn't always quite true...
174  // runtime_assert( pleating1 * pleating2 > 0.0 );
175  pleating = ( (pleating1+pleating2) < 0 ? 1 : 2 );
176  } else {
177  get_pairing_geometry( pose, pos2, pos1, forientation,pleating1,pleating2);
178 
179 
180  //This isn't always quite true...
181  // runtime_assert( pleating1 * pleating2 > 0.0 );
182 
183  if ( forientation < 0 ) {
184  // pleating for anti-parallel pairings is preserved when we
185  // interchange positions
186  pleating = ( (pleating1+pleating2) < 0 ? 1 : 2 );
187  } else {
188  // pleating for parallel pairings is reversed when we
189  // interchange positions
190  pleating = ( (pleating1+pleating2) < 0 ? 2 : 1 );
191  }
192  }
193  tr.Debug << " orientation " << forientation << " pleating " << pleating << std::endl;
194  orientation = forientation < 0 ? 1 : 2;
195 }
196 
197 
198 
199 }
200 }
201 }