20 #include <basic/MetricValue.hh>
29 #include <basic/Tracer.hh>
30 #include <utility/exit.hh>
31 #include <utility/string_util.hh>
34 #include <basic/options/keys/packing.OptionKeys.gen.hh>
39 #include <utility/vector1.hh>
46 static basic::Tracer
TR(
"protocols.toolbox.PoseMetricCalculators.InterGroupNeighborsCalculator");
50 namespace pose_metric_calculators {
57 :
parent(), groups_(groups), dist_cutoff_(dist_cutoff), num_neighbors_(0)
62 :
parent(), groups_(calculator.groups()), dist_cutoff_(calculator.dist_cutoff())
73 basic::MetricValueBase * valptr
76 if ( key ==
"groups" ) {
77 basic::check_cast( valptr, &
groups_,
"groups expects to return a utility::vector1< std::pair< std::set< core::Size >, std::set< core::Size > > >" );
78 (
static_cast<basic::MetricValue<group_set> *
>(valptr))->set(
groups_ );
80 }
else if ( key ==
"dist_cutoff" ) {
81 basic::check_cast( valptr, &
dist_cutoff_,
"dist_cutoff expects to return a core::Real" );
82 (
static_cast<basic::MetricValue<core::Real> *
>(valptr))->set(
dist_cutoff_ );
84 }
else if ( key ==
"num_neighbors" ) {
85 basic::check_cast( valptr, &
num_neighbors_,
"num_neighbors expects to return a core::Size" );
86 (
static_cast<basic::MetricValue<core::Size> *
>(valptr))->set(
num_neighbors_ );
88 }
else if ( key ==
"neighbors" ) {
89 basic::check_cast( valptr, &
neighbors_,
"neighbors expects to return a std::set< core::Size >" );
90 (
static_cast<basic::MetricValue< std::set< core::Size >
> *>(valptr))->set(
neighbors_ );
93 basic::Error() <<
"InterGroupNeighborsCalculator cannot compute metric " << key << std::endl;
102 if ( key ==
"dist_cutoff" ) {
105 }
else if ( key ==
"num_neighbors" ) {
108 }
else if ( key ==
"groups" || key ==
"neighbors" ) {
110 using namespace basic::options;
111 std::string const spacer( option[ OptionKeys::packing::print_pymol_selection].value() ?
"+" :
" ");
114 if ( key ==
"groups" ) {
116 nbrs_string +=
"{ (";
117 for( one_group::const_iterator it(
groups_[i].first.begin()),
end(
groups_[i].first.end()); it !=
end; ++it)
118 nbrs_string += spacer + utility::to_string(*it);
119 nbrs_string +=
") ; (";
120 for( one_group::const_iterator it(
groups_[i].second.begin()),
end(
groups_[i].second.end()); it !=
end; ++it)
121 nbrs_string += spacer + utility::to_string(*it);
122 nbrs_string +=
") }";
125 }
else if ( key ==
"neighbors" ) {
127 nbrs_string += utility::to_string(*it) + spacer;
131 basic::Error() <<
"InterGroupNeighborsCalculator cannot compute metric " << key << std::endl;
149 core::conformation::find_neighbors<core::conformation::PointGraphVertexData,core::conformation::PointGraphEdgeData>( pg,
dist_cutoff_ );
150 runtime_assert(nres == pg->num_vertices());
156 edge_end_iter = pg->get_vertex(r).upper_edge_list_end(); edge_iter != edge_end_iter; ++edge_iter ) {
157 neighborgraph.add_edge(r, edge_iter->upper_vertex());
160 runtime_assert(nres == neighborgraph.num_nodes());
161 runtime_assert(pg->num_edges() == neighborgraph.num_edges());
167 for( one_group::const_iterator it(
groups_[i].first.begin()),
end(
groups_[i].first.end()); it !=
end; ++it){
171 edge_iter != edge_end_iter; ++edge_iter ) {
172 core::Size const other = (*edge_iter)->get_other_ind(*it);