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
Constraint.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 src/core/scoring/constraints/Constraint.hh
11
/// @brief Base class definition for Constraint class hierarchy.
12
13
#ifndef INCLUDED_core_scoring_constraints_Constraint_hh
14
#define INCLUDED_core_scoring_constraints_Constraint_hh
15
16
// Unit header
17
#include <
core/scoring/constraints/Constraint.fwd.hh
>
18
19
// AUTO-REMOVED #include <core/scoring/constraints/XYZ_Func.hh>
20
#include <
core/scoring/constraints/FuncFactory.fwd.hh
>
21
22
#include <
core/scoring/ScoreType.hh
>
23
#include <
core/scoring/ScoreFunction.fwd.hh
>
24
25
// AUTO-REMOVED #include <core/id/AtomID.hh>
26
#include <
core/conformation/Conformation.fwd.hh
>
27
// AUTO-REMOVED #include <core/scoring/EnergyMap.hh>
28
#include <
core/pose/Pose.fwd.hh
>
29
#include <numeric/random/random.fwd.hh>
30
#include <
core/scoring/constraints/Func.hh
>
31
#include <
core/scoring/constraints/HarmonicFunc.hh
>
32
#include <
core/kinematics/ShortestPathInFoldTree.fwd.hh
>
33
34
//Utility Headers
35
#include <numeric/xyzVector.fwd.hh>
36
#include <utility/pointer/ReferenceCount.hh>
37
#include <utility/exit.hh>
38
39
// C++ Headers
40
// AUTO-REMOVED #include <ostream>
41
42
#include <
core/id/AtomID.fwd.hh
>
43
// #include <core/id/SequenceMapping.fwd.hh> Commented by Brian Weitzner to fix compilation
44
#include <
core/id/SequenceMapping.hh
>
45
#include <
core/scoring/EnergyMap.fwd.hh
>
46
#include <
core/scoring/constraints/XYZ_Func.fwd.hh
>
47
#include <utility/vector1.hh>
48
#include <sstream>
49
50
#ifdef WIN32
51
#include <
core/id/SequenceMapping.hh
>
52
#endif
53
54
55
namespace
core {
56
namespace
scoring {
57
namespace
constraints {
58
59
/// @brief Actually a *restraint*, like a virtual rubber band between a pair of atoms.
60
/// @details All Constraints are expected to be immutable once created,
61
/// meaning their internal data (state) should not change over their lifetime.
62
/// This allows Constraints to be shared between copies of Poses (e.g. in Monte Carlo),
63
/// and is important for both speed (with thousands of contraints) and correctness.
64
///
65
/// To "change" a constraint, remove the old one and add a new and different one.
66
/// The steal() methods have been removed because it is
67
/// incompatible with the idea of immutable constraints.
68
69
class
Constraint
:
public
utility::pointer::ReferenceCount
{
70
71
public
:
72
typedef
id::AtomID
AtomID
;
73
74
public
:
75
/// @brief Constructor for Constraint class.
76
Constraint
(
ScoreType
const
&
t
):
score_type_
(t) {}
77
78
/// @brief Virtual destructor.
79
virtual
80
~Constraint
();
81
82
/// @brief Copies the data from this Constraint into a new object and returns
83
/// an OP to the new object. Intended to be implemented by derived classes and
84
/// used by pose.add_constraint
85
virtual
ConstraintOP
clone
()
const
= 0;
86
87
virtual
ConstraintOP
clone
(
FuncOP
)
const
{
88
unimplemented_method_error
(
std::string
(
"clone"
) );
89
return
NULL;
90
}
91
92
93
/// @brief Copies the data from this Constraint into a new object and returns
94
/// an OP atoms are mapped to atoms with the same name in dest pose ( e.g.
95
/// for switch from centroid to fullatom ) if a sequence_mapping is present
96
/// it is used to map residue numbers .. NULL = identity mapping to the new
97
/// object. Intended to be implemented by derived classes.
98
virtual
ConstraintOP
remapped_clone
(
99
pose::Pose
const
&
/*src*/
,
100
pose::Pose
const
&
/*dest*/
,
101
id::SequenceMappingCOP
map=NULL )
const
{
102
unimplemented_method_error
(
std::string
(
"remapped_clone"
) );
103
if
( !map )
return
NULL;
// to make compile happy
104
return
NULL;
105
}
106
107
/// @brief Returns the number of atoms involved in defining this constraint.
108
/// If the constraint doesn't depend on particular atoms (e.g. a residue type constraint)
109
/// this function can return zero
110
/// @details Note that this function isn't actually used by the constraint scoring machenery.
111
/// If you're calling it on a generic Constraint (as opposed to specifically on a derived class)
112
/// you're probably doing something wrong.
113
virtual
114
Size
115
natoms
()
const
= 0;
116
117
/// @brief Returns the AtomID referred to by index.
118
/// @details Note that this function isn't actually used by the constraint scoring machenery.
119
/// If you're calling it on a generic Constraint (as opposed to specifically on a derived class)
120
/// you're probably doing something wrong.
121
virtual
122
AtomID
const
&
123
atom
(
Size
const
index )
const
= 0;
124
125
/// @brief Returns the pose numbers of the residues involved in this constraint, in no particular order.
126
/// @details Used in determining one-body/two-body/multi-body status.
127
/// For historical reasons, the default uses a simple protocol based on natoms()/atom() -
128
/// feel free to reimplement more efficiently.
129
virtual
130
utility::vector1< core::Size >
131
residues
()
const
;
132
133
/// @brief This method is totally redundant with read_def YAY
134
// DON'T USE THIS ONE.. Most Constraint classes have not overloaded this one, but read_def ! OL
135
virtual
136
void
read_constraint
( std::istream &
/*in*/
,
core::pose::Pose
const
&
/*pose*/
) {
137
unimplemented_method_error
(
std::string
(
"read_constraint"
) );
138
}
139
140
/// @brief Returns the ScoreType that this Constraint object will use.
141
ScoreType
const
&
142
score_type
()
const
143
{
144
return
score_type_
;
145
}
146
147
/// @brief initialize this Constraint from the given std::istream. It's amazing
148
/// that there are three functions for doing this inside of Constraint.hh.
149
/// SO WHAT IS THIS SUPPOSED TO DO ? not overloaded by e.g., AtomPairConstraint or CoordinateConstraint,
150
// -- use read_def() if in doubt.
151
virtual
void
read_data
( std::istream & ) {}
152
153
/// @brief apply a resid remapping to this constraint, returns the remapped
154
/// constraint Does this return an owning pointer to this constraint or a
155
/// copy? Documentation would be nice.
156
virtual
157
ConstraintOP
158
remap_resid
(
core::id::SequenceMapping
const
&
/*seqmap*/
)
const
159
{
160
unimplemented_method_error
(
std::string
(
"remap_resid"
) );
161
return
NULL;
162
}
163
164
165
/// @brief return the "raw" distance before handed to the FUNC object
166
virtual
167
core::Real
168
dist
(
core::pose::Pose
const
&
/*pose*/
)
const
{
169
unimplemented_method_error
(
std::string
(
"dist"
) );
170
return
-1.0;
171
}
172
173
virtual
174
core::Real
175
dist
(
XYZ_Func
const
&
/*xyz*/
)
const
{
176
unimplemented_method_error
(
std::string
(
"dist"
) );
177
return
-1.0;
178
};
179
180
/// @brief Calculates a score for this constraint using XYZ_Func, and puts
181
/// the UNWEIGHTED score into emap. Although the current set of weights
182
/// currently is provided, Constraint objects should put unweighted scores
183
/// into emap because the ScoreFunction will do the weighting itself.
184
virtual
185
void
186
score
(
XYZ_Func
const
& xyz_func,
EnergyMap
const
& weights,
EnergyMap
& emap )
const
= 0;
187
188
/// @brief Returns a unique string identified for this constraint. Used in several
189
/// places, including the ConstraintIO class.
190
virtual
191
std::string
type
()
const
{
192
return
"UNKNOWN_TYPE"
;
193
}
194
195
// do some pre-scoring calculations -- does nothing by default
196
virtual
void
setup_for_scoring
(
XYZ_Func
const
&,
ScoreFunction
const
& )
const
{}
197
198
// call the setup_for_derivatives for each constraint -- does nothing by default
199
virtual
void
setup_for_derivatives
(
XYZ_Func
const
&,
ScoreFunction
const
& )
const
{}
200
201
/// @brief Returns the score of this constraint computed over the given conformation.
202
/// Not necessarily implemented in all derived classes, as it's redundant with
203
/// the score( XYZ_Func, EnergyMap, EnergyMap ) method defined above. Returns
204
/// 0.0 if not implemented.
205
virtual
206
Real
207
score
(
conformation::Conformation
const
& )
const
{
return
0.0; }
208
209
/// @brief Fill the f1 and f2 vectors, necessary for considering the
210
/// derivative this constraint during minimization. (someone please reference
211
/// Bill Wedermeyer's paper here, as I'm in an airport and can't fill it in
212
/// myself!)
213
virtual
214
void
215
fill_f1_f2
(
216
AtomID
const
&
atom
,
217
XYZ_Func
const
& xyz_func,
218
Vector
& F1,
219
Vector
& F2,
220
EnergyMap
const
& weights
221
)
const
= 0;
222
223
/// @brief This method is intended to show the value of the Constraint function
224
/// evaluated over some reasonable range of values. For example, a constraint
225
/// between pairs of atoms might show the values of the Constraint function
226
/// between 4 and 12 angstroms.
227
virtual
void
show
( std::ostream &
/*out*/
)
const
{
228
unimplemented_method_error
(
std::string
(
"show"
) );
229
}
230
231
/// @brief Prints the definition of a Constraint to the given std::ostream,
232
/// using the given Pose, and the given FuncFactory. This method is intended
233
/// to be overridden by derived classes if they'd like to use the
234
/// ConstraintIO machinery. It's also not clear why this method takes a Pose,
235
/// other than to be symmetric with read_def.
236
virtual
void
show_def
( std::ostream &
/*out*/
,
pose::Pose
const
& )
const
{
237
unimplemented_method_error
(
std::string
(
"show_def"
) );
238
}
239
240
// @brief Reads the definition of a Constraint from the given std::istream,
241
// using the given Pose, and the given FuncFactory. This method is intended
242
// to be overridden by derived classes if they'd like to use the
243
// ConstraintIO machinery.
244
virtual
void
read_def
( std::istream &,
pose::Pose
const
&,
FuncFactory
const
& ) {
245
unimplemented_method_error
(
std::string
(
"read_def"
) );
246
}
247
248
// @brief take coordinates, distances, angles, etc from given pose
249
///
250
virtual
void
steal_def
(
pose::Pose
const
& ) {
251
unimplemented_method_error
(
std::string
(
"steal_def"
) );
252
}
253
254
/// @brief Convenience function, returns the results of show() as a string.
255
/// Not to be overriden by derived classes.
256
std::string
to_string
()
const
{
257
std::ostringstream out;
258
show
(out);
259
return
out.str();
260
}
261
262
/// @brief Prints the violations of this constraint to the given
263
/// std::ostream. What are violations? It's not defined, and it depends on
264
/// the constraint and the function! also - wtf is threshold? it was defined
265
/// as a Size in CoordinateConstraint, I don't know which definition is the
266
/// right one. Documentation would be nice ...
267
virtual
Size
show_violations
(
268
std::ostream & out,
269
pose::Pose
const
&,
270
Size
,
271
Real
threshold = 1
272
)
const
;
273
274
/// @brief Returns the Func object associated with this Constraint object.
275
virtual
276
Func
const
&
get_func
()
const
{
277
unimplemented_method_error
(
std::string
(
"get_func"
) );
278
static
HarmonicFunc
dummy_func( 0.0, 0.0);
279
return
dummy_func;
// satisfy compiler
280
}
281
282
283
/// @brief possibility to do object comparison instead
284
/// of pointer comparison
285
virtual
286
bool
operator ==
(
Constraint
const
&
/*other*/
)
const
{
287
unimplemented_method_error
(
std::string
(
"== operator"
) );
288
return
false
;
289
}
290
291
/// @brief possibility to do object comparison instead
292
/// of pointer comparison
293
bool
operator !=
(
Constraint
const
& other )
const
{
294
return
!(*
this
== other);
295
}
296
297
virtual
298
core::Size
choose_effective_sequence_separation
(
299
core::kinematics::ShortestPathInFoldTree
const
& sp,
300
numeric::random::RandomGenerator&
301
) {
302
return
effective_sequence_separation
( sp );
303
}
304
305
306
virtual
307
core::Size
effective_sequence_separation
(
core::kinematics::ShortestPathInFoldTree
const
& )
const
{
308
return
0;
309
}
310
311
private
:
312
ScoreType
const
score_type_
;
313
314
/// @brief Utility method for producing useful error messages and exiting
315
/// from program. Declared const which is funny, because exiting the program
316
/// certainly changes the state of this object! This might be replaced with
317
/// exception handling if we ever start using those inside of mini.
318
void
unimplemented_method_error
(
std::string
const
& method_name )
const
{
319
utility_exit_with_message(
320
"Called Constraint::"
+ method_name +
" method from derived class "
+
321
type
() +
","
+
"ended up in Constraint::"
+ method_name +
"\n"
322
);
323
}
324
};
// class Constraint
325
326
327
inline
std::ostream&
operator<<
( std::ostream & out,
Constraint
& cst ) {
328
cst.
show
( out );
329
return
out;
330
}
331
332
333
}
// constraints
334
}
// scoring
335
}
// core
336
337
#endif
Generated on Sat Jun 1 2013 11:35:12 for Rosetta 3.5 by
1.8.4