Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MMBondAngleResidueTypeParam.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/mm/MMBondAngleResidueTypeParam.cc
11 /// @brief Class to store bond angle parameters for a particular ResidueType
12 /// @author Colin A. Smith (colin.smith@ucsf.edu)
13 
14 // Unit headers
16 
17 // Project headers
18 #include <core/chemical/Atom.hh>
22 #include <basic/Tracer.hh>
23 
24 // Numeric headers
25 #include <numeric/xyz.functions.hh>
26 
27 // Utility header
28 #include <numeric/conversions.hh>
29 #include <utility/string_util.hh>
30 
32 #include <utility/vector1.hh>
33 
34 
35 // C++ headers
36 
37 static basic::Tracer TR("core.mm.MMBondAngleResidueTypeParam");
38 
39 
40 namespace core {
41 namespace scoring {
42 namespace mm {
43 
45 { }
46 
47 bool
49  core::chemical::ResidueType const & restype,
50  utility::vector1<std::string> const & central_atoms_to_score,
51  Size atomno
52 )
53 {
54  if ( central_atoms_to_score.size() == 0 ) return true;
55 
56  for ( Size ii = 1; ii <= central_atoms_to_score.size(); ++ii ) {
57  if ( utility::same_ignoring_spaces( restype.atom_name( atomno ), central_atoms_to_score[ ii ] )) {
58  //std::cout << "Counting atom " << atomno << " " << restype.name() << " " << restype.atom_name( atomno ) << std::endl;
59  return true;
60  }
61  }
62  return false;
63 }
64 
65 void
67  core::chemical::ResidueType const & residue_type,
69  bool use_residue_type_theta0,
70  utility::vector1<std::string> const & central_atoms_to_score
71 )
72 {
73  // add data for intraresidue bond angles
74  bondangle_atom_sets_.clear();
75  Ktheta_.clear();
76  theta0_.clear();
77 
78  for (core::Size i = 1; i <= residue_type.num_bondangles(); ++i) {
79 
80  three_atom_set const & atom_set(residue_type.bondangle(i));
81  if (!score_atom_centrally(residue_type, central_atoms_to_score, atom_set.key2())) continue;
82 
83  core::Real residue_type_theta0(numeric::angle_radians(residue_type.atom(atom_set.key1()).ideal_xyz(), residue_type.atom(atom_set.key2()).ideal_xyz(), residue_type.atom(atom_set.key3()).ideal_xyz()));
84 
85  std::string const & type1(residue_type.mm_atom_type(atom_set.key1()).name());
86  std::string const & type2(residue_type.mm_atom_type(atom_set.key2()).name());
87  std::string const & type3(residue_type.mm_atom_type(atom_set.key3()).name());
88 
89  //TR << residue_type.atom_name(atom_set.key1()) << "-"
90  // << residue_type.atom_name(atom_set.key2()) << "-"
91  // << residue_type.atom_name(atom_set.key3())
92  // << " (" << type1 << "-" << type2 << "-" << type3 << ")";
93 
94  core::scoring::mm::mm_bondangle_library_citer_pair mm_pair(mm_bondangle_library.lookup(type1, type2, type3));
95 
96  // make sure there is at least one set of parameters defined
97  assert(mm_pair.first != mm_pair.second);
98 
99  core::Real mm_Ktheta((mm_pair.first->second).key1());
100  core::Real mm_theta0((mm_pair.first->second).key2());
101 
102  // make sure there was only one set of parameters defined
103  assert(++mm_pair.first == mm_pair.second);
104 
105  //TR << " mm_Ktheta: " << mm_Ktheta << " mm_theta0: " << numeric::conversions::degrees(mm_theta0)
106  // << " rt_theta0: " << numeric::conversions::degrees(residue_type_theta0);
107 
108  if (mm_Ktheta) {
109  bondangle_atom_sets_.push_back(atom_set);
110  Ktheta_.push_back(mm_Ktheta);
111  theta0_.push_back(use_residue_type_theta0 ? residue_type_theta0 : mm_theta0);
112  } else {
113  //TR << " Ignoring";
114  }
115 
116  //TR << std::endl;
117  }
118 
119  // update bondangles_for_atom_ and bondangle_index_
120  bondangles_for_atom_.clear();
121  bondangles_for_atom_.resize( residue_type.natoms() );
122  bondangle_index_.clear();
123 
124  for (core::Size i = 1; i <= bondangle_atom_sets_.size(); ++i) {
125 
127  bondangles_for_atom_[bondangle_atom_set.key1()].push_back(i);
128  bondangles_for_atom_[bondangle_atom_set.key2()].push_back(i);
129  bondangles_for_atom_[bondangle_atom_set.key3()].push_back(i);
130 
131  // forward mapping
133  // reverse mapping
134  bondangle_index_[three_atom_set(bondangle_atom_set.key3(), bondangle_atom_set.key2(), bondangle_atom_set.key1())] = i;
135  }
136 
137  // add data for interresidue bond angles
138  connection_atom_sets_.clear();
139  connection_theta0_.clear();
140  connection_use_theta0_.clear();
141  connection_index_.clear();
142  connection_atom_sets_.resize(residue_type.n_residue_connections());
143  connection_theta0_.resize(residue_type.n_residue_connections());
144  connection_use_theta0_.resize(residue_type.n_residue_connections());
145  connection_index_.resize(residue_type.n_residue_connections());
146 
147  for (core::Size i = 1; i <= residue_type.n_residue_connections(); ++i) {
148 
149  core::chemical::ResidueConnection const & residue_connection(residue_type.residue_connection(i));
150  core::Size const connection_atomno(residue_connection.atomno());
151  if (!score_atom_centrally(residue_type, central_atoms_to_score, connection_atomno)) {
152  continue;
153  }
154  core::Vector external_xyz(residue_connection.icoor().build(residue_type));
155  core::chemical::AtomIndices const & bonded_neighbors(residue_type.bonded_neighbor(connection_atomno));
156 
157  for (core::Size j = 1; j <= bonded_neighbors.size(); ++j) {
158 
159  core::Real residue_type_theta0(numeric::angle_radians(residue_type.atom(bonded_neighbors[j]).ideal_xyz(), residue_type.atom(connection_atomno).ideal_xyz(), external_xyz));
160 
161  //std::string const & type1(residue_type.mm_atom_type(bonded_neighbors[j]).name());
162  //std::string const & type2(residue_type.mm_atom_type(connection_atomno).name());
163 
164  //TR << residue_type.atom_name(bonded_neighbors[j]) << "-"
165  // << residue_type.atom_name(connection_atomno) << "-?"
166  // << " (" << type1 << "-" << type2 << "-?)"
167  // << " rt_theta0: " << numeric::conversions::degrees(residue_type_theta0) << std::endl;
168 
169  two_atom_set const connection_atom_set(bonded_neighbors[j], connection_atomno);
170  connection_atom_sets_[i].push_back(connection_atom_set);
171  connection_theta0_[i].push_back(residue_type_theta0);
172  connection_use_theta0_[i].push_back(use_residue_type_theta0);
173 
174  connection_index_[i][connection_atom_set] = j;
175  }
176  }
177 }
178 
179 /// @brief stream << MMBondAngleResidueTypeParam
180 std::ostream &
182  std::ostream & os,
183  MMBondAngleResidueTypeParam const & residue_type_param
184 )
185 {
186  os << "Intraresidue Bond Angles:" << std::endl;
187  for (core::Size i = 1; i <= residue_type_param.bondangle_atom_sets_.size(); ++i) {
188  os << residue_type_param.bondangle_atom_sets_[i].key1() << "-"
189  << residue_type_param.bondangle_atom_sets_[i].key2() << "-"
190  << residue_type_param.bondangle_atom_sets_[i].key3()
191  << " Ktheta: " << residue_type_param.Ktheta_[i]
192  << " theta0: " << numeric::conversions::degrees(residue_type_param.theta0_[i]) << std::endl;
193  }
194 
195  for (core::Size i = 1; i <= residue_type_param.connection_atom_sets_.size(); ++i) {
196  os << "Connection " << i << " Bond Angles:" << std::endl;
197  for (core::Size j = 1; j <= residue_type_param.connection_atom_sets_[i].size(); ++j) {
198  os << residue_type_param.connection_atom_sets_[i][j].key1() << "-"
199  << residue_type_param.connection_atom_sets_[i][j].key2() << "-?"
200  << " rt_theta0: " << numeric::conversions::degrees(residue_type_param.connection_theta0_[i][j]) << " "
201  << (residue_type_param.connection_use_theta0_[i][j] ? "use_residue_type_theta0" : "use_mm_theta0") << std::endl;
202  }
203  }
204 
205  return os;
206 }
207 
208 } // namespace mm
209 } // namespace scoring
210 } // namespace core