20 #include <basic/MetricValue.hh>
29 #include <basic/options/option.hh>
32 #include <basic/Tracer.hh>
33 #include <utility/exit.hh>
34 #include <utility/string_util.hh>
37 #include <basic/options/keys/packing.OptionKeys.gen.hh>
38 #include <basic/options/keys/pose_metrics.OptionKeys.gen.hh>
40 static basic::Tracer
TR(
"protocols.toolbox.PoseMetricCalculators.NeighborhoodByDistanceCalculator");
46 namespace pose_metric_calculators {
50 :
parent(), central_residues_(central_residues), dist_cutoff_ ( basic::options::option[basic::options::OptionKeys::pose_metrics::neighbor_by_distance_cutoff] ), num_neighbors_(0)
57 :
parent(), central_residues_(central_residues), dist_cutoff_(dist_cutoff), num_neighbors_(0)
70 basic::MetricValueBase * valptr
75 if ( key ==
"central_residues" ) {
76 basic::check_cast( valptr, &
central_residues_,
"central_residues expects to return a std::set< core::Size >" );
77 (
static_cast<basic::MetricValue< std::set< core::Size >
>* > (valptr))->set(
central_residues_ );
79 }
else if ( key ==
"dist_cutoff" ) {
80 basic::check_cast( valptr, &
dist_cutoff_,
"dist_cutoff expects to return a core::Real" );
81 (
static_cast<basic::MetricValue<core::Real> *
>(valptr))->set(
dist_cutoff_ );
83 }
else if ( key ==
"num_neighbors" ) {
84 basic::check_cast( valptr, &
num_neighbors_,
"num_neighbors expects to return a core::Size" );
85 (
static_cast<basic::MetricValue<core::Size> *
>(valptr))->set(
num_neighbors_ );
86 }
else if ( key ==
"num_neighbors_map" ) {
87 basic::check_cast( valptr, &
num_neighbors_map_,
"num_neighbors_map expects to return a std::map<Size, Size>");
88 (
static_cast<basic::MetricValue< std::map< core::Size, core::Size >
> *>(valptr))->set(
num_neighbors_map_);
89 }
else if ( key ==
"neighbors" ) {
90 basic::check_cast( valptr, &
neighbors_,
"neighbors expects to return a std::set< core::Size >" );
91 (
static_cast<basic::MetricValue< std::set< core::Size >
> *>(valptr))->set(
neighbors_ );
94 basic::Error() <<
"NeighborhoodByDistanceCalculator cannot compute metric " << key << std::endl;
103 using namespace basic::options;
104 if ( key ==
"central_residues" ) {
105 std::string const spacer( option[ OptionKeys::packing::print_pymol_selection].value() ?
"+" :
" ");
108 res_string += utility::to_string(*it) + spacer;
111 }
else if ( key ==
"dist_cutoff" ) {
114 }
else if ( key ==
"num_neighbors" ) {
117 }
else if ( key ==
"num_neighbors_map" ) {
120 map_string += utility::to_string(it->first) +
":" + utility::to_string(it->second) +
" ";
123 }
else if ( key ==
"neighbors" ) {
124 using namespace basic::options;
125 std::string const spacer( option[ OptionKeys::packing::print_pymol_selection].value() ?
"+" :
" ");
128 nbrs_string += utility::to_string(*it) + spacer;
132 basic::Error() <<
"NeighborhoodByDistanceCalculator cannot compute metric " << key << std::endl;
151 core::conformation::find_neighbors<core::conformation::PointGraphVertexData,core::conformation::PointGraphEdgeData>( pg,
dist_cutoff_ );
152 runtime_assert(nres == pg->num_vertices());
158 edge_end_iter = pg->get_vertex(r).upper_edge_list_end(); edge_iter != edge_end_iter; ++edge_iter ) {
159 neighborgraph.add_edge(r, edge_iter->upper_vertex());
162 runtime_assert(nres == neighborgraph.num_nodes());
163 runtime_assert(pg->num_edges() == neighborgraph.num_edges());
172 edge_iter != edge_end_iter; ++edge_iter ) {
174 neighbors_.insert((*edge_iter)->get_other_ind(*it));