Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ClashCountCalculator.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 core/pose/metrics/ClashCountCalculator.cc
11 /// @brief ClashCountCalculator class
12 /// @author Oliver Lange
13 
14 // Unit headers
16 
17 // Project headers
20 #include <core/pose/Pose.hh>
21 #include <core/scoring/AtomVDW.hh>
23 
24 // ObjexxFCL headers
25 #include <ObjexxFCL/format.hh>
26 
27 // Utility headers
28 #include <basic/Tracer.hh>
29 #include <utility/exit.hh>
30 // AUTO-REMOVED #include <utility/string_util.hh>
31 #include <basic/MetricValue.hh>
32 // AUTO-REMOVED #include <core/scoring/sasa.hh>
33 
34 #include <cassert>
35 
36 #include <utility/vector1.hh>
37 
38 
39 using namespace core;
40 using namespace core::pose;
41 using namespace core::pose::metrics;
42 
43 static basic::Tracer tr("protocols.metrics.ClashCountCalculator");
44 
45 namespace protocols{
46 namespace toolbox {
47 namespace pose_metric_calculators {
48 ClashCountCalculator::ClashCountCalculator( core::Real clash_threshold ) :
49  clash_threshold_( clash_threshold ),
50  vdw_scale_factor_( 0.8 ) // hack from rosetta++
51 {}
52 
53 void ClashCountCalculator::lookup( std::string const & key, basic::MetricValueBase *valptr ) const {
54  if ( key == "total" ) {
55  basic::check_cast( valptr, &total_clashes_, "total_clashes expects to return a Real" );
56  ( static_cast< basic::MetricValue<core::Size> *>(valptr))->set( total_clashes_ );
57  } else if ( key == "bb" ) {
58  basic::check_cast( valptr, &bb_clashes_, "bb_clashes expects to return a Size" );
59  ( static_cast< basic::MetricValue<core::Size> *>(valptr))->set( bb_clashes_ );
60  } else {
61  basic::Error() << "This Calculator cannot compute metric " << key << std::endl;
62  utility_exit();
63  }
64 
65 }
66 
67 
69  /*
70  if ( key == "total_sasa" ) {
71  return utility::to_string( total_sasa_ );
72  } else if ( key == "atom_sasa" ) {
73  basic::Error() << "id::AtomID_Map< Real > has no output operator, for metric " << key << std::endl;
74  utility_exit();
75  } else if ( key == "residue_sasa" ) {
76  return utility::to_string( residue_sasa_ );
77  }
78 
79  basic::Error() << "This Calculator cannot compute metric " << key << std::endl;
80  utility_exit();
81  */
82  return "";
83 
84 }
85 
86 
88  total_clashes_ = 0;
89  bb_clashes_ = 0;
90  std::string atom_type_set_name;
91  if ( pose.is_fullatom() ) {
92  return;
93  // atom_type_set_name = chemical::FA_STANDARD;
94  } else {
95  atom_type_set_name = chemical::CENTROID;
96  }
97  core::scoring::AtomVDW const& atom_vdw( core::scoring::ScoringManager::get_instance()->get_AtomVDW( atom_type_set_name ));
98  total_clashes_ = 0;
99  bb_clashes_ = 0;
100  for ( Size ipos = 1; ipos <= pose.total_residue(); ipos++ ) {
101  for ( Size jpos = ipos+2; jpos <= pose.total_residue(); jpos++ ) {
102  conformation::Residue const & rsd1( pose.residue( ipos ) );
103  conformation::Residue const & rsd2( pose.residue( jpos ) );
104  if (!( rsd1.is_bonded( rsd2 ) || rsd1.is_pseudo_bonded( rsd2 ) )) {
105  for ( Size i = 1, i_end = rsd1.natoms(); i <= i_end; ++i ) {
106  Vector const & i_xyz( rsd1.xyz(i) );
107  Size const i_type( rsd1.atom_type_index(i) );
108  utility::vector1< Real > const & i_atom_vdw( atom_vdw( i_type ) );
109  for ( Size j = 1, j_end = rsd2.natoms(); j <= j_end; ++j ) {
110  Real const bump_dsq( i_atom_vdw[ rsd2.atom_type_index(j) ] );
111  Real const clash( bump_dsq - i_xyz.distance_squared( rsd2.xyz(j) ) );
112  if ( clash > 0.0 ) {
113  core::Real score( clash*clash/bump_dsq*vdw_scale_factor_ );
114  if ( score > clash_threshold_ ) {
115  using namespace ObjexxFCL::fmt;
116  std::string const TAG( ( i <= 4 && j <= 4 ) ? "BB BUMP: " : " BUMP: ");
117  tr.Info << TAG << I(4,rsd1.seqpos() ) << I(4,rsd2.seqpos() )
118  <<' ' << rsd1.atom_name(i) << ' ' << rsd2.atom_name(j) << ' '
119  << ( clash * clash ) / bump_dsq * vdw_scale_factor_
120  << ' ' << i_xyz.distance_squared( rsd2.xyz(j) ) << std::endl;
121 
122  ++total_clashes_;
123  if ( i <= 5 && j <= 5 ) ++bb_clashes_;
124  }
125 
126  } //clash>0.0
127  }//j-atoms
128  }//i-atoms
129  }// rsd is not bonded
130  }// jpos
131  }//ipos
132 }
133 
134 
135 
136 } // PoseMetricCalculators
137 } // toolbox
138 } //protocols