37 #include <numeric/constants.hh>
38 #include <numeric/xyz.functions.hh>
41 #include <utility/vector1.hh>
66 using namespace constraints;
75 virtual Real func(
Real const x )
const;
76 virtual Real dfunc(
Real const x )
const;
86 using namespace numeric;
87 using namespace numeric::constants::d;
108 if ( x >= ANGLE_CUTOFF_HIGH ) {
return 1.0; }
109 else if ( x <= ANGLE_CUTOFF_LOW ) {
return 0.0; }
111 static Real const range = ANGLE_CUTOFF_HIGH - ANGLE_CUTOFF_LOW;
113 Real const xprime = ( ANGLE_CUTOFF_HIGH - x ) / range;
115 return ( 1 - xprime*xprime )*( 1 - xprime*xprime );
123 if ( x >= ANGLE_CUTOFF_HIGH ) {
return 0.0; }
124 else if ( x <= ANGLE_CUTOFF_LOW ) {
return 0.0; }
127 static Real const range = ANGLE_CUTOFF_HIGH - ANGLE_CUTOFF_LOW;
128 Real const xprime = ( ANGLE_CUTOFF_HIGH - x ) / range;
134 return ( 4.0 / (range) ) * ( 1 - xprime*xprime ) * ( xprime );
141 solv1_(etable_in.solv1()),
142 solv2_(etable_in.solv2()),
143 dsolv1_( etable_in.dsolv1() ),
144 safe_max_dis2_( etable_in.get_safe_max_dis2() ),
145 get_bins_per_A2_( etable_in.get_bins_per_A2())
163 etable_(src.etable_),
164 solv1_( src.solv1_ ),
165 solv2_( src.solv2_ ),
166 dsolv1_( src.dsolv1_ ),
167 safe_max_dis2_( src.safe_max_dis2_ ),
168 get_bins_per_A2_( src.get_bins_per_A2_ )
187 using namespace etable::count_pair;
194 CountPairFactory::create_count_pair_function( rsd1, rsd2,
CP_CROSSOVER_4 );
204 res1_heavy_is_polar[ i ] =
true;
206 Vector base_pseudo_atom(0);
210 base_pseudo_atom += rsd1.
xyz(neighbor_id);
219 Size const neighbor_res_id( ii_conn.
resid() );
220 Size const nieghbor_atom_id( pose.
residue( ii_conn.
resid() ).residue_connection( ii_conn.
connid() ).atomno() );
222 base_pseudo_atom += pose.
residue( neighbor_res_id ).
xyz( nieghbor_atom_id );
227 base_pseudo_atom /= non_H_neib;
228 res1_base_vectors[i] = rsd1.
xyz(i) - base_pseudo_atom;
229 res1_base_vectors[i].normalize();
235 res2_heavy_is_polar[ i ] =
true;
237 Vector base_pseudo_atom(0);
241 base_pseudo_atom += rsd2.
xyz(neighbor_id);
248 Size const neighbor_res_id( ii_conn.
resid() );
249 Size const nieghbor_atom_id( pose.
residue( ii_conn.
resid() ).residue_connection( ii_conn.
connid() ).atomno() );
251 base_pseudo_atom += pose.
residue( neighbor_res_id ).
xyz( nieghbor_atom_id );
257 base_pseudo_atom /= non_H_neib;
258 res2_base_vectors[i] = rsd2.
xyz(i) - base_pseudo_atom;
259 res2_base_vectors[i].normalize();
270 if ( cpfxn->count( i, j, cp_weight, path_dist ) ) {
277 int disbin =
static_cast< int >( d2_bin ) + 1;
278 Real frac = d2_bin - ( disbin - 1 );
280 int const l2 = l1 + 1;
283 bool i_to_j_vec_normalized(
false );
285 Real i_to_j_angle_weight( 1.0 ), j_to_i_angle_weight( 1.0 );
287 if ( res1_heavy_is_polar[i] ) {
288 if (res1_base_vectors[i].dot( i_to_j_vec ) >= 0 ) {
291 i_to_j_vec *= 1 / ( std::sqrt( d2 ) );
292 i_to_j_vec_normalized =
true;
293 Real dotprod = res1_base_vectors[i].dot( i_to_j_vec );
298 i_to_j_angle_weight = 0;
300 Real angle = pi - std::acos( dotprod );
301 i_to_j_angle_weight = lksigmoidalfunc.func( angle );
305 i_to_j_angle_weight = 0.0;
310 if ( i_to_j_angle_weight != 0 ) {
311 score += i_to_j_angle_weight * cp_weight * ( (1.-frac)*
solv1_[ l1 ] + frac *
solv1_[ l2 ]);
314 if ( res2_heavy_is_polar[j] ) {
315 Vector j_to_i_vec = -1 * i_to_j_vec;
316 if (res2_base_vectors[j].dot( j_to_i_vec ) > 0 ) {
317 if ( ! i_to_j_vec_normalized ) {
319 j_to_i_vec *= 1 / ( std::sqrt( d2 ));
321 Real dotprod = res2_base_vectors[j].dot( j_to_i_vec );
327 j_to_i_angle_weight = 0;
329 Real angle = pi - std::acos( dotprod );
330 j_to_i_angle_weight = lksigmoidalfunc.func( angle );
335 j_to_i_angle_weight = 0.0;
340 if ( j_to_i_angle_weight != 0 ) {
341 score += j_to_i_angle_weight * cp_weight * ( (1.-frac)*
solv2_[ l1 ] + frac *
solv2_[ l2 ]);
382 for (
Size ii = 1; ii <= total_residue; ++ii ) {
389 for (
Size jj = 1; jj <= ii_nheavy; ++jj ) {
404 using namespace conformation;
408 for (
Size ii = 1; ii <= total_residue; ++ii ) {
411 for (
Size jj = 1; jj <= ii_nheavy; ++jj ) {
412 if (ii_res.atom_type(jj).is_acceptor() || ii_res.atom_type(jj).is_donor()) {
413 for (
Size kk = 1; kk <= ii_res.bonded_neighbor(jj).size(); ++kk){
415 if ( ! ii_res.atom_is_hydrogen(neighbor_id)){
420 if ( ii_res.type().n_residue_connections_for_atom(jj) > 0 ) {
421 for (
Size kk = 1; kk <= ii_res.type().residue_connections_for_atom(jj).size(); ++kk ) {
422 chemical::ResConnID kk_conn = ii_res.connect_map( ii_res.type().residue_connections_for_atom(jj)[ kk ] );
423 Size const neighbor_res_id( kk_conn.
resid() );
424 Size const nieghbor_atom_id( pose.
residue( kk_conn.
resid() ).residue_connection( kk_conn.
connid() ).atomno() );
438 for (
Size ii = 1; ii <= total_residue; ++ii ) {
451 using namespace constraints;
459 EnergyGraph const & energy_graph( energies.energy_graph() );
461 for (
Size ii = 1; ii <= total_residue; ++ii ) {
463 iru = energy_graph.get_node(ii)->const_upper_edge_list_begin(),
465 iru != irue; ++iru ) {
466 Size jj = (*iru)->get_second_node_ind();
480 using namespace etable::count_pair;
489 CountPairFactory::create_count_pair_function( lowerres, upperres,
CP_CROSSOVER_4 );
491 for (
Size ii = 1, iie = lowerres.nheavyatoms(), jje = upperres.nheavyatoms();
493 for (
Size jj = 1; jj <= jje; ++jj ) {
494 Real cp_weight = 1.0;
496 if ( ! cpfxn->count( ii, jj, cp_weight, path_dist ) )
continue;
498 Vector ii_to_jj = upperres.xyz( jj ) - lowerres.xyz( ii );
502 Distance const ii_jj_one_over_d( 1 / (std::sqrt( ii_jj_dis2 )));
503 ii_to_jj *= ii_jj_one_over_d;
506 if (
nneighbs_[ lower_res_id ][ ii ] != 0 ) {
511 Vector f1_ii( 0.0 ), f2_ii( 0.0 ), f1_jj( 0.0 ), f2_jj( 0.0 );
513 Real const dE_dR_over_r(
515 lowerres.atom(ii), upperres.atom(jj),
516 ii_jj_one_over_d, ii_jj_dis2,
517 f1_ii, f2_ii, f1_jj, f2_jj ) );
521 atom_f1_f2s_[ lower_res_id ][ ii ].first += dE_dR_over_r * cp_weight * f1_ii;
522 atom_f1_f2s_[ lower_res_id ][ ii ].second += dE_dR_over_r * cp_weight * f2_ii;
523 atom_f1_f2s_[ upper_res_id ][ jj ].first += dE_dR_over_r * cp_weight * f1_jj;
524 atom_f1_f2s_[ upper_res_id ][ jj ].second += dE_dR_over_r * cp_weight * f2_jj;
532 int disbin =
static_cast< int >( d2_bin ) + 1;
533 Real frac = d2_bin - ( disbin - 1 );
534 int const l1 =
solv1_.index( disbin, upperres.atom(jj).type(), lowerres.atom(ii).type() );
535 int const l2 = l1 + 1;
539 Vector w_f1_ii( 0.0 ), w_f2_ii( 0.0 ), w_f1_jj( 0.0 ), w_f2_jj( 0.0 ), w_f1_ii_pbase( 0.0 ), w_f2_ii_pbase( 0.0 );
542 w_f1_ii_pbase, w_f2_ii_pbase );
553 Real const w = lkfunc->func(
557 upperres.xyz( jj ) ) );
560 atom_f1_f2s_[ lower_res_id ][ ii ].first += w * dE_dR_over_r * cp_weight * f1_ii;
561 atom_f1_f2s_[ lower_res_id ][ ii ].second += w * dE_dR_over_r * cp_weight * f2_ii;
562 atom_f1_f2s_[ upper_res_id ][ jj ].first += w * dE_dR_over_r * cp_weight * f1_jj;
563 atom_f1_f2s_[ upper_res_id ][ jj ].second += w * dE_dR_over_r * cp_weight * f2_jj;
565 atom_f1_f2s_[ lower_res_id ][ ii ].first += lk * w_f1_ii;
566 atom_f1_f2s_[ lower_res_id ][ ii ].second += lk * w_f2_ii;
567 atom_f1_f2s_[ upper_res_id ][ jj ].first += lk * w_f1_jj;
568 atom_f1_f2s_[ upper_res_id ][ jj ].second += lk * w_f2_jj;
576 Vector f1_ii, f2_ii, f1_jj, f2_jj;
578 Real const dE_dR_over_r(
580 lowerres.atom(ii), upperres.atom(jj),
581 ii_jj_one_over_d, ii_jj_dis2,
582 f1_ii, f2_ii, f1_jj, f2_jj ) );
584 if ( dE_dR_over_r != 0.0 ) {
585 atom_f1_f2s_[ lower_res_id ][ ii ].first += dE_dR_over_r * cp_weight * f1_ii;
586 atom_f1_f2s_[ lower_res_id ][ ii ].second += dE_dR_over_r * cp_weight * f2_ii;
587 atom_f1_f2s_[ upper_res_id ][ jj ].first += dE_dR_over_r * cp_weight * f1_jj;
588 atom_f1_f2s_[ upper_res_id ][ jj ].second += dE_dR_over_r * cp_weight * f2_jj;
593 if (
nneighbs_[ upper_res_id ][ jj ] != 0 ) {
594 Vector jj_to_ii = -1*ii_to_jj;
600 Vector f1_jj( 0.0 ), f2_jj( 0.0 ), f1_ii( 0.0 ), f2_ii( 0.0 );
602 Real const dE_dR_over_r(
604 upperres.atom(jj), lowerres.atom(ii),
605 ii_jj_one_over_d, ii_jj_dis2,
606 f1_jj, f2_jj, f1_ii, f2_ii ) );
610 atom_f1_f2s_[ upper_res_id ][ jj ].first += dE_dR_over_r * cp_weight * f1_jj;
611 atom_f1_f2s_[ upper_res_id ][ jj ].second += dE_dR_over_r * cp_weight * f2_jj;
612 atom_f1_f2s_[ lower_res_id ][ ii ].first += dE_dR_over_r * cp_weight * f1_ii;
613 atom_f1_f2s_[ lower_res_id ][ ii ].second += dE_dR_over_r * cp_weight * f2_ii;
621 int disbin =
static_cast< int >( d2_bin ) + 1;
622 Real frac = d2_bin - ( disbin - 1 );
623 int const l1 =
solv1_.index( disbin, lowerres.atom(ii).type(), upperres.atom(jj).type() );
624 int const l2 = l1 + 1;
628 Vector w_f1_jj(0.0), w_f2_jj(0.0), w_f1_ii(0.0), w_f2_ii(0.0), w_f1_jj_pbase(0.0), w_f2_jj_pbase(0.0);
631 w_f1_jj_pbase, w_f2_jj_pbase );
642 Real const w = lkfunc->func(
646 lowerres.xyz( ii ) ) );
649 atom_f1_f2s_[ upper_res_id ][ jj ].first += w * dE_dR_over_r * cp_weight * f1_jj;
650 atom_f1_f2s_[ upper_res_id ][ jj ].second += w * dE_dR_over_r * cp_weight * f2_jj;
651 atom_f1_f2s_[ lower_res_id ][ ii ].first += w * dE_dR_over_r * cp_weight * f1_ii;
652 atom_f1_f2s_[ lower_res_id ][ ii ].second += w * dE_dR_over_r * cp_weight * f2_ii;
654 atom_f1_f2s_[ upper_res_id ][ jj ].first += lk * w_f1_jj;
655 atom_f1_f2s_[ upper_res_id ][ jj ].second += lk * w_f2_jj;
656 atom_f1_f2s_[ lower_res_id ][ ii ].first += lk * w_f1_ii;
657 atom_f1_f2s_[ lower_res_id ][ ii ].second += lk * w_f2_ii;
665 Vector f1_jj, f2_jj, f1_ii, f2_ii;
667 Real const dE_dR_over_r(
669 upperres.atom(jj), lowerres.atom(ii),
670 ii_jj_one_over_d, ii_jj_dis2,
671 f1_jj, f2_jj, f1_ii, f2_ii ) );
673 if ( dE_dR_over_r != 0.0 ) {
674 atom_f1_f2s_[ upper_res_id ][ jj ].first += dE_dR_over_r * cp_weight * f1_jj;
675 atom_f1_f2s_[ upper_res_id ][ jj ].second += dE_dR_over_r * cp_weight * f2_jj;
676 atom_f1_f2s_[ lower_res_id ][ ii ].first += dE_dR_over_r * cp_weight * f1_ii;
677 atom_f1_f2s_[ lower_res_id ][ ii ].second += dE_dR_over_r * cp_weight * f2_ii;
697 f1_1 = atom1.
xyz().cross( atom2.
xyz() );
698 f2_1 = atom1.
xyz() - atom2.
xyz();
705 int disbin =
static_cast< int >( d2_bin ) + 1;
706 Real frac = d2_bin - ( disbin - 1 );
722 return deriv * one_over_d;
736 for (
Size ii = 1; ii <= total_residue; ++ii ) {
739 for (
Size jj = 1; jj <= ii_nheavy; ++jj ) {
740 if (
nneighbs_[ ii ][ jj ] == 0 )
continue;
742 Real divvy_proportion = 1.0 / jj_nneighbs;
747 Size count_neighbors_found = 0;
748 for (
Size kk = 1; kk <= ii_res.bonded_neighbor(jj).size(); ++kk){
749 Size neighbor_id = ii_res.bonded_neighbor(jj)[kk];
750 if ( ! ii_res.atom_is_hydrogen(neighbor_id) ){
751 ++count_neighbors_found;
753 atom_f1_f2s_[ ii ][ neighbor_id ].second += f2_to_divvy;
756 if ( ii_res.type().n_residue_connections_for_atom( jj ) > 0 ) {
757 for (
Size kk = 1; kk <= ii_res.type().residue_connections_for_atom(jj).size(); ++kk ) {
759 chemical::ResConnID const kk_conn = ii_res.connect_map( ii_res.type().residue_connections_for_atom( jj )[ kk ] );
760 Size const neighbor_res_id( kk_conn.
resid() );
761 Size const nieghbor_atom_id( pose.
residue( kk_conn.
resid() ).residue_connection( kk_conn.
connid() ).atomno() );
763 atom_f1_f2s_[ neighbor_res_id ][ nieghbor_atom_id ].first += f1_to_divvy;
764 atom_f1_f2s_[ neighbor_res_id ][ nieghbor_atom_id ].second += f2_to_divvy;
765 count_neighbors_found++;
769 assert( count_neighbors_found == jj_nneighbs );
787 if ( pose.
residue(
id.rsd() ).atom_is_hydrogen(
id.atomno() ) )
return;