61 #include <utility/vector1.hh>
64 #include <numeric/xyzVector.hh>
65 #include <numeric/interpolation/spline/SplineGenerator.hh>
66 #include <numeric/interpolation/spline/SimpleInterpolator.hh>
69 #include <basic/Tracer.hh>
72 #include <basic/options/option.hh>
73 #include <basic/options/keys/run.OptionKeys.gen.hh>
74 #include <basic/options/keys/score.OptionKeys.gen.hh>
76 static basic::Tracer
TR(
"core.scoring.hackelec.HackElecEnergy");
127 max_dis_( options.hackelec_max_dis() ),
128 min_dis_( options.hackelec_min_dis() ),
129 smooth_hack_elec_( options.smooth_hack_elec() ),
130 die_( options.hackelec_die() ),
131 no_dis_dep_die_( options.hackelec_no_dis_dep_die() ),
132 exclude_protein_protein_( options.exclude_protein_protein_hack_elec() ),
133 exclude_monomer_( options.exclude_monomer_hack_elec() ),
134 exclude_DNA_DNA_( options.exclude_DNA_DNA() )
143 max_dis_( src.max_dis_ ),
144 min_dis_( src.min_dis_ ),
145 smooth_hack_elec_( src.smooth_hack_elec_ ),
147 no_dis_dep_die_( src.no_dis_dep_die_ ),
148 exclude_protein_protein_( src.exclude_protein_protein_ ),
149 exclude_monomer_( src.exclude_monomer_ ),
150 exclude_DNA_DNA_( src.exclude_DNA_DNA_ )
193 using namespace numeric::interpolation::spline;
194 Real low_poly_end_score(0.0), low_poly_end_deriv(0.0);
196 low_poly_end_score =
C1_ / low_poly_end_ -
C2_;
203 SplineGenerator gen_low_poly(
205 low_poly_end_, low_poly_end_score, low_poly_end_deriv );
206 InterpolatorOP interp_low( gen_low_poly.get_interpolator() );
207 SimpleInterpolatorOP sinterp_low =
dynamic_cast< SimpleInterpolator *
> (interp_low() );
208 if ( ! sinterp_low ) {
209 utility_exit_with_message(
"Hack Elec created non-simple-interpolator in initialize()" );
226 using namespace numeric::interpolation::spline;
227 Real hi_poly_start_score(0.0), hi_poly_start_deriv(0.0);
229 hi_poly_start_score =
C1_ / hi_poly_start_ -
C2_;
237 SplineGenerator gen_hi_poly(
238 hi_poly_start_, hi_poly_start_score, hi_poly_start_deriv,
239 hi_poly_end_, 0, 0 );
240 InterpolatorOP interp_hi( gen_hi_poly.get_interpolator() );
241 SimpleInterpolatorOP sinterp_hi =
dynamic_cast< SimpleInterpolator *
> (interp_hi() );
242 if ( ! sinterp_hi ) {
243 utility_exit_with_message(
"Hack Elec created non-simple-interpolator in initialize()" );
289 using namespace basic::options;
290 using namespace basic::options::OptionKeys;
307 nblist->setup( pose, sfxn, *
this);
347 using namespace trie;
358 tries->trie( ii, one_rotamer_trie );
386 using namespace trie;
390 TrieCollection & trie_collection
392 trie_collection.trie( resid, one_rotamer_trie );
412 using namespace etable::count_pair;
424 CountPairFactory::create_count_pair_function( rsd1, rsd2,
CP_CROSSOVER_4 );
455 if ( cpfxn->count( ii, jj, weight, path_dist )) {
458 d2 = rsd1.
xyz(ii).distance_squared( rsd2.
xyz(jj) );
461 if ( d2 > attached_h_max_dis2 )
continue;
465 for (
Size kk = ii_hatbegin; kk <= ii_hatend; ++kk ) {
468 if ( cpfxn->count( kk, jj, weight, path_dist )) score +=
score_atom_pair( rsd1, rsd2, kk, jj, emap, weight, d2 );
470 for (
Size kk = jj_hatbegin; kk <= jj_hatend; ++kk ) {
473 if ( cpfxn->count( ii, kk, weight, path_dist )) score +=
score_atom_pair( rsd1, rsd2, ii, kk, emap, weight, d2 );
475 for (
Size kk = ii_hatbegin; kk <= ii_hatend; ++kk ) {
476 for (
Size ll = jj_hatbegin; ll <= jj_hatend; ++ll ) {
479 if ( cpfxn->count( kk, ll, weight, path_dist )) score +=
score_atom_pair( rsd1, rsd2, kk, ll, emap, weight, d2 );
517 if ( d2 > attached_h_max_dis2 )
continue;
521 for (
Size kk = ii_hatbegin; kk <= ii_hatend; ++kk ) {
524 for (
Size kk = jj_hatbegin; kk <= jj_hatend; ++kk ) {
527 for (
Size kk = ii_hatbegin; kk <= ii_hatend; ++kk ) {
528 for (
Size ll = jj_hatbegin; ll <= jj_hatend; ++ll ) {
553 bool res_moving_wrt_eachother
566 return res_moving_wrt_eachother;
590 Real dsq, score( 0.0 );
592 for (
Size ii = 1, iiend = neighbs.size(); ii <= iiend; ++ii ) {
593 score +=
score_atom_pair( rsd1, rsd2, neighbs[ ii ].atomno1(), neighbs[ ii ].atomno2(), emap, neighbs[ ii ].weight(), dsq );
610 using namespace basic::options;
611 using namespace basic::options::OptionKeys;
620 Real const tolerated_narrow_nblist_motion = 0.75;
621 Real const XX2 = std::pow(
max_dis_ + 2*tolerated_narrow_nblist_motion, 2 );
623 nblist->initialize_from_residues( XX2, XX2, XX2, rsd1, rsd2, count_pair );
650 for (
Size ii = 1, iiend = neighbs.size(); ii <= iiend; ++ii ) {
651 Vector const & atom1xyz( rsd1.
xyz( neighbs[ ii ].atomno1() ) );
652 Vector const & atom2xyz( rsd2.
xyz( neighbs[ ii ].atomno2() ) );
657 Vector f2 = ( atom1xyz - atom2xyz );
658 Real const dis2( f2.length_squared() );
660 if ( dE_dr_over_r != 0.0 ) {
665 Vector f1 = atom1xyz.cross( atom2xyz );
666 f1 *= dE_dr_over_r * sfxn_weight;
667 f2 *= dE_dr_over_r * sfxn_weight;
668 r1_atom_derivs[ neighbs[ ii ].atomno1() ].f1() += f1;
669 r1_atom_derivs[ neighbs[ ii ].atomno1() ].f2() += f2;
670 r2_atom_derivs[ neighbs[ ii ].atomno2() ].f1() -= f1;
671 r2_atom_derivs[ neighbs[ ii ].atomno2() ].f2() -= f2;
687 using namespace etable::count_pair;
688 using namespace chemical;
698 CountPairFactory::create_count_pair_function( rsd1, rsd2,
CP_CROSSOVER_4 );
703 for (
Size ii=1, ii_end = rsd1_bb_atoms.size(); ii<= ii_end; ++ii ) {
704 Size const i = rsd1_bb_atoms[ ii ];
707 if ( i_charge == 0.0 )
continue;
708 for (
Size jj=1, jj_end = rsd2_bb_atoms.size(); jj<= jj_end; ++jj ) {
709 Size const j = rsd2_bb_atoms[ jj ];
711 if ( j_charge == 0.0 )
continue;
714 if ( cpfxn->count( i, j, weight, path_dist ) ) {
725 for (
Size ii=1, ii_end = rsd1_bb_atoms.size(); ii<= ii_end; ++ii ) {
726 Size const i = rsd1_bb_atoms[ ii ];
729 if ( i_charge == 0.0 )
continue;
730 for (
Size jj=1, jj_end = rsd2_bb_atoms.size(); jj<= jj_end; ++jj ) {
731 Size const j = rsd2_bb_atoms[ jj ];
733 if ( j_charge == 0.0 )
continue;
752 using namespace etable::count_pair;
753 using namespace chemical;
763 CountPairFactory::create_count_pair_function( rsd1, rsd2,
CP_CROSSOVER_4 );
768 for (
Size ii=1, ii_end = rsd1_bb_atoms.size(); ii<= ii_end; ++ii ) {
769 Size const i = rsd1_bb_atoms[ ii ];
772 if ( i_charge == 0.0 )
continue;
773 for (
Size jj=1, jj_end = rsd2_sc_atoms.size(); jj<= jj_end; ++jj ) {
774 Size const j = rsd2_sc_atoms[ jj ];
776 if ( j_charge == 0.0 )
continue;
779 if ( cpfxn->count( i, j, weight, path_dist ) ) {
790 for (
Size ii=1, ii_end = rsd1_bb_atoms.size(); ii<= ii_end; ++ii ) {
791 Size const i = rsd1_bb_atoms[ ii ];
794 if ( i_charge == 0.0 )
continue;
795 for (
Size jj=1, jj_end = rsd2_sc_atoms.size(); jj<= jj_end; ++jj ) {
796 Size const j = rsd2_sc_atoms[ jj ];
798 if ( j_charge == 0.0 )
continue;
819 using namespace etable::count_pair;
820 using namespace chemical;
830 CountPairFactory::create_count_pair_function( rsd1, rsd2,
CP_CROSSOVER_4 );
835 for (
Size ii=1, ii_end = rsd1_sc_atoms.size(); ii<= ii_end; ++ii ) {
836 Size const i = rsd1_sc_atoms[ ii ];
839 if ( i_charge == 0.0 )
continue;
840 for (
Size jj=1, jj_end = rsd2_sc_atoms.size(); jj<= jj_end; ++jj ) {
841 Size const j = rsd2_sc_atoms[ jj ];
843 if ( j_charge == 0.0 )
continue;
846 if ( cpfxn->count( i, j, weight, path_dist ) ) {
857 for (
Size ii=1, ii_end = rsd1_sc_atoms.size(); ii<= ii_end; ++ii ) {
858 Size const i = rsd1_sc_atoms[ ii ];
861 if ( i_charge == 0.0 )
continue;
862 for (
Size jj=1, jj_end = rsd2_sc_atoms.size(); jj<= jj_end; ++jj ) {
863 Size const j = rsd2_sc_atoms[ jj ];
865 if ( j_charge == 0.0 )
continue;
894 resvect.push_back( & pose.
residue( ii ) );
899 for (
Size ii=1, ii_end=ires.
natoms(); ii<= ii_end; ++ii ) {
900 AtomNeighbors const & nbrs( nblist.upper_atom_neighbors(i,ii) );
902 for ( AtomNeighbors::const_iterator nbr_iter=nbrs.begin(),
903 nbr_end=nbrs.end(); nbr_iter!= nbr_end; ++nbr_iter ) {
911 Real d2 = ires.
xyz( ii ).distance_squared( jres.xyz( jj ) );
912 nbr.
temp1() = nbr.
weight() * ii_charge * jres.atomic_charge( jj ) * (
C1_ / ( d2 + 1e-300 ) -
C2_ );
920 Real bb_sc_scores[ 3 ] = {0.0, 0.0, 0.0};
924 for (
Size ii=1, ii_end=ires.
natoms(); ii<= ii_end; ++ii ) {
925 AtomNeighbors const & nbrs( nblist.upper_atom_neighbors(i,ii) );
927 for ( AtomNeighbors::const_iterator nbr_iter=nbrs.begin(),
928 nbr_end=nbrs.end(); nbr_iter!= nbr_end; ++nbr_iter ) {
937 int jj_isbb = jres.atom_is_backbone( jj );
940 assert( ii_isbb + jj_isbb >= 0 && ii_isbb + jj_isbb < 3 );
942 assert( std::abs( nbr.
weight() *
949 bb_sc_scores[ ii_isbb + jj_isbb ] += score;
950 total_score += score;
967 ObjexxFCL::FArray2D< core::PackerEnergy > & energy_table
976 using namespace methods;
977 using namespace trie;
978 ObjexxFCL::FArray2D< core::PackerEnergy > temp_table1( energy_table );
979 ObjexxFCL::FArray2D< core::PackerEnergy > temp_table2( energy_table );
981 temp_table1 = 0; temp_table2 = 0;
1003 trie1->trie_vs_trie( *trie2, *cp, *
this, temp_table1, temp_table2 );
1006 energy_table += temp_table1;
1053 using namespace methods;
1054 using namespace trie;
1077 trie1->trie_vs_path( *trie2, *cp, *
this, temp_vector1, temp_vector2 );
1081 energy_vector[ ii ] += temp_vector1[ ii ];
1121 utility_exit_with_message(
"HackElecEnergy does not define intra-residue pair energies; do not call get_intrares_countpair()" );
1133 using namespace etable::count_pair;
1134 if ( res1 == res2 ) {
1135 return new CountPairNone;
1150 using namespace etable::count_pair;
1157 return CountPairFactory::create_count_pair_function( rsd1, rsd2,
CP_CROSSOVER_4 );
1159 return new CountPairAll;
1191 using namespace trie;
1192 using namespace etable::etrie;
1195 if ( cpdata_map.has_pseudobonds() ||
1196 cpdata_map.max_connpoints_for_residue() > 1 ||
1197 cpdata_map.n_entries() > 3 ) {
1200 }
else if ( cpdata_map.n_entries() == 1 || cpdata_map.n_entries() == 0 ) {
1203 }
else if ( cpdata_map.n_entries() == 2 ) {
1206 }
else if ( cpdata_map.n_entries() == 3 ) {
1210 std::cerr <<
"Unsupported number of residue connections in trie construction." << std::endl;
1223 using namespace trie;
1224 using namespace etable::etrie;
1227 if ( cpdata_map.has_pseudobonds() ||
1228 cpdata_map.max_connpoints_for_residue() > 1 ||
1229 cpdata_map.n_entries() > 3 ) {
1232 }
else if ( cpdata_map.n_entries() == 1 || cpdata_map.n_entries() == 0 ) {
1235 }
else if ( cpdata_map.n_entries() == 2 ) {
1238 }
else if ( cpdata_map.n_entries() == 3 ) {
1242 std::cerr <<
"Unsupported number of residue connections in trie construction." << std::endl;
1280 using namespace etable::count_pair;
1281 using namespace trie;
1282 using namespace etable::etrie;
1291 Size conn1 = trie1->get_count_pair_data_for_residue( res2.
seqpos() );
1292 Size conn2 = trie2->get_count_pair_data_for_residue( res1.
seqpos() );
1295 tcpfxn =
new TrieCountPair1BC4( conn1, conn2 );
1297 tcpfxn =
new TrieCountPairAll;
1299 tcpfxn =
new TrieCountPairGeneric( res1, res2, conn1, conn2 );
1314 Real const cpweight,