Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SaltBridgeCalculator.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 SaltBridgeCalculator
11 ///
12 /// @brief
13 /// How many salt bridge interactions are there?
14 ///
15 /// @detailed
16 /// Not much detailed here. Iterate through the oxygens of acidic residues and compare that to
17 /// the distance of the polar hydrogens in basic residues. Default distance is 3.2A.
18 /// Wait, you want to know how to use this? Well, within your protocol, you need to do the following:
19 /// First, create the calculator. To do this, see below:
20 /// core::pose::metrics::PoseMetricCalculatorOP sb_calculator = new protocols::toolbox::pose_metric_calculators::SaltBridgeCalculator();
21 /// Then you must register this so that the pose understands it. See below:
22 /// core::pose::metrics::CalculatorFactory::Instance().register_calculator( "sb_metric", sb_calculator );
23 /// To actually get the metric, you have to print it. For example:
24 /// core::pose::Pose pose;
25 /// pose.print_metric("sb_metric", "salt_bridge")
26 /// Where sb_metric is the name that it is registered under and "salt_bridge" is the key, seen below.
27 ///
28 ///
29 ///
30 /// @author
31 /// Steven Combs
32 ///
33 /// @last_modified October 22 2010
34 /////////////////////////////////////////////////////////////////////////
36 #include <core/pose/Pose.hh>
38 
39 // Utility headers
40 #include <basic/Tracer.hh>
41 #include <utility/exit.hh>
42 #include <utility/stream_util.hh>
43 #include <utility/string_util.hh>
44 #include <basic/MetricValue.hh>
45 
46 #include <utility/vector1.hh>
47 
48 
49 static basic::Tracer TR("protocols.toolbox.PoseMetricCalculators.SaltBridgeCalculator");
50 
51 namespace protocols{
52 namespace toolbox {
53 namespace pose_metric_calculators {
54 
55 
56  ///@brief default constructor sets distance_cutoff to 3.2. This is what is usually defined as a Hbond between heavy atom and Hydrogen
58  distance_cutoff_(3.2),
59  salt_bridge_total_(0)
60  {
61 
62  }
63 
64 
65  ///@brief constructur where you define what the distance cutoff is for the salt bridge
67  distance_cutoff_(dist_cutoff),
68  salt_bridge_total_(0)
69  {
70 
71  }
72 
73 
74 
75 
76 
77 void SaltBridgeCalculator::lookup( std::string const & key, basic::MetricValueBase * valptr ) const{
78  if ( key == "salt_bridge" ) {
79  basic::check_cast( valptr, &salt_bridge_total_, "salt_bridge expects to return a Size" );
80  (static_cast<basic::MetricValue<core::Size> *>(valptr))->set( salt_bridge_total_ );
81 
82  }else {
83  basic::Error() << "SaltBridgeCalculator cannot compute the requested metric " << key << std::endl;
84  utility_exit();
85  }
86 }
87 
88 
90  if(key == "salt_bridge"){
91  return utility::to_string(salt_bridge_total_);
92  }
93  basic::Error() << "SaltBridgeCalculator cannot compute metric " << key << std::endl;
94  utility_exit();
95  return "";
96 
97 }
98 
99 
100 
101 ///@brief not sure why they name this function recompute as you are actually computing the metric. Whateva
103  salt_bridge_total_ = 0;
104  //start iterating through the residues
105  for(core::Size res_num1=1; res_num1 <= pose.n_residue(); ++res_num1){
106  //assign the number to a residue based on the seqpos
107  core::conformation::Residue acceptor(pose.residue(res_num1));
108  //continue only if the residue is either aspartic or glutamic acid
109  if(acceptor.name3() == "ASP" || acceptor.name3() =="GLU"){
110  for(core::Size res_num2=1; res_num2 <= pose.n_residue(); ++res_num2){
111  core::conformation::Residue donate(pose.residue(res_num2));
112  //only continue if this residue is a his, lys or arg
113  if(donate.name3() == "HIS" || donate.name3() == "LYS" || donate.name3() =="ARG"){
114  //set up a flag that will stop us from double counting salt bridges
115  bool get_out_of_loop=false;
116  //start iteration through acceptor heavy atoms
117  for (
118  core::chemical::AtomIndices::const_iterator
119  anum = acceptor.accpt_pos().begin(),
120  anume = acceptor.accpt_pos().end(); anum != anume; ++anum )
121  {
122  core::Size const acc_atm( *anum );
123 
124 
125  for
126  (
127  core::chemical::AtomIndices::const_iterator
128  don_num = donate.Hpos_polar_sc().begin(),
129  don_nume = donate.Hpos_polar_sc().end();
130  don_num != don_nume; ++don_num
131  ){
132  core::Size const don_atm(*don_num);
133 
134  //get the distance between the donor residue and polar hydrogen sidechain
135  core::Real distance(acceptor.xyz(acc_atm).distance(donate.xyz(don_atm)) );
136 
137  if(get_out_of_loop ==false && distance < distance_cutoff_){
139  get_out_of_loop=true;
140  }
141 
142  }
143 
144 
145  }
146 
147 
148  }
149  }
150  }
151 
152  }
153 
154 
155 }
156 
157 
158 }
159 }
160 }