13 #include <core/io/pdb/pose_io.hh>
14 #include <core/pose/Pose.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>
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>
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>
86 using namespace core::pose::datacache;
87 using namespace core::optimization;
88 using namespace core::pose::metrics;
89 using namespace core::scoring;
91 using namespace core::id;
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;
103 OPT_KEY( Boolean, print_unbound )
104 OPT_KEY( Boolean, print_complex )
109 static basic::Tracer
TR( "apps.pilot.minimize_ppi" );
118 for (
int j = 1,
resnum = ref_pose.total_residue(); j <=
resnum; ++j ) {
119 if ( !ref_pose.residue(j).is_protein() ) {
124 if ( lig_res_num == 0 ) {
125 TR <<
"No ligand given in reference PDB structure. Cannot identify interface."<<std::endl;
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() );
140 EnergyMap
const &
emap( edge->fill_energy_map());
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);
154 TR << lig_res_num<< std::endl;
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);
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 );
198 return superimpose_pose( mod_pose, ref_pose, atom_map );
207 std::vector< core::Vector > p1_coords;
208 std::vector< core::Vector > p2_coords;
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 ) {
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));
232 assert( p1_coords.size() == p2_coords.size() );
234 int const natoms = p1_coords.size();
237 for (
int i = 0; i < natoms; ++i ) {
238 for (
int k = 0; k < 3; ++k ) {
239 p1a(k+1,i+1) = p1_coords[i][k];
240 p2a(k+1,i+1) = p2_coords[i][k];
252 for (
int j = 1,
resnum = pose1.total_residue(); j <=
resnum; ++j ) {
253 if ( !pose1.residue(j).is_protein() ) {
258 if ( ref_res_num == 0 ) {
259 std::cout<<
"Error, no reference ligand for RMSD calculation" << std::endl;
262 core::conformation::Residue
const & pose1_rsd = pose1.conformation().residue(ref_res_num);
265 for (
int j = 1,
resnum = pose2.total_residue(); j <=
resnum; ++j ) {
266 if ( !pose2.residue(j).is_protein() ) {
271 if ( inp_res_num == 0 ) {
272 std::cout<<
"Error, no input ligand for RMSD calculation" << std::endl;
275 core::conformation::Residue
const & pose2_rsd = pose2.conformation().residue(inp_res_num);
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;
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;
297 rmsd = sqrt(dist_sum/pose1_rsd.nheavyatoms());
304 int main(
int argc,
char * argv [] ){
306 NEW_OPT( cst_force_constant,
"coordinate constraint force constant", 0.0000001 );
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 );
318 scoring::ScoreFunctionOP
scorefxn(get_score_function());
321 std::string
const ref_decoy_fname =
option[ ref_decoy ];
324 std::string outfname;
326 if (
option[ iface_rmsd ] ) {
327 core::import_pose::pose_from_pdb( ref_pose, ref_decoy_fname );
329 TR <<
"Defined interface" << std::endl;
330 if ( !
option[ OptionKeys::out::output_tag ]().empty() ) {
331 outfname =
"minrmsd." +
option[ OptionKeys::out::output_tag ]() +
".out";
333 outfname =
"minrmsd.out";
336 outstream.
open(outfname, std::ios::out);
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 );
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;
361 core::import_pose::pose_from_pdb( bound_pose, input_pdb_name );
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";
371 int nres = bound_pose.total_residue();
372 Real coord_sdev(
option[ OptionKeys::cst_force_constant ] );
374 coord_sdev = sqrt(1/coord_sdev);
379 if ( !
option[ score_only ] ) {
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 );
388 ConstraintSetOP cst_set(
new ConstraintSet() );
389 core::scoring::func::HarmonicFuncOP spring(
390 new core::scoring::func::HarmonicFunc( 0 , coord_sdev ));
391 conformation::Conformation
const & conformation( bound_pose.conformation() );
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);
400 for (
int i=1; i <=
nres; i++ ) {
402 Residue
const & nat_i_rsd( bound_pose.residue(i) );
403 for (
Size ii = 1;
ii<= nat_i_rsd.nheavyatoms(); ++
ii ) {
405 AtomID CAi (
ii, i );
407 CAi, AtomID(1,my_anchor), conformation.xyz( CAi ), spring ));
409 cst_set->add_constraint(cst);
412 bound_pose.constraint_set( cst_set );
413 scorefxn->set_weight( coordinate_constraint, cst_weight );
415 TR <<
"Starting minimization...." << std::endl;
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;
459 bound_pose.remove_constraints();
460 (*scorefxn)(bound_pose);
461 if (
option[ print_complex ] ) {
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 );
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;
473 (*scorefxn)(bound_pose);
479 Size const rb_jump = bound_pose.num_jump();
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 );
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;
508 bound_pose.metric(sasa_calc_name,
"total_sasa",tot_sasa_mval);
510 unbound_pose.metric(sasa_calc_name,
"total_sasa",tot_sasa_mval);
512 core::Real Total_BSA = unbound_sasa - bound_sasa;
515 bound_pose.metric(hbond_calc_name,
"all_Hbonds", tot_hb_mval);
517 unbound_pose.metric(hbond_calc_name,
"all_Hbonds", tot_hb_mval);
519 core::Size Interface_HB = bound_hb - unbound_hb;
522 bound_pose.metric(packstat_calc_name,
"total_packstat", tot_packstat_mval);
526 core::Real Total_packstats = bound_packstat - unbound_packstat;
529 bound_pose.metric(burunsat_calc_name,
"all_bur_unsat_polars", tot_unsat_mval);
531 unbound_pose.metric(burunsat_calc_name,
"all_bur_unsat_polars", tot_unsat_mval);
533 core::Size Interface_unsat = bound_unsat - unbound_unsat;
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;
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 ] ) {
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;
547 std::cout <<
"Interface rmsd: " << heavyatom_rms << std::endl;
548 outstream << mini_pdb <<
' ' << CA_rms <<
' ' << heavyatom_rms <<std::endl;
559 std::cout <<
"caught exception " << e.
msg() << std::endl;
utility::pointer::shared_ptr< Constraint > ConstraintOP
Real interface_rmsd(pose::Pose &mod_pose, pose::Pose const &ref_pose)
virtual std::string const msg() const
Real calpha_pdb_superimpose_pose(pose::Pose &mod_pose, pose::Pose const &ref_pose)
void init(int argc, char *argv[])
Command line init() version.
common derived classes for thrown exceptions
void clear()
Clear the stream.
Real ligand_rmsd(pose::Pose const &pose1, pose::Pose const &pose2)
rule< Scanner, options_closure::context_t > options
#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.
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.
void define_interface(core::pose::Pose &ref_pose)
numeric::Real rms_wrapper(int natoms, FArray2D< numeric::Real > p1a, FArray2D< numeric::Real > p2a)
BooleanOptionKey const exit("options:exit")
vector1: std::vector with 1-based indexing
const_reference at(index_type const i) const
vectorL.at( i ) const
utility::vector1< std::string > start_files()
ozstream: Output file stream wrapper for uncompressed and compressed files
Program options global and initialization function.
rule< Scanner, tag_closure::context_t > tag
void open(std::string const &filename_a, std::ios_base::openmode open_mode=std::ios_base::out)
Open a file.
int main(int argc, char *argv[])
rule< Scanner, option_closure::context_t > option
FArray2D: Fortran-Compatible 2D Array.