Rosetta 3.5
Main Page
Related Pages
Namespaces
Classes
Files
Examples
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
src
protocols
optimize_weights
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
25
#include <
protocols/optimize_weights/IterativeOptEDriver.fwd.hh
>
26
27
// Core headers
28
#include <
core/types.hh
>
29
#include <
core/chemical/AA.hh
>
30
#include <
core/optimization/types.hh
>
31
// AUTO-REMOVED #include <core/optimization/Multifunc.hh>
32
#ifdef WIN32
33
#include <
core/pose/Pose.hh
>
34
#endif
35
#include <
core/pack/task/TaskFactory.fwd.hh
>
36
#include <
core/scoring/EnergyMap.hh
>
37
#include <
core/scoring/ScoreFunction.fwd.hh
>
38
#include <
core/pack/task/PackerTask.fwd.hh
>
39
40
#include <
protocols/optimize_weights/OptEData.fwd.hh
>
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
>
52
#include <
protocols/optimize_weights/OptEMultifunc.fwd.hh
>
53
54
55
namespace
protocols {
56
namespace
optimize_weights {
57
58
enum
AddStatus
59
{
60
ADDED_STRUCTURE_AS_INTENDED
,
61
ADDED_STRUCTURE_OPPOSITE_AS_INTENDED
,
62
DID_NOT_ADD_STRUCTURE
63
};
64
65
class
IterativeOptEDriver
{
66
public
:
67
typedef
core::Real
Real
;
68
typedef
core::Size
Size
;
69
typedef
core::scoring::ScoreTypes
ScoreTypes
;
70
typedef
core::scoring::EnergyMap
EnergyMap
;
71
72
public
:
73
IterativeOptEDriver
();
74
~IterativeOptEDriver
();
75
76
///@brief take care when using a custom TaskFactory:
77
/// TaskOperations must not 'accumulate state' as they will be reused repeatedly
78
void
task_factory
(
core::pack::task::TaskFactoryCOP
);
79
80
void
go
();
81
82
private
:
83
Size
num_outer_iterations
()
const
;
84
Size
num_inner_iterations
()
const
;
85
86
void
read_tagfile_to_taskfactory
(
std::string
tagfile_name,
core::pack::task::TaskFactoryOP
task_factory
);
87
void
load_pose
(
core::pose::Pose
& pose,
std::string
const
&
filename
,
bool
ignore_centroid_input_flag );
88
89
void
divide_up_pdbs
();
90
void
intialize_free_and_fixed_energy_terms
();
91
void
setup_derived_free_and_fixed_data
();
92
93
void
collect_rotamer_energies
();
94
void
compute_rotamer_energies_for_assigned_pdbs
();
95
void
collect_rotamer_energies_from_slave_cpus
();
96
void
collect_rotamer_energies_from_slave_cpu
(
Size
const
which_cpu );
97
void
send_rotamer_energies_to_master_cpu
();
98
99
void
optimize_weights
();
100
void
score_position_data
();
101
utility::vector1< Real >
read_reference_energies_from_file
(
std::string
const
& fname )
const
;
102
void
write_new_scorefile
();
103
104
void
test_sequence_recovery
();
105
void
collect_sequence_recovery_data_from_slave_cpus
();
106
void
collect_sequence_recovery_data_from_slave_cpu
(
Size
const
which_cpu );
107
void
run_design_on_assigned_pdbs
();
108
void
send_sequence_recovery_data_to_master_cpu
();
109
110
void
repack_assigned_pdbs
();
111
void
collect_rotamer_recovery_data_from_slave_cpus
();
112
void
collect_rotamer_recovery_data_from_slave_cpu
(
Size
const
which_cpu );
113
void
send_rotamer_recovery_data_to_master_cpu
();
114
115
bool
decide_if_sequence_recovery_improved
();
116
117
void
test_weight_sensitivity
(
118
OptEMultifunc
const
& func,
119
core::optimization::Multivec
const
& dofs
120
)
const
;
121
122
std::string
get_scorefile_name
();
123
void
barrier
();
124
void
exit_gracefully
();
125
126
utility::vector1< std::string >
127
get_native_pdb_names
();
128
129
void
zero_aa_counts
();
130
131
Real
132
measure_sequence_recovery
(
133
utility::vector1< std::string >
const
& native_pdb_names,
134
utility::vector1< std::string >
const
& names_for_output_pdbs,
135
core::scoring::ScoreFunctionOP
sfxn,
136
Size
& npos,
137
Size
& nrecovered
138
);
139
140
Real
141
measure_rotamer_recovery
(
142
utility::vector1< std::string >
const
& native_pdb_names,
143
utility::vector1< std::string >
const
& names_for_output_pdbs,
144
core::scoring::ScoreFunctionOP
sfxn,
145
Size
& npos,
146
Size
& nrecovered
147
);
148
149
Real
150
opte_weight_mixing_factor
(
151
Size
outer_loop_counter,
152
Size
inner_loop_counter
153
);
154
155
156
void
157
initialize_free_and_fixed
(
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
172
setup_pdbnames_next_round
(
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
180
write_parameters_to_std_out
(
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
187
get_nat_aa_opte_data
(
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
198
get_nat_rot_opte_data
(
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
210
set_aa_periodicity
(
211
PNatRotOptEPositionDataOP
pos_data,
212
core::chemical::AA
aa
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
219
residue_has_unacceptably_bad_dunbrack_energy
(
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
228
residue_has_bad_bfactor
(
229
core::pose::Pose
const
& pose,
230
Size
const
resid
231
)
const
;
232
233
234
core::scoring::EnergyMap
235
free_terms_energy_map_from_dofs
(
236
core::optimization::Multivec
const
& dofs
237
)
const
;
238
239
void
240
free_weights_and_refEs_from_vars
(
241
utility::vector1< Real >
const
& vars,
242
core::scoring::EnergyMap
& weights,
243
utility::vector1< Real >
& reference_energies
244
)
const
;
245
246
core::scoring::ScoreFunctionOP
247
configure_new_scorefunction
()
const
;
248
249
core::scoring::ScoreFunctionOP
250
create_unweighted_scorefunction
()
const
;
251
252
core::scoring::ScoreFunctionOP
253
create_weighted_scorefunction
()
const
;
254
255
void
256
collect_decoy_discrimination_data
();
257
258
SingleStructureDataOP
259
single_structure_data_for_pose
(
260
core::scoring::ScoreFunctionOP
scorefxn,
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
269
add_structure_based_on_rms
(
270
SingleStructureDataOP
ssd,
271
PNatStructureOptEDataOP
structure_data,
272
bool
intended_native
273
)
const
;
274
275
void
276
compute_rotamers_around_ligands
();
277
278
void
279
collect_ligand_discrimination_data
();
280
281
core::scoring::EnergyMap
282
score_ligand_interface
(
283
core::scoring::ScoreFunction
const
& scorefxn,
284
core::pose::Pose
& pose
// scoring is a non-const operation
285
);
286
287
SingleStructureDataOP
288
make_simple_ssd_from_pdb
(
289
std::string
const
& pdb_filename,
290
core::scoring::ScoreFunctionOP
sfxn,
291
bool
pretend_no_fa_rep =
false
292
)
const
;
293
294
void
295
collect_dG_of_binding_data
();
296
297
void
298
collect_ddG_of_mutation_data
();
299
300
void
301
collect_ddG_of_binding_data
();
302
303
void
304
load_pssm_data
(
std::string
const
& native_filename,
Size
const
which_protein );
305
306
core::pack::task::PackerTaskOP
307
copy_native_packertask_logic
(
core::pose::Pose
native_pose,
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
318
std::string
319
receive_string_from_node(
int
source );
320
private
:
321
#endif
322
323
void
324
repack_and_minimize_pose
(
core::pose::Pose
& pose,
core::scoring::ScoreFunctionOP
sfxn )
const
;
325
326
std::string
327
node_name
(
int
rank );
328
329
void
print_energies
(
330
core::pose::Pose
&,
331
core::scoring::ScoreFunctionOP
,
332
std::ostream & os = std::cout
333
);
334
335
void
output_weighted_unfolded_energies
();
336
337
private
:
338
core::pack::task::TaskFactoryOP
task_factory_
;
339
utility::vector1< std::string >
native_pdbs_
;
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
342
utility::vector1< std::string >
pdbs_this_round_
;
343
utility::vector1< std::string >
next_iteration_pdbs_
;
344
345
utility::vector1< core::pose::Pose >
rotamer_recovery_context_poses_
;
346
347
/// For rotamer recovery around ligands
348
utility::vector1< std::string >
ligand_repack_pdbs_
;
349
utility::vector1< core::pose::Pose >
ligand_repack_native_poses_
;
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.
354
utility::vector1< std::pair< std::string, std::string >
>
decdisc_native_decoy_pairs_
;
355
utility::vector1< std::string >
decdisc_crystal_natives_
;
356
utility::vector1< utility::vector1< core::pose::Pose >
>
decdisc_native_poses_
;
357
utility::vector1< utility::vector1< core::pose::Pose >
>
decdisc_decoy_poses_
;
358
utility::vector1< core::pose::Pose >
decdisc_xtal_natives_
;
359
360
/// A list of file-list pairs.
361
/// first = list of relaxed-native pdbs; second = list of decoy pdbs.
362
utility::vector1< std::pair< std::string, std::string >
>
ligand_native_decoy_pairs_
;
363
utility::vector1< std::string >
ligand_crystal_natives_
;
364
365
/// A list of file-list pairs:
366
/// first = list of relaxed mutant pdbs; second = list of native pdbs
367
utility::vector1< std::pair< std::string, std::string >
>
ddg_mut_wt_pairs_
;
368
utility::vector1< Real >
ddGs_
;
369
370
/// A list of lists for use in optimizing ddG binding predictions
371
utility::vector1< utility::vector1< std::string >
>
ddG_bind_files_
;
372
utility::vector1< Real >
ddGs_binding_
;
373
374
/// A list of PDB file pairs:
375
/// first = "bound" structure; second = "unbound" structure with partners well separated
376
utility::vector1< std::pair< std::string, std::string >
>
dG_bound_unbound_pairs_
;
377
utility::vector1< Real >
dG_binding_
;
378
379
/// preserve the decoy scores by component between iterations to minimize I/O.
380
OptEDataOP
decoy_discrim_data_
;
381
/// preserve the decoy scores by component between iterations to minimize I/O.
382
OptEDataOP
ligand_discrim_data_
;
383
/// preserve the dGbinding data between iterations to minimize I/O
384
OptEDataOP
dG_binding_data_
;
385
/// preserve the ddMutation data between iterations to minimize I/O
386
OptEDataOP
ddG_mutation_data_
;
387
/// preserve the ddG bind mutation data between iterations to minimize I/O
388
OptEDataOP
ddG_bind_optE_data_
;
389
390
/// These two get set by the user
391
EnergyMap
free_parameters_
;
392
EnergyMap
fixed_parameters_
;
393
394
/// These get updated from the above two
395
EnergyMap
include_terms_
;
396
Size
include_count_
;
397
Size
fixed_count_
;
398
Size
free_count_
;
399
ScoreTypes
free_score_list_
;
400
ScoreTypes
fixed_score_list_
;
401
utility::vector1< Real >
component_weights_
;
402
403
/// store the PSSM data so it's only read once.
404
utility::vector1< utility::vector1< std::pair< core::chemical::AA, utility::vector1< Real >
> > >
all_pssm_data_
;
405
utility::vector1< std::pair< core::chemical::AA, utility::vector1< Real >
> >
pssm_data_
;
406
407
#ifdef USEMPI
408
MPI_Status stat_;
409
int
tag_;
410
#endif
411
412
Size
MPI_rank_
;
413
Size
MPI_nprocs_
;
414
415
Size
outer_loop_counter_
;
416
Size
inner_loop_counter_
;
417
OptEDataOP
optE_data_
;
418
419
Size
total_positions_
;
420
Size
count_recovered_
;
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
426
Size
total_rotamer_positions_
;
427
Size
count_rotamers_recovered_
;
428
429
/// Hold the result of minimization -- interpolate between the
430
/// before and after weight sets during iterative sequence recovery.
431
utility::vector1< Real >
before_minimization_reference_energies_
;
432
utility::vector1< Real >
after_minimization_reference_energies_
;
433
utility::vector1< Real >
reference_energies_inner_loop_
;
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.
440
WrapperOptEMultifuncOP
wrapped_opt_min_
;
441
utility::vector1< Real >
minimizer_dofs_before_minimization_
;
442
utility::vector1< Real >
minimizer_dofs_after_minimization_
;
443
utility::vector1< Real >
minimizer_dofs_mixed_
;
444
445
EnergyMap
free_weights_before_minimization_
;
446
EnergyMap
free_weights_after_minimization_
;
447
EnergyMap
free_weights_inner_loop_
;
448
449
Real
mixing_factor_
;
450
451
Real
outer_loop_last_sequence_recovery_rate_
;
452
Real
outer_loop_seq_profile_cross_entropy_
;
453
Real
inner_loop_sequence_recovery_rate_
;
454
Real
inner_loop_rotamer_recovery_rate_
;
// output for curriousity's sake.
455
456
bool
using_unfolded_energy_term_
;
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
466
load_component_weights
(
467
utility::vector1< core::Real >
& component_weights
468
);
469
470
}
// namespace optimize_weights
471
}
// namespace protocols
472
473
#endif
Generated on Sat Jun 1 2013 12:01:58 for Rosetta 3.5 by
1.8.4