Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
metrics.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 metrics
11 /// @brief protocols that are specific to docking low resolution
12 /// @detailed
13 /// @author Brian Weitzner
14 
15 // Unit Headers
16 
17 // Package Headers
18 
19 // Project Headers
20 
21 // Utility Headers
22 
23 // Numeric Headers and ObjexxFCL Headers
24 
25 // C++ headers
26 
29 #include <core/pose/Pose.hh>
30 #include <core/types.hh>
31 #include <utility/vector1.hh>
33 #include <ObjexxFCL/FArray1D.fwd.hh>
34 #include <ObjexxFCL/FArray2D.hh>
35 #include <basic/Tracer.hh>
39 
41 
42 //Auto Headers
44 
45 
46 static basic::Tracer TR("protocols.docking.DockingProtocol.metrics");
47 
48 using namespace core;
49 
50 namespace protocols {
51 namespace docking {
52 
54 calc_interaction_energy( const core::pose::Pose & pose, const core::scoring::ScoreFunctionCOP dock_scorefxn, DockJumps const movable_jumps){
55  using namespace scoring;
56 
57  Real interaction_energy(0);
58 
59  core::scoring::ScoreFunctionOP docking_scorefxn;
60  core::pose::Pose complex_pose = pose;
61 
62  docking_scorefxn = new core::scoring::ScoreFunction( *dock_scorefxn ) ;
63  docking_scorefxn->set_weight( core::scoring::atom_pair_constraint, 0.0 );
64  /*
65  if ( pose.is_fullatom() ){
66  docking_scorefxn = new core::scoring::ScoreFunction( *docking_score_high_ ) ;
67  } else {
68  docking_scorefxn = new core::scoring::ScoreFunction( *docking_score_low_ ) ;
69  }
70  */
71 
72  // calculate energy of complexed pose
73  Real const bound_energy = (*docking_scorefxn)( complex_pose );
74 
75  // calculate energy of separated pose over each movable jump
76  // ddG is the "right" way to do this, to properly penalize strained rotamers
77  // but aroop reports that I_sc yields better results for antibodies
78  for( DockJumps::const_iterator it = movable_jumps.begin(); it != movable_jumps.end(); ++it ) {
79  Size const rb_jump = *it;
80  /*
81  Real const threshold = 100000; // dummy threshold
82  Size const repeats = 3;
83  protocols::simple_filters::DdgFilter ddg = protocols::simple_filters::DdgFilter( threshold, docking_scorefxn, rb_jump, repeats );
84  interaction_energy += ddg.compute( pose );
85  */
86  core::pose::Pose unbound_pose = complex_pose;
87  Real trans_magnitude = 1000;
88  rigid::RigidBodyTransMoverOP translate_away ( new rigid::RigidBodyTransMover( unbound_pose, rb_jump ) );
89  translate_away->step_size( trans_magnitude );
90  translate_away->apply( unbound_pose );
91 
92  Real const unbound_energy = (*docking_scorefxn)( unbound_pose );
93 
94  interaction_energy += (bound_energy - unbound_energy);
95  }
96 
97  return interaction_energy;
98 }
99 
101 calc_Lrmsd( const core::pose::Pose & pose, const core::pose::Pose & native_pose, DockJumps const movable_jumps ){
102  using namespace scoring;
103  Real Lrmsd(0);
104 
105  for( DockJumps::const_iterator it = movable_jumps.begin(); it != movable_jumps.end(); ++it ) {
106  Size const rb_jump = *it;
107  ObjexxFCL::FArray1D_bool temp_part ( pose.total_residue(), false );
108  ObjexxFCL::FArray1D_bool superpos_partner ( pose.total_residue(), false );
109  /// this gets the wrong partner, therefore it is stored in a temporary
110  /// array and then the opposite is put in the actualy array that is used
111  /// for superpositioning. there is probably a better way to do this
112  /// need to check TODO
113  pose.fold_tree().partition_by_jump( rb_jump, temp_part );
114  for ( Size i=1; i<= pose.total_residue(); ++i ) {
115  if (temp_part(i)) superpos_partner(i)=false;
116  else superpos_partner(i)=true;
117  }
118 
119  //Lrmsd += rmsd_no_super_subset( native_pose, pose, superpos_partner, is_protein_CA );
120  using namespace core::scoring;
121  Lrmsd += core::scoring::rmsd_no_super_subset( native_pose, pose, superpos_partner, is_protein_backbone );
122  }
123  return Lrmsd;
124 }
125 
127 calc_Irmsd( const core::pose::Pose & pose, const core::pose::Pose & native_pose, const core::scoring::ScoreFunctionCOP dock_scorefxn, DockJumps const movable_jumps ){
128  using namespace scoring;
129  Real Irmsd(0);
130 
131  for( DockJumps::const_iterator it = movable_jumps.begin(); it != movable_jumps.end(); ++it ) {
132  core::Size const rb_jump = *it;
133  if (!pose.is_fullatom() || !native_pose.is_fullatom()){
134  TR << "Irmsd calc called with non-fullatom pose!!!"<<std::endl;
135  return 0.0;
136  }
137 
138  core::pose::Pose native_docking_pose = native_pose;
139  using namespace kinematics;
140  FoldTree ft( pose.fold_tree() );
141  native_docking_pose.fold_tree(ft);
142 
143  //score to set up interface object
144  core::scoring::ScoreFunctionOP scorefxn = new core::scoring::ScoreFunction( *dock_scorefxn ) ;
145  (*scorefxn)( native_docking_pose );
146 
147  protocols::scoring::Interface interface( rb_jump );
148  interface.distance( 8.0 );
149  interface.calculate( native_docking_pose );
150  ObjexxFCL::FArray1D_bool is_interface ( pose.total_residue(), false );
151 
152  for ( Size i=1; i<= pose.total_residue(); ++i ) {
153  if (interface.is_interface(i)) is_interface(i) = true;
154  }
155 
156  //Irmsd += rmsd_with_super_subset(native_docking_pose, pose, is_interface, is_heavyatom);
157  using namespace core::scoring;
158  Irmsd += core::scoring::rmsd_with_super_subset(native_docking_pose, pose, is_interface, is_protein_backbone);
159  }
160  return Irmsd;
161 }
162 
164 calc_Fnat( const core::pose::Pose & pose, const core::pose::Pose & native_pose, const core::scoring::ScoreFunctionCOP dock_scorefxn, DockJumps const movable_jumps ){
165  using namespace scoring;
166  using namespace conformation;
167  Real Fnat(0);
168 
169  for( DockJumps::const_iterator it = movable_jumps.begin(); it != movable_jumps.end(); ++it ) {
170  core::Size const rb_jump = *it;
171 
172  if (!pose.is_fullatom() || !native_pose.is_fullatom()){
173  TR << "Fnat calc called with non-fullatom pose!!!"<<std::endl;
174  return 0.0;
175  }
176 
177  core::pose::Pose native_docking_pose = native_pose;
178  using namespace kinematics;
179  FoldTree ft( pose.fold_tree() );
180  native_docking_pose.fold_tree(ft);
181  Real cutoff = 5.0;
182 
183  //score to set up interface object
184  core::scoring::ScoreFunctionOP scorefxn = new core::scoring::ScoreFunction( *dock_scorefxn ) ;
185  (*scorefxn)( native_docking_pose );
186 
187  ObjexxFCL::FArray1D_bool temp_part ( pose.total_residue(), false );
188  pose.fold_tree().partition_by_jump( rb_jump, temp_part );
189 
190  utility::vector1< Size > partner1;
191  utility::vector1< Size > partner2;
192 
193  protocols::scoring::Interface interface( rb_jump );
194  interface.distance( 8.0 );
195  interface.calculate( native_docking_pose );
196 
197  //generate list of interface residues for partner 1 and partner 2
198  for ( Size i=1; i <= pose.total_residue(); i++){
199  if (interface.is_interface(i)){
200  if (!temp_part(i)) partner1.push_back(i);
201  if (temp_part(i)) partner2.push_back(i);
202  }
203  }
204 
205  //create contact pair list
206  ObjexxFCL::FArray2D_bool contact_list(partner1.size(), partner2.size(), false);
207 
208  //identify native contacts across the interface
209  //this will probably be changed to use PoseMetrics once I figure out how to use them - Sid
210  for ( Size i=1; i<= partner1.size(); i++){
211  ResidueOP rsd1 = new Residue(native_docking_pose.residue(partner1[i]));
212  for ( Size j=1; j<=partner2.size();j++){
213  ResidueOP rsd2 = new Residue(native_docking_pose.residue(partner2[j]));
214  contact_list(i,j)=calc_res_contact(rsd1, rsd2, cutoff);
215  }
216  }
217 
218  Real native_ncontact = 0;
219  Real decoy_ncontact = 0;
220 
221  //identify which native contacts are recovered in the decoy
222  for ( Size i=1; i<=partner1.size(); i++){
223  for ( Size j=1; j<=partner2.size(); j++){
224  if (contact_list(i,j)){
225  native_ncontact++;
226  ResidueOP rsd1 = new Residue(pose.residue(partner1[i]));
227  ResidueOP rsd2 = new Residue(pose.residue(partner2[j]));
228  if (calc_res_contact(rsd1, rsd2, cutoff)) decoy_ncontact++;
229  }
230  }
231  }
232 
233  Fnat += decoy_ncontact/native_ncontact;
234  }
235  return Fnat;
236 }
237 
241  Real dist_cutoff
242  )
243 {
244  Real dist_cutoff2 = dist_cutoff*dist_cutoff;
245 
246  for (Size m=1; m<=rsd1->nheavyatoms(); m++){
247  for (Size n=1; n<=rsd2->nheavyatoms(); n++){
248  double dist2 = rsd1->xyz(m).distance_squared( rsd2->xyz(n) ); //Is there a reason this is a double?
249  if (dist2 <= dist_cutoff2) return true;
250  }
251  }
252 
253  return false;
254 }
255 
256 }//docking
257 }//protocols