27 #include <basic/options/option.hh>
34 #include <basic/prof.hh>
35 #include <basic/Tracer.hh>
36 #include <basic/MetricValue.hh>
59 #include <numeric/conversions.hh>
60 #include <numeric/random/random.hh>
61 #include <numeric/xyzVector.io.hh>
62 #include <ObjexxFCL/FArray1D.hh>
63 #include <ObjexxFCL/string.functions.hh>
64 #include <utility/exit.hh>
65 #include <utility/vector1.hh>
66 #include <utility/file/FileName.hh>
68 #include <utility/pointer/owning_ptr.hh>
69 #include <utility/tools/make_vector1.hh>
78 #include <basic/options/keys/docking.OptionKeys.gen.hh>
79 #include <basic/options/keys/enzdes.OptionKeys.gen.hh>
83 #include <utility/vector0.hh>
89 namespace ligand_docking {
92 static numeric::random::RandomGenerator
my_RG(4049988);
93 static basic::Tracer
TR(
"protocols.ligand_docking.LigandDockProtocol");
98 protocols::moves::Mover(),
101 ligand_torsion_restraints_()
103 Mover::type(
"LigandDockProtocol" );
105 using basic::options::option;
106 using namespace basic::options;
109 protocol_ = option[ OptionKeys::docking::ligand::protocol ];
112 tether_ligand_ = option[ OptionKeys::docking::ligand::tether_ligand ].user();
125 if( option[ OptionKeys::docking::ligand::start_from ].user() ) {
128 if( start_from.size() % 3 != 0 ) {
129 utility_exit_with_message(
"-start_from requires one or more X,Y,Z triples -- you didn't provide enough numbers!");
131 for(
Size ii = 1; ii <= start_from.size(); ii += 3) {
135 if(
ligand_shear_moves_ && !basic::options::option[ basic::options::OptionKeys::docking::ligand::use_ambig_constraints ]() ) {
136 utility_exit_with_message(
"Must use ambiguous torsion constraints with ligand shear moves!");
142 bool const minimize_ligand,
143 bool const minimize_backbone,
144 bool const tether_ligand,
145 bool const mutate_same_name3,
168 Mover::type(
"LigandDockProtocol" );
172 using basic::options::option;
173 using namespace basic::options;
175 if(
ligand_shear_moves_ && !option[ OptionKeys::docking::ligand::use_ambig_constraints ]() ) {
176 utility_exit_with_message(
"Must use ambiguous torsion constraints with ligand shear moves!");
187 protocols::moves::
Mover(),
190 utility_exit_with_message(
"copy c-tor not allowed!");
208 using namespace protocols::moves;
227 (*scorefxn_)( pose );
250 slideTogether.
apply( pose );
277 else utility_exit_with_message(
"Unknown protocol '"+
protocol_+
"'");
284 monteCarlo->show_scores();
285 monteCarlo->recover_low(pose);
297 dfpMinTightTol->min_options()->nblist_auto_update(
true);
298 dfpMinTightTol->apply(pose);
323 return "LigandDockProtocol";
337 using namespace protocols::moves;
339 runtime_assert(repack_every_Nth >= 2);
353 for(
core::Size cycle = 1; cycle <= num_cycles; ++cycle ) {
364 min_mover->min_options()->nblist_auto_update(
true);
366 core::Real const score1 = (*scorefxn)( pose );
367 simple_rigbod->apply(pose);
369 pack_mover->apply(pose);
371 core::Real const score2 = (*scorefxn)( pose );
372 if(score2 - score1 < 15.0) {
374 min_mover->apply(pose);
380 monteCarlo->boltzmann( pose );
387 repack_task->or_include_current(
true);
388 rottrials_task->or_include_current(
true);
402 using namespace protocols::moves;
407 if(lig_rsd.nchi() == 0) {
408 TR <<
"Warning! Shear minimization protocol attempted on ligand without movable chis. (Lig id " << lig_id <<
")" << std::endl;
423 for(
core::Size cycle = 1; cycle <= num_cycles; ++cycle ) {
426 min_mover->min_options()->nblist_auto_update(
true);
432 core::Real const angle_delta = max_angle * 2. * (
my_RG.uniform() - 0.5);
435 pose.
set_chi(chi1, lig_id, lig_rsd.chi(chi1) + angle_delta);
436 pose.
set_chi(chi2, lig_id, lig_rsd.chi(chi2) - angle_delta);
451 min_mover->apply(pose);
457 monteCarlo->boltzmann( pose );
469 using namespace basic::options;
470 using namespace protocols::moves;
473 if( option[ OptionKeys::docking::ligand::random_conformer ]() ) {
501 using namespace protocols::moves;
502 using namespace core::scoring;
503 using namespace core::pack::task;
504 using namespace basic::options;
512 TR <<
"Making ligand grid ..." << std::endl;
520 TR <<
"Input score atr = " << atr <<
" ; rep = " << rep <<
" ; ha = " << pose.
residue(lig_id).
nheavyatoms() << std::endl;
523 if( option[ OptionKeys::docking::ligand::grid::grid_kin ].user() ) {
524 std::ofstream of( option[ OptionKeys::docking::ligand::grid::grid_kin ]().
name().c_str() );
526 of <<
"@group {grid}\n";
527 of <<
"@dotlist {atr} color= greentint\n";
528 grid_to_kin<int>(of, *grid, -1, -1, 2);
529 of <<
"@dotlist {rep} color= pinktint off\n";
530 grid_to_kin<int>(of, *grid, 1, 1, 2);
535 if( option[ OptionKeys::docking::ligand::grid::grid_map ].user() ) {
536 grid->write_to_BRIX( option[ OptionKeys::docking::ligand::grid::grid_map ]().
name() );
545 for(
Size cnt = 0; cnt < 50; ++cnt) {
546 initialPerturb->apply(pose);
550 if( grid->is_in_grid( c.x(), c.y(), c.z() ) && grid->getValue( c.x(), c.y(), c.z() ) <= 0 ) {
551 TR <<
"Accepting ligand position with nbr_atom at " << c << std::endl;
554 TR <<
"Rejecting ligand position with nbr_atom at " << c << std::endl;
559 if( ! option[ OptionKeys::docking::ligand::improve_orientation ].active() ) {
563 int const num_cycles = std::max(0, option[ OptionKeys::docking::ligand::improve_orientation ]());
564 runtime_assert( num_cycles >= 0 );
565 TR <<
"Doing " << num_cycles <<
" trials of improvement for ligand orientation..." << std::endl;
581 int best_rep(0), best_atr(0);
583 TR <<
"Starting orientation energy atr = " << best_atr <<
" ; rep = " << best_rep << std::endl;
596 core::Size perfect_count(0), diverse_count(0);
600 bool const score_csts = option[ OptionKeys::enzdes::cstfile ].user();
608 for(
int i = 0; i < num_cycles; ++i) {
615 flexible_jump.
set_rb_center( 1 , downstream_stub, rot_center );
620 int curr_rep(0), curr_atr(0);
623 if( i == 0 || curr_rep < best_rep || (curr_rep == best_rep && curr_atr < best_atr) ) {
626 best_jump = pose.
jump( jump_id );
633 if(curr_rep <= perfect_rep && curr_atr <= perfect_atr) {
636 for(
Size j = 1, j_end = perfect_rsds.size(); j <= j_end; ++j) {
638 if( rms < min_rms ) min_rms =
rms;
640 if( min_rms >= diverse_rms ) {
643 perfect_jumps.push_back( pose.
jump( jump_id ) );
644 perfect_cstscores.push_back( cst_scorefxn(pose) );
645 if( diverse_count >= max_diversity ) {
646 TR <<
"Aborting after " << i+1 <<
" cycles with " << diverse_count <<
" diverse 'perfect' poses" << std::endl;
651 TR.Debug <<
" Randomize energy atr = " << curr_atr <<
" ; rep = " << curr_rep << std::endl;
654 TR <<
"Best random orientation energy atr = " << best_atr <<
" ; rep = " << best_rep << std::endl;
655 TR <<
"Found " << perfect_count <<
" 'perfect' poses, kept " << diverse_count <<
" with rms >= " << diverse_rms << std::endl;
657 if( !perfect_rsds.empty() ) {
663 for(
core::Size j = 1, j_end = perfect_rsds.size(); j <= j_end; ++j) {
664 if( perfect_cstscores[j] < min_cstscore ) {
665 min_cstscore = perfect_cstscores[j];
671 pose.
set_jump( jump_id, perfect_jumps[which_perfect] );
675 pose.
set_xyz(atom_id, perfect_rsds[which_perfect]->
xyz(j));
680 pose.
set_jump( jump_id, best_jump );
704 using namespace protocols::moves;
707 min_mover->min_options()->nblist_auto_update(
true);
722 mctrial->keep_stats_type(
no_stats );
730 using namespace protocols::toolbox::pose_metric_calculators;
733 basic::MetricValue< core::Size > val;
734 calc.
get(
"all_bur_unsat_polars", val, pose);
742 using namespace protocols::toolbox::pose_metric_calculators;
746 basic::MetricValue< AtomID_Map< bool > > map_bound, map_unbound;
747 calc_bound.get(
"atom_bur_unsat", map_bound, bound);
748 calc_unbound.
get(
"atom_bur_unsat", map_unbound, unbound);
750 for(
core::Size r = 1; r <= map_bound.value().n_residue(); ++r) {
751 for(
core::Size a = 1; a <= map_bound.value().n_atom(r); ++a) {
752 if( map_bound.value()(r,a) && !map_unbound.value()(r,a) ) {
766 std::map< std::string, core::Real > & scores,
770 using namespace core::scoring;
780 if( constraint_io ) constraint_io->remove_constraints_from_pose(*after_unbound,
false,
true);
785 core::Real const together_score = (*scorefxn)( *after_unbound );
786 EnergyMap const together_energies = after_unbound->energies().total_energies();
787 core::Real const initial_fa_rep = after_unbound->energies().total_energies()[
fa_rep ];
791 trans_mover.
apply( *after_unbound );
792 (*scorefxn)( *after_unbound );
793 core::Real const push_together_fa_rep = after_unbound->energies().total_energies()[
fa_rep ];
794 bool const are_touching = (std::abs(initial_fa_rep - push_together_fa_rep) > 1e-4);
795 scores[
"ligand_is_touching"] = are_touching;
800 trans_mover.
apply( *after_unbound );
801 core::Real const separated_score = (*scorefxn)( *after_unbound );
802 EnergyMap const separated_energies = after_unbound->energies().total_energies();
803 scores[
"interface_delta"] = together_score - separated_score;
808 if ( !scorefxn->has_nonzero_weight(ii) )
continue;
809 scores[
"if_"+
name_from_score_type(ii) ] = ( scorefxn->get_weight(ii) * (together_energies[ii] - separated_energies[ii]) );
821 core::Vector upstream_dummy, downstream_before, downstream_after;
826 core::Real const ligand_centroid_travel = downstream_before.distance( downstream_after );
827 scores[
"ligand_centroid_travel"] = ligand_centroid_travel;
833 min_travel = std::min( min_travel, travel );
835 scores[
"ligand_centroid_travel"] = min_travel;
841 int lig_rg_natoms = 0;
845 if( is_upstream(i) )
continue;
848 lig_rg += downstream_before.distance_squared( rsd.
xyz(j) );
852 lig_rg = std::sqrt( lig_rg / lig_rg_natoms );
853 scores[
"ligand_radius_of_gyration"] = lig_rg;
869 scores[
"frac_atoms_within_0.5"] = fracs[1];
870 scores[
"frac_atoms_within_1.0"] = fracs[2];
871 scores[
"frac_atoms_within_2.0"] = fracs[3];
874 scores[
"ligand_num_chi"] = before.
residue(lig_id).
nchi();
881 using basic::options::option;
882 using namespace basic::options;
884 if( option[ OptionKeys::docking::ligand::use_ambig_constraints ] ) {