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
OneToAllEnergyContainer.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 core/scoring/OneToAllEnergyContainer.hh
11
/// @brief A container interface for storing and scoring long range energies
12
/// @author Frank DiMaio
13
14
#ifndef INCLUDED_core_scoring_OneToAllEnergyContainer_hh
15
#define INCLUDED_core_scoring_OneToAllEnergyContainer_hh
16
17
// Unit headers
18
#include <
core/scoring/OneToAllEnergyContainer.fwd.hh
>
19
20
// Package headers
21
#include <
core/scoring/LREnergyContainer.hh
>
22
#include <
core/scoring/EnergyMap.hh
>
23
24
// Utility headers
25
#include <utility/pointer/ReferenceCount.hh>
26
27
#include <utility/vector1.hh>
28
29
30
namespace
core {
31
namespace
scoring {
32
33
///////////////////////////////////////////////////////
34
35
class
OneToAllNeighborIterator
:
public
ResidueNeighborIterator
36
{
37
public
:
38
virtual
~OneToAllNeighborIterator
(){}
39
40
OneToAllNeighborIterator
(
41
Size
const
pos1_in,
42
Size
const
pos2_in,
43
bool
const
operating_on_pos1_in,
44
ScoreType
const
st,
45
utility::vector1< Real >
* table_in,
46
utility::vector1< bool >
* computed_in
47
):
48
pos1_
( pos1_in ),
49
pos2_
( pos2_in ),
50
operating_on_pos1_
(operating_on_pos1_in),
51
score_type_
( st ),
52
table_
( table_in ),
53
computed_
( computed_in )
54
{}
55
56
virtual
ResidueNeighborIterator
const
&
operator =
(
ResidueNeighborIterator
const
& src )
57
{
58
assert( dynamic_cast< OneToAllNeighborIterator const * >( &src ) );
59
OneToAllNeighborIterator
const
& my_src( static_cast< OneToAllNeighborIterator const & >( src ) );
60
pos1_
= my_src.
pos1_
;
61
pos2_
= my_src.
pos2_
;
62
table_
= my_src.
table_
;
63
computed_
= my_src.
computed_
;
64
return
*
this
;
65
}
66
67
virtual
ResidueNeighborIterator
const
&
operator ++
()
68
{
69
++
pos2_
;
70
if
(
pos2_
==
pos1_
) ++
pos2_
;
71
return
*
this
;
72
}
73
74
virtual
bool
operator ==
(
ResidueNeighborIterator
const
& other )
const
75
{
76
return
(
residue_iterated_on
() == other.
residue_iterated_on
() &&
77
neighbor_id
() == other.
neighbor_id
() );
78
}
79
80
virtual
bool
operator !=
(
ResidueNeighborIterator
const
& other )
const
81
{
82
return
!( *
this
== other );
83
}
84
85
virtual
Size
upper_neighbor_id
()
const
86
{
87
return
pos1_
;
// "upper" is always the fixed res, which is pos1_
88
}
89
90
virtual
Size
lower_neighbor_id
()
const
91
{
92
return
pos2_
;
93
}
94
95
virtual
Size
residue_iterated_on
()
const
96
{
97
return
operating_on_pos1_
?
pos1_
:
pos2_
;
98
}
99
100
virtual
Size
neighbor_id
()
const
101
{
102
return
operating_on_pos1_
?
pos2_
:
pos1_
;
103
}
104
105
virtual
void
save_energy
(
EnergyMap
const
& emap )
106
{
107
Real
const
energy( emap[
score_type_
] );
108
(*table_)[
pos2_
] = energy;
109
}
110
111
virtual
void
retrieve_energy
(
EnergyMap
& emap )
const
112
{
113
emap[
score_type_
] = (*table_)[
pos2_
];
114
}
115
116
virtual
void
accumulate_energy
(
EnergyMap
& emap )
const
117
{
118
emap[
score_type_
] += (*table_)[
pos2_
];
119
}
120
121
virtual
void
mark_energy_computed
()
122
{
123
//std::cerr << "OO mark_energy_computed( " << pos2_ << " )\n";
124
(*computed_)[
pos2_
] =
true
;
125
}
126
127
virtual
void
mark_energy_uncomputed
()
128
{
129
//std::cerr << "XX mark_energy_uncomputed( " << pos2_ << " )\n";
130
(*computed_)[
pos2_
] =
false
;
131
}
132
133
virtual
bool
energy_computed
()
const
134
{
135
return
(*
computed_
)[
pos2_
];
136
}
137
138
private
:
139
Size
pos1_
;
140
Size
pos2_
;
141
bool
operating_on_pos1_
;
142
ScoreType
score_type_
;
143
utility::vector1< Real >
*
table_
;
144
utility::vector1< bool >
*
computed_
;
145
};
146
147
148
///////////////////////////////////////////////////////
149
150
class
OneToAllNeighborConstIterator
:
public
ResidueNeighborConstIterator
151
{
152
public
:
153
virtual
~OneToAllNeighborConstIterator
(){}
154
155
OneToAllNeighborConstIterator
(
156
Size
const
pos1_in,
157
Size
const
pos2_in,
158
bool
const
operating_on_pos1_in,
159
ScoreType
const
st,
160
utility::vector1< Real >
const
* table_in,
161
utility::vector1< bool >
const
* computed_in
162
):
163
pos1_
( pos1_in ),
164
pos2_
( pos2_in ),
165
operating_on_pos1_
(operating_on_pos1_in),
166
score_type_
( st ),
167
table_
( table_in ),
168
computed_
( computed_in )
169
{}
170
171
virtual
ResidueNeighborConstIterator
const
&
operator =
(
ResidueNeighborConstIterator
const
& src )
172
{
173
assert( dynamic_cast< OneToAllNeighborConstIterator const * >( &src ) );
174
OneToAllNeighborConstIterator
const
& my_src( static_cast< OneToAllNeighborConstIterator const & >( src ) );
175
pos1_
= my_src.
pos1_
;
176
pos2_
= my_src.
pos2_
;
177
table_
= my_src.
table_
;
178
computed_
= my_src.
computed_
;
179
return
*
this
;
180
}
181
182
virtual
ResidueNeighborConstIterator
const
&
operator ++
()
183
{
184
++
pos2_
;
185
if
(
pos2_
==
pos1_
) ++
pos2_
;
186
return
*
this
;
187
}
188
189
virtual
bool
operator ==
(
ResidueNeighborConstIterator
const
& other )
const
190
{
191
return
(
residue_iterated_on
() == other.
residue_iterated_on
() &&
192
neighbor_id
() == other.
neighbor_id
() );
193
}
194
195
virtual
bool
operator !=
(
ResidueNeighborConstIterator
const
& other )
const
196
{
197
return
!( *
this
== other );
198
}
199
200
virtual
Size
upper_neighbor_id
()
const
201
{
202
return
pos1_
;
// "upper" is always the fixed res, which is pos1_
203
}
204
205
virtual
Size
lower_neighbor_id
()
const
206
{
207
return
pos2_
;
208
}
209
210
virtual
Size
residue_iterated_on
()
const
211
{
212
return
operating_on_pos1_
?
pos1_
:
pos2_
;
213
}
214
215
virtual
Size
neighbor_id
()
const
216
{
217
return
operating_on_pos1_
?
pos2_
:
pos1_
;
218
}
219
220
virtual
void
retrieve_energy
(
EnergyMap
& emap )
const
221
{
222
emap[
score_type_
] = (*table_)[
pos2_
];
223
}
224
225
virtual
void
accumulate_energy
(
EnergyMap
& emap )
const
226
{
227
emap[
score_type_
] += (*table_)[
pos2_
];
228
}
229
230
virtual
bool
energy_computed
()
const
231
{
232
return
(*
computed_
)[
pos2_
];
233
}
234
235
private
:
236
Size
pos1_
;
237
Size
pos2_
;
238
bool
operating_on_pos1_
;
239
ScoreType
score_type_
;
240
utility::vector1< Real >
const
*
table_
;
241
utility::vector1< bool >
const
*
computed_
;
242
};
243
244
///////////////////////////////////////////////////////////////////////////
245
246
class
OneToAllEnergyContainer
:
public
LREnergyContainer
247
{
248
public
:
249
virtual
250
~OneToAllEnergyContainer
(){};
251
252
virtual
253
LREnergyContainerOP
clone
()
const
254
{
255
return
new
OneToAllEnergyContainer
( *
this
);
256
}
257
258
OneToAllEnergyContainer
(
int
const
fixed_res_idx,
Size
const
size_in,
ScoreType
const
score_type_in ):
259
fixed_
( fixed_res_idx ),
260
size_
( size_in ),
261
score_type_
( score_type_in ),
262
table_
(
size_
, 0.0 ),
263
computed_
(
size_
, false )
264
{}
265
266
virtual
267
bool
empty
()
const
268
{
269
return
(
size_
== 0 );
270
}
271
272
virtual
273
void
274
set_num_nodes
(
Size
size_in ) {
275
size_
= size_in;
276
table_
.clear();
table_
.resize(
size_
, 0.0 );
277
computed_
.clear();
computed_
.resize(
size_
,
false
);
278
}
279
280
Size
281
size
()
const
282
{
283
return
size_
;
284
}
285
286
int
287
fixed
()
const
288
{
289
return
fixed_
;
290
}
291
292
//////////////////// const versions
293
virtual
294
ResidueNeighborConstIteratorOP
295
const_neighbor_iterator_begin
(
int
resid )
const
296
{
297
if
(resid ==
fixed_
) {
298
// loop over ALL tgts
299
return
new
OneToAllNeighborConstIterator
(
fixed_
, 1,
true
,
score_type_
, &
table_
, &
computed_
);
300
}
else
{
301
// loop over fixed only
302
//std::cerr << "START fixed " << fixed_ << " , resid " << resid << std::endl;
303
return
new
OneToAllNeighborConstIterator
(
fixed_
, resid,
false
,
score_type_
, &
table_
, &
computed_
);
304
}
305
}
306
307
virtual
308
ResidueNeighborConstIteratorOP
309
const_neighbor_iterator_end
(
int
resid )
const
310
{
311
if
(resid ==
fixed_
) {
312
// loop over ALL tgts
313
return
new
OneToAllNeighborConstIterator
(
fixed_
,
size_
+ 1,
true
,
score_type_
, &
table_
, &
computed_
);
314
}
else
{
315
// loop over fixed only
316
if
(resid+1 ==
fixed_
) {
317
//std::cerr << "END fixed " << fixed_ << " , resid " << resid+2 << std::endl;
318
return
new
OneToAllNeighborConstIterator
(
fixed_
, resid + 2,
false
,
score_type_
, &
table_
, &
computed_
);
319
}
else
{
320
//std::cerr << "END fixed " << fixed_ << " , resid " << resid+1 << std::endl;
321
return
new
OneToAllNeighborConstIterator
(
fixed_
, resid + 1,
false
,
score_type_
, &
table_
, &
computed_
);
322
}
323
}
324
}
325
326
virtual
327
ResidueNeighborConstIteratorOP
328
const_upper_neighbor_iterator_begin
(
int
resid )
const
329
{
330
if
(resid ==
fixed_
) {
331
// loop over NOTHING
332
return
new
OneToAllNeighborConstIterator
(
fixed_
,
size_
+ 1,
true
,
score_type_
, &
table_
, &
computed_
);
333
}
else
{
334
// loop over fixed only
335
return
new
OneToAllNeighborConstIterator
(
fixed_
, resid,
false
,
score_type_
, &
table_
, &
computed_
);
336
}
337
}
338
339
virtual
340
ResidueNeighborConstIteratorOP
341
const_upper_neighbor_iterator_end
(
int
resid )
const
342
{
343
return
const_neighbor_iterator_end
( resid );
344
}
345
346
//////////////////// non-const versions
347
virtual
348
ResidueNeighborIteratorOP
349
neighbor_iterator_begin
(
int
resid )
350
{
351
if
(resid ==
fixed_
) {
352
// loop over ALL tgts
353
return
new
OneToAllNeighborIterator
(
fixed_
, 1,
true
,
score_type_
, &
table_
, &
computed_
);
354
}
else
{
355
// loop over fixed only
356
return
new
OneToAllNeighborIterator
(
fixed_
, resid,
false
,
score_type_
, &
table_
, &
computed_
);
357
}
358
}
359
360
virtual
361
ResidueNeighborIteratorOP
362
neighbor_iterator_end
(
int
resid )
363
{
364
if
(resid ==
fixed_
) {
365
// loop over ALL tgts
366
return
new
OneToAllNeighborIterator
(
fixed_
,
size_
+ 1,
true
,
score_type_
, &
table_
, &
computed_
);
367
}
else
{
368
// loop over fixed only
369
if
(resid+1 ==
fixed_
)
370
return
new
OneToAllNeighborIterator
(
fixed_
, resid + 2,
false
,
score_type_
, &
table_
, &
computed_
);
371
else
372
return
new
OneToAllNeighborIterator
(
fixed_
, resid + 1,
false
,
score_type_
, &
table_
, &
computed_
);
373
}
374
}
375
376
virtual
377
ResidueNeighborIteratorOP
378
upper_neighbor_iterator_begin
(
int
resid )
379
{
380
if
(resid ==
fixed_
) {
381
// loop over NOTHING
382
return
new
OneToAllNeighborIterator
(
fixed_
,
size_
+ 1,
true
,
score_type_
, &
table_
, &
computed_
);
383
}
else
{
384
// loop over fixed only
385
return
new
OneToAllNeighborIterator
(
fixed_
, resid,
false
,
score_type_
, &
table_
, &
computed_
);
386
}
387
}
388
389
virtual
390
ResidueNeighborIteratorOP
391
upper_neighbor_iterator_end
(
int
resid )
392
{
393
return
neighbor_iterator_end
( resid );
394
}
395
396
private
:
397
int
fixed_
;
398
Size
/*const*/
size_
;
399
ScoreType
score_type_
;
400
401
utility::vector1< Real >
table_
;
402
utility::vector1< bool >
computed_
;
403
404
};
405
406
}
// namespace scoring
407
}
// namespace core
408
409
#endif
Generated on Sat Jun 1 2013 11:39:23 for Rosetta 3.5 by
1.8.4