Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
VdwGrid.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/VdwGrid.cc
11 /// @author Sam DeLuca
12 
15 
16 
17 #include <core/id/AtomID.hh>
22 #include <core/pose/util.hh>
23 #include <core/pose/Pose.hh>
24 
25 #include <basic/database/open.hh>
26 
27 #include <numeric/interpolation/util.hh>
28 #include <numeric/interpolation/spline/SimpleInterpolator.hh>
29 
30 #include <utility/tag/Tag.hh>
31 #include <utility/tools/make_vector.hh>
32 #include <utility/vector0.hh>
33 #include <utility/vector1.hh>
34 
35 
36 namespace protocols {
37 namespace qsar {
38 namespace scoring_grid {
39 
41 {
43 }
44 
46 {
47  GridBaseOP vdw_grid= new VdwGrid();
48 
49  vdw_grid->parse_my_tag(tag);
50 
51  return vdw_grid;
52 }
53 
55 {
56  return new VdwGrid();
57 }
58 
59 
61 {
62  return "VdwGrid";
63 }
64 
65 VdwGrid::VdwGrid() : SingleGrid("VdwGrid"), cutoff_(10.0)
66 {
67  std::string lj_file(basic::database::full_name("scoring/qsar/lj_table.txt"));
68  lj_spline_ = numeric::interpolation::spline_from_file(lj_file,0.01).get_interpolator();
69 }
70 
71 void
73 
74 }
75 
76 
77 void VdwGrid::refresh(core::pose::Pose const & pose, core::Vector const & )
78 {
79  // loop through all the atoms in the pose
80  // get the VDW radius of the atom
81  // for each square within cutoff of the atom, update the score
82  // continue
83 
85  //core::Size chain_begin = pose.conformation().chain_begin(chain_id);
86  //core::Size chain_end = pose.conformation().chain_end(chain_id);
87 
88  this->fill_with_value(cutoff_);
89 
90 
91  for(core::Size residue_index = 1; residue_index <= pose.n_residue(); ++residue_index)
92  {
93  core::conformation::Residue residue = pose.residue(residue_index);
94  if(residue.chain() == chain_id)
95  {
96  continue;
97  }
98  for(core::Size atom_index = 1; atom_index <= residue.natoms();++atom_index)
99  {
100  core::id::AtomID atom_id(atom_index,residue_index);
101  core::Vector xyz(pose.xyz(atom_id));
102  core::Real const & radius(residue.atom_type(atom_index).lj_radius());
104  }
105  }
106 }
107 
108 void VdwGrid::refresh(core::pose::Pose const & pose, core::Vector const & center, core::Size const & )
109 {
110  refresh(pose,center);
111 }
112 
114 {
115  refresh(pose,center);
116 }
117 
119 {
120 
121 }
122 
124 {
125  core::Real score = 0.0;
126 
127  for(core::Size atom_index = 1; atom_index <= residue.natoms() && score < max_score; ++atom_index )
128  {
129  core::Vector const & atom_coord(residue.xyz(atom_index));
130  core::Real const & radius(residue.atom_type(atom_index).lj_radius());
131  if(this->get_grid().is_in_grid(atom_coord.x(),atom_coord.y(),atom_coord.z()))
132  {
133  core::Real max_radius = this->get_point(atom_coord.x(),atom_coord.y(),atom_coord.z());
134  core::Real spline_score = 0.0;
135  core::Real spline_score_deriv = 0.0;
136 
137  lj_spline_->interpolate(max_radius-radius,spline_score,spline_score_deriv);
138 
139  score += spline_score;
140  }
141  }
142  return score;
143 }
144 
146 {
147  core::Vector const & atom_coord(residue.xyz(atomno));
148  core::Real const & radius(residue.atom_type(atomno).lj_radius());
149  if(this->get_grid().is_in_grid(atom_coord.x(),atom_coord.y(),atom_coord.z()))
150  {
151  core::Real max_radius = this->get_point(atom_coord.x(),atom_coord.y(),atom_coord.z());
152  core::Real spline_score = 0.0;
153  core::Real spline_score_deriv = 0.0;
154 
155  lj_spline_->interpolate(max_radius-radius,spline_score,spline_score_deriv);
156 
157  return spline_score;
158  }
159  return 0;
160 }
161 
162 utility::json_spirit::Value VdwGrid::serialize()
163 {
164  using utility::json_spirit::Value;
165  using utility::json_spirit::Pair;
166 
167  Pair cutoff_data("cutoff",Value(cutoff_));
168  Pair spline_data("spline",lj_spline_->serialize());
169  Pair base_data("base_data",SingleGrid::serialize());
170  #ifdef PYROSETTA
171  Value _; return _;
172  #endif
173  return Value(utility::tools::make_vector(cutoff_data,spline_data,base_data));
174 }
175 
176 void VdwGrid::deserialize(utility::json_spirit::mObject data)
177 {
178  cutoff_ = data["cutoff"].get_real();
179  numeric::interpolation::spline::InterpolatorOP interp = new numeric::interpolation::spline::SimpleInterpolator;
180  interp->deserialize(data["spline"].get_obj());
181  lj_spline_ = interp;
182  SingleGrid::deserialize(data["base_data"].get_obj());
183 }
184 
185 }
186 }
187 }