Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GeometrySecMatchRPE.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 // :noTabs=false:tabSize=4:indentSize=4:
4 //
5 // (c) Copyright Rosetta Commons Member Institutions.
6 // (c) This file is part of the Rosetta software suite and is made available under license.
7 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
8 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
9 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
10 
11 /// @file protocols/match/downstream/GeometrySecMatchRPE.cc
12 /// @brief
13 /// @author Florian Richter, floric@u.washington.edu, june 09
14 
15 // Unit headers
18 
19 // Package headers
20 
21 // Project headers
23 #include <basic/basic.hh>
24 
25 // Numeric headers
26 #include <numeric/constants.hh>
27 #include <numeric/xyz.functions.hh>
28 
29 // Utility headers
30 #include <utility/pointer/ReferenceCount.hh>
31 #include <utility/string_util.hh>
32 
33 // C++ headers
34 #include <list>
35 
36 #include <utility/vector1.hh>
37 
38 
39 namespace protocols {
40 namespace match {
41 namespace downstream {
42 
45 ) :
47  lowval_(gsi.ideal_val() - gsi.tolerance() ),
48  highval_( gsi.ideal_val() + gsi.tolerance() )
49 {
50  clear_at_inds();
51 }
52 
54 {}
55 
56 
57 bool
59 {
60  return false;
61 }
62 
63 bool
65 {
66  for ( Size ii = 1; ii <= at_inds_.size(); ++ii ) {
67  if ( at_inds_[ ii ].first == 2 && at_inds_[ ii ].second == target_atom_id ) {
68  return true;
69  }
70  }
71  return false;
72 }
73 
74 
75 bool
77  core::Real value ) const
78 {
79  if( value > highval_ ) return false;
80  else if ( value < lowval_ ) return false;
81  else return true;
82 }
83 
84 void
86  core::Size which_cst_res,
87  core::Size atom_ind_in_res
88 ){
89  at_inds_.push_back( std::make_pair( which_cst_res, atom_ind_in_res ) );
90 }
91 
92 
93 void
95  at_inds_.clear();
96 }
97 
98 void
100  core::Real lowval
101 )
102 {
103  lowval_ = lowval;
104 }
105 
106 void
108  core::Real highval
109 )
110 {
111  highval_ = highval;
112 }
113 
114 
117 ) :
119 {
120  set_lowval( lowval() * lowval() );
121  set_highval( highval() * highval() );
122 }
123 
124 
125 bool
127  core::conformation::Residue const & candidate_res,
128  core::conformation::Residue const & target_res
129 ) const
130 {
131 
132  assert( at_inds().size() == 2 );
133 
134  core::Real distance_squared( candidate_res.xyz( at_inds()[1].second ).distance_squared( target_res.xyz( at_inds()[2].second ) ) );
135 
136  /*if ( ! check_value( distance_squared ) ) {
137  std::cout << "AtomDistanceSecMatchRPE::evaluate_residues fail: " << distance_squared << std::endl;
138  }*/
139  return check_value( distance_squared );
140 
141 }
142 
145  core::chemical::ResidueTypeCOP candidate_restype,
146  core::chemical::ResidueTypeCOP target_restype
147 ) const
148 {
149  return "AtomDistance range " + utility::to_string( std::sqrt(lowval()) ) +
150  " A to " + utility::to_string( std::sqrt(highval()) ) + " A between " +
151  utility::trim( at_inds()[ 1 ].first == 1 ? candidate_restype->name() : target_restype->name() ) +
152  " atom " +
153  utility::trim( at_inds()[ 1 ].first == 1 ? candidate_restype->atom_name( at_inds()[ 1 ].second ) : target_restype->atom_name( at_inds()[ 1 ].second )) +
154  " and " +
155  utility::trim( at_inds()[ 2 ].first == 1 ? candidate_restype->name() : target_restype->name() ) +
156  " atom " +
157  utility::trim( at_inds()[ 2 ].first == 1 ? candidate_restype->atom_name( at_inds()[ 2 ].second ) : target_restype->atom_name( at_inds()[ 2 ].second ));
158 }
159 
160 
161 
162 bool
164  Size target_atom_id
165 ) const
166 {
167  assert( at_inds().size() == 2 );
168  assert( at_inds()[ 2 ].first == 2 ); // second atom is to the target residue
169 
170  return at_inds()[ 2 ].second == target_atom_id;
171 }
172 
175  Size target_atom_id
176 ) const
177 {
178  if ( at_inds()[ 2 ].second == target_atom_id ) {
179  utility::vector1< Size > other_atom( 1, at_inds()[ 1 ].second );
180  return other_atom;
181  } else {
183  return empty;
184  }
185 }
186 
189 {
190  if ( at_inds()[ 2 ].second == target_atom_id ) {
191  return std::sqrt( highval() );
192  } else {
193  return -1.0;
194  }
195 }
196 
197 
198 
201 ) :
203 {
204  set_lowval( lowval() * numeric::constants::d::degrees_to_radians );
205  set_highval( highval() * numeric::constants::d::degrees_to_radians );
206 
207 }
208 
209 bool
211  core::conformation::Residue const & candidate_res,
212  core::conformation::Residue const & target_res
213 ) const
214 {
215  assert( at_inds().size() == 3 );
216 
217  //first figure out which of the residues the atoms belong to
218  core::PointPosition p1( at_inds()[1].first == 1 ? candidate_res.xyz( at_inds()[1].second ) : target_res.xyz( at_inds()[1].second ) );
219  core::PointPosition p2( at_inds()[2].first == 1 ? candidate_res.xyz( at_inds()[2].second ) : target_res.xyz( at_inds()[2].second ) );
220  core::PointPosition p3( at_inds()[3].first == 1 ? candidate_res.xyz( at_inds()[3].second ) : target_res.xyz( at_inds()[3].second ) );
221 
222  //same approach as angle constraint
223  //core/scoring/constraints/AngleConstraint.cc
224  numeric::xyzVector< core::Real > u1( p1 - p2 );
225  numeric::xyzVector< core::Real > u2( p3 - p2 );
226  core::Real const n1( u1.length() );
227  core::Real const n2( u2.length() );
228 
229  core::Real angle( numeric::arccos( dot( u1,u2 ) / ( n1 * n2 ) ) );
230 
231 
232  /*if ( ! check_value( angle ) ) {
233  std::cout << "AtomAngleSecMatchRPE::evaluate_residues fail: " <<
234  numeric::constants::d::radians_to_degrees * angle << " low " <<
235  numeric::constants::d::radians_to_degrees * lowval() << " high " <<
236  numeric::constants::d::radians_to_degrees * highval() << std::endl;
237  }*/
238 
239 
240  return check_value( angle );
241 
242 }
243 
246  core::chemical::ResidueTypeCOP candidate_restype,
247  core::chemical::ResidueTypeCOP target_restype
248 ) const
249 {
250  return "AtomAngle range " + utility::to_string( numeric::constants::d::radians_to_degrees * lowval() ) +
251  " degrees to " + utility::to_string( numeric::constants::d::radians_to_degrees * highval() ) + " degrees between " +
252  utility::trim( at_inds()[ 1 ].first == 1 ? candidate_restype->name() : target_restype->name() ) +
253  " atom " +
254  utility::trim( at_inds()[ 1 ].first == 1 ? candidate_restype->atom_name( at_inds()[ 1 ].second ) : target_restype->atom_name( at_inds()[ 1 ].second )) +
255  ", " +
256  utility::trim( at_inds()[ 2 ].first == 1 ? candidate_restype->name() : target_restype->name() ) +
257  " atom " +
258  utility::trim( at_inds()[ 2 ].first == 1 ? candidate_restype->atom_name( at_inds()[ 2 ].second ) : target_restype->atom_name( at_inds()[ 2 ].second )) +
259  ", and " +
260  utility::trim( at_inds()[ 3 ].first == 1 ? candidate_restype->name() : target_restype->name() ) +
261  " atom " +
262  utility::trim( at_inds()[ 3 ].first == 1 ? candidate_restype->atom_name( at_inds()[ 3 ].second ) : target_restype->atom_name( at_inds()[ 3 ].second ));
263 }
264 
267 ) : AtomGeometrySecMatchRPE( gsi ),
268  check_periodicity_(gsi.periodicity() != 360.0 ),
269  periodicity_(gsi.periodicity() * numeric::constants::d::degrees_to_radians ),
270  offset_( basic::periodic_range( gsi.ideal_val() * numeric::constants::d::degrees_to_radians, periodicity_ ) )
271 {
272  set_lowval( -( gsi.tolerance() * numeric::constants::d::degrees_to_radians ) );
273  set_highval( gsi.tolerance() * numeric::constants::d::degrees_to_radians );
274 }
275 
276 bool
278  core::conformation::Residue const & candidate_res,
279  core::conformation::Residue const & target_res
280 ) const
281 {
282  assert( at_inds().size() == 4 );
283 
284  //first figure out which of the residues the atoms belong to
285  core::PointPosition p1( at_inds()[1].first == 1 ? candidate_res.xyz( at_inds()[1].second ) : target_res.xyz( at_inds()[1].second ) );
286  core::PointPosition p2( at_inds()[2].first == 1 ? candidate_res.xyz( at_inds()[2].second ) : target_res.xyz( at_inds()[2].second ) );
287  core::PointPosition p3( at_inds()[3].first == 1 ? candidate_res.xyz( at_inds()[3].second ) : target_res.xyz( at_inds()[3].second ) );
288  core::PointPosition p4( at_inds()[4].first == 1 ? candidate_res.xyz( at_inds()[4].second ) : target_res.xyz( at_inds()[4].second ) );
289 
290  Real value( basic::periodic_range( numeric::dihedral_radians( p1, p2, p3, p4 ) - offset_, periodicity_ ) );
291 
292  /*if ( ! check_value( value )) {
293  std::cout << "AtomDihedralSecMatchRPE::evaluate_residues fail: " <<
294  numeric::constants::d::radians_to_degrees * numeric::dihedral_radians( p1, p2, p3, p4 ) << " offsetper corrected " <<
295  numeric::constants::d::radians_to_degrees * value << " tol: " << numeric::constants::d::radians_to_degrees * highval() << std::endl;
296  }*/
297 
298  return check_value( value );
299 
300 }
301 
304  core::chemical::ResidueTypeCOP candidate_restype,
305  core::chemical::ResidueTypeCOP target_restype
306 ) const
307 {
308  std::string prefix = "AtomDihedral range" + std::string( std::abs( periodicity_ - numeric::constants::d::pi_2 ) > 1e-6 ? "s:" : ":" );
309  Size const n_periods = static_cast< Size > ( numeric::constants::d::pi_2 / periodicity_ );
310  for ( Size ii = 0; ii < n_periods; ++ii ) {
311  Real lo_deg = numeric::constants::d::radians_to_degrees * ( ii * periodicity_ + offset_ + lowval() );
312  Real hi_deg = numeric::constants::d::radians_to_degrees * ( ii * periodicity_ + offset_ + highval() );
313  prefix += " [ " + utility::to_string( lo_deg ) + ", " + utility::to_string( hi_deg ) + " ]";
314  }
315  prefix += " degrees between " +
316  utility::trim( at_inds()[ 1 ].first == 1 ? candidate_restype->name() : target_restype->name() ) +
317  " atom " +
318  utility::trim( at_inds()[ 1 ].first == 1 ? candidate_restype->atom_name( at_inds()[ 1 ].second ) : target_restype->atom_name( at_inds()[ 1 ].second )) +
319  ", " +
320  utility::trim( at_inds()[ 2 ].first == 1 ? candidate_restype->name() : target_restype->name() ) +
321  " atom " +
322  utility::trim( at_inds()[ 2 ].first == 1 ? candidate_restype->atom_name( at_inds()[ 2 ].second ) : target_restype->atom_name( at_inds()[ 2 ].second )) +
323  ", " +
324  utility::trim( at_inds()[ 3 ].first == 1 ? candidate_restype->name() : target_restype->name() ) +
325  " atom " +
326  utility::trim( at_inds()[ 3 ].first == 1 ? candidate_restype->atom_name( at_inds()[ 3 ].second ) : target_restype->atom_name( at_inds()[ 3 ].second )) +
327  ", and " +
328  utility::trim( at_inds()[ 4 ].first == 1 ? candidate_restype->name() : target_restype->name() ) +
329  " atom " +
330  utility::trim( at_inds()[ 4 ].first == 1 ? candidate_restype->atom_name( at_inds()[ 4 ].second ) : target_restype->atom_name( at_inds()[ 4 ].second ));
331  return prefix;
332 }
333 
334 void
337 )
338 {
339  atom_geom_rpes_.push_back( evaluator );
340 }
341 
342 
345  utility::vector1< core::Size > const & downstream_inds,
346  utility::vector1< core::Size > const & upstream_inds
347 ){
348 
349  if( mcfi.dis_U1D1() ){
351  adist->add_at_ind( 1, upstream_inds[1] );
352  adist->add_at_ind( 2, downstream_inds[1] );
353  atom_geom_rpes_.push_back( adist );
354  }
355 
356  if( mcfi.ang_U2D1() ){
357  AtomAngleSecMatchRPEOP aang1 = new AtomAngleSecMatchRPE( *(mcfi.ang_U2D1() ) );
358  aang1->add_at_ind( 1, upstream_inds[2] );
359  aang1->add_at_ind( 1, upstream_inds[1] );
360  aang1->add_at_ind( 2, downstream_inds[1] );
361  atom_geom_rpes_.push_back( aang1 );
362  }
363 
364  if( mcfi.ang_U1D2() ){
365  AtomAngleSecMatchRPEOP aang2 = new AtomAngleSecMatchRPE( *(mcfi.ang_U1D2() ) );
366  aang2->add_at_ind( 1, upstream_inds[1] );
367  aang2->add_at_ind( 2, downstream_inds[1] );
368  aang2->add_at_ind( 2, downstream_inds[2] );
369  atom_geom_rpes_.push_back( aang2 );
370  }
371 
372  if( mcfi.tor_U3D1() ){
374  adih1->add_at_ind( 1, upstream_inds[3] );
375  adih1->add_at_ind( 1, upstream_inds[2] );
376  adih1->add_at_ind( 1, upstream_inds[1] );
377  adih1->add_at_ind( 2, downstream_inds[1] );
378  atom_geom_rpes_.push_back( adih1 );
379  }
380 
381  if( mcfi.tor_U2D2() ){
383  adih2->add_at_ind( 1, upstream_inds[2] );
384  adih2->add_at_ind( 1, upstream_inds[1] );
385  adih2->add_at_ind( 2, downstream_inds[1] );
386  adih2->add_at_ind( 2, downstream_inds[2] );
387  atom_geom_rpes_.push_back( adih2 );
388  }
389 
390  if( mcfi.tor_U1D3() ){
392  adih3->add_at_ind( 1, upstream_inds[1] );
393  adih3->add_at_ind( 2, downstream_inds[1] );
394  adih3->add_at_ind( 2, downstream_inds[2] );
395  adih3->add_at_ind( 2, downstream_inds[3] );
396  atom_geom_rpes_.push_back( adih3 );
397  }
398 }
399 
400 bool
402  core::conformation::Residue const & candidate_res,
403  core::conformation::Residue const & target_res
404 ) const
405 {
407  it = atom_geom_rpes_.begin(), it_end = atom_geom_rpes_.end();
408  it != it_end; ++it ){
409  if ( ! (*it)->evaluate_residues( candidate_res, target_res ) ) return false;
410  }
411  //if we've made it to here, that means all AtomGeomRPEs returned true
412  return true;
413 }
414 
415 
416 bool
418 {
419  return false;
420 }
421 
422 bool
424 {
426  it = atom_geom_rpes_.begin(), it_end = atom_geom_rpes_.end();
427  it != it_end; ++it ){
428  if ( (*it)->require_target_atom_coordinate( target_atom_id ) ) return true;
429  }
430  return false;
431 }
432 
433 bool
435 {
437  it = atom_geom_rpes_.begin(), it_end = atom_geom_rpes_.end();
438  it != it_end; ++it ){
439  if ( (*it)->require_candidate_residue_atoms_to_lie_near_target_atom( target_atom_id ) ) return true;
440  }
441  return false;
442 }
443 
444 /// @details Aggregate the sets of atoms that are required to be near a given
445 /// target atom from the various AtomGeometry evaluators
448  Size target_atom_id
449 ) const
450 {
451  std::list< Size > atoms;
453  it = atom_geom_rpes_.begin(), it_end = atom_geom_rpes_.end();
454  it != it_end; ++it ){
455  utility::vector1< Size > reqd_atoms = (*it)->candidate_res_atoms_reqd_near_target_atom( target_atom_id );
456  if ( reqd_atoms.size() != 0 ) {
457  for ( Size ii = 1; ii <= reqd_atoms.size(); ++ii ) {
458  atoms.push_back( reqd_atoms[ ii ] );
459  atoms.sort();
460  atoms.unique();
461  }
462  }
463  }
464 
465  utility::vector1< Size > atom_vect( atoms.size() );
466  Size count( 1 );
467  for ( std::list< Size >::const_iterator iter = atoms.begin(),
468  iter_end = atoms.end(); iter != iter_end; ++iter ) {
469  atom_vect[ count ] = *iter;
470  ++count;
471  }
472  return atom_vect;
473 }
474 
475 /// @details Return the shortest of the distance cutoffs from the AtomGeometry that
476 /// do describe a distance cutoff to a particular target atom.
479 {
480  Real min_max_dis( -1.0 );
482  it = atom_geom_rpes_.begin(), it_end = atom_geom_rpes_.end();
483  it != it_end; ++it ) {
484  Real max_dis = (*it)->max_separation_dist_to_target_atom( target_atom_id );
485  if ( max_dis > 0.0 && min_max_dis > max_dis ) {
486  min_max_dis = max_dis;
487  }
488  }
489 
490  return min_max_dis;
491 
492 }
493 
494 
495 
496 }
497 }
498 }