29 #include <basic/Tracer.hh>
32 #include <utility/string_util.hh>
35 #include <numeric/xyz.functions.hh>
36 #include <numeric/deriv/angle_deriv.hh>
42 #include <utility/vector1.hh>
67 static basic::Tracer
TR(
"core.mm.MMBondAngleEnergy");
72 central_atoms_to_score_( options.bond_angle_central_atoms_to_score() )
83 central_atoms_to_score_( src.central_atoms_to_score_ )
280 TR(basic::t_trace) <<
"residue_pair_energy: processing residues "
281 << rsd1.
seqpos() <<
"." << rsd1_type.
name() <<
"-"
282 << rsd2.
seqpos() <<
"." << rsd2_type.
name() << std::endl;
286 for (
Size ii = 1; ii <= r1_resconn_ids.size(); ++ii ) {
288 Size const resconn_id1( r1_resconn_ids[ii] );
295 TR(basic::t_trace) <<
"Found residue connection id " << resconn_id1 <<
"-" << resconn_id2 <<
": "
296 << rsd1.
atom_name( resconn_atomno1 ) <<
"-" << rsd2.
atom_name( resconn_atomno2 ) << std::endl;
304 bool should_score1(
true );
305 bool should_score2(
true );
312 if ( should_score1 ) {
317 for (
Size jj = 1; jj <= rsd1_atoms_wi1_bond_of_ii.size(); ++jj ) {
318 assert( rsd1_atoms_wi1_bond_of_ii[ jj ].key1() == resconn_atomno1 );
319 Size const res1_lower_atomno = rsd1_atoms_wi1_bond_of_ii[ jj ].key2();
322 Real const angle = numeric::angle_radians(
323 rsd1.
atom( res1_lower_atomno ).
xyz(),
324 rsd1.
atom( resconn_atomno1 ).
xyz(),
325 rsd2.
atom( resconn_atomno2 ).
xyz() );
328 <<
"r1 " << res1_lower_atomno <<
" " << rsd1.
atom_name( res1_lower_atomno ) <<
"("
329 << rsd1_type.
atom( res1_lower_atomno ).
mm_name() <<
") - "
330 <<
"r1 " << resconn_atomno1 <<
" " << rsd1.
atom_name( resconn_atomno1 ) <<
"("
331 << rsd1_type.
atom( resconn_atomno1 ).
mm_name() <<
") - "
332 <<
"r2 " << resconn_atomno2 <<
" " << rsd2.
atom_name( resconn_atomno2 ) <<
"("
333 << rsd2_type.
atom( resconn_atomno2 ).
mm_name() <<
")" << std::endl;
355 energy +=
potential_.mm::MMBondAngleScore::score
367 if ( should_score2 ) {
372 for (
Size jj = 1; jj <= rsd2_atoms_wi1_bond_of_ii.size(); ++jj ) {
373 assert( rsd2_atoms_wi1_bond_of_ii[ jj ].key1() == resconn_atomno2 );
374 Size const res2_lower_atomno = rsd2_atoms_wi1_bond_of_ii[ jj ].key2();
377 Real const angle = numeric::angle_radians(
378 rsd2.
atom( res2_lower_atomno ).
xyz(),
379 rsd2.
atom( resconn_atomno2 ).
xyz(),
380 rsd1.
atom( resconn_atomno1 ).
xyz() );
382 TR(basic::t_trace) <<
"r2 " << res2_lower_atomno <<
" "
383 << rsd2.
atom_name( res2_lower_atomno ) <<
"("
384 << rsd2_type.
atom( res2_lower_atomno ).
mm_name() <<
") - " <<
"r2 " << resconn_atomno2
385 <<
" " << rsd2.
atom_name( resconn_atomno2 ) <<
"("
386 << rsd2_type.
atom( resconn_atomno2 ).
mm_name() <<
") - " <<
"r1 " << resconn_atomno1
387 <<
" " << rsd1.
atom_name( resconn_atomno1 ) <<
"("
388 << rsd1_type.
atom( resconn_atomno1 ).
mm_name() <<
")" << std::endl;
410 energy +=
potential_.mm::MMBondAngleScore::score
443 for (
Size bondang = 1; bondang <= rsd_param.num_bondangles(); ++bondang ) {
445 if ( rsd_param.Ktheta( bondang ) ) {
448 Size rt1 = ( rsd_param.bondangle( bondang ) ).key1();
449 Size rt2 = ( rsd_param.bondangle( bondang ) ).key2();
450 Size rt3 = ( rsd_param.bondangle( bondang ) ).key3();
453 Real angle = numeric::angle_radians
457 energy +=
potential_.
score( rsd_param.Ktheta( bondang ), rsd_param.theta0( bondang ), angle );
467 TR(basic::t_trace) <<
"MMIntrares Processing residue " << rsd.
seqpos() <<
" " << rsd_type.
name()
481 if (!should_score)
continue;
496 Real angle = numeric::angle_radians
502 <<
") angle " << angle << std::endl;
505 energy +=
potential_.mm::MMBondAngleScore::score
570 Size const atomno(
id.atomno());
573 bool const score_this_atom_centrally( score_everything ||
score_atom_centrally( restype, atomno ));
578 for (
Size ii = 1, ii_end = angs.size(); ii <= ii_end; ++ii ) {
580 assert( ii_bangle.key1() == atomno || ii_bangle.key2() == atomno || ii_bangle.key3() == atomno );
581 if ( score_everything ||
582 ( score_this_atom_centrally && ii_bangle.key2() == atomno ) ||
599 if ( !Ktheta )
continue;
603 if ( restype.
atom_type(ii_bangle.key1()).is_virtual()
604 || restype.
atom_type(ii_bangle.key2()).is_virtual()
605 || restype.
atom_type(ii_bangle.key3()).is_virtual() )
610 if ( ii_bangle.key1() == atomno ) {
611 numeric::deriv::angle_p1_deriv(
612 res.
xyz( ii_bangle.key1() ),
613 res.
xyz( ii_bangle.key2() ),
614 res.
xyz( ii_bangle.key3() ),
616 }
else if ( ii_bangle.key2() == atomno ) {
617 numeric::deriv::angle_p2_deriv(
618 res.
xyz( ii_bangle.key1() ),
619 res.
xyz( ii_bangle.key2() ),
620 res.
xyz( ii_bangle.key3() ),
623 numeric::deriv::angle_p1_deriv(
624 res.
xyz( ii_bangle.key3() ),
625 res.
xyz( ii_bangle.key2() ),
626 res.
xyz( ii_bangle.key1() ),
634 Size const mmat1 = restype.
atom( ii_bangle.key1() ).mm_atom_type_index();
635 Size const mmat2 = restype.
atom( ii_bangle.key2() ).mm_atom_type_index();
636 Size const mmat3 = restype.
atom( ii_bangle.key3() ).mm_atom_type_index();
644 LF1 += dE_dtheta * f1;
645 LF2 += dE_dtheta * f2;
654 for (
Size ii = 1; ii <= interres_wi1_for_this_atom.size(); ++ii ) {
655 Size const ii_resconn = interres_wi1_for_this_atom[ ii ].first;
656 Size const ii_whichpair = interres_wi1_for_this_atom[ ii ].second;
658 atoms_within_one_bond_of_a_residue_connection( ii_resconn )[ ii_whichpair ];
659 assert( ii_pair.key1() == atomno || ii_pair.key2() == atomno );
668 if ( score_everything ||
669 ( score_this_atom_centrally && ii_pair.key1() == atomno ) ||
686 if ( !Ktheta )
continue;
691 if ( ii_pair.key1() == atomno ) {
692 numeric::deriv::angle_p2_deriv(
693 neighb_res.xyz( neighb_atom ),
694 res.
xyz( ii_pair.key1() ),
695 res.
xyz( ii_pair.key2() ),
698 numeric::deriv::angle_p1_deriv(
699 res.
xyz( ii_pair.key2() ),
700 res.
xyz( ii_pair.key1() ),
701 neighb_res.xyz( neighb_atom ),
709 Size const mmat1 = neighb_restype.atom( neighb_atom ).mm_atom_type_index();
710 Size const mmat2 = restype.
atom( ii_pair.key1() ).mm_atom_type_index();
711 Size const mmat3 = restype.
atom( ii_pair.key2() ).mm_atom_type_index();
719 LF1 += dE_dtheta * f1;
720 LF2 += dE_dtheta * f2;
729 for (
Size ii = 1; ii <= connections.size(); ++ii ) {
730 Size const ii_resconn = connections[ ii ];
743 Size const mmat2 = neighb_restype.atom( neighb_atom1 ).mm_atom_type_index();
747 neighb_restype.atoms_within_one_bond_of_a_residue_connection( neighb_resconn ));
749 for (
Size jj = 1; jj <= neighb_atoms_wi1.size(); ++jj ) {
752 assert( neighb_pair.key1() == neighb_atom1 );
754 Size const neighb_atom2 = neighb_pair.key2();
755 Size const mmat3 = neighb_restype.atom( neighb_atom2 ).mm_atom_type_index();
765 id::AtomID(neighb_atom1, neighb_res.seqpos()),
766 id::AtomID(neighb_atom2, neighb_res.seqpos()),
771 if ( !Ktheta )
continue;
777 numeric::deriv::angle_p1_deriv(
779 neighb_res.xyz( neighb_atom1 ),
780 neighb_res.xyz( neighb_atom2 ),
793 LF1 += dE_dtheta * f1;
794 LF2 += dE_dtheta * f2;