Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
BuriedUnsatisfiedPolarsCalculator.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 /// @begin BuriedUnsatisfiedPolarsCalculator
11 ///
12 /// @brief
13 /// How many buried unsatisfied polars are there?
14 ///
15 /// @detailed
16 /// Buried unsatisfied polar hbonds are destabilizing for proteins. It is good to have less.
17 /// In a study of 2299 high resolution crystal structures of 1.5A or better, there was an average
18 /// 71 unsatisfied buried polar hbonds. The normalized average (normalized against aa #) was 0.30 (unpublished).
19 /// To get this piece of code to work, you must first load in your pdb. Then, you need the following lines:
20 ///
21 /// core::pose::metrics::PoseMetricCalculatorOP sasa_calculator = new protocols::toolbox::PoseMetricCalculators::SasaCalculator;
22 /// core::pose::metrics::CalculatorFactory::Instance().register_calculator( "sasa", sasa_calculator );
23 ///
24 /// core::pose::metrics::PoseMetricCalculatorOP num_hbonds_calculator = new protocols::toolbox::PoseMetricCalculators::NumberHBondsCalculator();
25 /// core::pose::metrics::CalculatorFactory::Instance().register_calculator( "num_hbonds", num_hbonds_calculator );
26 ///
27 /// core::pose::metrics::PoseMetricCalculatorOP unsat_calculator = new protocols::toolbox::PoseMetricCalculators::BuriedUnsatisfiedPolarsCalculator("sasa", "num_hbonds");
28 /// core::pose::metrics::CalculatorFactory::Instance().register_calculator( "unsat", unsat_calculator );
29 ///
30 /// This segment of code sets everything up to be used in the calculator. To use this on your protein, you simply need to
31 /// write the following: pose.print_metric("unsat", "all_bur_unsat_polars");
32 ///
33 /// @author
34 /// Florian Richter
35 /// Steven Combs - comments
36 ///
37 /// @last_modified November 19 2010
38 /////////////////////////////////////////////////////////////////////////
39 /// @file core/pose/metrics/BuriedUnsatisfiedPolarsCalculator.cc
40 /// @brief number of hbonds calculator class
41 /// @author Florian Richter
42 
43 // Unit headers
45 
48 #include <core/pose/Pose.hh>
51 
52 
53 
54 
55 // Utility headers
56 #include <basic/Tracer.hh>
57 #include <utility/exit.hh>
58 #include <utility/stream_util.hh>
59 #include <utility/string_util.hh>
60 #include <basic/MetricValue.hh>
61 
62 
63 #include <cassert>
64 
66 #include <utility/vector1.hh>
67 
68 
69 
70 using namespace core;
71 using namespace core::pose;
72 using namespace core::pose::metrics;
73 
74 static basic::Tracer TR("protocols.toolbox.PoseMetricCalculators.BuriedUnsatisfiedPolarsCalculator");
75 
76 namespace protocols{
77 namespace toolbox {
78 namespace pose_metric_calculators {
79 
80 BuriedUnsatisfiedPolarsCalculator::BuriedUnsatisfiedPolarsCalculator(
81  std::string sasa_calc,
82  std::string hbond_calc,
83  core::Real burial_cutoff
84 ) : all_bur_unsat_polars_( 0 ),
85  special_region_bur_unsat_polars_(0),
86  name_of_hbond_calc_( hbond_calc ),
87  name_of_sasa_calc_( sasa_calc ),
88  burial_sasa_cutoff_( burial_cutoff )
89 {
92  special_region_.clear();
94 
95 }
96 
97 
99  std::string sasa_calc,
100  std::string hbond_calc,
101  std::set< core::Size > const & special_region,
102  core::Real burial_cutoff
103 ) : all_bur_unsat_polars_(0),
104  special_region_bur_unsat_polars_(0),
105  name_of_hbond_calc_( hbond_calc ),
106  name_of_sasa_calc_( sasa_calc ),
107  burial_sasa_cutoff_( burial_cutoff ),
108  special_region_( special_region )
109 {
113 }
114 
115 
116 void
118 {
119  if( !CalculatorFactory::Instance().check_calculator_exists( name_of_hbond_calc_ ) ){
120  if( name_of_hbond_calc_ != "default" ) TR << "Attention: couldn't find the specified hbond calculator ( " << name_of_hbond_calc_ << " ), instantiating default one." << std::endl;
121  name_of_hbond_calc_ = "bur_unsat_calc_default_hbond_calc";
122  if( !CalculatorFactory::Instance().check_calculator_exists( name_of_hbond_calc_ ) ){
123  CalculatorFactory::Instance().register_calculator( name_of_hbond_calc_, new NumberHBondsCalculator() );
124  }
125  }
126 
127  if( !CalculatorFactory::Instance().check_calculator_exists( name_of_sasa_calc_ ) ){
128  if( name_of_sasa_calc_ != "default" ) TR << "Attention: couldn't find the specified sasa calculator ( " << name_of_sasa_calc_ << " ), instantiating default one." << std::endl;
129  name_of_sasa_calc_ = "bur_unsat_calc_default_sasa_calc";
130  if( !CalculatorFactory::Instance().check_calculator_exists( name_of_sasa_calc_ ) ){
131  CalculatorFactory::Instance().register_calculator( name_of_sasa_calc_, new core::pose::metrics::simple_calculators::SasaCalculator() );
132  }
133  }
134 }
135 
136 
137 void
139  std::string const & key,
140  basic::MetricValueBase * valptr
141 ) const
142 {
143 
144  if ( key == "all_bur_unsat_polars" ) {
145  basic::check_cast( valptr, &all_bur_unsat_polars_, "all_bur_unsat_polars expects to return a Size" );
146  (static_cast<basic::MetricValue<Size> *>(valptr))->set( all_bur_unsat_polars_ );
147 
148  } else if ( key == "special_region_bur_unsat_polars" ) {
149  basic::check_cast( valptr, &special_region_bur_unsat_polars_, "special_region_bur_unsat_polars expects to return a Size" );
150  (static_cast<basic::MetricValue<Size> *>(valptr))->set( special_region_bur_unsat_polars_ );
151 
152  } else if ( key == "atom_bur_unsat" ) {
153  basic::check_cast( valptr, &atom_bur_unsat_, "atom_bur_unsat expects to return a id::AtomID_Map< bool >" );
154  (static_cast<basic::MetricValue<id::AtomID_Map< bool > > *>(valptr))->set( atom_bur_unsat_ );
155 
156  } else if ( key == "residue_bur_unsat_polars" ) {
157  basic::check_cast( valptr, &residue_bur_unsat_polars_, "residue_bur_unsat_polars expects to return a utility::vector1< Size >" );
158  (static_cast<basic::MetricValue<utility::vector1< Size > > *>(valptr))->set( residue_bur_unsat_polars_ );
159 
160  } else {
161  basic::Error() << "NumberHbondsCalculator cannot compute the requested metric " << key << std::endl;
162  utility_exit();
163  }
164 
165 } //lookup
166 
167 
168 
171 {
172 
173  if ( key == "all_bur_unsat_polars" ) {
174  return utility::to_string( all_bur_unsat_polars_ );
175  } else if ( key == "special_region_bur_unsat_polars" ) {
176  return utility::to_string( special_region_bur_unsat_polars_ );
177  } else if ( key == "atom_Hbonds" ) {
178  basic::Error() << "id::AtomID_Map< bool > has no output operator, for metric " << key << std::endl;
179  utility_exit();
180  } else if ( key == "residue_bur_unsat_polars" ) {
181  return utility::to_string( residue_bur_unsat_polars_ );
182  }
183 
184  basic::Error() << "NumberHbondsCalculator cannot compute metric " << key << std::endl;
185  utility_exit();
186  return "";
187 
188 } //print
189 
190 
191 /// @brief this function doesn't actually recompute anything by itself, but calls the
192 /// @brief two member calculators and then processes the information out of the two of them
193 void
195 {
196 
199 
200  if( this_pose.total_residue() != residue_bur_unsat_polars_.size() ){
201  residue_bur_unsat_polars_.resize( this_pose.total_residue() );
202  atom_bur_unsat_.resize( this_pose.total_residue() );
203  }
204 
205  basic::MetricValue< id::AtomID_Map< Real > > atom_sasa;
206  basic::MetricValue< id::AtomID_Map< Size > > atom_hbonds;
207 
208 
209 
210  this_pose.metric( name_of_hbond_calc_, "atom_Hbonds", atom_hbonds );
211  this_pose.metric( name_of_sasa_calc_, "atom_sasa", atom_sasa);
212 
213  for( Size i = 1; i <= this_pose.total_residue(); ++i){
214 
216 
217  conformation::Residue const & rsd = this_pose.residue( i );
218 
219  //utility::vector1< Real > const & atom_sasas_this_res = atom_sasa.value()[ i ];
220  //utility::vector1< Size > const & atom_hbonds_this_res = atom_hbonds.value()[ i ];
221 
222  for( Size at = 1; at <= rsd.nheavyatoms(); ++at){
223 
224  core::id::AtomID atid( at, i );
225  bool this_atom_bur_unsat(false);
226 
227  if( rsd.atom_type( at ).is_acceptor() || rsd.atom_type( at ).is_donor() ){
228  //we have to add up the sasas for the H attached to this atom
229  Real cursasa = atom_sasa.value()[ atid ];
230  for( Size hcount = rsd.type().attached_H_begin( at ); hcount<= rsd.type().attached_H_end( at ); hcount++){
231  cursasa = cursasa + atom_sasa.value()[ core::id::AtomID ( hcount, i ) ];
232  }
233 
234  if( cursasa < burial_sasa_cutoff_ ){
235  Size satisfac_cut = satisfaction_cutoff( rsd.type().atom_type( at ).name() );
236  Size bonded_heavyatoms = rsd.n_bonded_neighbor_all_res( at ) - rsd.type().number_bonded_hydrogens( at );
237  if( ( bonded_heavyatoms + atom_hbonds.value()[ atid ] ) < satisfac_cut ){
238 
239  //TR << rsd.type().atom_name( at ) << " of res " << i << " has " << atom_sasa.value()[atid] << " sasa and " << cursasa << " combined sasa, and " << bonded_heavyatoms << " bonded heavyatoms, and " << atom_hbonds.value()[ atid ] << " hbonds, counts as buried unsatisfied." << std::endl;
240 
243  this_atom_bur_unsat = true;
244 
246  }
247  }
248  }
249  atom_bur_unsat_.set( atid, this_atom_bur_unsat );
250  }
251  }
252 
253 
254 } //recompute
255 
258 {
259 
260  //according to jk, buried hydroxyls are often seen making only one hydrogen bond. also, ether oxygens often are bad h-bond acceptors
261  if( atom_type == "OH" ) return 2;
262 
263  //backbone oxygens also only have one h-bbond in most secondary structure elements
264  else if (atom_type == "OCbb") return 2;
265 
266  else if( atom_type == "S") return 2;
267 
268  //everything else we expect to have 3 bonded/h-bonded neighbours to count as satisfied
269  else return 3;
270 
271 
272 }
273 
274 } //namespace pose_metric_calculators
275 } //namespace toolbox
276 } //namespace protocols