Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SurfaceCalculator.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/PoseMetricCalculators/SurfaceCalculator.cc
11 /// @brief A class which will keep track of surface energy as a Pose metric
12 /// @author Ron Jacak
13 
14 // Unit headers
17 #include <basic/MetricValue.hh>
18 #include <core/pose/Pose.hh>
21 
22 // Utility headers
23 #include <basic/Tracer.hh>
24 #include <utility/exit.hh>
25 #include <utility/string_util.hh>
26 
27 #include <ObjexxFCL/format.hh>
28 
29 #include <cassert>
30 #include <iostream>
31 #include <sstream>
32 
33 #include <utility/vector1.hh>
34 
35 
36 using namespace core;
37 
38 namespace protocols {
39 namespace toolbox {
40 namespace pose_metric_calculators {
41 
42 SurfaceCalculator::SurfaceCalculator( bool remove_nonprotein_res )
43  : total_surface_energy_(0.0), remove_nonprotein_res_(remove_nonprotein_res )
44 {}
45 
47 
48 void
49 SurfaceCalculator::lookup( std::string const & key, basic::MetricValueBase* valptr ) const {
50 
51  if ( key == "total_surface" ) {
52  basic::check_cast( valptr, &total_surface_energy_, "total_surface expects to return a Real" );
53  (static_cast<basic::MetricValue<Real> *>(valptr))->set( total_surface_energy_ );
54 
55  } else if ( key == "residue_surface" ) {
56  basic::check_cast( valptr, &residue_surface_energy_, "residue_surface expects to return a utility::vector1< Real >" );
57  (static_cast<basic::MetricValue<utility::vector1<Real > > *>(valptr) )->set( residue_surface_energy_ );
58 
59  } else {
60  basic::Error() << "This Calculator cannot compute metric " << key << std::endl;
61  utility_exit();
62  }
63 
64 }
65 
66 
68 SurfaceCalculator::print( std::string const & key ) const {
69 
70  if ( key == "total_surface" ) {
71  std::ostringstream ss;
72  ss << utility::to_string( total_surface_energy_ ) << " (UNWEIGHTED)";
73  return ss.str();
74  //return utility::to_string( total_surface_energy_ );
75 
76  } else if ( key == "residue_surface" ) {
77  std::ostringstream ss;
78  ss << "[";
79  for ( Size ii=1; ii < residue_surface_energy_.size(); ++ii ) {
80  ss << ii << ":";
81  if ( residue_surface_energy_[ ii ] != 0.00 )
82  ss << ObjexxFCL::fmt::F(8,4, residue_surface_energy_[ ii ]);
83  else
84  ss << "---";
85  ss << ", ";
86  }
87  ss << "] (UNWEIGHTED)";
88  return ss.str();
89  //return utility::to_string( residue_surface_energy_ );
90  }
91 
92  basic::Error() << "This Calculator cannot compute metric " << key << std::endl;
93  return "";
94 
95 }
96 
97 
98 void
100 
101  // use the SurfacePotential class to recompute the surface energy
102  if ( !remove_nonprotein_res_ ) {
103  pack::interaction_graph::SurfacePotential::get_instance()->compute_pose_surface_energy( this_pose, total_surface_energy_, residue_surface_energy_ );
104 
105  } else {
106  bool has_nonprot_res(false);
107  for ( core::Size i = 1; i <= this_pose.total_residue(); ++i) {
108  if ( ! this_pose.residue_type(i).is_protein() ) {
109  has_nonprot_res = true;
110  break;
111  }
112  }
113  if ( has_nonprot_res ) {
114  core::pose::PoseOP pureprotpose = new core::pose::Pose( this_pose );
116  pureprotpose->update_residue_neighbors();
117  pack::interaction_graph::SurfacePotential::get_instance()->compute_pose_surface_energy( *pureprotpose, total_surface_energy_, residue_surface_energy_ );
118  } else {
119  pack::interaction_graph::SurfacePotential::get_instance()->compute_pose_surface_energy( this_pose, total_surface_energy_, residue_surface_energy_ );
120  }
121  }
122 }
123 
124 
125 } // PoseMetricCalculators
126 } // toolbox
127 } // protocols
128