Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SS_Info.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/scoring/ScoringManager.hh
11 /// @brief Scoring manager class header
12 /// @author Andrew Leaver-Fay (leaverfa@email.unc.edu)
13 
14 /// Unit headers
15 #include <core/scoring/SS_Info.hh>
16 
17 /// Package headers
19 #include <core/pose/Pose.hh>
20 
21 #include <ObjexxFCL/format.hh>
22 
23 /// C++ Headers
24 #include <iostream>
25 
26 #include <utility/vector1.hh>
27 
28 
29 namespace core {
30 namespace scoring {
31 
32 /// @details. After a change in size, the residue types and the integer indices are all wrong.
33 /// Erase the old information.
34 void
35 BB_Pos::resize( int const nres )
36 {
37  if ( N_.size() == (Size) nres ) return;
38 
39  N_.resize( nres );
40  CA_.resize( nres );
41  C_.resize( nres );
42  O_.resize( nres );
43  CB_.resize( nres );
44 
45  residue_types_.resize( nres ); std::fill( residue_types_.begin(), residue_types_.end(), static_cast< chemical::ResidueType const * > (0) );
46  N_index_.resize( nres ); std::fill( N_index_.begin(), N_index_.end(), 0 );
47  CA_index_.resize( nres ); std::fill( CA_index_.begin(), CA_index_.end(), 0 );
48  CB_index_.resize( nres ); std::fill( CB_index_.begin(), CB_index_.end(), 0 );
49  C_index_.resize( nres ); std::fill( C_index_.begin(), C_index_.end(), 0 );
50  O_index_.resize( nres ); std::fill( O_index_.begin(), O_index_.end(), 0 );
51 
52 }
53 
54 /// @details: Optimize the common case where the sequence of the pose is not changing from
55 /// score function evaluation to evaluation (e.g. abinitio!)
56 void
58 {
59  if ( ! bbindices_up_to_date( pose ) ) {
60  update_indices( pose );
61  }
62 
63  for ( Size i=1; i<= pose.total_residue(); ++i ) {
64  conformation::Residue const & rsd( pose.residue(i) );
65  if ( rsd.is_protein() ) {
66  assert( N_index_[ i ] );
67  assert( CA_index_[ i ] );
68  assert( C_index_[ i ] );
69  assert( O_index_[ i ] );
70 
71  N_ [i] = rsd.xyz( N_index_[ i ] );
72  CA_[i] = rsd.xyz( CA_index_[ i ] );
73  C_ [i] = rsd.xyz( C_index_[ i ] );
74  O_ [i] = rsd.xyz( O_index_[ i ] );
75  if ( rsd.aa() == chemical::aa_gly ) {
76  CB_[i] = 0.0;
77  } else {
78  CB_[i] = rsd.xyz( CB_index_[ i ] );
79  }
80  } else {
81  N_ [i] = 0.0;
82  CA_[i] = 0.0;
83  C_ [i] = 0.0;
84  O_ [i] = 0.0;
85  CB_[i] = 0.0;
86  }
87  }
88 
89 }
90 
91 bool
93 {
94  if ( N_.size() != pose.total_residue() ) return false;
95 
96  for ( Size ii = 1; ii <= pose.total_residue(); ++ii ) {
97  if ( residue_types_[ ii ] != & ( pose.residue_type( ii ) ) ) return false;
98  }
99  return true;
100 }
101 
102 void
104 {
105  resize( pose.total_residue() );
106 
107  static std::string const bbN("N");
108  static std::string const bbCA("CA");
109  static std::string const bbC("C");
110  static std::string const bbO("O");
111  static std::string const scCB("CB");
112 
113  for ( Size i = 1; i <= pose.total_residue(); ++i ) {
114  conformation::Residue const & rsd( pose.residue(i) );
115  residue_types_[ i ] = & ( rsd.type() );
116  if ( rsd.is_protein() ) {
117 
118  N_index_[ i ] = rsd.atom_index( bbN );
119  CA_index_[ i ] = rsd.atom_index( bbCA );
120  C_index_[ i ] = rsd.atom_index( bbC );
121  O_index_[ i ] = rsd.atom_index( bbO );
122 
123  if ( rsd.aa() == chemical::aa_gly ) {
124  CB_index_[ i ] = 0;
125  } else {
126  CB_index_[ i ] = rsd.atom_index( scCB );
127  }
128  } else {
129  N_index_[ i ] = 0;
130  CA_index_[ i ] = 0;
131  C_index_[ i ] = 0;
132  O_index_[ i ] = 0;
133  CB_index_[ i ] = 0;
134  }
135  }
136 
137 
138 }
139 
140 
141 
142 //////////////////////////////////////////////////////////////////////////////////////////////////////
143 
144 /// @brief default constructor
146 {}
147 
148 /// @brief total residue constructor
150  int const & total_residue
151 )
152 {
153  resize( total_residue );
154 }
155 
156 /// @brief copy constructor
158  Strands const & s
159 ) : total_SS_dimer( s.total_SS_dimer ),
160  SS_resnum( s.SS_resnum ),
161  total_strands( s.total_strands ),
162  SS_strand( s.SS_strand ),
163  SS_dimer( s.SS_dimer ),
164  SS_strand_end( s.SS_strand_end ),
165  dimer_neighbor( s.dimer_neighbor )
166  //strand_strand_score( s.strand_strand_score )
167 {}
168 
169 /// @brief default destructor
171 {}
172 
173 ///
174 void
175 Strands::resize( Size const nres )
176 {
177  if ( SS_resnum.size1() == nres ) return;
178  SS_resnum.dimension( nres );
179  SS_strand.dimension( nres );
180  SS_dimer.dimension( nres );
181  SS_strand_end.dimension( 2, nres );
182  dimer_neighbor.dimension( 2, nres );
183  clear();
184 }
185 
187  SS_resnum = 0;
188  SS_strand = 0;
189  SS_dimer = 0;
190  SS_strand_end = 0;
191  dimer_neighbor = 0;
192 }
193 
194 /// @brief copy assignment
195 Strands const &
197 {
198  if ( this != &s ) {
200  SS_resnum = s.SS_resnum;
202  SS_strand = s.SS_strand;
203  SS_dimer = s.SS_dimer;
206  //strand_strand_score = s.strand_strand_score;
207  }
208  return *this;
209 }
210 
211 
212 std::ostream &
213 operator<< ( std::ostream & out, Strands const & s )
214 {
215  using ObjexxFCL::fmt::I;
216  out << "Strands: " << s.total_strands << " strands, " << s.total_SS_dimer << " dimers.\n";
217  for ( int i=1; i<= s.total_SS_dimer; ++i ) {
218  out << "Strands: " << I(4,i) << I(4,s.SS_strand(i)) << I(4,s.SS_resnum(i)) << I(4,s.SS_dimer(s.SS_resnum(i))) <<
219  I(4,s.SS_strand_end(1,i)+1) << "-" << I(4,s.SS_strand_end(2,i)-1) << '\n';
220  }
221  return out;
222 }
223 
224 //////////////////////////////////////////////////////////////////////////////////////////////////////
225 
226 
227 /// @brief default constructor
229 {}
230 
231 /// @brief total residue constructor
233  int const & total_residue
234 )
235 {
236  resize( total_residue );
237 }
238 
239 ///
240 void
241 Helices::resize( int const nres )
242 {
243  HH_resnum.dimension( nres );
244  HH_helix_end.dimension( 2, nres );
245 }
246 
248  Helices const & h
249 ) : total_HH_dimer( h.total_HH_dimer ),
250  HH_resnum( h.HH_resnum ),
251  HH_helix_end( h.HH_helix_end )
252 {}
253 
255 {}
256 
257 Helices const &
259 {
260  if ( this != &h ) {
262  HH_resnum = h.HH_resnum;
264  }
265  return *this;
266 }
267 
268 std::ostream &
269 operator<< ( std::ostream & out, Helices const & s )
270 {
271  using ObjexxFCL::fmt::I;
272  out << "Helices: " << s.total_HH_dimer << " dimers.\n";
273  for ( int i=1; i<= s.total_HH_dimer; ++i ) {
274  out << "Helices: " << I(4,i) << I(4,s.HH_resnum(i)) << I(4,s.HH_helix_end(1,i)+1) << "-" <<
275  I(4,s.HH_helix_end(2,i)-1) << '\n';
276  }
277  return out;
278 }
279 
280 
281 
282 } // ns scoring
283 } // ns core
284