Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
BB_Pos.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 ./src/protocols/fldsgn/topology/BB_Pos.cc
11 /// @brief
12 /// @author Andrew Leaver-Fay (leaverfa@email.unc.edu), Nobuyasu Koga ( nobuyasu@u.washington.edu )
13 
14 /// Unit headers
16 
17 /// Package headers
19 #include <core/pose/Pose.hh>
20 
21 #include <utility/vector1.hh>
22 
23 
24 namespace protocols {
25 namespace fldsgn {
26 namespace topology {
27 
28 /// @details. After a change in size, the residue types and the integer indices are all wrong.
29 /// Erase the old information.
30 void
31 BB_Pos::resize( Size const nres )
32 {
33  if ( N_.size() == (Size) nres ) return;
34 
35  N_.resize( nres );
36  CA_.resize( nres );
37  C_.resize( nres );
38  O_.resize( nres );
39  CB_.resize( nres );
40 
41  residue_types_.resize( nres ); std::fill( residue_types_.begin(), residue_types_.end(), static_cast< core::chemical::ResidueType const * > (0) );
42  N_index_.resize( nres ); std::fill( N_index_.begin(), N_index_.end(), 0 );
43  CA_index_.resize( nres ); std::fill( CA_index_.begin(), CA_index_.end(), 0 );
44  CB_index_.resize( nres ); std::fill( CB_index_.begin(), CB_index_.end(), 0 );
45  C_index_.resize( nres ); std::fill( C_index_.begin(), C_index_.end(), 0 );
46  O_index_.resize( nres ); std::fill( O_index_.begin(), O_index_.end(), 0 );
47 
48 }
49 
50 /// @details. After a change in size, the residue types and the integer indices are all wrong.
51 /// Erase the old information.
52 void
54 {
55  N_.clear();
56  CA_.clear();
57  C_.clear();
58  O_.clear();
59  CB_.clear();
60  residue_types_.clear();
61  N_index_.clear();
62  CA_index_.clear();
63  CB_index_.clear();
64  C_index_.clear();
65  O_index_.clear();
66 }
67 
68 /// @details: Optimize the common case where the sequence of the pose is not changing from
69 /// score function evaluation to evaluation (e.g. abinitio!)
70 void
72 {
73  if ( ! bbindices_up_to_date( pose ) ) {
74  update_indices( pose );
75  }
76 
77  for ( Size i=1; i<= pose.total_residue(); ++i ) {
78  core::conformation::Residue const & rsd( pose.residue(i) );
79  if ( rsd.is_protein() ) {
80  assert( N_index_[ i ] );
81  assert( CA_index_[ i ] );
82  assert( C_index_[ i ] );
83  assert( O_index_[ i ] );
84 
85  N_ [i] = rsd.xyz( N_index_[ i ] );
86  CA_[i] = rsd.xyz( CA_index_[ i ] );
87  C_ [i] = rsd.xyz( C_index_[ i ] );
88  O_ [i] = rsd.xyz( O_index_[ i ] );
89  if ( rsd.aa() == core::chemical::aa_gly ) {
90  CB_[i] = 0.0;
91  } else {
92  CB_[i] = rsd.xyz( CB_index_[ i ] );
93  }
94  } else {
95  N_ [i] = 0.0;
96  CA_[i] = 0.0;
97  C_ [i] = 0.0;
98  O_ [i] = 0.0;
99  CB_[i] = 0.0;
100  }
101  }
102 
103 }
104 
105 bool
106 BB_Pos::bbindices_up_to_date( Pose const & pose ) const
107 {
108  if ( N_.size() != pose.total_residue() ) return false;
109 
110  for ( Size ii = 1; ii <= pose.total_residue(); ++ii ) {
111  if ( residue_types_[ ii ] != & ( pose.residue_type( ii ) ) ) return false;
112  }
113  return true;
114 }
115 
116 void
118 {
119  resize( pose.total_residue() );
120 
121  static std::string const bbN("N");
122  static std::string const bbCA("CA");
123  static std::string const bbC("C");
124  static std::string const bbO("O");
125  static std::string const scCB("CB");
126 
127  for ( Size i = 1; i <= pose.total_residue(); ++i ) {
128  core::conformation::Residue const & rsd( pose.residue(i) );
129  residue_types_[ i ] = & ( rsd.type() );
130  if ( rsd.is_protein() ) {
131 
132  N_index_[ i ] = rsd.atom_index( bbN );
133  CA_index_[ i ] = rsd.atom_index( bbCA );
134  C_index_[ i ] = rsd.atom_index( bbC );
135  O_index_[ i ] = rsd.atom_index( bbO );
136 
137  if ( rsd.aa() == core::chemical::aa_gly ) {
138  CB_index_[ i ] = 0;
139  } else {
140  CB_index_[ i ] = rsd.atom_index( scCB );
141  }
142  } else {
143  N_index_[ i ] = 0;
144  CA_index_[ i ] = 0;
145  C_index_[ i ] = 0;
146  O_index_[ i ] = 0;
147  CB_index_[ i ] = 0;
148  }
149  }
150 
151 }
152 
153 
154 } // ns topology
155 } // ns fldsgn
156 } // ns protocols
157