Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HSPairPotential.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@uw.edu )
13 
14 // Unit header
16 
17 // Package headers
21 
22 // Project headers
23 // AUTO-REMOVED #include <core/conformation/Conformation.hh>
24 #include <core/pose/Pose.hh>
25 #include <core/scoring/Energies.hh>
27 #include <basic/Tracer.hh>
28 #include <basic/database/open.hh>
29 
30 // utility
31 #include <utility/io/izstream.hh>
32 
33 // C++ headers
34 #include <cmath>
35 #include <iostream>
36 
37 #include <ObjexxFCL/format.hh>
38 
39 #include <utility/vector1.hh>
40 #include <ObjexxFCL/FArray3D.hh>
41 
42 //Auto Headers
44 #include <core/kinematics/Jump.hh>
45 
46 
47 
48 static basic::Tracer TR( "protocols.fldsgn.potentials.sspot.HSPairPotential", basic::t_info );
49 
50 namespace protocols {
51 namespace fldsgn {
52 namespace potentials {
53 namespace sspot {
54 
55 /// @brief default constructor
57  dist_cutoff_( 12.0 ),
58  phithetascore_( 2, 3, 36, 36 )
59 {
61 }
62 
63 /// @brief default destructor
65 {}
66 
67 /// @brief
69 HSPairPotential::calc_phithetascore( Size const strand_seqsep, Real const phi, Real const theta ) const
70 {
71  Size istrand_seqsep;
72  if ( strand_seqsep >= 2 && strand_seqsep <= 10 ) {
73  istrand_seqsep = 2;
74  } else {
75  if ( strand_seqsep > 10 ) {
76  istrand_seqsep = 3;
77  } else {
78  istrand_seqsep = 1;
79  }
80  }
81  Size iphi = static_cast< Size >( 1 + ( phi + 180.0 )/10 );
82  if ( iphi > 36 ) {
83  iphi = 36;
84  } else if ( iphi < 1 ) {
85  iphi = 1;
86  }
87  Size itheta = static_cast< Size >( 1 + ( theta/5 ) );
88  if ( itheta > 36 ) {
89  itheta = 36;
90  } else if ( itheta < 1 ) {
91  itheta = 1;
92  }
93  return phithetascore_( 1, int( istrand_seqsep ), int( iphi ), int( itheta ) );
94 }
95 
96 
97 /// @brief function reads in two points in sequence and returns two points in space,
98 /// @brief the endpoints of the axis through an alpha-helix
99 void
101  Size const & pos1,
102  BB_Pos const & bb_pos,
103  Vector & p1,
104  Vector & p2
105 ) const
106 {
107  static Real const eleven_inv = 1.0 / 11.0;
108  Size const s1 = pos1;
109  Size const s2 = pos1+1;
110  Size const s3 = pos1+2;
111  Size const s4 = pos1+3;
112 
113  Vector const Epos_sum( ( bb_pos.CA( s1 ) + bb_pos.C( s1 ) ) +
114  ( bb_pos.N( s2 ) + bb_pos.CA( s2 ) + bb_pos.C( s2 ) ) +
115  ( bb_pos.N( s3 ) + bb_pos.CA( s3 ) + bb_pos.C( s3 ) ) +
116  ( bb_pos.N( s4 ) + bb_pos.CA( s4 ) ) );
117 
118  p1 = ( Epos_sum + bb_pos.N( s1 ) ) * eleven_inv;
119  p2 = ( Epos_sum + bb_pos.C( s4 ) ) * eleven_inv;
120 }
121 
122 
123 /// @brief
124 void
126  Pose const & pose,
127  SS_Info2 const & ss_info,
128  Real & hs_score
129 ) const
130 {
137 
138  hs_score = 0.0;
139 
140  Helices const & helices( ss_info.helices() );
141  Strands const & strands( ss_info.strands() );
142  BB_Pos const & bb_pos( ss_info.bb_pos() );
143 
144  EnergyGraph const & energy_graph( pose.energies().energy_graph() );
145 
146  for( Size ihelix=1; ihelix<=helices.size(); ihelix++ ) {
147 
148  HelixOP const helix( helices[ ihelix ] );
149 
150  if( helix->length() <= 3 ) continue;
151 
152  for( Size ss1=helix->begin(); ss1<=helix->end()-3; ss1++ ) {
153 
154  Vector pt1, pt2;
155  helix_end( ss1, bb_pos, pt1, pt2 );
156 
158  iru = energy_graph.get_node( ss1+1 )->const_edge_list_begin(),
159  irue = energy_graph.get_node( ss1+1 )->const_edge_list_end();
160  iru != irue; ++iru ) {
161 
162  Size ss2( (*iru)->get_second_node_ind() );
163  //Edges always have first node < second node. Just in case we picked the wrong one:
164  if ( ss1+1 == ss2 ) ss2 = (*iru)->get_first_node_ind();
165 
166  Size jstrand = ss_info.strand_id( ss2 );
167  if( jstrand == 0 || ss_info.strand_id( ss2+1 ) == 0 ) continue;
168  if( pose.residue_type( ss2 ).is_upper_terminus() ) continue;
169 
170  Vector const & pt3( bb_pos.N( ss2 ) );
171  Vector const & pt4( bb_pos.C( ss2+1 ) );
172 
173  // midpoint coordinates of two dimers
174  Vector cen1 = Real( 0.5 )*( pt1 + pt2 );
175  Vector cen2 = Real( 0.5 )*( pt3 + pt4 );
176 
177  // vector between midpoints
178  Vector mid_vector = cen2 -cen1;
179 
180  if ( mid_vector.length() <= dist_cutoff_ ) {
181  Real phi, theta;
182  spherical( pt2, pt4, phi, theta, cen1, cen2, mid_vector );
183 
184  Size const helix_end_1 = helix->begin() - 1;
185  Size const helix_end_2 = helix->end() + 1;
186 
187  Size const strand_end_1 = strands[ jstrand ]->begin() - 1;
188  Size const strand_end_2 = strands[ jstrand ]->end() + 1;
189 
190  Size seqsep = std::min( get_foldtree_seqsep( pose, helix_end_2, strand_end_1 ) + 1,
191  get_foldtree_seqsep( pose, strand_end_2, helix_end_1 ) + 1 );
192 
193  hs_score += calc_phithetascore( seqsep, phi, theta );
194  }
195  } // loop over neighbors of ss1
196  } // ss1
197  } // ihelix
198 
199  // modify by proper weighting
200  hs_score *= 0.090;
201 } // score
202 
203 
204 /// @brief load phi/theta bins for use in secondary structure scoring
205 void
207 {
208  using ObjexxFCL::fmt::skip;
209  typedef ObjexxFCL::FArray3D< Real > FArray3D_real;
210  FArray3D_real pts_HS( 36, 36, 3 );
211 
212  FArray1D_int iptsn( 36 );
213  for ( int itheta = 1; itheta <= 36; ++itheta ) {
214  iptsn(itheta) = 100;
215  }
216 
217  utility::io::izstream HS_stream;
218  basic::database::open( HS_stream, hs_filename );
219  for ( int isep = 1; isep <= 3; ++isep ) {
220  for ( int itheta = 1; itheta <= 36; ++itheta ) {
221  for ( int iph = 1; iph <= 36; ++iph ) {
222  HS_stream >> pts_HS( itheta, iph, isep ) >> skip;
223  }
224  }
225  }
226  HS_stream.close();
227  HS_stream.clear();
228 
229  for ( int isep = 1; isep <= 3; ++isep ) {
230  Real tot = 0.0;
231  Real totn = 0.0;
232  for ( int iph = 1; iph <= 36; ++iph ) {
233  for ( int itheta = 1; itheta <= 36; ++itheta ) {
234  // SMALL COUNTS CORRECTION
235  pts_HS( itheta, iph, isep ) += iptsn( itheta )*0.000001f;
236  tot += pts_HS( itheta, iph, isep );
237  totn += iptsn( itheta );
238  }
239  }
240  for ( int iph = 1; iph <= 36; ++iph ) {
241  for ( int itheta = 1; itheta <= 36; ++itheta ) {
242  phithetascore_( 1, isep, iph, itheta ) = -std::log(pts_HS( itheta, iph, isep )/tot ) +
243  std::log(iptsn( itheta )/totn );
244  }
245  }
246  }
247 } // load_phi_theta_bins
248 
249 
250 } // ns sspot
251 } // ns potentials
252 } // ns fldsgn
253 } // ns protocols