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
core
scoring
constraints
ConstraintSet.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
11
/// @brief
12
13
14
#ifndef INCLUDED_core_scoring_constraints_ConstraintSet_hh
15
#define INCLUDED_core_scoring_constraints_ConstraintSet_hh
16
17
// Unit headers
18
#include <
core/scoring/constraints/ConstraintSet.fwd.hh
>
19
#include <
core/scoring/constraints/Func.hh
>
/// cant get to compile w/ Func.fwd.hh
20
21
22
// Package headers
23
#include <
core/scoring/ScoreFunction.fwd.hh
>
24
#include <
core/scoring/MinimizationData.fwd.hh
>
25
#include <
core/scoring/constraints/Constraint.hh
>
26
#include <
core/scoring/constraints/Constraints.hh
>
27
#include <
core/scoring/EnergyMap.fwd.hh
>
28
#include <
core/scoring/constraints/DOF_Constraint.hh
>
29
#include <
core/scoring/ScoreType.hh
>
30
31
// Project headers
32
#include <
core/types.hh
>
33
#include <
core/conformation/Residue.fwd.hh
>
34
#include <
core/conformation/Conformation.fwd.hh
>
35
#include <
core/pose/Pose.fwd.hh
>
36
#include <
core/id/AtomID.fwd.hh
>
37
#include <
core/id/DOF_ID.fwd.hh
>
38
// AUTO-REMOVED #include <core/id/TorsionID.fwd.hh>
39
#include <
core/kinematics/MinimizerMapBase.fwd.hh
>
40
#include <
core/id/SequenceMapping.fwd.hh
>
41
#include <
core/conformation/signals/LengthEvent.fwd.hh
>
//for observing conformation length changes
42
#include <
core/conformation/signals/ConnectionEvent.fwd.hh
>
43
// Utility Headers
44
#include <utility/pointer/ReferenceCount.hh>
45
46
//Utility Headers
47
48
// C++ Headers
49
#include <map>
50
51
#include <utility/vector1.hh>
52
53
54
namespace
core {
55
namespace
scoring {
56
namespace
constraints {
57
58
////////////////////////////////////////////////////////////////////////////////////////
59
////////////////////////////////////////////////////////////////////////////////////////
60
/// silly helper class, a wrapper for std::map so we can hold in owning_ptr
61
////////////////////////////////////////////////////////////////////////////////////////
62
////////////////////////////////////////////////////////////////////////////////////////
63
64
class
ResidueConstraints
:
public
utility::pointer::ReferenceCount
{
65
public
:
66
///@brief Automatically generated virtual destructor for class deriving directly from ReferenceCount
67
virtual
~ResidueConstraints
();
68
typedef
std::map< Size, ConstraintsOP >
Map
;
69
typedef
Map::const_iterator
const_iterator
;
70
typedef
Map::iterator
iterator
;
71
72
public
:
73
const_iterator
74
begin
()
const
75
{
76
return
map_
.begin();
77
}
78
79
const_iterator
80
end
()
const
81
{
82
return
map_
.end();
83
}
84
85
const_iterator
86
find
(
Size
const
seqpos )
const
87
{
88
return
map_
.find( seqpos );
89
}
90
91
iterator
92
find
(
Size
const
seqpos )
93
{
94
return
map_
.find( seqpos );
95
}
96
97
void
98
erase
(
Size
const
seqpos )
99
{
100
map_
.erase( seqpos );
101
}
102
103
bool
104
has
(
Size
const
seqpos )
105
{
106
return
(
map_
.find( seqpos ) !=
map_
.end() );
107
}
108
109
void
110
insert
(
Size
const
seqpos,
ConstraintsOP
cst )
111
{
112
map_
.insert( std::make_pair( seqpos, cst ) );
113
}
114
115
Size
116
size
()
const
117
{
118
return
map_
.size();
119
}
120
121
void
122
clear
()
123
{
124
map_
.clear();
125
}
126
127
private
:
128
Map
map_
;
129
};
130
131
132
133
////////////////////////////////////////////////////////////////////////////////////////
134
////////////////////////////////////////////////////////////////////////////////////////
135
// ConstraintSet
136
////////////////////////////////////////////////////////////////////////////////////////
137
////////////////////////////////////////////////////////////////////////////////////////
138
139
class
ConstraintSet
:
public
utility::pointer::ReferenceCount
{
140
public
:
141
typedef
id::AtomID
AtomID
;
142
typedef
id::DOF_ID
DOF_ID
;
143
144
typedef
conformation::Residue
Residue
;
145
typedef
pose::Pose
Pose
;
146
147
typedef
utility::vector1< ResidueConstraintsOP >
ResiduePairConstraints
;
148
typedef
ResidueConstraints::const_iterator
ResiduePairConstraintsIterator
;
149
150
// typedef utility::vector1< DOF_ConstraintOP > DOF_Constraints;
151
152
public
:
153
ConstraintSet
();
154
ConstraintSet
(
ConstraintSet
const
& other );
155
ConstraintSet
(
156
ConstraintSet
const
& other,
157
core::Size
start_residue,
158
core::Size
end_residue
159
);
160
/// @brief Destructor so far only detaches from conformation
161
virtual
~ConstraintSet
() { this->
detach_from_conformation
(); }
162
163
virtual
ConstraintSetOP
clone
()
const
;
164
165
/// @brief Copies the data from this ConstraintSet into a new object and
166
/// returns its OP; atoms are mapped to atoms with the same name in dest pose
167
/// ( e.g. for switch from centroid to fullatom ) if a sequence_mapping is
168
/// present it is used to map residue numbers .. NULL = identity mapping to
169
/// the new object. This will really clone all constraints since they have to
170
/// change their atom-numbers and residue-numbers
171
virtual
ConstraintSetOP
172
remapped_clone
(
173
pose::Pose
const
& src,
174
pose::Pose
const
& dest,
175
id::SequenceMappingCOP
smap = NULL
176
)
const
;
177
178
/// @brief like remapped_clone, but constraints also steal_def from src-pose
179
/// use, e.g., to get a new set of CoordinateConstraints for given xyz
180
/// coordinates in src-pose
181
virtual
ConstraintSetOP
steal_def_clone
(
182
pose::Pose
const
& src,
183
pose::Pose
const
& dest,
184
id::SequenceMappingCOP
smap = NULL
185
)
const
;
186
187
188
/// @brief remaps the constraints in this particular constraint set according
189
/// to brief the passed in sequence mapping --- redundant with
190
/// remapped_clone!!!
191
void
192
remap_residue_positions
(
193
id::SequenceMapping
const
& smap
194
);
195
196
/// @brief Cache the ConstraintsCOP for a particular residue
197
/// in the res_data_cache, under the "cst_res_data" element of
198
/// the data-cache's CachableDataOP array. Derived ConstraintSet
199
/// classes should decide HERE whether any constraints should be evaluated
200
/// for this residue, since, once a ConstraintsOP is added
201
/// to the minimization graph, the derived class looses the chance to
202
/// veto the evaluation of that constraint.
203
virtual
204
void
205
setup_for_minimizing_for_residue
(
206
conformation::Residue
const
& rsd,
207
pose::Pose
const
& pose,
208
ScoreFunction
const
& sfxn,
209
kinematics::MinimizerMapBase
const
& minmap,
210
ResSingleMinimizationData
& res_data_cache
211
)
const
;
212
213
214
/// @brief Cache the ConstraintsCOP for a particular residue pair
215
/// in the respair_data_cache, under the "cst_respair_data" element of
216
/// the data-cache's CachableDataOP array. Derived ConstraintSet
217
/// classes should decide HERE whether any constraints should be evaluated
218
/// between this pair of residues, since, once a ConstraintsOP is added
219
/// to the minimization graph, the derived class looses the chance to
220
/// veto the evaluation of that constraint.
221
virtual
222
void
223
setup_for_minimizing_for_residue_pair
(
224
conformation::Residue
const
& rsd1,
225
conformation::Residue
const
& rsd2,
226
pose::Pose
const
& pose,
227
ScoreFunction
const
& sfxn,
228
kinematics::MinimizerMapBase
const
& minmap,
229
ResSingleMinimizationData
const
& res1_data_cache,
230
ResSingleMinimizationData
const
& res2_data_cache,
231
ResPairMinimizationData
& respair_data_cache
232
)
const
;
233
234
235
virtual
void
236
setup_for_scoring
(
pose::Pose
& pose,
ScoreFunction
const
& scfxn )
const
;
237
238
virtual
void
239
setup_for_derivatives
(
pose::Pose
& pose,
ScoreFunction
const
& scfxn )
const
;
240
241
///
242
virtual
243
void
244
residue_pair_energy
(
245
Residue
const
& rsd1,
246
Residue
const
& rsd2,
247
Pose
const
& pose,
248
ScoreFunction
const
& scorefxn,
249
EnergyMap
& emap
250
)
const
;
251
252
/// @brief Switching over to a pairwise decomposable eval-atom-deriv system for
253
/// RTMin means deprecating the old "evaluate an atom's derivative wrt the entire structure"
254
/// This function is preserved (for now) for use by the RNA_TorsionEnergy
255
virtual
256
void
257
deprecated_eval_atom_derivative
(
258
id::AtomID
const
& atom_id,
259
pose::Pose
const
& pose,
260
ScoreFunction
const
&,
261
EnergyMap
const
& weights,
262
Vector
& F1,
263
Vector
& F2
264
)
const
;
265
266
/// @brief evaluate the derivatives for an atom that contains 3- or higher-body
267
/// constraints. Such derivatives cannot be evalauated in an extra-posal context
268
/// (e.g. such as in RTMin).
269
virtual
270
void
271
eval_multibody_atom_derivative
(
272
id::AtomID
const
& atom_id,
273
pose::Pose
const
& pose,
274
ScoreFunction
const
&,
275
EnergyMap
const
& weights,
276
Vector
& F1,
277
Vector
& F2
278
)
const
;
279
280
/// uses the dof constraints
281
/*
282
Real
283
eval_dof_derivative(
284
id::DOF_ID const & id,
285
id::TorsionID const & tor,
286
pose::Pose const & pose,
287
ScoreFunction const & scorefxn,
288
EnergyMap const & weights
289
) const;*/
290
291
292
///
293
virtual
bool
294
residue_pair_constraint_exists
(
int
const
pos1,
int
const
pos2 )
const
295
{
296
return
(
residue_pair_constraints_
.size() >=
Size
(pos1) &&
297
residue_pair_constraints_
[ pos1 ] &&
298
residue_pair_constraints_
[ pos1 ]->has( pos2 ) );
299
}
300
301
///
302
virtual
bool
303
residue_pair_constraints_exists
(
Size
const
pos )
const
{
304
return
( (
residue_pair_constraints_
.size() >= pos ) &&
305
residue_pair_constraints_
[ pos ]
306
);
307
}
308
309
///
310
virtual
void
311
eval_intrares_energy
(
312
conformation::Residue
const
& rsd,
313
pose::Pose
const
& pose,
314
ScoreFunction
const
& sfxn,
315
EnergyMap
& emap
316
)
const
;
317
318
///
319
void
320
eval_intrares_energy
(
321
conformation::Residue
const
& rsd,
322
EnergyMap
& emap
323
)
const
;
324
325
/// Does *NOT* zero the emap values, just adds the additional contribution to the
326
/// existing emap energies (so can be called inside finalize_total_energies)
327
virtual
void
328
eval_non_residue_pair_energy
(
329
Pose
const
& pose,
330
ScoreFunction
const
& sfxn,
331
EnergyMap
& emap
332
)
const
;
333
334
///
335
void
336
add_constraint
(
ConstraintCOP
cst );
337
338
void
339
add_constraints
(
ConstraintCOPs
cst_list );
340
341
/// @brief Returns true if the constraint was successfully found and removed.
342
/// if object comparison is set to true, the constraint to be removed is found
343
/// through the Constraint::== operator and not through pointer comparison
344
bool
345
remove_constraint
(
346
ConstraintCOP
cst,
347
bool
object_comparison );
348
349
// @brief returns true if all the constraints in the list were successfully
350
// found and removed.
351
bool
352
remove_constraints
(
353
ConstraintCOPs
cst_list,
354
bool
object_comparison );
355
356
/// @brief Note -- still hacky. Will not be included in packing, just scoring
357
/// and minimization
358
void
359
add_dof_constraint
(
360
DOF_ID
const
&
id
,
361
FuncOP
func,
362
ScoreType
const
&
t
=
dof_constraint
363
);
364
365
/// @brief Returns all constraints in the set as a flat list, regardless of
366
/// type.
367
ConstraintCOPs
368
get_all_constraints
()
const
;
369
370
ResiduePairConstraintsIterator
371
residue_pair_constraints_begin
(
Size
resid )
const
;
372
373
ResiduePairConstraintsIterator
374
residue_pair_constraints_end
(
Size
resid )
const
;
375
376
void
377
on_length_change
(
conformation::signals::LengthEvent
const
& event );
378
379
void
380
on_connection_change
(
381
core::conformation::signals::ConnectionEvent
const
& event
382
);
383
384
void
385
attach_to_conformation
(
core::conformation::Conformation
* conformation );
386
387
void
388
detach_from_conformation
();
389
390
Size
391
revision_id
()
const
;
392
393
// output statements, useful for debugging
394
virtual
void
395
show
( std::ostream& out )
const
;
396
397
// output statements, useful for debugging
398
virtual
void
399
show_definition
( std::ostream& out,
core::pose::Pose
const
& )
const
;
400
401
// this is the worst function name ever. This might as well be print_string.
402
virtual
void
403
show_numbers
( std::ostream& out )
const
;
404
405
virtual
Size
406
show_violations
(
407
std::ostream & out,
408
pose::Pose
&,
409
Size
verbose_level,
410
Real
threshold = 1
411
)
const
;
412
413
bool
414
has_residue_pair_constraints
()
const
{
415
return
residue_pair_constraints_
.size() > 0;
416
}
417
418
bool
419
has_intra_residue_constraints
()
const
{
420
return
intra_residue_constraints_
.
size
() > 0;
421
}
422
423
bool
424
has_dof_constraints
()
const
{
425
return
dof_constraints_
.size() > 0;
426
}
427
428
bool
429
has_non_residue_pair_constraints
()
const
{
430
return
non_residue_pair_constraints_
.
size
() > 0;
431
}
432
433
bool
434
has_constraints
()
const
{
435
return
has_residue_pair_constraints
()
436
||
has_intra_residue_constraints
()
437
||
has_dof_constraints
()
438
||
has_non_residue_pair_constraints
();
439
}
440
441
void
442
clear
();
443
444
bool
445
is_empty
()
const
;
446
447
protected
:
448
449
450
virtual
451
void
452
deprecated_eval_atom_derivative_for_residue_pairs
(
453
id::AtomID
const
& atom_id,
454
pose::Pose
const
& pose,
455
ScoreFunction
const
&,
456
EnergyMap
const
& weights,
457
Vector
& F1,
458
Vector
& F2
459
)
const
;
460
461
void
462
mark_revision_id_expired
();
463
464
private
:
465
void
466
add_residue_pair_constraint
(
467
Size
const
pos1,
468
Size
const
pos2,
469
ConstraintCOP
cst
470
);
471
472
/// @brief Returns true iff the constraint was successfully found and removed.
473
bool
474
remove_residue_pair_constraint
(
475
Size
const
pos1,
476
Size
const
pos2,
477
ConstraintCOP
cst,
478
bool
object_comparison
479
);
480
481
protected
:
482
ResiduePairConstraints
const
&
483
residue_pair_constraints
()
const
;
484
485
Constraints
const
&
non_residue_pair_constraints
()
const
{
486
return
non_residue_pair_constraints_
;
487
}
488
489
private
:
490
491
/// constraints are added symmetrically
492
ResiduePairConstraints
residue_pair_constraints_
;
493
494
ResidueConstraints
intra_residue_constraints_
;
495
496
Constraints
non_residue_pair_constraints_
;
497
498
// do not put anything in this -- used to return iterators to empty containers
499
ResidueConstraints
empty_rsdcst_
;
500
501
// vector of DOF constraints
502
DOF_ConstraintOPs
dof_constraints_
;
503
504
// a constraint set's "state identifier" for rapidly determining if any constraints
505
// have changed since the last time the constraint energies were evaluated
506
mutable
Size
revision_id_
;
507
mutable
bool
revision_id_current_
;
508
509
core::conformation::Conformation
*
conformation_pt_
;
510
};
511
512
std::ostream &
operator <<
(std::ostream & os,
ConstraintSet
const
& set);
513
514
}
// constraints
515
}
// scoring
516
}
// core
517
518
#endif
Generated on Sat Jun 1 2013 11:35:18 for Rosetta 3.5 by
1.8.4