Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TenANeighborGraph.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/scoring/TenANeighborGraph.cc
11 /// @brief Neighbor graph to represent for each residue the number of other residues within 10 Angstroms
12 /// @author Andrew Leaver-Fay (leaverfa@email.unc.edu)
13 
14 // Unit Headers
16 
17 // Boost Headers
19 
20 #include <utility/vector1.hh>
21 #include <boost/pool/pool.hpp>
22 
23 
24 
25 namespace core {
26 namespace scoring {
27 
28 ///////////////////////////////
29 // class TenANeighborNode ///
30 ///////////////////////////////
31 
33 
35 :
36  parent( owner, node_id ),
37  neighbor_mass_( 1.0 ), // Default -- 1 neighbor mass unit
38  sum_of_neighbors_masses_( 0.0 ),
39  since_last_sonm_update_( 0 )
40 {}
41 
42 void
44 {
45  assert( dynamic_cast< TenANeighborNode const * > (source) );
46  TenANeighborNode const * tAsource( static_cast< TenANeighborNode const * > (source) );
47  neighbor_mass_ = tAsource->neighbor_mass_;
50 }
51 
52 /// @details triggers update of the neighbor mass sums for this nodes' neighbors
53 void
55  neighbor_mass_ = mass;
57  eiter_end = const_edge_list_end(); eiter != eiter_end; ++eiter ) {
58  TenANeighborNode const * tenaneighb =
59  static_cast< TenANeighborNode const * > ((*eiter)->get_other_node( get_node_index() ));
60  tenaneighb->update_neighbor_mass_sum();
61  }
62 }
63 
64 
65 Size
67  return sizeof( TenANeighborNode );
68 }
69 
70 
71 Size
74 }
75 
76 void
78 {
79  using namespace graph;
82  eiter_end = const_edge_list_end(); eiter != eiter_end; ++eiter ) {
83  TenANeighborNode const * tenaneighb =
84  static_cast< TenANeighborNode const * > ((*eiter)->get_other_node( get_node_index() ));
86  }
88 }
89 
90 
91 ///////////////////////////////
92 // class TenANeighborEdge ///
93 ///////////////////////////////
94 
96 {
97  get_TenANode( 0 )->subtract_neighbors_mass( get_TenANode( 1 )->neighbor_mass() );
98  get_TenANode( 1 )->subtract_neighbors_mass( get_TenANode( 0 )->neighbor_mass() );
99 }
100 
102  graph::Graph* owner,
103  Size first_node_ind,
104  Size second_node_ind )
105 :
106  parent( owner, first_node_ind, second_node_ind )
107 {
108  get_TenANode( 0 )->add_neighbors_mass( get_TenANode( 1 )->neighbor_mass() );
109  get_TenANode( 1 )->add_neighbors_mass( get_TenANode( 0 )->neighbor_mass() );
110 }
111 
112 void TenANeighborEdge::copy_from( Edge const * /*source*/ )
113 {
114  //assert( dynamic_cast< TenNeighborEdge const * > ( source ) );
115 }
116 
118 {
119  return sizeof( TenANeighborEdge );
120 }
121 
123 {
125 }
126 
127 ///////////////////////////////
128 // class TenANeighborGraph ///
129 ///////////////////////////////
130 
131 Distance const TenANeighborGraph::tenA_( 10.0 );
133 
135 
137 :
138  parent(),
139  tenA_edge_pool_( new boost::unordered_object_pool< TenANeighborEdge > ( 256 ) )
140 {}
141 
143 :
144  parent(),
145  tenA_edge_pool_( new boost::unordered_object_pool< TenANeighborEdge > ( 256 ) )
146 {
147  set_num_nodes( num_nodes );
148 }
149 
151 :
152  parent(),
153  tenA_edge_pool_( new boost::unordered_object_pool< TenANeighborEdge > ( 256 ) )
154 {
155  parent::operator = ( source );
156 }
157 
158 
161 {
162  return static_cast< TenANeighborGraph & > (parent::operator = ( source ));
163 }
164 
165 Distance
167 {
168  return tenA_;
169 }
170 
171 void
173  Size lower_node_id,
174  Size upper_node_id,
175  DistanceSquared dsq
176 )
177 {
178  if ( dsq < tenA_squared_ ) add_edge( lower_node_id, upper_node_id );
179 }
180 
183 {
184  return new TenANeighborGraph( *this );
185 }
186 
187 void
189  pose::Pose const & /*pose*/
190 )
191 {}
192 
194 {
195  //delete edge;
196  assert( dynamic_cast< TenANeighborEdge* > (edge) );
197  tenA_edge_pool_->destroy( static_cast< TenANeighborEdge* > (edge) );
198 
199 }
200 
201 Size
203  return sizeof ( TenANeighborGraph );
204 }
205 
206 Size
209 }
210 
213  return new TenANeighborNode( this, node_index );
214 }
215 
218 {
219  return tenA_edge_pool_->construct( this, index1, index2 );
220 }
221 
224 {
225  return tenA_edge_pool_->construct(
226  this,
227  example_edge->get_first_node_ind(),
228  example_edge->get_second_node_ind()
229  );
230 }
231 
232 
233 } // scoring
234 } // core
235