36 #include <basic/Tracer.hh>
38 #include <ObjexxFCL/format.hh>
48 #include <utility/vector1.hh>
49 #include <basic/options/keys/OptionKeys.hh>
52 #include <boost/foreach.hpp>
53 #define foreach BOOST_FOREACH
61 using namespace ObjexxFCL;
63 using namespace basic::options;
64 using namespace OptionKeys;
70 static basic::Tracer
tr(
"core.scoring.hbonds.hbonds");
86 bool const calculate_derivative,
96 if(rsd1.is_RNA()==
false)
continue;
108 bool const calculate_derivative,
110 bool const exclude_bb ,
111 bool const exclude_bsc ,
112 bool const exclude_scb ,
113 bool const exclude_sc
134 iru = energy_graph.get_node(res1)->const_upper_edge_list_begin(),
136 iru != irue; ++iru ) {
138 int const res2( (*iru)->get_second_node_ind() );
143 int const nb2 = tenA_neighbor_graph.get_node( res2 )->num_neighbors_counting_self_static();
149 rsd1, rsd2, nb1, nb2, calculate_derivative,
150 exclude_bb, exclude_bsc, exclude_scb, exclude_sc, hbond_set, pose);
154 rsd2, rsd1, nb2, nb1, calculate_derivative,
155 exclude_bb, exclude_bsc, exclude_scb, exclude_sc, hbond_set, pose);
159 rsd1, rsd2, nb1, nb2, calculate_derivative,
160 exclude_bb, exclude_bsc, exclude_scb, exclude_sc, hbond_set);
164 rsd2, rsd1, nb2, nb1, calculate_derivative,
165 exclude_bb, exclude_bsc, exclude_scb, exclude_sc, hbond_set);
174 rsd1, rsd1, nb1, nb1, calculate_derivative,
175 exclude_bb, exclude_bsc, exclude_scb, exclude_sc, hbond_set, pose);
179 rsd1, rsd1, nb1, nb1, calculate_derivative,
180 exclude_bb, exclude_bsc, exclude_scb, exclude_sc, hbond_set);
197 Real const AHdist_threshold,
211 for (
Size acc_rsd_num = 1; acc_rsd_num <= pose.
total_residue(); ++acc_rsd_num ) {
213 int const n_acc_nbrs = tenA_neighbor_graph.get_node( acc_rsd_num )->num_neighbors_counting_self_static();
216 iru = energy_graph.get_node(acc_rsd_num)->const_upper_edge_list_begin(),
218 iru != irue; ++iru ) {
219 int const don_rsd_num( (*iru)->get_second_node_ind() );
221 int const n_don_nbrs = tenA_neighbor_graph.get_node(don_rsd_num)->num_neighbors_counting_self_static();
224 acc_rsd.is_DNA() && don_rsd.is_DNA() )
continue;
226 foreach(
Size const hatm, don_rsd.Hpos_polar()){
227 Size const datm(don_rsd.atom_base(hatm));
228 Vector const & hatm_xyz(don_rsd.atom(hatm).xyz());
229 Vector const & datm_xyz(don_rsd.atom(datm).xyz());
231 foreach(
Size const aatm, acc_rsd.accpt_pos()){
232 if(hatm_xyz.distance( acc_rsd.xyz( aatm )) > AHdist_threshold)
continue;
234 HBEvalTuple hbe_type(datm, don_rsd, aatm, acc_rsd);
235 int const base ( acc_rsd.atom_base( aatm ) );
236 int const base2( acc_rsd.abase2( aatm ) );
238 Real unweighted_energy( 0.0 );
240 hbe_type, datm_xyz, hatm_xyz,
241 acc_rsd.atom(aatm ).xyz(),
242 acc_rsd.atom(base ).xyz(),
243 acc_rsd.atom(base2).xyz(),
246 Real environmental_weight
251 hatm, don_rsd, aatm, acc_rsd, hbe_type, unweighted_energy, environmental_weight,
DUMMY_DERIVS );
304 bool const evaluate_derivative,
305 bool const exclude_bb,
306 bool const exclude_bsc,
307 bool const exclude_scb,
308 bool const exclude_sc,
319 for ( chemical::AtomIndices::const_iterator
321 hnum != hnume; ++hnum ) {
322 Size const hatm( *hnum );
327 if (exclude_bb && exclude_scb)
continue;
329 if (exclude_sc && exclude_bsc)
continue;
334 for ( chemical::AtomIndices::const_iterator
336 anum != anume; ++anum ) {
337 Size const aatm( *anum );
340 if (exclude_bb)
continue;
342 if (exclude_bsc)
continue;
346 if (exclude_scb)
continue;
348 if (exclude_sc)
continue;
353 if ( hatm_xyz.distance_squared( acc_rsd.
xyz( aatm ) ) >
MAX_R2 )
continue;
355 Real unweighted_energy( 0.0 );
357 HBEvalTuple hbe_type( datm, don_rsd, aatm, acc_rsd);
359 int const base ( acc_rsd.
atom_base( aatm ) );
360 int const base2( acc_rsd.
abase2( aatm ) );
361 assert( base2 > 0 && base != base2 );
365 hbe_type, datm_xyz, hatm_xyz,
369 unweighted_energy, evaluate_derivative, derivs);
373 Real environmental_weight
380 hbe_type, unweighted_energy, environmental_weight, derivs );
395 bool const evaluate_derivative,
396 bool const exclude_bb,
397 bool const exclude_bsc,
398 bool const exclude_scb,
399 bool const exclude_sc,
411 for ( chemical::AtomIndices::const_iterator
413 hnum != hnume; ++hnum ) {
414 Size const hatm( *hnum );
419 if (exclude_bb && exclude_scb)
continue;
421 if (exclude_sc && exclude_bsc)
continue;
426 for ( chemical::AtomIndices::const_iterator
428 anum != anume; ++anum ) {
429 Size const aatm( *anum );
432 if (exclude_bb)
continue;
434 if (exclude_bsc)
continue;
438 if (exclude_scb)
continue;
440 if (exclude_sc)
continue;
445 if ( hatm_xyz.distance_squared( acc_rsd.
xyz( aatm ) ) >
MAX_R2 )
continue;
447 Real unweighted_energy( 0.0 );
449 HBEvalTuple hbe_type( datm, don_rsd, aatm, acc_rsd);
451 int const base ( acc_rsd.
atom_base( aatm ) );
452 int const base2( acc_rsd.
abase2( aatm ) );
453 assert( base2 > 0 && base != base2 );
459 unweighted_energy, evaluate_derivative, derivs);
463 Real environmental_weight
470 Real hbE = unweighted_energy * environmental_weight ;
488 tr <<
"Warning: energy from unexpected HB type ignored "
490 runtime_assert(
false);
505 bool const evaluate_derivative,
510 if(rsd.
is_RNA()==
false)
return;
522 for ( chemical::AtomIndices::const_iterator anum = rsd.
accpt_pos().begin(), anume = rsd.
accpt_pos().end(); anum != anume; ++anum ) {
524 Size const aatm( *anum );
525 int const base ( rsd.
atom_base( aatm ) );
526 int const base2( rsd.
abase2( aatm ) );
527 assert( base2 > 0 && base != base2 );
533 for ( chemical::AtomIndices::const_iterator hnum = rsd.
Hpos_polar().begin(), hnume = rsd.
Hpos_polar().end(); hnum != hnume; ++hnum ) {
534 Size const hatm( *hnum );
539 if( rsd.
path_distance( aatm, datm ) < 4) utility_exit_with_message(
"rsd.path_distance(aatm, datm) < 4");
548 if ( hatm_xyz.distance_squared( rsd.
xyz( aatm ) ) >
MAX_R2 )
continue;
550 Real unweighted_energy( 0.0 );
555 hbe_type, datm_xyz, hatm_xyz,
559 unweighted_energy, evaluate_derivative, derivs);
563 Real environmental_weight=1;
566 hbond_set.
append_hbond( hatm, rsd, aatm, rsd, hbe_type, unweighted_energy, environmental_weight, derivs );
579 bool const evaluate_derivative,
583 if(rsd.
is_RNA()==
false)
return;
595 for ( chemical::AtomIndices::const_iterator anum = rsd.
accpt_pos().begin(), anume = rsd.
accpt_pos().end(); anum != anume; ++anum ) {
597 Size const aatm( *anum );
598 int const base ( rsd.
atom_base( aatm ) );
599 int const base2( rsd.
abase2( aatm ) );
600 assert( base2 > 0 && base != base2 );
606 for ( chemical::AtomIndices::const_iterator hnum = rsd.
Hpos_polar().begin(), hnume = rsd.
Hpos_polar().end(); hnum != hnume; ++hnum ) {
607 Size const hatm( *hnum );
612 if( rsd.
path_distance( aatm, datm ) < 4) utility_exit_with_message(
"rsd.path_distance(aatm, datm) < 4");
621 if ( hatm_xyz.distance_squared( rsd.
xyz( aatm ) ) >
MAX_R2 )
continue;
623 Real unweighted_energy( 0.0 );
628 hbe_type, datm_xyz, hatm_xyz,
632 unweighted_energy, evaluate_derivative, derivs);
636 Real environmental_weight=1;
638 Real hbE = unweighted_energy * environmental_weight;
654 bool const evaluate_derivative,
655 bool const exclude_bb,
656 bool const exclude_bsc,
657 bool const exclude_scb,
658 bool const exclude_sc,
672 for ( chemical::AtomIndices::const_iterator
674 hnum != hnume; ++hnum ) {
675 Size const hatm( *hnum );
680 if (exclude_bb && exclude_scb)
continue;
682 if (exclude_sc && exclude_bsc)
continue;
687 for ( chemical::AtomIndices::const_iterator
689 anum != anume; ++anum ) {
690 Size const aatm( *anum );
693 if (exclude_bb)
continue;
695 if (exclude_bsc)
continue;
699 if (exclude_scb)
continue;
701 if (exclude_sc)
continue;
706 if ( hatm_xyz.distance_squared( acc_rsd.
xyz( aatm ) ) >
MAX_R2 )
continue;
708 Real unweighted_energy( 0.0 );
710 HBEvalTuple hbe_type( datm, don_rsd, aatm, acc_rsd);
712 int const base ( acc_rsd.
atom_base( aatm ) );
713 int const base2( acc_rsd.
abase2( aatm ) );
714 assert( base2 > 0 && base != base2 );
718 hbe_type, datm_xyz, hatm_xyz,
722 unweighted_energy, evaluate_derivative, derivs);
727 Real environmental_weight(
735 hbe_type, unweighted_energy, environmental_weight, derivs );
750 bool const evaluate_derivative,
751 bool const exclude_bb,
752 bool const exclude_bsc,
753 bool const exclude_scb,
754 bool const exclude_sc,
767 for ( chemical::AtomIndices::const_iterator
769 hnum != hnume; ++hnum ) {
770 Size const hatm( *hnum );
775 if (exclude_bb && exclude_scb)
continue;
777 if (exclude_sc && exclude_bsc)
continue;
782 for ( chemical::AtomIndices::const_iterator
784 anum != anume; ++anum ) {
785 Size const aatm( *anum );
788 if (exclude_bb)
continue;
790 if (exclude_bsc)
continue;
794 if (exclude_scb)
continue;
796 if (exclude_sc)
continue;
801 if ( hatm_xyz.distance_squared( acc_rsd.
xyz( aatm ) ) >
MAX_R2 )
continue;
803 Real unweighted_energy( 0.0 );
805 HBEvalTuple hbe_type( datm, don_rsd, aatm, acc_rsd);
807 int const base ( acc_rsd.
atom_base( aatm ) );
808 int const base2( acc_rsd.
abase2( aatm ) );
809 assert( base2 > 0 && base != base2 );
812 hbe_type, datm_xyz, hatm_xyz,
816 unweighted_energy, evaluate_derivative, derivs);
822 Real environmental_weight(
829 Real hbE = unweighted_energy * environmental_weight ;
847 tr <<
"Warning: energy from unexpected HB type ignored "
849 runtime_assert(
false);
878 Real hbE = hbond.energy() * hbond.weight() ;
897 tr <<
"Warning: energy from unexpected HB type ignored "
898 << hbond << std::endl;
899 runtime_assert(
false);
951 bool const intra_res )
979 runtime_assert(
false);
1002 if ( nb < 7 )
return 0.1;
1003 if ( nb > 24 )
return 0.5;
1004 return (nb-2.75)*(0.5/21.25);
1026 int const neighbors,
1027 int const threshold_1,
1028 int const threshold_3
1033 if ( neighbors > threshold_1 ) {
1034 if ( neighbors >= threshold_3 )
return 3;
1046 int const exposed_threshold = { 10 };
1047 int const buried_threshold = { 20 };
1052 return burial3class_weight(
1053 get_burial_3( nb1, exposed_threshold, buried_threshold ),
1054 get_burial_3( nb2, exposed_threshold, buried_threshold ) );
1089 Real wat_weight(1.0), memb_weight(1.0), total_weight(1.0);
1101 Real fa_depth_H = dot(Hxyz-center, normal);
1102 Real internal_product = std::abs(fa_depth_H);
1103 Real z = internal_product;
1105 Real zn = std::pow( z, steepness );
1106 Real fa_proj_H = zn/(1 + zn);
1109 Real fa_depth_A = dot(Axyz-center, normal);
1110 internal_product = std::abs(fa_depth_A);
1111 z = internal_product;
1113 zn = std::pow( z, steepness );
1114 Real fa_proj_A = zn/(1 + zn);
1116 Real fa_proj_AH = 0.5*(fa_proj_H+fa_proj_A);
1117 total_weight = fa_proj_AH * wat_weight + (1-fa_proj_AH) * memb_weight;
1123 return total_weight;
1130 Real const & thickness,
1131 Real const & steepness,
1138 Real wat_weight(1.0), memb_weight(1.0), total_weight(1.0);
1145 Real fa_depth_H = dot(Hxyz-center, normal);
1146 Real internal_product = std::abs(fa_depth_H);
1147 Real z = internal_product;
1149 Real zn = std::pow( z, steepness );
1150 Real fa_proj_H = zn/(1 + zn);
1153 Real fa_depth_A = dot(Axyz-center, normal);
1154 internal_product = std::abs(fa_depth_A);
1155 z = internal_product;
1157 zn = std::pow( z, steepness );
1158 Real fa_proj_A = zn/(1 + zn);
1160 Real fa_proj_AH = 0.5*(fa_proj_H+fa_proj_A);
1161 total_weight = fa_proj_AH * wat_weight + (1-fa_proj_AH) * memb_weight;
1167 return total_weight;