Rosetta
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
minimize_ppi.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 // (c) Copyright Rosetta Commons Member Institutions.
4 // (c) This file is part of the Rosetta software suite and is made available under license.
5 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
6 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
7 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
8 /// @brief
9 /// @author jk, ragul, skelow, bazzoli (bazzoli@ku.edu)
10 
11 // Project Headers
12 #include <devel/init.hh>
13 #include <core/io/pdb/pose_io.hh>
14 #include <core/pose/Pose.hh>
15 #include <basic/MetricValue.hh>
16 
17 #include <basic/options/util.hh>
18 #include <basic/options/option.hh>
19 #include <basic/options/keys/relax.OptionKeys.gen.hh>
20 #include <basic/options/keys/in.OptionKeys.gen.hh>
21 #include <basic/options/keys/out.OptionKeys.gen.hh>
22 #include <basic/options/keys/docking.OptionKeys.gen.hh>
26 
27 #include <protocols/simple_moves/ScoreMover.hh>
28 #include <core/pose/metrics/CalculatorFactory.hh>
29 #include <core/pose/metrics/simple_calculators/SasaCalculatorLegacy.hh>
30 #include <protocols/toolbox/pose_metric_calculators/NumberHBondsCalculator.hh>
31 #include <protocols/toolbox/pose_metric_calculators/PackstatCalculator.hh>
32 #include <protocols/toolbox/pose_metric_calculators/BuriedUnsatisfiedPolarsCalculator.hh>
33 #include <core/scoring/constraints/ConstraintSet.hh>
34 #include <protocols/rigid/RigidBodyMover.hh>
35 #include <protocols/rigid/RB_geometry.hh>
36 #include <core/chemical/ResidueTypeSet.hh>
37 #include <core/conformation/ResidueFactory.hh>
38 #include <core/conformation/Residue.hh>
39 #include <core/kinematics/FoldTree.hh>
40 #include <core/scoring/func/HarmonicFunc.hh>
41 #include <core/optimization/MinimizerOptions.hh>
42 #include <core/optimization/AtomTreeMinimizer.hh>
43 #include <core/pack/task/TaskFactory.hh>
44 #include <core/pack/task/PackerTask.hh>
45 #include <core/pack/pack_rotamers.hh>
46 #include <protocols/simple_moves/SuperimposeMover.hh>
47 
48 // Utility Headers
49 #include <utility/vector1.hh>
50 #include <utility/io/ozstream.hh>
51 
52 // C++ Headers
53 #include <iostream>
54 #include <iomanip>
55 #include <fstream>
56 #include <ostream>
57 #include <string>
58 #include <sstream>
59 #include <cmath>
60 #include <map>
61 
62 //Auto Headers
63 #include <core/io/pdb/pose_io.hh>
64 #include <core/import_pose/import_pose.hh>
65 #include <core/kinematics/MoveMap.hh>
66 #include <protocols/rigid/RigidBodyMover.hh>
67 #include <core/scoring/constraints/CoordinateConstraint.hh>
68 #include <core/conformation/Residue.hh>
69 #include <core/pose/Pose.hh>
70 #include <core/pose/PDBInfo.hh>
71 #include <core/pose/util.hh>
72 #include <core/pose/metrics/CalculatorFactory.hh>
73 #include <core/scoring/Energies.hh>
74 #include <core/scoring/EnergyGraph.hh>
75 #include <core/scoring/ScoreFunction.hh>
76 #include <core/scoring/ScoreType.hh>
77 #include <core/scoring/rms_util.hh>
78 #include <core/scoring/rms_util.tmpl.hh>
79 #include <core/scoring/constraints/util.hh>
80 #include <core/scoring/ScoreFunctionFactory.hh>
81 #include <core/scoring/rms_util.hh>
82 #include <core/id/AtomID.hh>
83 #include <core/id/AtomID_Map.hh>
84 
85 using namespace core;
86 using namespace core::pose::datacache;
87 using namespace core::optimization;
88 using namespace core::pose::metrics;
89 using namespace core::scoring;
90 using namespace core::scoring::constraints;
91 using namespace core::id;
92 using namespace basic::options;
93 using namespace basic::options::OptionKeys;
94 using namespace conformation;
95 using namespace protocols::simple_moves;
96 using namespace protocols::rigid;
97 using namespace core::chemical;
98 using namespace core::conformation;
99 
100 OPT_KEY( Real, cst_force_constant )
101 //OPT_KEY( Real, coord_cst_weight )
102 OPT_KEY( Boolean, print_init )
103 OPT_KEY( Boolean, print_unbound )
104 OPT_KEY( Boolean, print_complex )
105 OPT_KEY( Boolean, iface_rmsd )
106 OPT_KEY( String, ref_decoy )
107 OPT_KEY( Boolean, score_only )
108 
109 static basic::Tracer TR( "apps.pilot.minimize_ppi" );
110 
111 //set to store pdb info keys
112 std::set <std::string> interface;
113 //stores resid of the ligand residue
115 
116 void define_interface( core::pose::Pose & ref_pose ) {
117  lig_res_num =0;
118  for ( int j = 1, resnum = ref_pose.total_residue(); j <= resnum; ++j ) {
119  if ( !ref_pose.residue(j).is_protein() ) {
120  lig_res_num = j;
121  break;
122  }
123  }
124  if ( lig_res_num == 0 ) {
125  TR << "No ligand given in reference PDB structure. Cannot identify interface."<<std::endl;
126  exit (1);
127  }
128 
129  TR <<"sele ";
130 
131  EnergyGraph & energy_graph(ref_pose.energies().energy_graph());
132  for ( graph::Graph::EdgeListIter
133  iru = energy_graph.get_node( lig_res_num )->lower_edge_list_begin(),
134  irue = energy_graph.get_node( lig_res_num )->lower_edge_list_end();
135  iru != irue; ++iru ) {
136  EnergyEdge * edge( static_cast< EnergyEdge *> (*iru) );
137  Size const j( edge->get_first_node_ind() );
138 
139  // the pair energies cached in the link
140  EnergyMap const & emap( edge->fill_energy_map());
141  Real const attr( emap[ fa_atr ] );
142  //TR<<"\n"<<j<<": "<<attr<<"\n";
143  if ( attr < -.2 ) {
144  // create string id to store in set
145  std::ostringstream residuestream;
146  TR << "resi "<< ref_pose.pdb_info()->number(j)<<" or ";
147  residuestream << ref_pose.pdb_info()->chain(j) << ref_pose.pdb_info()->number(j);
148  std::string res_id = residuestream.str();
149  interface.insert(res_id);
150  }
151  }
152 
153  TR << std::endl;
154  TR << lig_res_num<< std::endl;
155 
156  // ref_pose.delete_polymer_residue(lig_res_num);
157 }
158 
159 bool
161  core::pose::Pose const & pose,
162  core::pose::Pose const & ,//pose2,
163  core::Size resno,
164  core::Size atomno
165 )
166 {
167  // ws get residue "key" for set
168  std::ostringstream residuestream;
169  residuestream << pose.pdb_info()->chain(resno) << pose.pdb_info()->number(resno);
170  std::string res_id = residuestream.str();
171  core::conformation::Residue const & rsd = pose.residue(resno);
172  if ( interface.count( res_id ) > 0 ) return rsd.is_protein() && !rsd.atom_is_hydrogen(atomno);
173  return false;
174 }
175 
176 Real
178  pose::Pose & mod_pose,
179  pose::Pose const & ref_pose
180 )
181 {
182  id::AtomID_Map< id::AtomID > atom_map;
183  core::pose::initialize_atomid_map( atom_map, mod_pose, id::BOGUS_ATOM_ID );
184  for ( Size ii = 1; ii <= mod_pose.total_residue(); ++ii ) {
185  if ( ! mod_pose.residue(ii).has("CA") ) continue;
186  if ( ! mod_pose.residue(ii).is_protein() ) continue;
187  for ( Size jj = 1; jj <= ref_pose.total_residue(); ++jj ) {
188  if ( ! ref_pose.residue(jj).has("CA") ) continue;
189  if ( ! ref_pose.residue(jj).is_protein() ) continue;
190  if ( mod_pose.pdb_info()->chain(ii) != ref_pose.pdb_info()->chain(jj) ) continue;
191  if ( mod_pose.pdb_info()->number(ii) != ref_pose.pdb_info()->number(jj) ) continue;
192  id::AtomID const id1( mod_pose.residue(ii).atom_index("CA"), ii );
193  id::AtomID const id2( ref_pose.residue(jj).atom_index("CA"), jj );
194  atom_map.set( id1, id2 );
195  break;
196  }
197  }
198  return superimpose_pose( mod_pose, ref_pose, atom_map );
199 }
200 
201 Real
203  pose::Pose & mod_pose,
204  pose::Pose const & ref_pose
205 )
206 {
207  std::vector< core::Vector > p1_coords;
208  std::vector< core::Vector > p2_coords;
209 
210  for ( Size ii = 1; ii <= ref_pose.total_residue(); ++ii ) {
211  if ( ! ref_pose.residue(ii).has("CA") ) continue;
212  if ( ! ref_pose.residue(ii).is_protein() ) continue;
213  for ( Size jj = 1; jj <= mod_pose.total_residue(); ++jj ) {
214  if ( ! ref_pose.residue(ii).has("CA") ) continue;
215  if ( ! ref_pose.residue(ii).is_protein() ) continue;
216  if ( mod_pose.pdb_info()->chain(jj) != ref_pose.pdb_info()->chain(ii) ) continue;
217  if ( mod_pose.pdb_info()->number(jj) != ref_pose.pdb_info()->number(ii) ) continue;
218  Size num_atoms ( ref_pose.residue(ii).natoms() );
219  for ( core::Size i = 1; i <= num_atoms; ++i ) {
220  if ( is_interface_heavyatom ( ref_pose, mod_pose, ii, i) ) {
221  Size num_atoms2 ( mod_pose.residue(jj).natoms() );
222  for ( core::Size j = 1; j <= num_atoms2; ++j ) {
223  if ( !ref_pose.residue(ii).atom_name(i).compare(mod_pose.residue(jj).atom_name(j)) ) {
224  p1_coords.push_back(ref_pose.residue(ii).xyz(i));
225  p2_coords.push_back(mod_pose.residue(jj).xyz(j));
226  }
227  }
228  }
229  }
230  }
231  }
232  assert( p1_coords.size() == p2_coords.size() );
233 
234  int const natoms = p1_coords.size();
235  ObjexxFCL::FArray2D< core::Real > p1a( 3, natoms );
236  ObjexxFCL::FArray2D< core::Real > p2a( 3, natoms );
237  for ( int i = 0; i < natoms; ++i ) {
238  for ( int k = 0; k < 3; ++k ) { // k = X, Y and Z
239  p1a(k+1,i+1) = p1_coords[i][k];
240  p2a(k+1,i+1) = p2_coords[i][k];
241  }
242  }
243 
244  return numeric::model_quality::rms_wrapper( natoms, p1a, p2a );
245 
246 }
247 
248 
249 Real ligand_rmsd (pose::Pose const & pose1, pose::Pose const & pose2) {
250 
251  core::Size ref_res_num = 0;
252  for ( int j = 1, resnum = pose1.total_residue(); j <= resnum; ++j ) {
253  if ( !pose1.residue(j).is_protein() ) {
254  ref_res_num = j;
255  break;
256  }
257  }
258  if ( ref_res_num == 0 ) {
259  std::cout<<"Error, no reference ligand for RMSD calculation" << std::endl;
260  exit(1);
261  }
262  core::conformation::Residue const & pose1_rsd = pose1.conformation().residue(ref_res_num);
263 
264  core::Size inp_res_num = 0;
265  for ( int j = 1, resnum = pose2.total_residue(); j <= resnum; ++j ) {
266  if ( !pose2.residue(j).is_protein() ) {
267  inp_res_num = j;
268  break;
269  }
270  }
271  if ( inp_res_num == 0 ) {
272  std::cout<<"Error, no input ligand for RMSD calculation" << std::endl;
273  exit(1);
274  }
275  core::conformation::Residue const & pose2_rsd = pose2.conformation().residue(inp_res_num);
276 
277 
278  //CALCULATE RMSD
279  //IMPORTANT:this rmsd calculation does not consider symmetry
280  //assert input & reference ligand should have same num of atoms
281  if ( !(pose2_rsd.nheavyatoms() == pose1_rsd.nheavyatoms()) ) {
282  std::cout<<"Error, input & reference ligand should have same no. of atoms in the same order" << std::endl;
283  exit(1);
284  } else {
285  core::Real rmsd, dist_sum(0.);
286  Size j = 1;
287  for ( Size i = 1; i <= pose1_rsd.nheavyatoms(); ++i ) {
288  if ( j <= pose2_rsd.nheavyatoms() ) {
289  assert ( pose1_rsd.atom_name(i) == pose2_rsd.atom_name(j) );
290  core::Real x_dist = ( (pose1_rsd.atom(i).xyz()(1) - pose2_rsd.atom(j).xyz()(1)) * (pose1_rsd.atom(i).xyz()(1) - pose2_rsd.atom(j).xyz()(1)) );
291  core::Real y_dist = ( (pose1_rsd.atom(i).xyz()(2) - pose2_rsd.atom(j).xyz()(2)) * (pose1_rsd.atom(i).xyz()(2) - pose2_rsd.atom(j).xyz()(2)) );
292  core::Real z_dist = ( (pose1_rsd.atom(i).xyz()(3) - pose2_rsd.atom(j).xyz()(3)) * (pose1_rsd.atom(i).xyz()(3) - pose2_rsd.atom(j).xyz()(3)) );
293  dist_sum += x_dist + y_dist + z_dist;
294  }
295  ++j;
296  }
297  rmsd = sqrt(dist_sum/pose1_rsd.nheavyatoms());
298  return rmsd;
299  }
300 
301 }
302 
303 
304 int main( int argc, char * argv [] ){
305  try{
306  NEW_OPT( cst_force_constant, "coordinate constraint force constant", 0.0000001 );
307  //NEW_OPT( coord_cst_weight, "coordinate constraint weight", 1 );
308  NEW_OPT( print_init, "print the initial complex for debugging", false );
309  NEW_OPT( print_unbound, "print the mimized protein for debugging", false );
310  NEW_OPT( print_complex, "print the minimized complex", true );
311  NEW_OPT( iface_rmsd, "calculate the interface rmsd", false );
312  NEW_OPT( ref_decoy, "the structure to compute RMSD and relative score to", "" );
313  NEW_OPT( score_only, "compute all scores for the iput complex without minimization", false );
314 
315  devel::init(argc, argv);
316 
317  //setup scorefxn
318  scoring::ScoreFunctionOP scorefxn(get_score_function());
319  // scoring::ScoreFunctionOP repack_scorefxn = getScoreFunction();
320 
321  std::string const ref_decoy_fname = option[ ref_decoy ];
322  // create pose from pdb
323  pose::Pose ref_pose;
324  std::string outfname;
325  utility::io::ozstream outstream;
326  if ( option[ iface_rmsd ] ) {
327  core::import_pose::pose_from_pdb( ref_pose, ref_decoy_fname );
328  define_interface( ref_pose );
329  TR << "Defined interface" << std::endl;
330  if ( !option[ OptionKeys::out::output_tag ]().empty() ) {
331  outfname = "minrmsd." + option[ OptionKeys::out::output_tag ]() + ".out";
332  } else {
333  outfname = "minrmsd.out";
334  }
335  //std::cout<<outfname<<" output_tag: "<<option[ OptionKeys::out::output_tag ]()<<std::endl;
336  outstream.open(outfname, std::ios::out);
337  }
338 
339  //Register calculators
340  std::string sasa_calc_name = "sasa";
341  std::string hbond_calc_name = "hbond";
342  std::string packstat_calc_name = "packstat";
343  std::string burunsat_calc_name = "burunsat";
344  core::pose::metrics::PoseMetricCalculatorOP sasa_calculator(new core::pose::metrics::simple_calculators::SasaCalculatorLegacy);
345  core::pose::metrics::CalculatorFactory::Instance().register_calculator( sasa_calc_name, sasa_calculator );
346  core::pose::metrics::PoseMetricCalculatorOP hb_calc(new protocols::toolbox::pose_metric_calculators::NumberHBondsCalculator());
347  core::pose::metrics::CalculatorFactory::Instance().register_calculator( hbond_calc_name, hb_calc );
348  core::pose::metrics::PoseMetricCalculatorOP packstat_calc(new protocols::toolbox::pose_metric_calculators::PackstatCalculator());
349  core::pose::metrics::CalculatorFactory::Instance().register_calculator( packstat_calc_name, packstat_calc );
350  core::pose::metrics::PoseMetricCalculatorOP burunsat_calc(new protocols::toolbox::pose_metric_calculators::BuriedUnsatisfiedPolarsCalculator(sasa_calc_name, hbond_calc_name));
351  core::pose::metrics::CalculatorFactory::Instance().register_calculator( burunsat_calc_name, burunsat_calc );
352 
353  //Description of output scores
354  std::cout << "Description of output scores"<< std::endl;
355  std::cout << "Interface_Scores:TAG" <<" "<< "input_pdb_name" <<" " << "bound_energy" <<" " << "Interface_Energy" <<" "<< "Total_BSA" <<" "<< "Interface_HB" <<" "<< "Total_packstats" <<" "<< "Interface_unsat" << std::endl;
356 
357  for ( core::Size f=1; f <= basic::options::start_files().size(); f++ ) {
358  //setup the bound pose
359  pose::Pose bound_pose;
360  std::string const input_pdb_name = basic::options::start_files().at(f);
361  core::import_pose::pose_from_pdb( bound_pose, input_pdb_name );
362  pose::Pose pre_min_darc_pose = bound_pose;
363  //create tag for output filename
364  int pfounddir = input_pdb_name.find_last_of("/\\");
365  int pfounddot = input_pdb_name.find_last_of(".");
366  std::string tag = input_pdb_name.substr((pfounddir+1),(pfounddot-(pfounddir+1)));
367  std::string init_pdb = "init_" + tag + ".pdb";
368  std::string mini_pdb = "mini_" + tag + ".pdb";
369  std::string unbo_pdb = "unbo_" + tag + ".pdb";
370 
371  int nres = bound_pose.total_residue();
372  Real coord_sdev( option[ OptionKeys::cst_force_constant ] );
373  //take reciprocal and sqrt to pass as force constant
374  coord_sdev = sqrt(1/coord_sdev);
375  //std::cout<<" coord sdev "<< coord_sdev <<std::endl;
376  Real cst_weight = 1;
377 
378 
379  if ( !option[ score_only ] ) {
380 
381  //Initial score
382  (*scorefxn)(bound_pose);
383  TR << "Initial score: " << bound_pose.energies().total_energies()[ total_score ] << std::endl;
384  if ( option [ print_init ] ) {
385  bound_pose.dump_scored_pdb( init_pdb, *scorefxn );
386  }
387 
388  ConstraintSetOP cst_set( new ConstraintSet() );
389  core::scoring::func::HarmonicFuncOP spring(
390  new core::scoring::func::HarmonicFunc( 0 /*mean*/, coord_sdev /*std-dev*/));
391  conformation::Conformation const & conformation( bound_pose.conformation() );
392 
393  // jk we need an anchor in order to use CoordinateConstraint !!!
394  Size const my_anchor = 1;
395  core::kinematics::FoldTree fold_tree=bound_pose.fold_tree();
396  core::kinematics::FoldTree rerooted_fold_tree = fold_tree;
397  rerooted_fold_tree.reorder( my_anchor );
398  bound_pose.fold_tree( rerooted_fold_tree);
399 
400  for ( int i=1; i <= nres; i++ ) {
401  //Residue const & reside = pose.residue( i );
402  Residue const & nat_i_rsd( bound_pose.residue(i) );
403  for ( Size ii = 1; ii<= nat_i_rsd.nheavyatoms(); ++ii ) {
404 
405  AtomID CAi ( ii, i );
406  ConstraintOP cst(new CoordinateConstraint(
407  CAi, AtomID(1,my_anchor), conformation.xyz( CAi ), spring ));
408 
409  cst_set->add_constraint(cst);
410  }
411  }
412  bound_pose.constraint_set( cst_set );
413  scorefxn->set_weight( coordinate_constraint, cst_weight );
414 
415  TR << "Starting minimization...." << std::endl;
416  //AtomTreeMinimizer minimizer;
417  AtomTreeMinimizer minimizer;
418  MinimizerOptions min_options( "dfpmin", 0.00001, true, false );
419  kinematics::MoveMap mm_all;
420  mm_all.set_chi( true );
421  mm_all.set_bb( true );
422  mm_all.set_jump( true );
423  minimizer.run( bound_pose, mm_all, *scorefxn, min_options );
424  (*scorefxn)(bound_pose);
425  TR << "Post minimization 1 constrained score: " << bound_pose.energies().total_energies()[ total_score ] << std::endl;
426  //bound_pose.dump_scored_pdb( "1.pdb", *scorefxn );
427 
428  /* // Setup packer task for repacking
429  pack::task::PackerTaskOP base_packer_task( pack::task::TaskFactory::create_packer_task( bound_pose ));
430  base_packer_task->set_bump_check( false );
431  base_packer_task->initialize_from_command_line();
432  base_packer_task->or_include_current( true );
433  for ( Size ii = 1; ii <= bound_pose.total_residue(); ++ii ) {
434  base_packer_task->nonconst_residue_task(ii).restrict_to_repacking();
435  }
436  // First repack
437  pack::pack_rotamers( bound_pose, *scorefxn, base_packer_task );
438  // Report Scores
439  (*scorefxn)(bound_pose);
440  //bound_pose.dump_scored_pdb( "repacked_once.pdb", *scorefxn );
441  TR << "Score after repacking once: " << bound_pose.energies().total_energies()[ total_score ] << std::endl << std::endl;
442 
443  // iterate over minimizing and repacking
444  for ( Size iter = 1; iter <= 5; ++iter ) {
445  cst_weight = cst_weight/2;
446  scorefxn->set_weight( coordinate_constraint, cst_weight );
447  minimizer.run( bound_pose, mm_all, *scorefxn, min_options );
448  minimizer.run( bound_pose, mm_all, *scorefxn, min_options );
449  minimizer.run( bound_pose, mm_all, *scorefxn, min_options );
450  (*scorefxn)(bound_pose);
451  TR << "Current score after minimizing: " << bound_pose.energies().total_energies()[ total_score ] << std::endl << std::endl;
452  pack::pack_rotamers( bound_pose, *scorefxn, base_packer_task );
453  (*scorefxn)(bound_pose);
454  TR << "Current score after repacking: " << bound_pose.energies().total_energies()[ total_score ] << std::endl << std::endl;
455  }
456  //bound_pose.dump_scored_pdb( "2.pdb", *scorefxn ); */
457 
458  // final minimization
459  bound_pose.remove_constraints();
460  (*scorefxn)(bound_pose);
461  if ( option[ print_complex ] ) {
462  //align minimized pose to the original docked pose and dump pdb complex and ligand
463  protocols::simple_moves::SuperimposeMoverOP sp_mover(new protocols::simple_moves::SuperimposeMover());
464  sp_mover->set_reference_pose( pre_min_darc_pose, 1, (pre_min_darc_pose.total_residue()-1) );
465  sp_mover->set_target_range( 1, (bound_pose.total_residue()-1) );
466  sp_mover->apply( bound_pose );
467  bound_pose.dump_scored_pdb( mini_pdb, *scorefxn );
468  }
469  (*scorefxn)(bound_pose);
470  TR << "Final score: " << bound_pose.energies().total_energies()[ total_score ] << std::endl << std::endl;
471  TR << "Successfully finished minimizing input." << std::endl;
472  }
473  (*scorefxn)(bound_pose);
474 
475  //setup the unbound pose
476  core::pose::Pose unbound_pose = bound_pose;
477  core::Real const unbound_dist = 80.;
478  //Size const rb_jump = 1; // use the first jump as the one between partners
479  Size const rb_jump = bound_pose.num_jump(); // use the LAST jump as the one between partners
480  protocols::rigid::RigidBodyTransMover trans_mover( unbound_pose, rb_jump );
481  trans_mover.trans_axis( trans_mover.trans_axis() );
482  trans_mover.step_size(unbound_dist);
483  trans_mover.apply( unbound_pose );
484  (*scorefxn)(unbound_pose);
485  if ( option[ print_unbound ] ) {
486  unbound_pose.dump_pdb( unbo_pdb );
487  }
488 
489  // define containers for metrics for total complex
490  basic::MetricValue<Real> tot_sasa_mval;
491  basic::MetricValue<Size> tot_hb_mval;
492  basic::MetricValue<Real> tot_packstat_mval;
493  basic::MetricValue<Size> tot_unsat_mval;
494 
495  // calculate and store total metrics for bound and unbound poses
496  //core::Real bound_energy = 0.0, unbound_energy = 0.0, Interface_Energy = 0.0;
497  //core::Real bound_sasa = 0.0, unbound_sasa = 0.0, Total_BSA = 0.0;
498  //core::Size bound_hb = 0, unbound_hb = 0, Interface_HB = 0;
499  core::Real /*bound_packstat = 0.0, */unbound_packstat = 0.0/*, Total_packstats = 0.0*/;
500  //core::Size bound_unsat = 0, unbound_unsat = 0, Interface_unsat = 0;
501 
502  //calculate interface Energy
503  core::Real bound_energy = bound_pose.energies().total_energies()[ total_score ];
504  core::Real unbound_energy = unbound_pose.energies().total_energy();
505  core::Real Interface_Energy = bound_energy - unbound_energy;
506 
507  //delta sasa calculation
508  bound_pose.metric(sasa_calc_name,"total_sasa",tot_sasa_mval);
509  core::Real bound_sasa = tot_sasa_mval.value();
510  unbound_pose.metric(sasa_calc_name,"total_sasa",tot_sasa_mval);
511  core::Real unbound_sasa = tot_sasa_mval.value();
512  core::Real Total_BSA = unbound_sasa - bound_sasa;
513 
514  //interface hb calculation
515  bound_pose.metric(hbond_calc_name,"all_Hbonds", tot_hb_mval);
516  core::Size bound_hb = tot_hb_mval.value();
517  unbound_pose.metric(hbond_calc_name,"all_Hbonds", tot_hb_mval);
518  core::Size unbound_hb = tot_hb_mval.value();
519  core::Size Interface_HB = bound_hb - unbound_hb;
520 
521  //packstat calculation
522  bound_pose.metric(packstat_calc_name,"total_packstat", tot_packstat_mval);
523  core::Real bound_packstat = tot_packstat_mval.value();
524  //unbound_pose.metric(packstat_calc_name,"total_packstat", tot_packstat_mval);
525  //unbound_packstat = tot_packstat_mval.value();
526  core::Real Total_packstats = bound_packstat - unbound_packstat;
527 
528  //unsat polar calculation
529  bound_pose.metric(burunsat_calc_name,"all_bur_unsat_polars", tot_unsat_mval);
530  core::Size bound_unsat = tot_unsat_mval.value();
531  unbound_pose.metric(burunsat_calc_name,"all_bur_unsat_polars", tot_unsat_mval);
532  core::Size unbound_unsat = tot_unsat_mval.value();
533  core::Size Interface_unsat = bound_unsat - unbound_unsat;
534 
535  //print RMSD between input and minimized ligands (only after superposition)
536  if ( option[print_complex] ) {
537  std::cout << "computing post minization ligand RMSD for " << input_pdb_name << ":"
538  << ligand_rmsd(pre_min_darc_pose, bound_pose) << std::endl;
539  }
540 
541  std::cout << "Interface_Scores:"<< tag <<"\t"<< input_pdb_name <<"\t" << bound_energy <<"\t" << Interface_Energy <<"\t"<< Total_BSA <<"\t"<< Interface_HB <<"\t"<< Total_packstats <<"\t"<< Interface_unsat << std::endl;
542  if ( option[ iface_rmsd ] ) {
543  /*core::Real CA_rms = */calpha_pdb_superimpose_pose( unbound_pose, ref_pose);
544  core::Real CA_rms = core::scoring::CA_rmsd( unbound_pose, ref_pose );
545  std::cout << "superimpose to native. Rms to native: " << CA_rms << std::endl;
546  core::Real heavyatom_rms = interface_rmsd( ref_pose, unbound_pose );
547  std::cout << "Interface rmsd: " << heavyatom_rms << std::endl;
548  outstream << mini_pdb << ' ' << CA_rms << ' ' << heavyatom_rms <<std::endl;
549  }
550 
551  }//end for loop of all decoys
552 
553  outstream.close();
554  outstream.clear();
555 
556  return 0;
557 
558  } catch ( utility::excn::EXCN_Base const & e ) {
559  std::cout << "caught exception " << e.msg() << std::endl;
560  return -1;
561  }
562 }
utility::pointer::shared_ptr< Constraint > ConstraintOP
Real interface_rmsd(pose::Pose &mod_pose, pose::Pose const &ref_pose)
virtual std::string const msg() const
Definition: EXCN_Base.hh:70
Real calpha_pdb_superimpose_pose(pose::Pose &mod_pose, pose::Pose const &ref_pose)
T const & value() const
Definition: MetricValue.hh:60
std::string String
Definition: remodel.cc:69
void init(int argc, char *argv[])
Command line init() version.
Definition: init.cc:23
core::pose::Pose Pose
Definition: supercharge.cc:101
common derived classes for thrown exceptions
void clear()
Clear the stream.
Definition: ozstream.hh:413
tuple scorefxn
Definition: PyMOL_demo.py:63
Real ligand_rmsd(pose::Pose const &pose1, pose::Pose const &pose2)
rule< Scanner, options_closure::context_t > options
Definition: Tag.cc:377
core::Size lig_res_num
#define OPT_KEY(type, key)
list resnum
if line_edit[13:14]=='P': #Nucleic acid? Skip.
std::set< std::string > interface
Output file stream wrapper for uncompressed and compressed files.
void close()
Close the ofstream and reset the state.
Definition: ozstream.hh:430
double Real
Definition: types.hh:39
Option lookup functions emulating Rosetta++ equivalents for transitional use.
#define NEW_OPT(akey, help, adef)
static basic::Tracer TR("apps.pilot.minimize_ppi")
bool is_interface_heavyatom(core::pose::Pose const &pose, core::pose::Pose const &, core::Size resno, core::Size atomno)
ocstream cout(std::cout)
Wrapper around std::cout.
Definition: ocstream.hh:287
void define_interface(core::pose::Pose &ref_pose)
numeric::Real rms_wrapper(int natoms, FArray2D< numeric::Real > p1a, FArray2D< numeric::Real > p2a)
Definition: rms.cc:91
BooleanOptionKey const exit("options:exit")
Definition: OptionKeys.hh:51
vector1: std::vector with 1-based indexing
const_reference at(index_type const i) const
vectorL.at( i ) const
Definition: vectorL.hh:388
utility::vector1< std::string > start_files()
Definition: util.cc:53
ozstream: Output file stream wrapper for uncompressed and compressed files
Definition: ozstream.hh:53
Program options global and initialization function.
rule< Scanner, tag_closure::context_t > tag
Definition: Tag.cc:373
void open(std::string const &filename_a, std::ios_base::openmode open_mode=std::ios_base::out)
Open a file.
Definition: ozstream.cc:62
int main(int argc, char *argv[])
platform::Size Size
Definition: random.fwd.hh:30
rule< Scanner, option_closure::context_t > option
Definition: Tag.cc:378
FArray2D: Fortran-Compatible 2D Array.
Definition: FArray2.hh:27