Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
packer_neighbors.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/pack/packer_neighbors.cc
11 /// @brief creates a graph that describes the possible connectivity induced by designing-in larger side chains
12 /// @author Andrew Leaver-Fay (aleaverfay@gmail.com)
13 
14 // Unit Headers
16 
17 // Package Headers
20 
21 // Project Headers
24 #include <core/pose/Pose.hh>
25 #include <core/scoring/Energies.hh>
28 #include <core/graph/Graph.hh>
33 
34 // Utility Headers
35 #include <utility/vector1.functions.hh>
36 
39 #include <utility/vector1.hh>
40 
41 //Auto Headers
43 
44 namespace core {
45 namespace pack {
46 
47 
48 
49 /// @brief Constructs a graph where edges represent the possibility of interactions between
50 /// residue pairs
53  pose::Pose const & pose,
54  scoring::ScoreFunction const & scfxn,
56 )
57 {
58  utility::vector1< Distance > residue_radii = find_residue_max_radii( pose, task );
59 
60  return create_packer_graph( pose, scfxn, task, pose.total_residue(), residue_radii );
61 }
62 
63 /// @brief Constructs a graph where edges represent the possibility of interactions between
64 /// residue pairs
67  pose::Pose const & pose,
68  scoring::ScoreFunction const & scfxn,
70  core::Size total_nodes,
71  utility::vector1< Distance > const & residue_radii
72 )
73 {
74  using namespace graph;
75 
76  //GraphOP g = new Graph( pose.total_residue() );
77  GraphOP g = new Graph( total_nodes );
78 
79  if ( ! task->design_any() && ! pose.conformation().structure_moved() ) {
80  //if ( false ) {
81  g->copy_connectivity( pose.energies().energy_graph() );
82  } else {
83 
84  /// OK -- rewriting this function to be symmetry aware
86  if ( dynamic_cast< conformation::symmetry::SymmetricConformation const * > ( & pose.conformation() ) ) {
88  static_cast< conformation::symmetry::SymmetricConformation const & > ( pose.conformation() ));
89  symm_info = symmconf.Symmetry_Info();
90  }
91 
92  // find radii for residues... NOTE: flo oct 08, not anymore, doing this in above function now
93  //utility::vector1< Distance > residue_radii = find_residue_max_radii( pose, task );
94 
95  // find max radius
96  Distance const max_radius = utility::max( residue_radii );
97  Distance const atomic_itxn_dist = scfxn.info()->max_atomic_interaction_distance();
98 
99  // create point graph and detect neighbors
102  core::conformation::find_neighbors<core::conformation::PointGraphVertexData,core::conformation::PointGraphEdgeData>( point_graph, atomic_itxn_dist + 2 * max_radius );
103 
104  // add edges
105  //for ( Size ii = 1; ii <= pose.total_residue(); ++ii ) {
106  for ( Size ii = 1; ii <= total_nodes; ++ii ) {
107  Size ii_asu = ii;
108  if ( symm_info && symm_info->bb_follows( ii ) != 0 ) {
109  ii_asu = symm_info->bb_follows(ii);
110  }
111  Distance const ii_itxn_rad = residue_radii[ ii_asu ] + atomic_itxn_dist;
113  iter = point_graph->get_vertex( ii ).const_upper_edge_list_begin(),
114  iter_end = point_graph->get_vertex( ii ).const_upper_edge_list_end();
115  iter != iter_end; ++iter ) {
116 
117  Size jj = iter->upper_vertex();
118  Size jj_asu = jj;
119  if ( symm_info && symm_info->bb_follows( jj ) != 0 ) {
120  jj_asu = symm_info->bb_follows(jj);
121  }
122  Distance const jj_rad = residue_radii[ jj_asu ];
123 
124  if ( jj_rad + ii_itxn_rad > 0 &&
125  iter->data().dsq() < ( jj_rad + ii_itxn_rad )*( jj_rad + ii_itxn_rad ) ) {
126  //std::cout << "packer_neighbors adding edge " << ii << " " << jj << std::endl;
127  g->add_edge( ii, jj );
128  } else {
129  //std::cout << "packer_neighbors NOT adding edge " << ii << " " << jj << std::endl;
130  }
131  }
132  }
133  }
134  return g;
135 }
136 
137 
138 /// @brief for each residue in the protein, finds the largest bounding sphere
139 /// over all allowable rotameric/chemical modifications possible given the input task.
140 ///
143  pose::Pose const & pose,
144  task::PackerTaskCOP the_task
145 )
146 {
147  using namespace chemical;
148 
149  utility::vector1< Distance > residue_max_radii( pose.total_residue(), 0.0 );
150 
151  for ( Size ii = 1, ii_end = pose.total_residue(); ii <= ii_end; ++ii ) {
152  Distance max_radius_for_res( 0.0 );
153  /*
154  if ( task->design_residue( ii ) ) {
155 
156  for ( ResidueTypeSet::AAsIter iter = residue_set.aas_defined_begin(),
157  eiter = residue_set.aas_defined_end(); iter != eiter; ++iter ) {
158 
159  if ( task->allow_aa( ii, *iter )) {
160  ResidueTypeCOPs const & concrete_residues( residue_set.aa_map( *iter ) );
161  for ( ResidueTypeCOPs::const_iterator resiter = concrete_residues.begin(),
162  eresiter = concrete_residues.end(); resiter != eresiter; ++resiter ) {
163  if ( task->allow_concrete( pose.residue(ii), **resiter )) {
164  if ( (*resiter)->nbr_radius() > max_radius_for_res ) {
165  max_radius_for_res = (*resiter)->nbr_radius();
166  }
167  }
168  }
169  }
170  }
171  } else if ( task->pack_residue( ii ) ) {
172 
173  chemical::AA const resaa( pose.residue( ii ).aa());
174  ResidueTypeCOPs const & concrete_residues( residue_set.aa_map( resaa ) );
175  for ( ResidueTypeCOPs::const_iterator resiter = concrete_residues.begin(),
176  eresiter = concrete_residues.end(); resiter != eresiter; ++resiter ) {
177  if ( task->repacking_allow_concrete( pose.residue(ii), **resiter)) {
178  if ( (*resiter)->nbr_radius() > max_radius_for_res ) {
179  max_radius_for_res = (*resiter)->nbr_radius();
180  }
181  }
182  }
183  } */
184  if ( the_task->pack_residue( ii ) ) {
186  allowed_iter = the_task->residue_task( ii ).allowed_residue_types_begin(),
187  allowed_end = the_task->residue_task( ii ).allowed_residue_types_end();
188  allowed_iter != allowed_end; ++allowed_iter ) {
189  if ((*allowed_iter)->nbr_radius() > max_radius_for_res ) {
190  max_radius_for_res = (*allowed_iter)->nbr_radius();
191  }
192  }
193  //check whether the radius at any position needs to be increased
194  Distance max_rad_change(0.0);
196  rotsetop_iter = the_task->residue_task( ii ).rotamer_set_operation_begin(),
197  rotsetop_end = the_task->residue_task( ii ).rotamer_set_operation_end();
198  rotsetop_iter != rotsetop_end; ++rotsetop_iter ) {
199 
200  core::Real radius_change = (*rotsetop_iter)->increase_packer_residue_radius( pose, the_task, ii );
201  if( radius_change > max_rad_change ) {
202  max_rad_change = radius_change;
203  }
204  }
205  if( max_rad_change != 0.0 ) max_radius_for_res = max_radius_for_res + max_rad_change;
206  } else {
207  max_radius_for_res = pose.residue( ii ).nbr_radius();
208  }
209  residue_max_radii[ ii ] = max_radius_for_res;
210  }
211  return residue_max_radii;
212 }
213 
214 /// @details pose and score function must have met before packing
215 /// may begin; this function will force a score evaluation if the
216 /// energie's scorefunction-info object does not match that of the
217 /// given score function.
218 void
220  pose::Pose & pose,
221  scoring::ScoreFunction const & scfxn
222 )
223 {
224 // if ( true ){//pose.energies().get_scorefxn_info() != *(scfxn.info() ) ) {
225  scfxn( pose );
226 // }
227 }
228 
229 } // namespace core
230 } // namespace pack