Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Mutant.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 // This file is part of the Rosetta software suite and is made available under license.
5 // The Rosetta software is developed by the contributing members of the Rosetta Commons consortium.
6 // (C) 199x-2009 Rosetta Commons participating institutions and developers.
7 // For more information, see http://www.rosettacommons.org/.
8 
9 /// @file protocols/pmut_scan/Mutant.cc
10 /// @brief A helper class for the point mut scan protocol which holds data about mutants.
11 /// @author Ron Jacak
12 
13 
14 // Project Headers
16 
17 // AUTO-REMOVED #include <core/graph/Graph.hh>
18 #include <core/types.hh>
19 // AUTO-REMOVED #include <core/pose/Pose.fwd.hh>
20 // AUTO-REMOVED #include <core/scoring/ScoreFunction.fwd.hh>
21 // AUTO-REMOVED #include <core/scoring/EnergyMap.fwd.hh>
22 
23 // AUTO-REMOVED #include <basic/options/util.hh>
24 
25 // Utility headers
26 
27 // ObjexxFCL header
28 
29 // C++
30 // AUTO-REMOVED #include <string>
31 #include <iostream>
32 
33 #include <utility/vector1.hh>
34 #include <sstream>
35 
36 
37 namespace protocols {
38 namespace pmut_scan {
39 
40 
41 ///
42 /// @begin MutationData::MutationData
43 ///
44 /// @brief
45 /// Constructor for MutationData objects. A mutation holds the wt and mutant amino acid type, pdb resnum, pose resnum, chain and icode.
46 ///
47 MutationData::MutationData( char wt_residue, char mut_residue, core::Size pose_resnum, core::Size pdb_resnum, char icode, char chain ) :
48  wt_residue_( wt_residue ),
49  mut_residue_( mut_residue ),
50  pose_resnum_( pose_resnum ),
51  pdb_resnum_( pdb_resnum ),
52  icode_( icode ),
53  chain_( chain )
54 {}
55 
56 
57 ///
58 /// @begin MutationData::~MutationData
59 ///
60 /// @brief
61 /// Destructor for MutationData objects. No dynamically allocated memory held in MutationData objects so nothing to do here.
62 ///
64 
65 
66 ///
67 /// @begin MutationData::mutation_string
68 ///
69 /// @brief
70 /// Returns a string representation of this mutation.
71 ///
73  std::stringstream out;
74  out << chain_ << "-" << wt_residue_ << pose_resnum_ << mut_residue_;
75  return out.str();
76 }
77 
78 ///
79 /// @begin MutationData::mutation_string_PDB_numbering
80 ///
81 /// @brief
82 /// Returns a string representation of this mutation using PDB not pose numbering.
83 ///
85  std::stringstream out;
86  out << chain_ << "-" << wt_residue_ << pdb_resnum_;
87  if ( icode_ != ' ' ) {
88  out << icode_;
89  }
90  out << mut_residue_;
91  return out.str();
92 }
93 
94 ///
95 /// @begin MutationData::mut_residue
96 ///
97 /// @brief
98 /// Accessor for the mut_residue member variable. Needed by the function make_mutant_structure() in the PointMutScanDriver class.
99 ///
101  return mut_residue_;
102 }
103 
104 ///
105 /// @begin MutationData::pose_resnum
106 ///
107 /// @brief
108 /// Accessor for the pose_resnum member variable. Needed by the function make_mutant_structure() in the PointMutScanDriver class.
109 ///
111  return pose_resnum_;
112 }
113 
114 ///
115 /// @begin MutationData::print_mutation_data
116 ///
117 /// @brief
118 /// print function for MutationData class; only used by unit tests
119 ///
121  std::cout << md.wt_residue_ << md.pose_resnum_ << md.mut_residue_ << " (pdb chain/res: " << md.chain_ << "/" << md.pdb_resnum_ << ", icode: '" << md.icode_ << "')";
122 }
123 
124 ///
125 /// @begin MutationData::mutation_data_equals
126 ///
127 /// @brief
128 /// function which tests two MutationData objects for equality; only used by unit tests
129 ///
130 bool MutationData::operator==( const MutationData & md_other ) const {
131  if ( wt_residue_ == md_other.wt_residue_ && mut_residue_ == md_other.mut_residue_ &&
132  pose_resnum_ == md_other.pose_resnum_ && pdb_resnum_ == md_other.pdb_resnum_ &&
133  icode_ == md_other.icode_ && chain_ == md_other.chain_ ) {
134  return true;
135  }
136  return false;
137 }
138 
139 
140 /// @brief
141 /// Mutant class constructor
143 
144 /// @brief
145 /// Mutant class destructor
147 
148 
149 ///
150 /// @begin Mutant::n_mutations
151 ///
152 /// @brief
153 /// Returns the number of mutations in this mutant.
154 ///
156  return mutations_.size();
157 }
158 
159 ///
160 /// @begin Mutant::add_mutation
161 ///
162 /// @brief
163 /// Adds the passed in mutation to the class member list.
164 ///
166  mutations_.push_back( md );
167 }
168 
169 ///
170 /// @begin Mutant::mutations_begin
171 ///
172 /// @brief
173 /// Returns a const iterator to beginning of the mutations vector
174 ///
176  return mutations_.begin();
177 }
178 
179 ///
180 /// @begin Mutant::mutations_end
181 ///
182 /// @brief
183 /// Returns a const iterator to end of the mutations vector
184 ///
186  return mutations_.end();
187 }
188 
189 ///
190 /// @begin Mutant::operator==
191 ///
192 /// @brief
193 /// Function which tests two Mutant objects for equality; only used by unit tests
194 ///
195 bool Mutant::operator==( const Mutant & m_other ) const {
196 
197  if ( this->n_mutations() != m_other.n_mutations() ) { return false; }
198  utility::vector1< MutationData >::const_iterator this_iter, m_other_iter;
199 
200  for ( this_iter = mutations_begin(), m_other_iter = m_other.mutations_begin(); ((this_iter != mutations_end()) && (m_other_iter != m_other.mutations_end())); ++this_iter, ++m_other_iter ) {
201 
202  if ( !( (*this_iter).operator==(*m_other_iter) ) ) {
203  return false;
204  }
205  }
206 
207  return true;
208 }
209 
210 
211 ///
212 /// @begin Mutant::pop_mutation
213 ///
214 /// @brief
215 /// Sets the passed in reference to the first element of the mutations_ vector, and removes that element from the vector.
216 ///
218 
219  MutationData md = mutations_.front(); // uses MutationData assignment operator! does this need to be defined?
220  mutations_.erase( mutations_.begin() );
221 
222  return md;
223 }
224 
225 std::ostream & operator<< ( std::ostream & os, const MutationData & md ) {
226  os << md.chain_ << "/" << md.wt_residue_ << md.pose_resnum_ << md.mut_residue_ << " (pdb chain/res/icode: " << md.chain_ << "/" << md.pdb_resnum_ << md.icode_ << ")";
227  return os;
228 }
229 
230 
231 std::ostream & operator<< ( std::ostream & os, const Mutant & m ) {
232 
234  for ( m_iter = m.mutations_begin(); m_iter != m.mutations_end(); ++m_iter ) {
235  // don't print " + " token on first time through
236  if ( m_iter != m.mutations_begin() ) {
237  os << " + ";
238  }
239  os << *(m_iter);
240  }
241  return os;
242 }
243 
244 
245 } // namespace pmut_scan
246 } // namespace protocols
247