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
NeighborList.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
/// @author
13
14
15
#ifndef INCLUDED_core_scoring_NeighborList_hh
16
#define INCLUDED_core_scoring_NeighborList_hh
17
18
// Unit Headers
19
#include <
core/scoring/NeighborList.fwd.hh
>
20
21
// Package headers
22
23
// AUTO-REMOVED #include <core/scoring/EnergyGraph.fwd.hh>
24
#include <
core/scoring/ScoreFunction.fwd.hh
>
25
// AUTO-REMOVED #include <core/scoring/etable/EtableEnergy.fwd.hh>
26
27
28
// Project Headers
29
#include <
core/id/AtomID.hh
>
30
// AUTO-REMOVED #include <core/kinematics/DomainMap.hh>
31
#include <
core/pose/Pose.fwd.hh
>
32
#include <
core/types.hh
>
33
34
#include <numeric/xyzVector.hh>
35
36
37
// Utility Headers
38
// AUTO-REMOVED #include <utility/vector1.hh>
39
#include <utility/pointer/owning_ptr.hh>
40
#include <utility/pointer/ReferenceCount.hh>
41
42
#include <
core/kinematics/DomainMap.fwd.hh
>
43
#include <utility/vector1.hh>
44
#include <ObjexxFCL/FArray1D.hh>
45
46
47
48
namespace
core {
49
namespace
scoring {
50
51
/// an atom-atom neighborlist object
52
53
/**
54
The neighborlist is used during minimization to speed atom-atom energy
55
calculations. It stores a list of potentially interacting neighbor atoms
56
for each atom in the system.
57
58
The logic for using the nblist is tricky.
59
60
Tentative scheme:
61
turn on nblist scoring at start of minimization
62
63
// at this point, want pose to be fully scored
64
// so perhaps a call to scorefxn(pose) ??
65
// Real const start_score( scorefxn( pose ) );
66
67
pose.energies().setup_use_nblist( true );
68
69
Real const start_func( func( vars ) ); // nblist setup inside this call
70
71
now require that all energy evaluations have an identical set of moving
72
dofs (guaranteed if all energy calculations are inside function
73
evaluations). This is checked inside each scorecaln using the
74
nblist.
75
76
when using the nblist, the rsd-rsd neighbor information is not
77
updated. This will probably be a good thing in that it will smooth
78
the energy landscape during minimization...
79
80
in a nblist score calculation, we do two things: recover cached
81
energies for non-pair-moved positions, and get atom-atom energies
82
for the pairs that are on the nblist. We don't cache 2d energies
83
for moving positions, since we are not looping over rsd nbr links
84
for that score calculation so the caching would be pretty time-
85
consuming I think.
86
87
The nblist has the count_pair weights stored, so no calls to
88
count_pair !!
89
90
turn off nblist scoring at the end of minimization. Since we have not
91
been updating rsd-pair energies for moving pairs, and the rsd-rsd
92
nblist is potentially out of data, we reset the neighborgraph at this
93
point to ensure a complete score calculation next time.
94
95
**/
96
97
// move to separate file
98
class
AtomNeighbor
99
{
100
public
:
101
AtomNeighbor
() :
rsd_
( 0 ),
atomno_
( 0 ),
path_dist_
( 0 ),
weight_
( 0.0 ),
weight_func_
( 0.0 ) {}
102
103
AtomNeighbor
(
104
int
const
rsd_in,
105
int
const
atomno_in,
106
Size
const
path_dist_in,
107
Real
const
weight_in,
108
Real
const
weight_func_in = 1
109
):
110
rsd_
(rsd_in),
111
atomno_
(atomno_in),
112
path_dist_
(path_dist_in),
113
weight_
(weight_in),
114
weight_func_
(weight_func_in)
115
{}
116
117
118
///
119
int
120
rsd
()
const
121
{
122
return
rsd_
;
123
}
124
125
///
126
int
127
atomno
()
const
128
{
129
return
atomno_
;
130
}
131
132
Size
133
path_dist
()
const
134
{
135
return
path_dist_
;
136
}
137
138
///
139
Real
140
weight
()
const
141
{
142
return
weight_
;
143
}
144
145
///fpd
146
Real
147
weight_func
()
const
148
{
149
return
weight_func_
;
150
}
151
152
153
Real
&
temp1
()
const
{
return
temp1_
; }
154
Real
&
temp2
()
const
{
return
temp2_
; }
155
Real
&
temp3
()
const
{
return
temp3_
; }
156
Real
&
temp4
()
const
{
return
temp4_
; }
157
158
159
private
:
160
int
rsd_
;
161
int
atomno_
;
162
Size
path_dist_
;
163
Real
weight_
;
164
Real
weight_func_
;
///fpd
165
166
mutable
Real
temp1_
;
167
mutable
Real
temp2_
;
168
mutable
Real
temp3_
;
169
mutable
Real
temp4_
;
170
171
};
172
173
typedef
utility::vector1< AtomNeighbor >
AtomNeighbors
;
174
175
///////////////////////////////////////////////////////////////////////////////
176
class
NeighborList
:
public
utility::pointer::ReferenceCount
177
{
178
public
:
179
NeighborList
(
180
kinematics::DomainMap
const
&
domain_map
,
181
Real
const
XX_cutoff,
182
Real
const
XH_cutoff,
183
Real
const
HH_cutoff
184
);
185
186
virtual
187
~NeighborList
();
188
189
// Clone method used in copy ctors of classes that contain NeighborListOP's
190
// like, for example, Energies.
191
NeighborListOP
clone
()
const
{
return
new
NeighborList
( *
this
); }
192
193
///
194
AtomNeighbors
const
&
195
atom_neighbors
(
196
int
const
pos,
197
int
const
atomno
198
)
const
199
{
200
return
nblist_
[ pos ][ atomno ];
201
}
202
203
///
204
AtomNeighbors
const
&
205
atom_neighbors
(
206
id::AtomID
const
&
id
207
)
const
208
{
209
return
nblist_
[
id
.rsd() ][
id
.atomno() ];
210
}
211
212
AtomNeighbors
const
&
213
upper_atom_neighbors
(
214
int
const
pos,
215
int
const
atomno
216
)
const
217
{
218
return
upper_nblist_
[ pos ][ atomno ];
219
}
220
221
///
222
AtomNeighbors
const
&
223
upper_atom_neighbors
(
224
id::AtomID
const
&
id
225
)
const
226
{
227
return
upper_nblist_
[
id
.rsd() ][
id
.atomno() ];
228
}
229
230
AtomNeighbors
const
&
231
intrares_upper_atom_neighbors
(
232
int
const
pos,
233
int
const
atomno
234
)
const
235
{
236
return
intrares_upper_nblist_
[ pos ][ atomno ];
237
}
238
239
///
240
AtomNeighbors
const
&
241
intrares_upper_atom_neighbors
(
242
id::AtomID
const
&
id
243
)
const
244
{
245
return
intrares_upper_nblist_
[
id
.rsd() ][
id
.atomno() ];
246
}
247
248
249
250
/// @brief Initialize the nblist so that it reflects the current coordinates in the pose.
251
template
<
class
T_Etable >
252
void
253
setup
(
254
pose::Pose
const
& pose,
255
ScoreFunction
const
& sfxn,
256
T_Etable
const
&
etable_method
257
)
const
;
258
259
///
260
void
261
check_domain_map
(
262
kinematics::DomainMap
const
& domain_map_in
263
)
const
;
264
265
266
///
267
void
268
clear
()
269
{
270
nblist_
.clear();
271
}
272
273
///
274
kinematics::DomainMap
const
&
275
domain_map
()
const
276
{
277
return
domain_map_
;
278
}
279
280
/// @brief If auto_update_, ensure that no atom in the pose has not moved too much
281
/// since the last time the neighborlist was updated. The neighborlist
282
/// tracks the starting coords for all atoms, and then updates
283
template
<
class
T_Etable >
284
void
285
prepare_for_scoring
(
286
pose::Pose
const
& pose,
287
ScoreFunction
const
& sfxn,
288
T_Etable
const
&
etable_method
289
)
const
;
290
291
void
292
set_auto_update
(
Distance
move_tolerance );
293
294
void
295
disable_auto_update
();
296
297
private
:
298
299
void
300
update_from_wide_nblist
(
pose::Pose
const
& pose )
const
;
301
302
inline
303
DistanceSquared
304
atom_pair_cutoff
(
bool
atom1_is_hydrogen,
bool
atom2_is_hydrogen )
const
305
{
306
return
( ( atom1_is_hydrogen && atom2_is_hydrogen ) ?
307
HH_cutoff_
: ( ( atom1_is_hydrogen || atom2_is_hydrogen ) ?
308
XH_cutoff_
:
XX_cutoff_
) );
309
}
310
311
protected
:
312
313
void
314
declare_atoms_neighbors
(
id::AtomID
at1,
id::AtomID
at2,
Size
path_dist,
Real
weight,
Real
weight_func
= 1.0 )
const
;
315
316
void
317
declare_atom_neighbor_1sided
(
id::AtomID
at1,
id::AtomID
at2,
Size
path_dist,
Real
weight,
Real
weight_func
= 1.0 )
const
;
318
319
private
:
320
321
bool
auto_update_
;
322
323
//square of how far can any atom move before the nblist needs to be updated
324
DistanceSquared
move_tolerance_sqr_
;
325
326
// How far out should the wide nblist reach beyond XX_cutoff_
327
Distance
const
wide_nblist_extension_
;
328
329
// square of the coordinate movement before the wide_nblist's data becomes stale
330
// == ( wide_nblist_extension - sqrt( move_tolerance_) ) ^ 2
331
DistanceSquared
wide_move_tolerance_sqr_
;
332
333
mutable
utility::vector1< utility::vector1< AtomNeighbors >
>
nblist_
;
334
mutable
utility::vector1< utility::vector1< AtomNeighbors >
>
upper_nblist_
;
335
mutable
utility::vector1< utility::vector1< AtomNeighbors >
>
intrares_upper_nblist_
;
336
mutable
utility::vector1< utility::vector1< AtomNeighbors >
>
wide_nblist_
;
337
mutable
utility::vector1< utility::vector1< Vector >
>
reference_coords_
;
338
mutable
utility::vector1< utility::vector1< Vector >
>
wide_reference_coords_
;
339
340
kinematics::DomainMap
const
domain_map_
;
341
DistanceSquared
const
XX_cutoff_
;
342
DistanceSquared
const
XH_cutoff_
;
343
DistanceSquared
const
HH_cutoff_
;
344
345
Distance
const
sqrt_XX_cutoff_
;
346
Distance
const
sqrt_XH_cutoff_
;
347
Distance
const
sqrt_HH_cutoff_
;
348
349
350
/// Separation square distance for atom pairs in kept in the wide neighbor list
351
DistanceSquared
const
XX_cutoff_wide_
;
352
DistanceSquared
const
XH_cutoff_wide_
;
353
DistanceSquared
const
HH_cutoff_wide_
;
354
355
/// Variables for updating the nblist from the wide nblist
356
/// don't use v1< bool >: too slow
357
mutable
utility::vector1< utility::vector1< Size >
>
atom_needs_update_from_wide_
;
358
//mutable utility::vector1< utility::vector1< Size > > atom_has_been_updated_from_wide_;
359
mutable
utility::vector1< id::AtomID >
atoms_to_update_
;
360
361
mutable
Size
n_prepare_for_scorings_
;
362
mutable
Size
n_update_from_wide_
;
363
mutable
Size
n_full_updates_
;
364
};
365
366
typedef
utility::pointer::owning_ptr< NeighborList >
NeighborListOP
;
367
368
}
// namespace scoring
369
}
// namespace core
370
371
372
#endif
Generated on Sat Jun 1 2013 11:39:21 for Rosetta 3.5 by
1.8.4