Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DME_FilterMover.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 TrialMover
11 /// @brief performs a move and accepts it according to Monte Carlo accept/reject criterion.
12 /// @author Monica Berrondo
13 
15 
16 // Rosetta Headers
17 #include <core/pose/Pose.hh>
19 // AUTO-REMOVED #include <basic/basic.hh>
20 #include <basic/Tracer.hh>
21 
22 // AUTO-REMOVED #include <protocols/moves/MonteCarlo.hh>
23 #include <protocols/moves/Mover.hh>
24 
27 
28 // Random number generator
29 // AUTO-REMOVED #include <numeric/random/random.hh>
30 
31 static basic::Tracer TR( "protocols.DME_FilterMover" );
32 
33 //
34 #include <string>
35 
38 #include <utility/vector1.hh>
39 
40 
41 namespace protocols {
42 namespace simple_moves {
43 
44 using namespace core;
45 
46 
47 /// @details Setup a pointgraph for later use in dma calcs
49 setup_dme_point_graph( pose::Pose const & ref_pose, Real const threshold )
50 {
53  core::conformation::find_neighbors<core::conformation::PointGraphVertexData,core::conformation::PointGraphEdgeData>( pg, threshold );
54  return pg;
55 }
56 
57 /// @details Calculate the dme using a pointgraph
58 Real
60 {
61  Size total(0);
62  Real dme(0.0);
63  for ( Size i=1; i<= pose.total_residue(); ++i ) {
64  conformation::Residue const & i_rsd( pose.residue(i) );
66  i_iter = pg.get_vertex( i ).const_upper_edge_list_begin(),
67  i_end_iter = pg.get_vertex( i ).const_upper_edge_list_end();
68  i_iter != i_end_iter; ++i_iter ) {
69  Size const j = i_iter->upper_vertex();
70  Real const reference_distance( std::sqrt( i_iter->data().dsq() ) );
71  Real const pose_distance( i_rsd.nbr_atom_xyz().distance( pose.residue(j).nbr_atom_xyz() ) );
72  dme += ( reference_distance - pose_distance ) * ( reference_distance - pose_distance );
73  ++total;
74  }
75  }
76  return std::sqrt( dme / total );
77 }
78 
79 /// @details Keep trying to make a move with my_mover until the dme is less than our threshold or
80 /// max_tries is exceeded
81 /// @note At the expense of a few additional pose copies we could save the pose with the best dme and use
82 /// that if we exceed max_tries
83 
84 void
86 {
87  // setup a pointgraph for future dme calculations
89 
90  // for undoing moves with dme's that are too big
91  pose::Pose const start_pose( pose );
92 
93  Size ntries( 0 );
94  while ( true ) { // keep looping until we succeed
95  ++ntries;
96 
97  my_mover_->apply( pose );
98 
99  Real const dme( point_graph_dme( *pg, pose ) );
100 
101  TR.Trace << "apply: " << type() << " ntries= " << ntries << " dme= " << dme << std::endl;
102 
103  if ( ntries >= max_tries_ || dme < dme_threshold_ ) break;
104 
105  pose = start_pose;
106  }
107 }
108 
111  return "DME_FilterMover";
112 }
113 
114 } // namespace moves
115 } // namespace protocols