Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 FilterMover
11 /// @brief apply filter after mover
12 /// @author Nobuyasu Koga ( nobuyasu@uw.edu )
13 
14 // Unit headers
16 
17 // Project Headers
19 #include <core/pose/Pose.hh>
20 
21 // AUTO-REMOVED #include <basic/basic.hh>
22 #include <basic/Tracer.hh>
23 
24 static basic::Tracer TR( "protocols.FilterMover" );
25 
26 //
27 #include <string>
28 
29 #include <utility/vector1.hh>
30 
31 
32 namespace protocols {
33 namespace moves {
34 
36  max_tries_( 1 ),
37  ms_whenfail_( FAIL_DO_NOT_RETRY )
38 {}
39 
41  MoverOP const & my_mover,
42  FilterOP const & my_filter,
43  Size const max_tries,
44  MoverStatus const mover_status
45 ):Mover( my_mover->type() ),
46  my_mover_( my_mover ),
47  my_filter_( my_filter ),
48  max_tries_( max_tries ),
49  ms_whenfail_( mover_status )
50 {}
51 
53 
54 void FilterMover::add_filter( FilterOP const & my_filter ){
55  my_filter_ = my_filter;
56 }
57 
58 void FilterMover::set_mover( MoverOP const & my_mover ){
59  my_mover_ = my_mover;
60 }
61 
63  max_tries_ = mt;
64 }
65 
66 /// @details Keep trying to make a move with my_mover until my_filter return true or max_tries is exceeded
67 /// @note At the expense of a few additional pose copies we could save the pose with the best and use
68 /// that if we exceed max_tries
69 
70 void FilterMover::apply( Pose & pose )
71 {
72 
73  Pose const start_pose( pose );
74 
75  Size ntries( 0 );
76 
77  while ( true ) { // keep looping until we succeed
78 
79  ++ntries;
80  TR << " ntries/max_tries = " << ntries << '/' << max_tries_ << std::endl;
81  my_mover_->apply( pose );
82 
83  //pose.dump_pdb( "hoge.pdb" );
84  if( my_mover_->get_last_move_status() == MS_SUCCESS ){
85 
86  bool filter_status = my_filter_->apply( pose );
87 
88  if( filter_status ){
90  break;
91  }else{
92  if( ntries >= max_tries_ ){
94  break;
95  }
96  } // filter_status
97 
98  }else{
99  set_last_move_status( my_mover_->get_last_move_status() );
100  break;
101  }// my_mover_->get_last_move_status() == MS_SUCCESS
102 
103  pose = start_pose;
104 
105  }
106 
107 } //apply
108 
111  return "FilterMover";
112 }
113 
114 } // namespace moves
115 } // namespace protocols