Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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
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 
28 :
29  ReferenceCount(),
30  total_residue_( 0 )
31 {
32 }
33 
35 {}
36 
39 {
40  if ( this == &rhs ) return *this;
41 
42  clear(); // O(k) -- wipe change information from up until now.
43 
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
66 {
67  assert( empty() );
69 
73 }
74 
75 
76 /// @brief Is the list of the changed residues empty? bool
77 bool
79 {
80  return changed_residues_.size() == 0;
81 }
82 
83 bool
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
97 {
98  for ( Size ii = 1; ii <= changed_residues_.size(); ++ii ) {
99  assert( 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
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
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.
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.
140 {
141  return changed_residues_.end();
142 }
143 
144 
145 } // namespace kinematics
146 } // namespace core
147