Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HbaGrid.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/qsar/scoring_grid/HbaGrid.cc
11 /// @author Sam DeLuca
12 
15 
16 #include <core/pose/Pose.hh>
19 #include <core/id/AtomID.hh>
20 
21 #include <utility/tag/Tag.hh>
22 #include <utility/tools/make_vector.hh>
23 #include <utility/json_spirit/json_spirit_value.h>
24 #include <utility/vector0.hh>
25 #include <utility/vector1.hh>
26 #include <utility/io/mpistream.hh>
27 
28 #include <basic/database/open.hh>
29 
30 #include <numeric/interpolation/util.hh>
31 
32 namespace protocols {
33 namespace qsar {
34 namespace scoring_grid {
35 
36 
38 {
40 }
41 
43 {
44  GridBaseOP hba_grid= new HbaGrid();
45 
46  hba_grid->parse_my_tag(tag);
47 
48  return hba_grid;
49 }
50 
52 {
53  return new HbaGrid();
54 }
55 
57 {
58  return "HbaGrid";
59 }
60 
62 {
63  std::string lj_file(basic::database::full_name("scoring/qsar/hb_table.txt"));
64  lj_spline_ = numeric::interpolation::spline_from_file(lj_file,0.05).get_interpolator();
65 }
66 
67 
69 {
70 
71 }
72 
73 utility::json_spirit::Value HbaGrid::serialize()
74 {
75  using utility::json_spirit::Value;
76  using utility::json_spirit::Pair;
77 
78  Pair spline_data("spline",lj_spline_->serialize());
79  Pair base_data("base_data",SingleGrid::serialize());
80 
81  return Value(utility::tools::make_vector(spline_data,base_data));
82 
83 }
84 
85 void HbaGrid::deserialize(utility::json_spirit::mObject data)
86 {
87  lj_spline_->deserialize(data["spline"].get_obj());
88  SingleGrid::deserialize(data["base_data"].get_obj());
89 }
90 
91 void
93 
94 }
95 
96 void HbaGrid::refresh(core::pose::Pose const & pose, core::Vector const & )
97 {
98 
99  this->fill_with_value(0.0);
100 
101  for(core::Size residue_index = 1; residue_index <= pose.total_residue();++residue_index)
102  {
103  core::conformation::Residue const residue = pose.residue(residue_index);
104  if(!residue.is_protein())
105  {
106  continue;
107  }
108  for(core::Size atom_index=1; atom_index <= residue.natoms();++atom_index)
109  {
110  core::chemical::AtomType atom_type(residue.atom_type(atom_index));
111  if(atom_type.is_acceptor())
112  {
113  core::id::AtomID atom_id(atom_index,residue_index);
114  core::Vector xyz(pose.xyz(atom_id));
116  }
117  }
118  }
119 }
120 
121 void HbaGrid::refresh(core::pose::Pose const & pose, core::Vector const & center, core::Size const & )
122 {
123  refresh(pose,center);
124 }
125 
127 {
128  refresh(pose,center);
129 }
130 
131 core::Real HbaGrid::score(core::conformation::Residue const & residue, core::Real const max_score, qsarMapOP /*qsar_map*/)
132 {
133  core::Real score = 0.0;
134  //GridBaseTracer << "map size is: " << qsar_map->size() <<std::endl;
135  for(core::Size atom_index = 1; atom_index <= residue.nheavyatoms() && score < max_score;++atom_index)
136  {
137  core::Vector const & atom_coord(residue.xyz(atom_index));
138  if(this->get_grid().is_in_grid(atom_coord.x(),atom_coord.y(),atom_coord.z()))
139  {
140  core::chemical::AtomType atom_type(residue.atom_type(atom_index));
141  if(atom_type.is_hydrogen())
142  {
143  utility::vector1<core::Size> bonded_to_hydrogen(residue.bonded_neighbor(atom_index));
144  for(core::Size index = 1; index <= bonded_to_hydrogen.size();++index)
145  {
146  if(residue.atom_type(bonded_to_hydrogen[index]).is_donor())
147  {
148  core::Real grid_value = this->get_point(atom_coord.x(),atom_coord.y(),atom_coord.z());
149  score += grid_value;
150  }
151  }
152  }
153  }
154  }
155 
156  return score;
157 }
158 
160 {
161  core::Real score = 0;
162  core::Vector const & atom_coord(residue.xyz(atomno));
163  if(this->get_grid().is_in_grid(atom_coord.x(),atom_coord.y(),atom_coord.z()))
164  {
165  core::chemical::AtomType atom_type(residue.atom_type(atomno));
166  if(atom_type.is_hydrogen())
167  {
168  utility::vector1<core::Size> bonded_to_hydrogen(residue.bonded_neighbor(atomno));
169  for(core::Size index = 1; index <= bonded_to_hydrogen.size();++index)
170  {
171  if(residue.atom_type(bonded_to_hydrogen[index]).is_donor())
172  {
173  core::Real grid_value = this->get_point(atom_coord.x(),atom_coord.y(),atom_coord.z());
174  score += grid_value;
175  }
176  }
177  }
178  return score;
179  }
180  return 0;
181 }
182 
183 }
184 }
185 }