Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
IterativeOptEDriver.hh
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 protocols/optimize_weights/IterativeOptEDriver.hh
11 /// @brief A class for optimizing weights in an iterative weight fitting, sequence recovery test protocol
12 /// @author Andrew Leaver-Fay -- emulating a protocol by Jim Havranek and Brian Kuhlman.
13 
14 
15 #ifndef INCLUDED_protocols_optimize_weights_IterativeOptEDriver_hh
16 #define INCLUDED_protocols_optimize_weights_IterativeOptEDriver_hh
17 
18 
19 // MPI Headers have to be #included first
20 #ifdef USEMPI
21 #include <mpi.h>
22 #endif
23 
24 // Unit headers
26 
27 // Core headers
28 #include <core/types.hh>
29 #include <core/chemical/AA.hh>
31 // AUTO-REMOVED #include <core/optimization/Multifunc.hh>
32 #ifdef WIN32
33 #include <core/pose/Pose.hh>
34 #endif
39 
41 // AUTO-REMOVED #include <protocols/optimize_weights/OptEMultifunc.hh>
42 
43 // Utility headers
44 // AUTO-REMOVED #include <utility/vector1.hh>
45 
46 /// STL Headers
47 //#include <map>
48 // AUTO-REMOVED #include <string>
49 
50 //Auto Headers
51 #include <core/pose/Pose.fwd.hh>
53 
54 
55 namespace protocols {
56 namespace optimize_weights {
57 
59 {
63 };
64 
66 public:
67  typedef core::Real Real;
68  typedef core::Size Size;
71 
72 public:
75 
76  ///@brief take care when using a custom TaskFactory:
77  /// TaskOperations must not 'accumulate state' as they will be reused repeatedly
79 
80  void go();
81 
82 private:
83  Size num_outer_iterations() const;
84  Size num_inner_iterations() const;
85 
87  void load_pose( core::pose::Pose & pose, std::string const & filename, bool ignore_centroid_input_flag );
88 
89  void divide_up_pdbs();
92 
96  void collect_rotamer_energies_from_slave_cpu( Size const which_cpu );
98 
99  void optimize_weights();
100  void score_position_data();
102  void write_new_scorefile();
103 
104  void test_sequence_recovery();
106  void collect_sequence_recovery_data_from_slave_cpu( Size const which_cpu );
109 
110  void repack_assigned_pdbs();
112  void collect_rotamer_recovery_data_from_slave_cpu( Size const which_cpu );
114 
116 
118  OptEMultifunc const & func,
119  core::optimization::Multivec const & dofs
120  ) const;
121 
123  void barrier();
124  void exit_gracefully();
125 
128 
129  void zero_aa_counts();
130 
131  Real
133  utility::vector1< std::string > const & native_pdb_names,
134  utility::vector1< std::string > const & names_for_output_pdbs,
136  Size & npos,
137  Size & nrecovered
138  );
139 
140  Real
142  utility::vector1< std::string > const & native_pdb_names,
143  utility::vector1< std::string > const & names_for_output_pdbs,
145  Size & npos,
146  Size & nrecovered
147  );
148 
149  Real
151  Size outer_loop_counter,
152  Size inner_loop_counter
153  );
154 
155 
156  void
158  core::scoring::EnergyMap & free_parameters,
159  core::scoring::EnergyMap & fixed_parameters
160  );
161 
162  bool
163  converged(
164  core::scoring::EnergyMap & free_parameters_prev,
165  core::scoring::EnergyMap & free_parameters_curr,
166  utility::vector1< Real > const & reference_energies_prev,
167  utility::vector1< Real > const & reference_energies_curr
168  );
169 
170 
171  void
173  Size const outer_loop_counter,
174  utility::vector1< std::string > & pdbs_next_round,
175  utility::vector1< std::string > const & native_pdb_names
176  );
177 
178 
179  void
181  core::scoring::EnergyMap & free_parameters,
182  utility::vector1< Real > const & reference_energies
183  );
184 
185  /// @brief refactor this into an optE common...
186  void
188  std::string const & pdb_name,
189  core::pose::Pose & pose,
190  core::pose::Pose & native_pose,
191  core::scoring::ScoreFunction const & scorefxn,
192  ScoreTypes & score_list,
193  ScoreTypes & fixed_score_vec,
194  OptEData & opte_data
195  );
196 
197  void
199  std::string const & pdb_name,
200  core::pose::Pose & pose,
201  core::pose::Pose & native_pose,
202  utility::vector1<bool> include_rsd,
203  core::scoring::ScoreFunction const & scorefxn,
204  ScoreTypes & score_list,
205  ScoreTypes & fixed_score_vec,
206  OptEData & opte_data
207  );
208 
209  void
211  PNatRotOptEPositionDataOP pos_data,
213  ) const;
214 
215  /// @brief True/False: a particular residue be skipped for inclusion
216  /// into the native-rotamer recovery test
217  /// because its dunbrack energy is really high
218  bool
220  core::pose::Pose const & pose,
221  Size const resid
222  ) const;
223 
224  /// @brief True/False: a particular residue be skipped for inclusion
225  /// into the native-rotamer recovery test
226  /// because it contains an atom with a high B-factor
227  bool
229  core::pose::Pose const & pose,
230  Size const resid
231  ) const;
232 
233 
236  core::optimization::Multivec const & dofs
237  ) const;
238 
239  void
241  utility::vector1< Real > const & vars,
242  core::scoring::EnergyMap & weights,
243  utility::vector1< Real > & reference_energies
244  ) const;
245 
248 
251 
254 
255  void
257 
261  core::pose::Pose & pose,
262  core::pose::Pose const & crystal_native,
263  utility::vector1< Real > & free_data, // scratch space; avoids new
264  utility::vector1< Real > & fixed_data, // scratch space; avoids new
265  std::string const & structure_tag = ""
266  ) const;
267 
268  AddStatus
271  PNatStructureOptEDataOP structure_data,
272  bool intended_native
273  ) const;
274 
275  void
277 
278  void
280 
283  core::scoring::ScoreFunction const & scorefxn,
284  core::pose::Pose & pose // scoring is a non-const operation
285  );
286 
289  std::string const & pdb_filename,
291  bool pretend_no_fa_rep = false
292  ) const;
293 
294  void
296 
297  void
299 
300  void
302 
303  void
304  load_pssm_data( std::string const & native_filename, Size const which_protein );
305 
308  core::pose::Pose context_pose,
309  core::pack::task::TaskFactoryOP native_taskfactory);
310 
311 #ifdef USEMPI
312 public:
313  static
314  void
315  send_string_to_node( int destination, std::string const & string_to_send );
316 
317  static
319  receive_string_from_node( int source );
320 private:
321 #endif
322 
323  void
325 
327  node_name( int rank );
328 
329  void print_energies(
332  std::ostream & os = std::cout
333  );
334 
336 
337 private:
340  utility::vector1< core::pose::Pose > native_poses_; // the pose of the xtal native used in the design step
341  utility::vector1< core::pose::Pose > context_poses_; // After the first round, the poses from the previous round of design
344 
346 
347  /// For rotamer recovery around ligands
350  //utility::vector1< core::pose::Pose > ligand_repack_context_poses_;
351 
352  /// A list of file-list pairs.
353  /// first = list of relaxed-native pdbs; second = list of decoy pdbs.
359 
360  /// A list of file-list pairs.
361  /// first = list of relaxed-native pdbs; second = list of decoy pdbs.
364 
365  /// A list of file-list pairs:
366  /// first = list of relaxed mutant pdbs; second = list of native pdbs
369 
370  /// A list of lists for use in optimizing ddG binding predictions
373 
374  /// A list of PDB file pairs:
375  /// first = "bound" structure; second = "unbound" structure with partners well separated
378 
379  /// preserve the decoy scores by component between iterations to minimize I/O.
381  /// preserve the decoy scores by component between iterations to minimize I/O.
383  /// preserve the dGbinding data between iterations to minimize I/O
385  /// preserve the ddMutation data between iterations to minimize I/O
387  /// preserve the ddG bind mutation data between iterations to minimize I/O
389 
390  /// These two get set by the user
393 
394  /// These get updated from the above two
402 
403  /// store the PSSM data so it's only read once.
406 
407 #ifdef USEMPI
408  MPI_Status stat_;
409  int tag_;
410 #endif
411 
414 
418 
421  utility::vector1< Size > aa_obs_; /// the counts for each amino acid from the previous round of design (observed)
422  utility::vector1< Size > aa_exp_; /// the counts for each amino acid in the input data set (expected)
423  utility::vector1< Real > aa_freq_obs_; /// the frequency for each amino acid from the previous round of design
424  utility::vector1< Real > aa_freq_exp_; /// the frequency for each amino acid in the input data set
425 
428 
429  /// Hold the result of minimization -- interpolate between the
430  /// before and after weight sets during iterative sequence recovery.
434 
435  /// When using the optEMultifunc wrapper, hold on to the dofs that
436  /// the minimizer has access to and interpolate in the space of
437  /// those dofs; then convert the interpolated dofs into weights.
438  /// Interpolating the weights directly might result in weights that
439  /// violate the mixing rules for the wrapper.
444 
448 
450 
454  Real inner_loop_rotamer_recovery_rate_; // output for curriousity's sake.
455 
457 
458 };
459 
460 /// @brief Read options[ optE::component_weights ] file from input file.
461 /// Not a member of the above driver class since its independent of the driver;
462 /// possibly belongs in a separate source file.
463 /// Any component specified in the weights file is set to the corresponding weight.
464 /// Any component not specified in the weights file is set to 1.
465 void
467  utility::vector1< core::Real > & component_weights
468 );
469 
470 } // namespace optimize_weights
471 } // namespace protocols
472 
473 #endif