Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SolvationMetaGrid.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/ligand_docking/scoring_grid/SolvationMetaGrid.cc
11 /// @author Sam DeLuca
12 
15 
18 
22 
23 #include <utility/tag/Tag.hh>
24 
25 #include <map>
26 
27 namespace protocols {
28 namespace qsar {
29 namespace scoring_grid {
30 
32 {
34 }
35 
37 {
38  GridBaseOP solvation_meta_grid = new SolvationMetaGrid();
39  solvation_meta_grid->parse_my_tag(tag);
40  return solvation_meta_grid;
41 }
42 
44 {
45  return new SolvationMetaGrid();
46 }
47 
49 {
50  return "SolvationMetaGrid";
51 }
52 
53 SolvationMetaGrid::SolvationMetaGrid() :type_("SolvationMetaGrid")
54 {
55 
56 }
57 
59 {
60 
61 }
62 
63 void SolvationMetaGrid::initialize(core::Vector const & center, core::Real width, core::Real resolution)
64 {
65  core::chemical::AtomTypeSetCAP atom_type_set(
66  core::chemical::ChemicalManager::get_instance()->atom_type_set("fa_standard"));
67 
68  core::ShortSize max_atom_type = atom_type_set->n_atomtypes();
69  for(core::ShortSize atom_type = 1; atom_type <= max_atom_type;++atom_type)
70  {
71 
72  SolvationGridOP new_grid = new SolvationGrid();
73  new_grid->set_probe_atom_type(atom_type);
74  new_grid->initialize(center, width, resolution);
75  grid_map_[atom_type] = SingleGridOP(new_grid);
76  }
77 }
78 
79 void SolvationMetaGrid::refresh(core::pose::Pose const & pose, core::Vector const & center, core::Size const & )
80 {
81  refresh(pose,center);
82 }
83 
85 {
86  refresh(pose,center);
87 }
88 
89 void SolvationMetaGrid::refresh(core::pose::Pose const & pose, core::Vector const & center)
90 {
91  std::map<core::ShortSize,SingleGridOP>::iterator it = grid_map_.begin();
92  for(;it != grid_map_.end();++it)
93  {
94  std::cout << "initializing solvation grid for atom type " <<it->first <<std::endl;
95  it->second->refresh(pose,center);
96  }
97 }
98 
100 {
101 }
102 
104 {
105  core::Real total_score = 0.0;
106  for(core::Size atom_index = 1; atom_index <= residue.natoms();++atom_index)
107  {
108  //core::Vector const & coords = residue.xyz(atom_index);
109  core::conformation::Atom current_atom(residue.atom(atom_index));
110  std::map<core::ShortSize,SingleGridOP>::iterator grid_iterator(grid_map_.find(current_atom.type()));
111  if(grid_iterator == grid_map_.end())
112  {
113  utility_exit_with_message("Ligands must be parameterized with the FA_STANDARD atom type set for use in the SolvationMetaGrid");
114  }
115 
116  SingleGridOP current_grid = grid_iterator->second;
117  total_score += current_grid->get_point(current_atom.xyz());
118  }
119 
120  return total_score;
121 }
122 
124 {
125  core::conformation::Atom current_atom(residue.atom(atomno));
126  std::map<core::ShortSize,SingleGridOP>::iterator grid_iterator(grid_map_.find(current_atom.type()));
127  if(grid_iterator == grid_map_.end())
128  {
129  utility_exit_with_message("Ligands must be parameterized with the FA_STANDARD atom type set for use in the SolvationMetaGrid");
130  }
131 
132  SingleGridOP current_grid = grid_iterator->second;
133  return current_grid->get_point(current_atom.xyz());
134 }
135 
137 {
138  return "SolvationMetaGrid";
139 }
140 
142 {
143  std::map<core::ShortSize,SingleGridOP>::iterator it = grid_map_.begin();
144  for(;it != grid_map_.end();++it)
145  {
146  it->second->set_chain(chain);
147  }
148 }
149 
151 {
152  utility_exit_with_message("SolvationMetaGrid is currently unable to output a BRIX grid, sorry :(");
153 }
154 
155 utility::json_spirit::Value SolvationMetaGrid::serialize()
156 {
157  using utility::json_spirit::Value;
158  using utility::json_spirit::Pair;
159 
160  Pair type_record("type",Value(type_));
161  std::vector<Value> grid_map_vector;
162 
163  for(std::map<core::ShortSize,SingleGridOP>::iterator it = grid_map_.begin();it != grid_map_.end();++it)
164  {
165  std::vector<Value> current_map_data(utility::tools::make_vector(Value(core::ShortSize(it->first)),Value(it->second->serialize())));
166  grid_map_vector.push_back(Value(current_map_data));
167  }
168 
169  Pair grid_map_data("grids",grid_map_vector);
170 
171  #ifdef PYROSETTA
172  Value _; return _;
173  #endif
174 
175  return Value(utility::tools::make_vector(type_record,grid_map_data));
176 
177 }
178 
179 void SolvationMetaGrid::deserialize(utility::json_spirit::mObject data)
180 {
181  type_ = data["type"].get_str();
182  utility::json_spirit::mArray grid_map_data(data["grids"].get_array());
183  for(utility::json_spirit::mArray::iterator it = grid_map_data.begin();it != grid_map_data.end();++it)
184  {
185  utility::json_spirit::mArray grid_pair(it->get_array());
186  core::ShortSize atom_type = grid_pair[0].get_int();
187  SingleGridOP grid = new SolvationGrid();
188  grid->deserialize(grid_pair[1].get_obj());
189  grid_map_[atom_type] = grid;
190  }
191 }
192 
194 {
195  for(std::map<core::ShortSize,SingleGridOP>::iterator it = grid_map_.begin();it != grid_map_.end();++it)
196  {
197  if(!it->second->is_in_grid(residue))
198  {
199  return false;
200  }
201  }
202  return true;
203 }
204 
205 }
206 }
207 }