Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CatPiCalculator.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 CatPiCalculator
11 ///
12 /// @brief
13 /// How many cation-pi interactions are there?
14 ///
15 /// @detailed
16 /// Not much detailed here. Iterate through the carbons of aromatic rings and compare that to
17 /// the distance of the polar hydrogens in basic residues...histidine not considered. 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 cat_pi_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( "cat_pi_metric", cat_pi_calculator );
23 /// To actually get the metric, you have to print it. For example:
24 /// core::pose::Pose pose;
25 /// pose.print_metric("cat_pi_metric", "cat_pi")
26 /// Where cat_pi_metric is the name that it is registered under and "cat_pi" 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.CatPiCalculator");
50 
51 namespace protocols{
52 namespace toolbox {
53 namespace pose_metric_calculators {
54 
55 
56  ///@brief default constructor sets distance_cutoff to 5.0. This is what is usually defined as a Hbond between heavy atom (carbon) and Hydrogen
58  distance_cutoff_(5.0),
59  cat_pi_total_(0)
60  {
61 
62  }
63 
64 
65  ///@brief constructur where you define what the distance cutoff is for the pi pi
67  distance_cutoff_(dist_cutoff),
68  cat_pi_total_(0)
69  {
70 
71  }
72 
73 
74 
75 
76 
77 void CatPiCalculator::lookup( std::string const & key, basic::MetricValueBase * valptr ) const{
78  if ( key == "cat_pi" ) {
79  basic::check_cast( valptr, &cat_pi_total_, "cat_pi expects to return a Size" );
80  (static_cast<basic::MetricValue<core::Size> *>(valptr))->set( cat_pi_total_ );
81 
82  }else {
83  basic::Error() << "CatPiCalculator cannot compute the requested metric " << key << std::endl;
84  utility_exit();
85  }
86 }
87 
88 
90  if(key == "cat_pi"){
91  return utility::to_string(cat_pi_total_);
92  }
93  basic::Error() << "CatPiCalculator 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  cat_pi_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() == "TYR" || acceptor.name3() =="PHE" || acceptor.name3() == "TRP"){
110  for(core::Size res_num2=1; res_num2 <= pose.n_residue(); ++res_num2){
111  if(res_num1 == res_num2) continue;//stop from counting same residues as a pair
112  core::conformation::Residue donate(pose.residue(res_num2));
113  //only continue if this residue is a his, lys or arg
114  if(donate.name3() == "ARG" || donate.name3() == "LYS" ){
115  //set up a flag that will stop us from double counting salt bridges
116  bool get_out_of_loop=false;
117  //start iteration through acceptor heavy atoms.
118  for (
119  core::Size acc_atm = acceptor.first_sidechain_atom();
120  acc_atm != acceptor.nheavyatoms();
121  ++acc_atm
122  )
123  {
124 
125  if(acceptor.atom_name(acc_atm) == " CB ") continue; //not interested in the cb atom
126  for
127  (
128  core::chemical::AtomIndices::const_iterator
129  don_num = donate.Hpos_polar_sc().begin(),
130  don_nume = donate.Hpos_polar_sc().end();
131  don_num != don_nume; ++don_num
132  ){
133  core::Size const don_atm(*don_num);
134 
135  //get the distance between the donor residue and polar hydrogen sidechain
136  core::Real distance(acceptor.xyz(acc_atm).distance(donate.xyz(don_atm)) );
137 
138  if(get_out_of_loop ==false && distance < distance_cutoff_){
139  ++cat_pi_total_;
140  get_out_of_loop=true;
141  }
142 
143  }
144 
145 
146  }
147 
148 
149  }
150  }
151  }
152 
153  }
154 
155 
156 }
157 
158 
159 }
160 }
161 }