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
kinematics
ResidueCoordinateChangeList.cc
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/kinematics/ResidueCoordinateChangeList.fwd.hh
11
/// @brief AtomTree/Conformation communication vector class forward declaration
12
/// @author Andrew Leaver-Fay
13
14
// Unit headers
15
#include <
core/kinematics/ResidueCoordinateChangeList.hh
>
16
17
// Package headers
18
#include <
core/id/AtomID.hh
>
19
20
#include <basic/Tracer.hh>
21
22
static
basic::Tracer
tr
(
"core.kinematics"
,basic::t_info);
23
24
namespace
core {
25
namespace
kinematics {
26
27
ResidueCoordinateChangeList::ResidueCoordinateChangeList
()
28
:
29
ReferenceCount(),
30
total_residue_( 0 )
31
{
32
}
33
34
ResidueCoordinateChangeList::~ResidueCoordinateChangeList
()
35
{}
36
37
ResidueCoordinateChangeList
const
&
38
ResidueCoordinateChangeList::operator =
(
ResidueCoordinateChangeList
const
& rhs )
39
{
40
if
(
this
== &rhs )
return
*
this
;
41
42
clear
();
// O(k) -- wipe change information from up until now.
43
44
total_residue_
= rhs.
total_residue_
;
45
changed_residues_
.reserve(
total_residue_
);
46
changed_residues_
= rhs.
changed_residues_
;
47
residue_change_id_
.resize(
total_residue_
, 0 );
48
if
(
changed_residues_
.size() != 0 ) {
49
// O(k) -- copy over the parts that need changing
50
for
(
Size
ii = 1; ii <=
changed_residues_
.size(); ++ii ) {
51
residue_change_id_
[
changed_residues_
[ ii ] ] = rhs.
residue_change_id_
[ changed_residues_ [ ii ] ];
52
}
53
}
54
return
*
this
;
55
}
56
57
58
/// @details adding and deleting residues repeatedly should be O(1)
59
/// so use the stl resize-with-argument command when resizing residue_change_id_.
60
/// That way, if residue_change_id_ has reserved space of at least total_residue,
61
/// then the resize will initialize exactly the number of new residues that have
62
/// been added.
63
/// In debug mode, this operation is O( total_residue ).
64
void
65
ResidueCoordinateChangeList::total_residue
(
Size
total_residue )
66
{
67
assert(
empty
() );
68
assert(
no_residues_with_nonzero_change_id
() );
69
70
total_residue_
=
total_residue
;
71
changed_residues_
.reserve(
total_residue_
);
72
residue_change_id_
.resize(
total_residue_
, 0 );
73
}
74
75
76
/// @brief Is the list of the changed residues empty? bool
77
bool
78
ResidueCoordinateChangeList::empty
()
const
79
{
80
return
changed_residues_
.size() == 0;
81
}
82
83
bool
84
ResidueCoordinateChangeList::no_residues_with_nonzero_change_id
()
const
85
{
86
for
(
Size
ii = 1; ii <=
total_residue_
; ++ii ) {
87
if
(
residue_change_id_
[ ii ] != 0 ) {
88
return
false
;
89
}
90
}
91
return
true
;
92
}
93
94
/// @details -- reset the residue_change_id_ for those residues which had previously changed
95
void
96
ResidueCoordinateChangeList::clear
()
97
{
98
for
(
Size
ii = 1; ii <=
changed_residues_
.size(); ++ii ) {
99
assert(
residue_change_id_
[
changed_residues_
[ ii ] ] != 0 );
100
residue_change_id_
[
changed_residues_
[ ii ] ] = 0;
101
}
102
changed_residues_
.clear();
103
}
104
105
/// @brief Mark a residue as having changed by passing in an AtomId for one atom
106
/// in that residue
107
void
108
ResidueCoordinateChangeList::mark_residue_moved
(
id::AtomID
atid )
109
{
110
mark_residue_moved
( atid.
rsd
() );
111
}
112
113
/// @brief Mark a residue as having changed by passing in the index of that residue.
114
void
115
ResidueCoordinateChangeList::mark_residue_moved
(
Size
resid )
116
{
117
if
( !(resid>0 && resid <=
total_residue_
)) {
118
tr
.Error <<
"ASSERTION FAILED IN ResidueCoordinateChangeList: resid: "
<< resid <<
" total_residue "
<<
total_residue_
<< std::endl;
119
}
120
assert( resid > 0 && resid <=
total_residue_
);
121
if
(
residue_change_id_
[ resid ] == 0 ) {
122
changed_residues_
.push_back( resid );
123
residue_change_id_
[ resid ] =
changed_residues_
.size();
124
}
/// else, the residue has already been marked as having changed
125
126
}
127
128
/// @brief returns an iterator to the beginning of the (unordered) list of
129
/// residues that have moved.
130
ResidueListIterator
131
ResidueCoordinateChangeList::residues_moved_begin
()
const
132
{
133
return
changed_residues_
.begin();
134
}
135
136
/// @brief returns an iterator to the end of the (unordered) list of
137
/// residues that have moved.
138
ResidueListIterator
139
ResidueCoordinateChangeList::residues_moved_end
()
const
140
{
141
return
changed_residues_
.end();
142
}
143
144
145
}
// namespace kinematics
146
}
// namespace core
147
Generated on Sat Jun 1 2013 11:33:07 for Rosetta 3.5 by
1.8.4