Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ChargeCalculator.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 protocols/toolbox/PoseMetricCalculator/ChargeCalculator.cc
11 /// @brief calculator to compute nonlocal/tertiary contacts in a given pose
12 /// @author Florian Richter
13 
14 // Unit headers
16 
17 //#include <core/pose/metrics/CalculatorFactory.hh>
18 #include <core/chemical/AA.hh>
20 #include <core/pose/Pose.hh>
21 
22 // Utility headers
23 //#include <core/util/Tracer.hh>
24 #include <utility/exit.hh>
25 // AUTO-REMOVED #include <utility/string_util.hh>
26 #include <basic/MetricValue.hh>
27 
28 
29 #include <cassert>
30 
31 #include <utility/vector1.hh>
32 
33 
34 
35 using namespace core;
36 using namespace core::pose;
37 using namespace core::pose::metrics;
38 
39 
40 namespace protocols{
41 namespace toolbox {
42 namespace pose_metric_calculators {
43 
44 ChargeCalculator::ChargeCalculator()
45 : total_charge_(0.0), total_pos_charges_(0),
46  total_neg_charges_(0), SR_total_charge_(0.0),
47  SR_total_pos_charges_(0), SR_total_neg_charges_(0)
48 {}
49 
51  std::set< core::Size > const & special_region
52 ) : total_charge_(0.0), total_pos_charges_(0),
53  total_neg_charges_(0), SR_total_charge_(0.0),
54  SR_total_pos_charges_(0), SR_total_neg_charges_(0),
55  special_region_(special_region)
56 {}
57 
58 
60 
61 
62 void
64  std::string const & key,
65  basic::MetricValueBase * valptr
66 ) const
67 {
68 
69  if ( key == "total_charge" ) {
70  basic::check_cast( valptr, &total_charge_, "total_charge expects to return a Real" );
71  (static_cast<basic::MetricValue<Real> *>(valptr))->set( total_charge_ );
72 
73  } else if ( key == "total_pos_charges" ) {
74  basic::check_cast( valptr, &total_pos_charges_, "total_pos_charges expects to return a Size" );
75  (static_cast<basic::MetricValue<Size> *>(valptr))->set( total_pos_charges_ );
76 
77  } else if ( key == "total_neg_charges" ) {
78  basic::check_cast( valptr, &total_neg_charges_, "total_neg_charges expects to return a Size" );
79  (static_cast<basic::MetricValue<Size> *>(valptr))->set( total_neg_charges_ );
80 
81  } else if ( key == "SR_total_charge" ) {
82  basic::check_cast( valptr, &SR_total_charge_, "SR_total_charge expects to return a Real" );
83  (static_cast<basic::MetricValue<Real> *>(valptr))->set( SR_total_charge_ );
84 
85  } else if ( key == "SR_total_pos_charges" ) {
86  basic::check_cast( valptr, &SR_total_pos_charges_, "SR_total_pos_charges expects to return a Size" );
87  (static_cast<basic::MetricValue<Size> *>(valptr))->set( SR_total_pos_charges_ );
88 
89  } else if ( key == "SR_total_neg_charges" ) {
90  basic::check_cast( valptr, &SR_total_neg_charges_, "SR_total_neg_charges expects to return a Size" );
91  (static_cast<basic::MetricValue<Size> *>(valptr))->set( SR_total_neg_charges_ );
92  }
93 
94  else {
95  basic::Error() << "ChargeCalculator cannot compute the requested metric " << key << std::endl;
96  utility_exit();
97  }
98 
99 } //lookup
100 
101 
102 
105 {
106 
107 
108  basic::Error() << "ChargeCalculator print function not written yet, developer too lazy, cannot compute metric " << key << std::endl;
109  utility_exit();
110  return "";
111 
112 } //print
113 
114 
115 /// @brief simple: go through sequence and figure out how many charged residue
116 /// there are. Note: code in here doesn't check for (de)protonated residue types
117 /// at the moment.
118 void
119 ChargeCalculator::recompute( Pose const & this_pose )
120 {
121  using namespace core::chemical;
122 
125 
126 
127  for( core::Size i = 1; i <= this_pose.total_residue(); ++i ){
128  if( !this_pose.residue_type(i).is_protein() ) continue;
129  AA i_aa( this_pose.residue_type(i).aa() );
130 
131  if( (i_aa == aa_glu) || (i_aa == aa_asp) ){
132  total_charge_ -= 1.0;
134  if( special_region_.find( i ) != special_region_.end() ){
135  SR_total_charge_ -= 1.0;
137  }
138  }
139  else if( (i_aa == aa_arg) || (i_aa == aa_lys) ){
140  total_charge_ += 1.0;
142  if( special_region_.find( i ) != special_region_.end() ){
143  SR_total_charge_ += 1.0;
145  }
146  }
147 
148  } //loop over residues
149 } //recompute
150 
151 
152 } //namespace PoseMetricCalculators
153 } //namespace toolbox
154 } //namespace protocols