Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
InterfaceNeighborDefinitionCalculator.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 core/pose/metrics/simple_calculators/InterfaceNeighborDefinitionCalculator.cc
11 /// @brief
12 /// @author John Karanicolas
13 
14 // Unit headers
16 #include <core/pose/Pose.hh>
19 
20 // Utility headers
21 #include <basic/MetricValue.hh>
22 #include <basic/Tracer.hh>
23 #include <utility/exit.hh>
24 #include <utility/string_util.hh>
25 #include <basic/options/option.hh>
26 
27 #include <cassert>
28 
29 // option key includes
30 
31 #include <basic/options/keys/pose_metrics.OptionKeys.gen.hh>
32 
35 #include <utility/vector1.hh>
36 
37 
38 
39 
40 using namespace core;
41 using namespace core::pose;
42 using namespace core::pose::metrics;
43 
44 namespace core{
45 namespace pose {
46 namespace metrics {
47 namespace simple_calculators {
48 
49 
50 void InterfaceNeighborDefinitionCalculator::lookup( std::string const & key, basic::MetricValueBase * valptr ) const {
51 
52  if ( key == "list_interface" ) {
53  basic::check_cast( valptr, &list_interface_, "list_interface expects to return a std::pair< utility::vector1<Size>, utility::vector1<Size> >" );
54  (static_cast<basic::MetricValue<std::pair< utility::vector1<Size>, utility::vector1<Size> > > *>(valptr))->set( list_interface_ );
55 
56  } else if ( key == "interface_residues" ) {
57  basic::check_cast( valptr, &interface_residues_, "interface_residues expects to return a std::set< Size >" );
58  (static_cast<basic::MetricValue<std::set<Size> > *>(valptr))->set( interface_residues_ );
59 
60  } else if ( key == "first_chain_interface_residues" ) {
61  basic::check_cast( valptr, &chain1_interface_residues_, "first_chain_interface_residues expects to return a std::set< Size >" );
62  (static_cast<basic::MetricValue<std::set<Size> > *>(valptr))->set( chain1_interface_residues_ );
63 
64  } else if ( key == "second_chain_interface_residues" ) {
65  basic::check_cast( valptr, &chain2_interface_residues_, "second_chain_interface_residues expects to return a std::set< Size >" );
66  (static_cast<basic::MetricValue<std::set<Size> > *>(valptr))->set( chain2_interface_residues_ );
67 
68  } else if ( key == "num_interface_residues" ) {
69  basic::check_cast( valptr, &num_interface_residues_, "num_interface_residues expects to return a Size" );
70  (static_cast<basic::MetricValue<Size> *>(valptr))->set( num_interface_residues_ );
71 
72  } else if ( key == "num_first_chain_interface_residues" ) {
73  basic::check_cast( valptr, &num_chain1_interface_residues_, "num_first_chain_interface_residues expects to return a Size" );
74  (static_cast<basic::MetricValue<Size> *>(valptr))->set( num_chain1_interface_residues_ );
75 
76  } else if ( key == "num_second_chain_interface_residues" ) {
77  basic::check_cast( valptr, &num_chain2_interface_residues_, "num_second_chain_interface_residues expects to return a Size" );
78  (static_cast<basic::MetricValue<Size> *>(valptr))->set( num_chain2_interface_residues_ );
79 
80  } else if ( key == "first_chain_first_resnum" ) {
81  basic::check_cast( valptr, &ch1_begin_num_, "first_chain_first_resnum expects to return a Size" );
82  (static_cast<basic::MetricValue<Size> *>(valptr))->set( ch1_begin_num_ );
83 
84  } else if ( key == "first_chain_last_resnum" ) {
85  basic::check_cast( valptr, &ch1_end_num_, "first_chain_last_resnum expects to return a Size" );
86  (static_cast<basic::MetricValue<Size> *>(valptr))->set( ch1_end_num_ );
87 
88  } else if ( key == "second_chain_first_resnum" ) {
89  basic::check_cast( valptr, &ch2_begin_num_, "second_chain_first_resnum expects to return a Size" );
90  (static_cast<basic::MetricValue<Size> *>(valptr))->set( ch2_begin_num_ );
91 
92  } else if ( key == "second_chain_last_resnum" ) {
93  basic::check_cast( valptr, &ch2_end_num_, "second_chain_first_resnum expects to return a Size" );
94  (static_cast<basic::MetricValue<Size> *>(valptr))->set( ch2_end_num_ );
95 
96  } else {
97  basic::Error() << "This Calculator cannot compute metric " << key << std::endl;
98  utility_exit();
99  }
100 
101 }
102 
103 
104 std::string InterfaceNeighborDefinitionCalculator::print( std::string const & key ) const {
105 
106  if ( key == "list_interface" ) {
107  basic::Error() << "No output operator, for metric " << key << std::endl;
108  utility_exit();
109  } else if ( key == "interface_residues" ) {
110  basic::Error() << "No output operator, for metric " << key << std::endl;
111  utility_exit();
112  } else if ( key == "first_chain_interface_residues" ) {
113  basic::Error() << "No output operator, for metric " << key << std::endl;
114  utility_exit();
115  } else if ( key == "second_chain_interface_residues" ) {
116  basic::Error() << "No output operator, for metric " << key << std::endl;
117  utility_exit();
118  } else if ( key == "num_interface_residues" ) {
119  return utility::to_string( num_interface_residues_ );
120  } else if ( key == "num_first_chain_interface_residues" ) {
121  return utility::to_string( num_chain1_interface_residues_ );
122  } else if ( key == "num_second_chain_interface_residues" ) {
123  return utility::to_string( num_chain2_interface_residues_ );
124  } else if ( key == "first_chain_first_resnum" ) {
125  return utility::to_string( ch1_begin_num_ );
126  } else if ( key == "first_chain_last_resnum" ) {
127  return utility::to_string( ch1_end_num_ );
128  } else if ( key == "second_chain_first_resnum" ) {
129  return utility::to_string( ch2_begin_num_ );
130  } else if ( key == "second_chain_last_resnum" ) {
131  return utility::to_string( ch2_end_num_ );
132  }
133 
134  basic::Error() << "This Calculator cannot compute metric " << key << std::endl;
135  utility_exit();
136  return "";
137 
138 }
139 
140 
141 void InterfaceNeighborDefinitionCalculator::recompute( Pose const & this_pose ) {
142 
143  verify_chain_setup( this_pose );
144 
145  Length const distcut(basic::options::option[basic::options::OptionKeys::pose_metrics::interface_cutoff].value());
146 
147  interface_residues_.clear();
148  chain1_interface_residues_.clear();
149  chain2_interface_residues_.clear();
150 
153  core::conformation::find_neighbors<core::conformation::PointGraphVertexData,core::conformation::PointGraphEdgeData>( pg, distcut );
154 
155  // for all nodes in chain1 == for all residues in chain 1
156  utility::vector1< Size > chain1_interface, chain2_interface;
157  for ( Size partner1_res = ch1_begin_num_; partner1_res <= ch1_end_num_; ++partner1_res ) {
158  for ( conformation::PointGraph::UpperEdgeListConstIter edge_iter = pg->get_vertex( partner1_res ).upper_edge_list_begin(),
159  edge_end_iter = pg->get_vertex( partner1_res ).upper_edge_list_end(); edge_iter != edge_end_iter; ++edge_iter ) {
160 
161  // get node on other edge of that node == 2nd residue index
162  Size const partner2_res = edge_iter->upper_vertex();
163 
164  // if that node(residue) is in chain 2
165  if ( ( partner2_res >= ch2_begin_num_ ) && (partner2_res <= ch2_end_num_ ) ) {
166  interface_residues_.insert( partner1_res );
167  chain1_interface_residues_.insert( partner1_res );
168  interface_residues_.insert( partner2_res );
169  chain2_interface_residues_.insert( partner2_res );
170  chain1_interface.push_back( partner1_res ); // add partner1 residue
171  chain2_interface.push_back( partner2_res ); // add partner2 residue
172  }
173  else continue;
174 
175  } // end - for all edges of node
176  } // end - for all nodes in chain1
177  list_interface_ = std::make_pair( chain1_interface, chain2_interface ); // populate list_interface
178 
179  num_interface_residues_ = interface_residues_.size();
180  num_chain1_interface_residues_ = chain1_interface_residues_.size();
181  num_chain2_interface_residues_ = chain2_interface_residues_.size();
182 
183 }
184 
185 } // simple_calculators
186 } // metrics
187 } // pose
188 } // core