Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ligand_scores.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 protocols/ligand_docking/MultiResidueLigandDock.cc
11 ///
12 /// @brief
13 /// @Gordon Lemmon
14 
16 #include <core/pose/util.hh>
17 
20 #include <ObjexxFCL/FArray1D.hh>
21 
22 #include <protocols/moves/Mover.hh>
23 // AUTO-REMOVED #include <protocols/simple_moves/MinMover.hh>
24 
25 //#include <protocols/qsar/qsarTypeManager.hh>
27 
28 #include <protocols/jd2/Job.hh>
29 
33 
34 #include <core/scoring/Energies.hh>
35 #include <core/scoring/rms_util.hh>
38 #include <core/pose/PDBInfo.hh>
39 // AUTO-REMOVED #include <core/pack/dunbrack/RotamerConstraint.hh>
40 
41 #include <core/types.hh>
42 // AUTO-REMOVED #include <basic/prof.hh>
44 
45 #include <basic/Tracer.hh>
46 
47 // AUTO-REMOVED #include <ObjexxFCL/FArray1.io.hh>
48 // AUTO-REMOVED #include <ObjexxFCL/string.functions.hh>
49 #include <core/kinematics/MoveMap.fwd.hh> // needed?
50 
51 #include <sstream>
52 
53 #include <utility/vector1.hh>
54 
55 //Auto Headers
56 #define foreach BOOST_FOREACH
57 namespace protocols {
58 namespace ligand_docking {
59 
60 using namespace ObjexxFCL;
61 
62 ///@brief append interface_delta scores
63 void
65  core::Size jump_id,
67  core::pose::Pose const & after,
68  const core::scoring::ScoreFunctionOP scorefxn
69 ){
70  core::pose::PoseOP after_copy = new core::pose::Pose( after );
71 
72  char const ligand_chain= core::pose::get_chain_from_jump_id(jump_id, after);
73 
74  // A very hacky way of guessing whether the components are touching:
75  // if pushed together by 1A, does fa_rep change at all?
76  // (The docking rb_* score terms aren't implemented as of this writing.)
77  core::Real const together_score = (*scorefxn)( *after_copy );
78  core::scoring::EnergyMap const together_energies = after_copy->energies().total_energies();
79  core::Real const initial_fa_rep = after_copy->energies().total_energies()[ core::scoring::fa_rep ];
80  protocols::rigid::RigidBodyTransMover trans_mover( *after_copy, jump_id );
81  trans_mover.trans_axis( trans_mover.trans_axis().negate() ); // now move together
82  trans_mover.step_size(1);
83  trans_mover.apply( *after_copy );
84  (*scorefxn)( *after_copy );
85  core::Real const push_together_fa_rep = after_copy->energies().total_energies()[ core::scoring::fa_rep ];
86  bool const are_touching = (std::abs(initial_fa_rep - push_together_fa_rep) > 1e-4);
87 
88  {
89  std::ostringstream touching;
90  touching << "ligand_is_touching_"<< ligand_chain;
91  job->add_string_real_pair(touching.str(), are_touching);
92  }
93 
94  // Now pull apart by 500 A to determine the reference E for calculating interface E.
95  trans_mover.trans_axis( trans_mover.trans_axis().negate() ); // now move apart
96  trans_mover.step_size(500); // make sure they're fully separated!
97  trans_mover.apply( *after_copy );
98  core::Real const separated_score = (*scorefxn)( *after_copy );
99  core::scoring::EnergyMap const separated_energies = after_copy->energies().total_energies();
100 
101  {
102  std::ostringstream delta;
103  delta<< "interface_delta_"<< ligand_chain;
104  job->add_string_real_pair(delta.str(), together_score - separated_score);
105  }
106 
107  // Interface delta, broken down by component
108  for(int i = 1; i <= core::scoring::n_score_types; ++i) {
110 
111  if ( !scorefxn->has_nonzero_weight(ii) ) continue;
112  core::Real component_score= scorefxn->get_weight(ii) * (together_energies[ii] - separated_energies[ii]);
113  {
114  std::ostringstream if_score;
115  if_score<< "if_"<< ligand_chain<< '_' << name_from_score_type(ii);
116  job->add_string_real_pair(if_score.str(), component_score);
117  }
118 
119 
120  }
121 }
122 
123 ///@brief Another interesting metric -- how far does the ligand centroid move?
124 ///@brief Large values indicate we're outside of the intended binding site.
125 void
127  core::Size jump_id,
129  core::pose::Pose const & before,
130  core::pose::Pose const & after
131 ){
132  core::Vector const before_vector= protocols::geometry::downstream_centroid_by_jump(before, jump_id);
133  core::Vector const after_vector= protocols::geometry::downstream_centroid_by_jump(after, jump_id);
134 
135  char const ligand_chain= core::pose::get_chain_from_jump_id(jump_id, after);
136  {
137  std::ostringstream centroid;
138  centroid<< "ligand_centroid_travel_"<< ligand_chain;
139  job->add_string_real_pair(centroid.str(), before_vector.distance(after_vector));
140  }
141 }
142 
144  core::Size jump_id,
146  core::pose::Pose const & after
147 )
148 {
150 
151  if (grid_manager->size()==0){
152  ligand_scores_tracer << "skipping 'append ligand grid scores'. No grids used.";
153  return;
154  }
155 
157  grid_manager->initialize_all_grids(center);
158  grid_manager->update_grids(after,center);
159 
160  core::Size const chain_id = core::pose::get_chain_id_from_jump_id(jump_id,after);
161  core::Real total_score = grid_manager->total_score(after,chain_id);
162  char const ligand_chain=core::pose::get_chain_from_jump_id(jump_id,after);
163 
164  qsar::scoring_grid::ScoreMap grid_scores(grid_manager->get_cached_scores());
165  foreach(qsar::scoring_grid::ScoreMap::value_type grid_score, grid_scores){
166  std::ostringstream score_label;
167  score_label << grid_score.first << "_grid_" <<ligand_chain;
168  job->add_string_real_pair(score_label.str(),grid_score.second);
169  }
170 
171  std::ostringstream score_label;
172  score_label << "total_score_" <<ligand_chain;
173  job->add_string_real_pair(score_label.str(),total_score);
174 }
175 
176 ///@brief Calculate radius of gyration for downstream non-H atoms
177 ///@brief Ligands tend to bind in outstretched conformations...
178 void
180  core::Size jump_id,
182  core::pose::Pose const & before
183 ){
184 
185  core::Real lig_rg = 0;
186  int lig_rg_natoms = 0;
187  core::Vector const before_vector= protocols::geometry::downstream_centroid_by_jump(before, jump_id);
188  FArray1D_bool is_upstream ( before.total_residue(), false );
189  before.fold_tree().partition_by_jump( jump_id, is_upstream );
190  for(core::Size i = 1, i_end = before.total_residue(); i <= i_end; ++i) {
191  if( is_upstream(i) ) continue; // only downstream residues
192  core::conformation::Residue const & rsd = before.residue(i);
193  for(core::Size j = 1, j_end = rsd.nheavyatoms(); j <= j_end; ++j) {
194  lig_rg += before_vector.distance_squared( rsd.xyz(j) );
195  lig_rg_natoms += 1;
196  }
197  }
198  lig_rg = std::sqrt( lig_rg / lig_rg_natoms );
199 
200  char const ligand_chain= core::pose::get_chain_from_jump_id(jump_id, before);
201  {
202  std::ostringstream centroid;
203  centroid<< "ligand_radius_of_gyration_"<< ligand_chain;
204  job->add_string_real_pair(centroid.str(), lig_rg);
205  }
206 
207 
208 }
209 
210 void
212  core::Size const jump_id,
214  core::pose::Pose const & before,
215  core::pose::Pose const & after
216 ){
217  assert(before.num_jump() >= jump_id);
218  assert(after.num_jump() >= jump_id);
219 
220  core::Size chain_id= core::pose::get_chain_id_from_jump_id(jump_id, before);
221  core::Size const begin = before.conformation().chain_begin(chain_id);
222  core::Size const end = before.conformation().chain_end(chain_id);
223 
224  if (end-begin > 0){
225  append_multi_residue_ligand_RMSD(jump_id, job, before, after);
226  }else{
227  append_automorphic_rmsd(begin, job, before, after);
228  }
229 }
230 
231 void
233  core::Size jump_id,
235  core::pose::Pose const & before,
236  core::pose::Pose const & after
237 ){
238  core::pose::Pose before_ligand;
239  core::pose::Pose after_ligand;
240  { ///TODO make this section a function
241  core::Size const before_first_residue = before.fold_tree().downstream_jump_residue(jump_id);
242  core::Size const after_first_residue = after.fold_tree().downstream_jump_residue(jump_id);
243  core::Size const before_chain= before.chain(before_first_residue);
244  core::Size const after_chain= before.chain(after_first_residue);
245  core::pose::Pose before_copy(before);
246  core::pose::PoseOP after_copy= new core::pose::Pose(after);
247  before_copy.remove_constraints();/// TODO fix split_by_chain to avoid this
248  after_copy->remove_constraints();/// TODO fix split_by_chain to avoid this
249  before_ligand= before_copy.split_by_chain(before_chain);
250  after_ligand= after_copy->split_by_chain(after_chain);
251  }
252 
253  char const ligand_chain= core::pose::get_chain_from_jump_id(jump_id, after);
254  {
255  core::Real ligand_rms_no_super= core::scoring::rmsd_no_super(
256  before_ligand,
257  after_ligand,
259  );
260  std::ostringstream rms_no_super;
261  rms_no_super<< "ligand_rms_no_super_"<< ligand_chain;
262  job->add_string_real_pair(rms_no_super.str(), ligand_rms_no_super);
263  }
264  {
265  core::Real ligand_rms_with_super= core::scoring::rmsd_with_super(
266  before_ligand,
267  after_ligand,
269  );
270  std::ostringstream rms_with_super;
271  rms_with_super<< "ligand_rms_with_super_"<< ligand_chain;
272  job->add_string_real_pair(rms_with_super.str(), ligand_rms_with_super);
273  }
274 }
275 
276 void
278  core::Size ligand_residue_id,
280  core::pose::Pose const & before,
281  core::pose::Pose const & after
282 ){
283 
284  char const ligand_chain= before.pdb_info()->chain(ligand_residue_id);
285  {
286  core::Real ligand_rms_no_super= core::scoring::automorphic_rmsd(
287  before.residue(ligand_residue_id),
288  after.residue(ligand_residue_id),
289  false /*don't superimpose*/
290  );
291 
292  std::ostringstream rms_no_super;
293  rms_no_super<< "ligand_rms_no_super_"<< ligand_chain;
294  job->add_string_real_pair(rms_no_super.str(), ligand_rms_no_super);
295  }
296  {
297  core::Real ligand_rms_with_super= core::scoring::automorphic_rmsd(
298  before.residue(ligand_residue_id),
299  after.residue(ligand_residue_id),
300  true /*superimpose*/
301  );
302  std::ostringstream rms_with_super;
303  rms_with_super<< "ligand_rms_with_super_"<< ligand_chain;
304  job->add_string_real_pair(rms_with_super.str(), ligand_rms_with_super);
305  }
306 
307 }
308 
309 } // namespace ligand_docking
310 } // namespace protocols