Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
NatbiasHelicesSheetPotential.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 protocols/fldsgn/potentials/sspot/NatbiasHelicesSheetPotential.cc
11 /// @brief native-biased centroid score for helices on sheets
12 /// @author Nobuyasu Koga ( nobuyasu@uw.edu )
13 
14 // Unit header
16 
17 // Package headers
21 #include <basic/Tracer.hh>
22 
23 // numeric
24 #include <numeric/xyzVector.hh>
25 #include <numeric/conversions.hh>
26 
27 #include <utility/vector1.hh>
28 
29 
30 static basic::Tracer TR("protocols.fldsgn.potentials.sspot.NatbiasHelicesSheetPotential", basic::t_info );
31 
32 namespace protocols {
33 namespace fldsgn {
34 namespace potentials {
35 namespace sspot {
36 
37 
38 /// @Brief default constructor
40  hss3set_( NULL ),
41  hpairset_( NULL )
42 {
43  set_params();
44 }
45 
46 /// @brief value constructor
48  hss3set_( hss3set ),
49  hpairset_( NULL )
50 {
51  set_params();
52 }
53 
54 /// @brief value constructor
56  hss3set_( hss3set ),
57  hpairset_( hpairset )
58 {
59  set_params();
60 }
61 
62 /// @brief value constructor
64  ReferenceCount(),
65  hss3set_( src.hss3set_ ),
66  hpairset_( src.hpairset_ ),
67  hs_dist_wts_( src.hs_dist_wts_ ),
68  hs_dist_( src.hs_dist_ ),
69  hs_dist_sigma2_( src.hs_dist_sigma2_ ),
70  hsheet_dist_repulsive_( src.hsheet_dist_repulsive_ ),
71  hs_angle_wts_( src.hs_angle_wts_ ),
72  hs_angle_( src.hs_angle_ ),
73  hs_angle_sigma2_( src.hs_angle_sigma2_ ),
74  hh_align_angle_wts_( src.hh_align_angle_wts_ ),
75  hh_align_angle_( src.hh_align_angle_ ),
76  hh_align_angle_sigma2_( src.hh_align_angle_sigma2_ )
77 {}
78 
79 /// @brief default destructor
81 {}
82 
83 /// @brief set parameters
84 void
86 {
87  // hs_dist_wts_ + hs_angle_wts_ supposed to be 1.0
88  hs_dist_wts_ = 0.5;
89  hs_dist_ = 13.0;
90  hs_dist_sigma2_ = 6.5;
91 
92  hs_angle_wts_ = 0.5;
93  hs_angle_ = -12.5;
94  hs_angle_sigma2_ = 10.0;
95 
97 
98  hh_align_angle_wts_ = 1.0;
99  hh_align_angle_ = 15.0;
100  hh_align_angle_sigma2_ = 15.0;
101 }
102 
103 /// @brif set HSSTrirpletSet
104 void
106 {
107  hss3set_ = hss3set;
108 }
109 
110 /// @brief set HelixPairingSet
111 void
113 {
115 }
116 
117 /// @brief set dist parameters for helix-sheet interaction
118 void
120  Real const hs_dist_wts,
121  Real const hs_dist,
122  Real const hs_dist_sigma2 )
123 {
124  hs_dist_wts_ = hs_dist_wts;
125  hs_dist_ = hs_dist;
126  hs_dist_sigma2_ = hs_dist_sigma2;
127 }
128 
129 /// @brief set dist parameters for helix-sheet interaction
130 void
132 {
133  hsheet_dist_repulsive_ = hsheet_dist_repulsive;
134 }
135 
136 /// @brief set angle parameters for helix-sheet interaction
137 void
139  Real const hs_angle_wts,
140  Real const hs_angle,
141  Real const hs_angle_sigma2 )
142 {
143  hs_angle_wts_ = hs_angle_wts;
144  hs_angle_ = hs_angle;
145  hs_angle_sigma2_ = hs_angle_sigma2;
146 }
147 
148 /// @brief set angle parameters for helices on sheet
149 void
151  Real const hh_align_angle_wts,
152  Real const hh_align_angle,
153  Real const hh_align_angle_sigma2 )
154 {
155  hh_align_angle_wts_ = hh_align_angle_wts;
156  hh_align_angle_ = hh_align_angle;
157  hh_align_angle_sigma2_ = hh_align_angle_sigma2;
158 }
159 
160 /// @brief
161 void
163 {
164 
165  TR << "Distance pot of helix & strands: wts, atr_dist, sigma2 : "
166  << hs_dist_wts_ << " " << hs_dist_ << " " << hs_dist_sigma2_ << std::endl;
167 
168  TR << "Distance pot of helix & sheet: " << hsheet_dist_repulsive_ << std::endl;
169 
170  TR << "Angle pot of helix & strands: wts, angle, sigma2 : "
171  << hs_angle_wts_ << " " << hs_angle_ << " " << hs_angle_sigma2_ << std::endl;
172 
173  TR << "Angle pot of helix-helix projected onto sheet: wts, angle, sigma2 : "
174  << hh_align_angle_wts_ << " " << hh_align_angle_ << " "<< hh_align_angle_sigma2_ << std::endl;
175 }
176 
177 /// @brief calc score
178 void
179 NatbiasHelicesSheetPotential::score( SS_Info2_COP const ss_info, Real & hh_score, Real & hs_score ) const
180 {
187 
188  // parameters for score calculation
189  Real hs_dist_wts = 0.5*hs_dist_wts_;
190  Real hs_dist_sigma2 = 2*hs_dist_sigma2_;
191  Real hs_angle_sigma2 = 2*hs_angle_sigma2_;
192  Real judge_hs_close = -0.5;
193 
194  // set helices and strands from ss_info
195  Helices const & helices( ss_info->helices() );
196  Strands const & strands( ss_info->strands() );
197 
198  // a helix is close to a sheet ?
199  // If true, the helix-pair score on sheet for the helix will be calculated
200  utility::vector1< bool > is_hs_close( ss_info->helices().size(), false );
201 
202  Size num( 0 );
203  hs_scores_.resize( hss3set_->size() );
204 
205  // interaction between helix and sheet
206  for( HSSConstIterator it=hss3set_->begin(), ite=hss3set_->end(); it !=ite; ++it ) {
207 
208  num++;
209  hs_scores_[ num ] = 0.0;
210 
211  HSSTripletOP hssop( *it );
212 
213  runtime_assert( helices.size() >= hssop->helix() );
214  runtime_assert( strands.size() >= hssop->strand1() );
215  runtime_assert( strands.size() >= hssop->strand2() );
216 
217  hssop->calc_geometry( ss_info );
218 
219  Real hsheet_dist = hssop->hsheet_dist();
220  Real hs1_dist = hssop->hs1_dist();
221  Real hs2_dist = hssop->hs2_dist();
222 
223  // repulsive between helix and sheet
224  if( hsheet_dist < hsheet_dist_repulsive_ ) {
225 
226  hs_scores_[ num ] += 10.0;
227  TR.Debug << "hseet_dist=" << hsheet_dist << std::endl;
228 
229  } else {
230 
231  Real dist_score1( 0.0 ), dist_score2( 0.0 ), angle_score( 0.0 );
232 
233  // distance energy between helix and 1st strand
234  if( hs1_dist <= hs_dist_ ) {
235  dist_score1 = -1.0;
236  } else {
237  Real r = numeric::square( hs1_dist - hs_dist_ )/hs_dist_sigma2;
238  dist_score1 = -exp( -r );
239  }
240 
241  // distance energy between helix and 2nd strand
242  if( hs2_dist <= hs_dist_ ) {
243  dist_score2 = -1.0;
244  } else {
245  Real r = numeric::square( hs2_dist - hs_dist_ )/hs_dist_sigma2;
246  dist_score2 = -exp( -r );
247  }
248 
249  TR.Debug << "HS_dist_score: "
250  << hssop->helix() << "-" << hssop->strand1() << "," << hssop->strand2() << " "
251  << hsheet_dist << " " << hs1_dist << " " << hs2_dist << " "
252  << dist_score1 << " " << dist_score2 << std::endl;
253 
254  // angle between helix and sheet
255  if( dist_score1 <= judge_hs_close && dist_score2 <= judge_hs_close ) {
256 
257  is_hs_close[ hssop->helix() ] = true;
258 
259  Real hs_angle = hssop->hs_angle();
260 
261  /// 90 < hs_angle < 180 has to have penalty !! this functionality need to be implemented.
262  if( hs_angle >= hs_angle_ ) {
263  angle_score = -1.0;
264  } else {
265  Real r = numeric::square( hs_angle - hs_angle_ )/hs_angle_sigma2;
266  angle_score = -exp( -r );
267  }
268 
269  TR.Debug << "HS_angle_score: "
270  << hssop->helix() << "-" << hssop->strand1() << "," << hssop->strand2() << " "
271  << hs_angle << " " << angle_score << " " << std::endl;
272  }
273 
274  // add to hs_score
275  hs_scores_[ num ] = hs_dist_wts * ( dist_score1 + dist_score2 ) + hs_angle_wts_ * angle_score;
276  }
277 
278  hs_score += hs_scores_[ num ];
279 
280  }
281 
282  Real hh_align_angle_sigma2 = 2*hh_align_angle_sigma2_;
283 
284  // interaction of helix pair on sheet
285  if( hpairset_ ) {
286 
287  hh_scores_.resize( hpairset_->size() );
288 
289  Size num( 0 );
290  HelixPairings const & hpairs = hpairset_->helix_pairings();
291  for( HelixPairings::const_iterator it=hpairs.begin(), ite=hpairs.end(); it != ite; ++it ) {
292 
293  num++;
294  hh_scores_[ num ] = 0.0;
295 
296  HelixPairing const & hpair( **it );
297 
298  runtime_assert( helices.size() >= hpair.h1() && helices.size() >= hpair.h2() );
299 
300  // only if both helices are close to sheet, helix pairing score is calculated
301  if( !is_hs_close[ hpair.h1() ] || !is_hs_close[ hpair.h2() ] ) continue;
302 
303  Helix const & h1 = *helices[ hpair.h1() ];
304  Helix const & h2 = *helices[ hpair.h2() ];
305 
306  HSSTripletOP hssop1 = hss3set_->hss_triplet( hpair.h1() );
307  HSSTripletOP hssop2 = hss3set_->hss_triplet( hpair.h2() );
308 
309  // make sure that HSSTripletOP is defined
310  runtime_assert( hssop1 && hssop2 );
311 
312  // get helix-pair orientation
313  Real flip( 1.0 );
314 
315  Size const s1 = hssop1->strand1();
316  Size const s2 = hssop2->strand2();
317 
318  Real ag = numeric::conversions::degrees( angle_of( strands[ s1 ]->orient(), strands[ s2 ]->orient() ) );
319  if( ag > 90.0 ) flip = -1.0;
320  Vector const v1 = strands[ s2 ]->mid_pos() - strands[ s1 ]->mid_pos();
321  Vector const v2 = strands[ s1 ]->orient() + flip*strands[ s2 ]->orient();
322  Vector const v3 = h1.orient().project_parallel( v1 ) + h1.orient().project_parallel( v2 );
323  Vector const v4 = h2.orient().project_parallel( v1 ) + h2.orient().project_parallel( v2 );
324 
325  if( hpair.orient() == 'A' ) flip = -1.0;
326  Real angle = numeric::conversions::degrees( angle_of( v3, flip*v4 ) );
327 
328  Real score;
329  if( angle <= hh_align_angle_ ) {
330  score = -hh_align_angle_wts_;
331  } else {
332  Real r = numeric::square( angle - hh_align_angle_ )/hh_align_angle_sigma2;
333  score = -hh_align_angle_wts_*exp( -r );
334  }
335  hh_scores_[ num ] = score;
336  hh_score += hh_scores_[ num ];
337 
338  TR.Debug << "HH_align_score : " << hpair.h1() << "-" << hpair.h2() << " " << angle << " " << score << std::endl;
339 
340  } // for( HelixPairings )
341  } // if( hpairset_ )
342 
343 
344 } // score
345 
346 
347 } // ns sspot
348 } // ns potentials
349 } // ns fldsgn
350 } // ns protocols
351