Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HPatchCalculator.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 the SASA-based hpatch score of a Pose object
12 /// @author Ron Jacak
13 
14 // Unit headers
17 
19 #include <core/pose/Pose.hh>
21 #include <basic/MetricValue.hh>
22 #include <basic/Tracer.hh>
23 
24 // Utility headers
25 #include <utility/exit.hh>
26 #include <utility/string_util.hh>
27 
28 // AUTO-REMOVED #include <ObjexxFCL/format.hh>
29 
30 #include <cassert>
31 #include <iostream>
32 #include <sstream>
33 
34 #include <core/id/AtomID.hh>
35 #include <utility/vector1.hh>
36 
37 
38 using namespace core;
39 
40 namespace protocols {
41 namespace toolbox {
42 namespace pose_metric_calculators {
43 
44 HPatchCalculator::HPatchCalculator( bool remove_nonprotein_res )
45  : total_hpatch_score_(0.0), remove_nonprotein_res_(remove_nonprotein_res )
46 {}
47 
49 
50 void
51 HPatchCalculator::lookup( std::string const & key, basic::MetricValueBase* valptr ) const {
52 
53  if ( key == "total_hpatch" ) {
54  basic::check_cast( valptr, &total_hpatch_score_, "total_hpatch expects to return a Real" );
55  (static_cast<basic::MetricValue<Real> *>(valptr))->set( total_hpatch_score_ );
56 
57  } else if ( key == "patch_scores" ) {
58  basic::check_cast( valptr, &patch_scores_, "patch_scores expects to return a std::map< Size, Real >" );
59  (static_cast<basic::MetricValue<std::map< Size, std::pair< Real, Real > > > *>(valptr) )->set( patch_scores_ );
60 
61  } else if ( key == "atoms_in_patches" ) {
62  basic::check_cast( valptr, &atoms_in_patches_, "atoms_in_patches expects to return a std::map< Size, utility::vector1< id::AtomID > >" );
63  (static_cast<basic::MetricValue< std::map< Size, utility::vector1< id::AtomID > > > *>(valptr) )->set( atoms_in_patches_ );
64 
65  } else {
66  basic::Error() << "This Calculator cannot compute metric " << key << std::endl;
67  utility_exit();
68  }
69 
70 }
71 
72 
74 HPatchCalculator::print( std::string const & key ) const {
75 
76  if ( key == "total_hpatch" ) {
77  std::ostringstream ss;
78  ss << utility::to_string( total_hpatch_score_ ) << " (UNWEIGHTED)";
79  return ss.str();
80  //return utility::to_string( total_hpatch_score_ );
81 
82  }
83 
84  basic::Error() << "This Calculator cannot compute metric " << key << std::endl;
85  return "";
86 
87 }
88 
89 
90 void
92 
93  // use the SurfacePotential class to recompute the hpatch score
95  pack::interaction_graph::SurfacePotential::get_instance()->compute_pose_hpatch_score( this_pose, total_hpatch_score_, patch_scores_, atoms_in_patches_ );
96 
97  } else {
98  // iterate over all residues to see if this pose has any non-protein residues
99  bool has_nonprot_res(false);
100  for ( core::Size ii = 1; ii <= this_pose.total_residue(); ++ii ) {
101  if ( ! this_pose.residue_type(ii).is_protein() ) {
102  has_nonprot_res = true;
103  break;
104  }
105  }
106  if ( has_nonprot_res ) {
107  core::pose::PoseOP pureprotpose = new core::pose::Pose( this_pose );
109  pack::interaction_graph::SurfacePotential::get_instance()->compute_pose_hpatch_score( *pureprotpose, total_hpatch_score_, patch_scores_, atoms_in_patches_ );
110 
111  } else {
112  pack::interaction_graph::SurfacePotential::get_instance()->compute_pose_hpatch_score( this_pose, total_hpatch_score_, patch_scores_, atoms_in_patches_ );
113  }
114  }
115 }
116 
117 
118 } // PoseMetricCalculators
119 } // toolbox
120 } // protocols
121