40 #include <basic/Tracer.hh>
43 #include <ObjexxFCL/FArray2D.hh>
47 #include <utility/exit.hh>
48 #include <utility/string_util.hh>
51 #include <numeric/model_quality/rms.hh>
55 #include <utility/vector1.hh>
60 namespace downstream {
62 static basic::Tracer
TR(
"protocols.match.downstream.LigandConformerBuilder" );
66 ignore_h_collisions_( false ),
67 idealize_conformers_( true ),
68 rmsd_unique_cutoff_(0.05)
75 downstream_restype_( other.downstream_restype_ ),
76 upstream_restype_( other.upstream_restype_ ),
77 ignore_h_collisions_( other.ignore_h_collisions_ ),
78 idealize_conformers_( other.idealize_conformers_ ),
79 orientation_atoms_( other.orientation_atoms_ ),
80 atoms_123_( other.atoms_123_ ),
81 radii_123_( other.radii_123_ ),
82 ats123_reqd_in_active_site_( other.ats123_reqd_in_active_site_ ),
83 atom_radii_( other.atom_radii_ ),
84 atom_required_in_active_site_( other.atom_required_in_active_site_ ),
85 non_collision_detection_atoms_reqd_in_active_site_( other.non_collision_detection_atoms_reqd_in_active_site_ ),
86 rmsd_unique_cutoff_( other.rmsd_unique_cutoff_ ),
87 conformer_group_indices_( other.conformer_group_indices_ ),
88 lig_conformers_( other.lig_conformers_.
size() ),
89 min_sep_d2_from_upstream_atoms_( other.min_sep_d2_from_upstream_atoms_ )
128 HTReal const & atom3_frame,
129 Size const scaffold_build_point_id,
130 Size const upstream_conf_id,
131 Size const external_geometry_id,
135 std::list< Hit > hitlist;
138 upstream_conf_id, external_geometry_id, upstream_residue );
139 hitlist.splice( hitlist.end(), ii_hits );
149 Size num_relevant_atoms( relevant_atom_indices.size() );
159 ObjexxFCL::FArray2D< numeric::Real > queryconf_coord( 3, num_relevant_atoms );
160 lig_conformers_[ii]->get_global_coords_as_FArray2D( queryconf_coord, identity_ht, relevant_atom_indices );
162 bool conformer_unique(
true);
165 ObjexxFCL::FArray2D< numeric::Real > uniqueconf_coord( 3, num_relevant_atoms );
168 Real rmsd_this_pair = numeric::model_quality::rms_wrapper( num_relevant_atoms, queryconf_coord, uniqueconf_coord );
173 conformer_unique =
false;
178 if( conformer_unique ){
210 Hit const & other_hit,
214 return other.
compatible( other_hit, *
this, my_hit,
false );
223 Hit const & other_hit,
237 runtime_assert(
id.rsd() == 1 );
239 if (
lig_conformers_[ 1 ]->restype_id_2_collision_check_id(
id.atomno() ) == 0 ) {
243 for (
Size ii = 1; ii <= 3; ++ii ) {
343 for (
Size ii = 1; ii <= lig_res.
natoms(); ++ii ) {
345 coordinate_in_global_frame( ii, global_frame ) );
349 pose->append_residue_by_jump( lig_res, 1 );
353 pose->pdb_info( pdbinf );
354 pose->pdb_info()->chain( 1,
'X' );
373 Size orientation_atom1,
374 Size orientation_atom2,
375 Size orientation_atom3,
379 TR <<
"Initializing from residue " << residue.
name() << std::endl;
391 utility_exit_with_message(
"ERROR in LigandConformerBuilder: cannot build a residue with fewer than three atoms" );
397 for (
Size ii = 1; ii <= natoms; ++ii ) {
403 for (
Size ii = 1; ii <= 3; ++ii ) {
420 assert( upstream_res );
432 Size n_to_count( 0 );
437 if ( ! count_pair || ( count_pair->count( jj, ii_restype_id, weight, path_dist ) && weight == 1.0 ) ) {
450 if ( count_pair && ( ! count_pair->count( jj, ii_restype_id, weight, path_dist ) || weight != 1.0 )) {
461 if ( ! count_pair || ( count_pair->count( jj, ii_restype_id, weight, path_dist ) && weight == 1.0 ) ) {
469 for (
Size ii = 1; ii <= 3; ++ii ) {
475 if ( ! count_pair->count( jj, ii_id, weight, path_dist ) || weight != 1.0 ) {
493 utility_exit_with_message(
"ERROR: ignore_h_collisions_ must be set before the downstream restype is initialized" );
501 Size const confgrp_id,
502 HTReal const & atom3_frame,
503 Size const scaffold_build_point_id,
504 Size const upstream_conf_id,
505 Size const external_geometry_id,
514 std::list< Hit > hitlist;
525 bool ii_good(
true );
526 for (
Size jj = 1; jj <=
lig_conformers_[ ii_conf_id ]->n_collision_check_atoms(); ++jj ) {
529 Vector const jjloc =
lig_conformers_[ ii_conf_id ]->coordinate_in_D3_frame( jj_restype_id, atom3_frame );
553 if ( ! ii_good )
continue;
559 Vector const jjloc =
lig_conformers_[ ii_conf_id ]->coordinate_in_D3_frame( jj_restype_id, atom3_frame );
567 if ( ! ii_good )
continue;
569 Real6 global_coordinate =
lig_conformers_[ ii_conf_id ]->global_orientation_from_frame3( atom3_frame );
586 hit.
first()[ 1 ] = scaffold_build_point_id;
587 hit.
first()[ 2 ] = upstream_conf_id;
588 hit.
first()[ 3 ] = external_geometry_id;
589 hit.
first()[ 4 ] = ii_conf_id;
590 hit.
second() = global_coordinate;
593 hitlist.push_back( hit );
630 using namespace core;
631 using namespace core::conformation;
632 using namespace core::scoring;
633 using namespace core::pack::dunbrack;
638 if ( res_rotlib != 0 ) {
644 if ( lig_rotlib == 0 ) {
645 utility_exit_with_message(
"Failed to retrieve a ligand rotamer library for "
646 + residue.
name() +
". Did you mean to remove the -match::enumerate_ligand_rotamers flag from your command line?");
649 Size const nligrots = lig_rotlib->get_rotamers().size();
650 if ( nligrots == 0 ) {
651 utility_exit_with_message(
"Ligand rotamer library for " + residue.
name() +
" has 0 rotamers." );
654 TR <<
"Found " << nligrots <<
" rotamers for " << residue.
name() << std::endl;
663 TR <<
"Idealizing ligand rotamers" << std::endl;
668 for (
Size ii = 1; ii <= nligrots; ++ii ) {
675 ligpose.
replace_residue( 1, *lig_rotlib->get_rotamers()[ ii ], false );
678 idealizer.
apply( ligpose );
682 rms += lig_rotlib->get_rotamers()[ ii ]->xyz(jj).distance_squared( ligpose.
residue(1).
xyz(jj) );
685 if( rms_this_rot >= 0.1 )
TR <<
"WARNING: Ligand rotamer " << ii <<
" has idealized RMS of " << rms_this_rot <<
". Usually this number is < 0.1. Check whether ligand rotamers have the same bond lengths/bond angles as specified in the ligand .params file." << std::endl;
698 for (
Size ii = 1; ii <= nligrots; ++ii ) {
707 * lig_rotlib->get_rotamers()[ ii ] );
725 Real const distance_tolerance = 2e-3;
726 Real const angle_tolerance = 1e-1;
728 for (
Size ii = 2; ii <= nligrots; ++ii ) {
731 utility_exit_with_message(
"Ligand rotamers disagree on distances between atoms "
734 + utility::to_string( conf1_d12 ) +
" vs "
736 +
" for ligand rotamers #1 vs #" + utility::to_string( ii ) );
739 utility_exit_with_message(
"Ligand rotamers disagree on distances between atoms "
742 + utility::to_string( conf1_d23 ) +
" vs "
744 +
" for ligand rotamers #1 vs #" + utility::to_string( ii ) );
747 utility_exit_with_message(
"Ligand rotamers disagree on the angle between atoms "
751 + utility::to_string( conf1_ang123 ) +
" vs "
753 +
" for ligand rotamers #1 vs #" + utility::to_string( ii ) );
756 if ( std::abs(
lig_conformers_[ ii ]->oatom1_oatom2_distance() - conf1_oat_d12 ) > distance_tolerance ) {
757 utility_exit_with_message(
"Ligand rotamers disagree on distances between atoms "
760 + utility::to_string( conf1_oat_d12 ) +
" vs "
761 + utility::to_string(
lig_conformers_[ ii ]->oatom1_oatom2_distance() )
762 +
" for ligand rotamers #1 vs #" + utility::to_string( ii ) );
764 if ( std::abs(
lig_conformers_[ ii ]->oatom2_oatom3_distance() - conf1_oat_d23 ) > distance_tolerance ) {
765 utility_exit_with_message(
"Ligand rotamers disagree on distances between atoms "
768 + utility::to_string( conf1_oat_d23 ) +
" vs "
769 + utility::to_string(
lig_conformers_[ ii ]->oatom2_oatom3_distance() )
770 +
" for ligand rotamers #1 vs #" + utility::to_string( ii ) );
772 if ( std::abs(
lig_conformers_[ ii ]->oatom1_oatom2_oatom3_angle() - conf1_oat_ang123 ) > angle_tolerance ) {
773 utility_exit_with_message(
"Ligand rotamers disagree on the angle between atoms "
777 + utility::to_string( conf1_oat_ang123 ) +
" vs "
778 + utility::to_string(
lig_conformers_[ ii ]->oatom1_oatom2_oatom3_angle() )
779 +
" for ligand rotamers #1 vs #" + utility::to_string( ii ) );
784 TR <<
"No ligand rotamer library found, matching with geometry specified form .params file." << std::endl;