Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RepGrid.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/RepGrid.cc
11 /// @author Sam DeLuca
12 
17 #include <utility/vector1.hh>
18 #include <utility/tag/Tag.hh>
19 #include <basic/Tracer.hh>
20 
21 #include <core/pose/Pose.hh>
22 #include <utility/excn/Exceptions.hh>
23 #include <utility/vector0.hh>
24 
25 
26 namespace protocols {
27 namespace qsar {
28 namespace scoring_grid {
29 
30 static basic::Tracer RepGridTracer("protocols.ligand_docking.scoring_grid.RepGrid");
31 
33 {
35 }
36 
38 {
39  GridBaseOP rep_grid= new RepGrid();
40 
41  rep_grid->parse_my_tag(tag);
42 
43  return rep_grid;
44 }
45 
47 {
48  return new RepGrid();
49 }
50 
52 {
53  return "RepGrid";
54 }
55 
56 RepGrid::RepGrid() : SingleGrid("RepGrid"), radius_(2.25), bb_(1), sc_(0), ligand_(1)
57 {
58 
59 }
60 
61 utility::json_spirit::Value RepGrid::serialize()
62 {
63  using utility::json_spirit::Value;
64  using utility::json_spirit::Pair;
65 
66  // [inner_radius, outer_radius]
67  Pair radius("radius",radius_);
68  Pair bb("bb",Value(bb_));
69  Pair sc("sc",Value(sc_));
70  Pair ligand("ligand",Value(ligand_));
71  Pair base_data("base_data",SingleGrid::serialize());
72 
73  return Value(utility::tools::make_vector(radius,bb,sc,ligand,base_data));
74 
75 }
76 
77 void RepGrid::deserialize(utility::json_spirit::mObject data)
78 {
79  radius_ = data["radius"].get_real();
80  bb_ = data["bb"].get_real();
81  sc_ = data["sc"].get_real();
82  ligand_ = data["ligand"].get_real();
83  SingleGrid::deserialize(data["base_data"].get_obj());
84 }
85 
86 void
88 
89  if (tag->hasOption("bb") || tag->hasOption("sc") || tag->hasOption("ligand") ){
90  // the user MUST provide all 3 if he/she is providing any of these 3 options
91  if (!(tag->hasOption("bb") && tag->hasOption("sc") && tag->hasOption("ligand") ) ){
92  throw utility::excn::EXCN_RosettaScriptsOption("'RepGrid' requires bb, sc, and ligand if any one of these are used");
93  }else{
94  bb_= tag->getOption<core::Real>("bb");
95  sc_= tag->getOption<core::Real>("sc");
96  ligand_= tag->getOption<core::Real>("ligand");
97  }
98  }
99 }
100 
101 void RepGrid::refresh( core::pose::Pose const & pose, core::Vector const & )
102 {
103  for(core::Size residue_index = 1; residue_index <= pose.total_residue(); ++residue_index)
104  {
105  //RepGridTracer <<"refreshing residue " <<residue_index << " of " << pose.total_residue() <<std::endl;
106  core::conformation::Residue const & residue = pose.residue(residue_index);
107  if(!residue.is_protein())
108  continue;
109 
110  if(residue.has("CB"))
111  this->set_sphere(residue.xyz("CB"),this->radius_,1.0);
112  if(residue.has("N"))
113  this->set_sphere(residue.xyz("N"),this->radius_,1.0);
114  if(residue.has("CA"))
115  this->set_sphere(residue.xyz("CA"),this->radius_,1.0);
116  if(residue.has("C"))
117  this->set_sphere(residue.xyz("C"),this->radius_,1.0);
118  if(residue.has("O"))
119  this->set_sphere(residue.xyz("O"),this->radius_,1.0);
120  }
121 }
122 
123 void RepGrid::refresh( core::pose::Pose const & pose, core::Vector const & center, const core::Size & )
124 {
125  //for the repulsive force, the case of no ligands and all ligands are identical
126  refresh(pose, center);
127 }
128 
130 {
131  //for the repulsive force, the case of no ligands and all ligands are identical
132  refresh(pose,center);
133 }
134 
135 
136 }
137 }
138 }