Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
IterativeAbrelax.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 // This file is part of the Rosetta software suite and is made available under license.
5 // The Rosetta software is developed by the contributing members of the Rosetta Commons consortium.
6 // (C) 199x-2009 Rosetta Commons participating institutions and developers.
7 // For more information, see http://www.rosettacommons.org/.
8 
9 /// @file IterativeAbrelax
10 /// @brief iterative protocol starting with abinitio and getting progressively more concerned with full-atom relaxed structures
11 /// @detailed
12 ///
13 ///
14 /// @author Oliver Lange
15 
16 
17 // Unit Headers
20 
21 // Package Headers
22 
23 // Project Headers
24 #include <core/types.hh>
25 #include <core/pose/Pose.hh>
26 
30 #include <basic/Tracer.hh>
31 
32 #include <utility/file/FileName.hh>
33 
34 //// C++ headers
35 #include <cstdlib>
36 #include <string>
37 
38 // Utility headers
39 #include <basic/options/option_macros.hh>
40 
41 #include <utility/vector1.hh>
42 
43 #include <ctime>
44 
45 static basic::Tracer tr("protocols.iterative");
46 
47 using core::Real;
48 using namespace core;
49 using namespace basic;
50 using namespace basic::options;
51 using namespace basic::options::OptionKeys;
52 
53 OPT_1GRP_KEY( Boolean, iterative, fullatom )
54 
55 namespace protocols {
56 namespace abinitio {
57 using namespace jd2::archive;
58 
60 
61 
63  if ( !options_registered_ ) {
64  NEW_OPT( iterative::fullatom, "sample fullatom structures in iterative protocol", false );
65  options_registered_ = true;
66  }
70 }
71 
72 IterativeAbrelax::IterativeAbrelax()
73  : Parent( "abstract" ),
74  centroid_archive_( &fullatom_archive_ ), //calling cstor of IterativeCentroid
75  fullatom_( false )
76 {
77  fullatom_ = option[ iterative::fullatom ]();
78  //not needed anymore: if I initialize base with this finish_stage
80 }
81 
83  if ( sfd.begin() != sfd.end() ) {
84  pose::Pose pose;
85  sfd.begin()->fill_pose( pose );
86  sfd.begin()->has_energy( "user_tag" );
87  std::string centroid_str( sfd.begin()->get_string_value( "user_tag" ) );
88  bool isPseudoFullatom ( centroid_str == "centroid" );
89  if ( pose.is_fullatom() && !isPseudoFullatom ) {
90  runtime_assert( fullatom_ );
91  tr.Debug << "reading full-atom structures into fullatom_pool" << std::endl;
92  fullatom_archive_.read_structures( sfd, batch );
93  } else {
94  tr.Debug << "reading " << (isPseudoFullatom ? " pseuod-fullatom " : "centroid" ) << " structures into centroid_pool" << std::endl;
95  centroid_archive_.read_structures( sfd, batch );
96  }
97  }
98 }
99 
102 }
103 
107 }
108 
109 bool IterativeAbrelax::still_interested( Batch const& batch ) const {
110  // return Parent::still_interested( batch )&&
111  return ( centroid_archive_.still_interested( batch ) && ( fullatom_ && fullatom_archive_.still_interested( batch ) ) );
112 }
113 
114 ///@details ready for new batch .... if queue is empty batch will be generated any way, but otherwise we only generate if this yields true.
115 /// logic here: new batch at beginning, but only if we are in startup phase ( not a reload of a full archive )
116 /// otherwise make new batch if sufficiently many structures have been accepted since last batch
117 // bool IterativeAbrelax::ready_for_batch() const {
118 // return centroid_archive_.ready_for_batch() || ( fullatom_ && fullatom_archive_.ready_for_batch() );
119 // }
120 
121 ///@details generate new batch...
122 /// type of batch depends on stage_. we switch to next stage based on some convergence criteria:
123 /// right now it is how many decoys were accepted from last batch.. if this number drops sufficiently ---> next stage...
124 /// (maybe need to put a safeguard in here: ratio small but at least XXX decoys proposed since last batch... )
125 ///
128  // fixed this already by using the noesy_cst_file from the very first batch that is read in...
129  // re-starting assign cycle from cmdline parameter..
130 // if ( fullatom_archive_.first_noesy_fa_cst_file()=="n/a") {
131 // fullatom_archive_.set_first_noesy_fa_cst_file( centroid_archive_.first_noesy_fa_cst_file() );
132 // fullatom_archive_.set_noesy_assign_float_cycle( centroid_archive_.noesy_assign_float_cycle() );
133 // }
135  } else {
137  }
138 }
139 
141  Parent::set_manager( manager );
142  tr.Info << "IterativeAbrelax: set ArchiveManager also for sub-archives... " << std::endl;
143  fullatom_archive_.set_manager( manager );
144  centroid_archive_.set_manager( manager );
145 }
146 
147 
149  int start_time( time(NULL) );
151  int later( time(NULL) );
152  int centroid_idle( later-start_time);
153  if ( centroid_idle > 10 ) {
154  tr.Debug << "spend " << centroid_idle << " seconds in idle() function of " << centroid_archive_.name() << std::endl;
155  if ( fullatom_ ) tr.Debug << "will postpone idle() call for " << fullatom_archive_.name() << std::endl;
156  return;
157  }
159  int final( time(NULL) );
160  int fullatom_idle( final-later );
161  if ( fullatom_idle > 10 ) {
162  tr.Debug << "spend " << fullatom_idle << " seconds in idle() function of " << fullatom_archive_.name() << std::endl;
163  tr.Debug << "will postpone idle() call for " << fullatom_archive_.name() << std::endl;
164  return;
165  }
166 }
167 
170  if ( fullatom_ ) fullatom_archive_.save_to_file( suffix );
171 }
172 
173 void IterativeAbrelax::save_status( std::ostream& os ) const {
176 }
177 
179  bool b_have_restored = centroid_archive_.restore_from_file();
181  return b_have_restored;
182 }
183 
186 }
187 
188 
189 
190 } //abinitio
191 } //protocols