26 #include <basic/Tracer.hh>
29 #include <numeric/xyz.functions.hh>
30 #include <numeric/deriv/dihedral_deriv.hh>
36 #include <utility/vector1.hh>
61 static basic::Tracer
TR(
"core.scoring.methods.MMTorsionEnergy");
247 TR(basic::t_trace) <<
"residue_pair_energy: processing residues "
248 << rsd1.
seqpos() <<
"." << rsd1_type.
name() <<
"-"
249 << rsd2.
seqpos() <<
"." << rsd2_type.
name() << std::endl;
253 for (
Size ii = 1; ii <= r1_resconn_ids.size(); ++ii ) {
255 Size const resconn_id1( r1_resconn_ids[ii] );
261 TR(basic::t_trace) <<
"Found residue connection id " << resconn_id1 <<
"-" << resconn_id2 <<
": "
262 << rsd1.
atom_name( resconn_atomno1 ) <<
"-" << rsd2.
atom_name( resconn_atomno2 ) << std::endl;
274 Size const mmat2 = resconn_mmat1;
275 Size const mmat3 = resconn_mmat2;
283 for (
Size jj = 1; jj <= rsd1_atoms_wi1_bond_of_ii.size(); ++jj ) {
284 assert( rsd1_atoms_wi1_bond_of_ii[ jj ].key1() == resconn_atomno1 );
285 Size const jj_term_atomno = rsd1_atoms_wi1_bond_of_ii[ jj ].key2();
288 for (
Size kk = 1; kk <= rsd2_atoms_wi1_bond_of_ii.size(); ++kk ) {
289 assert( rsd2_atoms_wi1_bond_of_ii[ kk ].key1() == resconn_atomno2 );
290 Size const kk_term_atomno = rsd2_atoms_wi1_bond_of_ii[ kk ].key2();
293 Real const angle = numeric::dihedral_radians(
294 rsd1.
xyz( jj_term_atomno ),
295 rsd1.
xyz( resconn_atomno1 ),
296 rsd2.
xyz( resconn_atomno2 ),
297 rsd2.
xyz( kk_term_atomno ) );
300 <<
"r1 " << jj_term_atomno <<
" " << rsd1.
atom_name( jj_term_atomno ) <<
"("
301 << rsd1_type.
atom( jj_term_atomno ).
mm_name() <<
") - "
302 <<
"r1 " << resconn_atomno1 <<
" " << rsd1.
atom_name( resconn_atomno1 ) <<
"("
303 << rsd1_type.
atom( resconn_atomno1 ).
mm_name() <<
") - "
304 <<
"r2 " << resconn_atomno2 <<
" " << rsd2.
atom_name( resconn_atomno2 ) <<
"("
305 << rsd2_type.
atom( resconn_atomno2 ).
mm_name() <<
") - "
306 <<
"r2 " << kk_term_atomno <<
" " << rsd2.
atom_name( kk_term_atomno ) <<
"("
307 << rsd2_type.
atom( kk_term_atomno ).
mm_name() <<
")" << std::endl;
309 energy +=
potential_.core::scoring::mm::MMTorsionScore::score(
318 Size const mmat3 = resconn_mmat1;
319 Size const mmat4 = resconn_mmat2;
324 for (
Size jj = 1; jj <= rsd1_atoms_wi2_bonds_of_ii.size(); ++jj ) {
325 assert( rsd1_atoms_wi2_bonds_of_ii[ jj ].key1() == resconn_atomno1 );
327 Size const jj_atom2 = rsd1_atoms_wi2_bonds_of_ii[ jj ].key2();
330 Size const jj_atom1 = rsd1_atoms_wi2_bonds_of_ii[ jj ].key3();
333 Real const angle = numeric::dihedral_radians(
334 rsd1.
xyz( jj_atom1 ),
335 rsd1.
xyz( jj_atom2 ),
336 rsd1.
xyz( resconn_atomno1 ),
337 rsd2.
xyz( resconn_atomno2 ) );
339 energy +=
potential_.core::scoring::mm::MMTorsionScore::score(
349 Size const mmat1 = resconn_mmat1;
350 Size const mmat2 = resconn_mmat2;
355 for (
Size jj = 1; jj <= rsd2_atoms_wi2_bonds_of_ii.size(); ++jj ) {
356 assert( rsd2_atoms_wi2_bonds_of_ii[ jj ].key1() == resconn_atomno2 );
358 Size const jj_atom3 = rsd2_atoms_wi2_bonds_of_ii[ jj ].key2();
361 Size const jj_atom4 = rsd2_atoms_wi2_bonds_of_ii[ jj ].key3();
364 Real const angle = numeric::dihedral_radians(
365 rsd1.
xyz( resconn_atomno1 ),
366 rsd2.
xyz( resconn_atomno2 ),
367 rsd2.
xyz( jj_atom3 ),
368 rsd2.
xyz( jj_atom4 ) );
370 energy +=
potential_.core::scoring::mm::MMTorsionScore::score(
396 TR(basic::t_trace) <<
"Intrares Processing residue " << rsd.
seqpos() <<
" " << rsd_type.
name()
400 for (
Size dihe = 1; dihe <= rsd_type.
ndihe(); ++dihe )
403 int rt1 = ( rsd_type.
dihedral( dihe ) ).key1();
404 int rt2 = ( rsd_type.
dihedral( dihe ) ).key2();
405 int rt3 = ( rsd_type.
dihedral( dihe ) ).key3();
406 int rt4 = ( rsd_type.
dihedral( dihe ) ).key4();
415 Real angle = numeric::dihedral_radians
423 <<
") angle " << angle << std::endl;
426 energy +=
potential_.core::scoring::mm::MMTorsionScore::score
462 Size const atomno(
id.atomno());
467 for (
Size ii = 1, ii_end = diheds.size(); ii <= ii_end; ++ii ) {
469 assert( ii_dihed.key1() == atomno || ii_dihed.key2() == atomno || ii_dihed.key3() == atomno || ii_dihed.key4() == atomno );
473 Size const mmat1 = restype.
atom( ii_dihed.key1()).mm_atom_type_index();
474 Size const mmat2 = restype.
atom( ii_dihed.key2()).mm_atom_type_index();
475 Size const mmat3 = restype.
atom( ii_dihed.key3()).mm_atom_type_index();
476 Size const mmat4 = restype.
atom( ii_dihed.key4()).mm_atom_type_index();
480 if ( ii_dihed.key1() == atomno ) {
481 numeric::deriv::dihedral_p1_cosine_deriv(
482 res.
xyz( ii_dihed.key1() ),
483 res.
xyz( ii_dihed.key2() ),
484 res.
xyz( ii_dihed.key3() ),
485 res.
xyz( ii_dihed.key4() ),
487 }
else if ( ii_dihed.key2() == atomno ) {
488 numeric::deriv::dihedral_p2_cosine_deriv(
489 res.
xyz( ii_dihed.key1() ),
490 res.
xyz( ii_dihed.key2() ),
491 res.
xyz( ii_dihed.key3() ),
492 res.
xyz( ii_dihed.key4() ),
494 }
else if ( ii_dihed.key3() == atomno ) {
495 numeric::deriv::dihedral_p2_cosine_deriv(
496 res.
xyz( ii_dihed.key4() ),
497 res.
xyz( ii_dihed.key3() ),
498 res.
xyz( ii_dihed.key2() ),
499 res.
xyz( ii_dihed.key1() ),
502 numeric::deriv::dihedral_p1_cosine_deriv(
503 res.
xyz( ii_dihed.key4() ),
504 res.
xyz( ii_dihed.key3() ),
505 res.
xyz( ii_dihed.key2() ),
506 res.
xyz( ii_dihed.key1() ),
515 LF1 += dE_dtheta * f1;
516 LF2 += dE_dtheta * f2;
523 for (
Size ii = 1; ii <= interres_wi2_for_this_atom.size(); ++ii ) {
524 Size const ii_resconn = interres_wi2_for_this_atom[ ii ].first;
525 Size const ii_whichpair = interres_wi2_for_this_atom[ ii ].second;
528 atoms_within_two_bonds_of_a_residue_connection( ii_resconn )[ ii_whichpair ];
529 assert( ii_triple.key1() == atomno || ii_triple.key2() == atomno || ii_triple.key3() == atomno );
541 Size const mmat1 = neighb_restype.atom( neighb_atom ).mm_atom_type_index();
542 Size const mmat2 = restype.
atom( ii_triple.key1()).mm_atom_type_index();
543 Size const mmat3 = restype.
atom( ii_triple.key2()).mm_atom_type_index();
544 Size const mmat4 = restype.
atom( ii_triple.key3()).mm_atom_type_index();
549 if ( ii_triple.key1() == atomno ) {
550 numeric::deriv::dihedral_p2_cosine_deriv(
551 neighb_res.xyz( neighb_atom ),
552 res.
xyz( ii_triple.key1() ),
553 res.
xyz( ii_triple.key2() ),
554 res.
xyz( ii_triple.key3() ),
556 }
else if ( ii_triple.key2() == atomno ) {
557 numeric::deriv::dihedral_p2_cosine_deriv(
558 res.
xyz( ii_triple.key3() ),
559 res.
xyz( ii_triple.key2() ),
560 res.
xyz( ii_triple.key1() ),
561 neighb_res.xyz( neighb_atom ),
564 numeric::deriv::dihedral_p1_cosine_deriv(
565 res.
xyz( ii_triple.key3() ),
566 res.
xyz( ii_triple.key2() ),
567 res.
xyz( ii_triple.key1() ),
568 neighb_res.xyz( neighb_atom ),
576 LF1 += dE_dtheta * f1;
577 LF2 += dE_dtheta * f2;
588 for (
Size ii = 1; ii <= interres_wi1_for_this_atom.size(); ++ii ) {
589 Size const ii_resconn = interres_wi1_for_this_atom[ ii ].first;
590 Size const ii_whichpair = interres_wi1_for_this_atom[ ii ].second;
593 atoms_within_one_bond_of_a_residue_connection( ii_resconn )[ ii_whichpair ];
594 assert( ii_pair.key1() == atomno || ii_pair.key2() == atomno );
597 Size const mmat1 = restype.
atom( ii_pair.key2()).mm_atom_type_index();
598 Size const mmat2 = restype.
atom( ii_pair.key1()).mm_atom_type_index();
606 Size const mmat3 = neighb_restype.atom( neighb_atom1 ).mm_atom_type_index();
609 neighb_restype.atoms_within_one_bond_of_a_residue_connection( neighb_resconn ));
611 for (
Size jj = 1; jj <= neighb_atoms_wi1_bond_of_ii.size(); ++jj ) {
613 assert( neighb_pair.key1() == neighb_atom1 );
615 Size const mmat4 = neighb_restype.atom( neighb_pair.key2() ).mm_atom_type_index();
619 if ( ii_pair.key1() == atomno ) {
620 numeric::deriv::dihedral_p2_cosine_deriv(
621 res.
xyz( ii_pair.key2() ),
622 res.
xyz( ii_pair.key1() ),
623 neighb_res.xyz( neighb_atom1 ),
624 neighb_res.xyz( neighb_pair.key2() ),
627 numeric::deriv::dihedral_p1_cosine_deriv(
628 res.
xyz( ii_pair.key2() ),
629 res.
xyz( ii_pair.key1() ),
630 neighb_res.xyz( neighb_atom1 ),
631 neighb_res.xyz( neighb_pair.key2() ),
640 LF1 += dE_dtheta * f1;
641 LF2 += dE_dtheta * f2;
651 for (
Size ii = 1; ii <= connections.size(); ++ii ) {
652 Size const ii_resconn = connections[ ii ];
660 Size const mmat2 = neighb_restype.atom( neighb_atom1 ).mm_atom_type_index();
663 neighb_restype.atoms_within_two_bonds_of_a_residue_connection( neighb_resconn ));
665 for (
Size jj = 1; jj <= neighb_atoms_wi2.size(); ++jj ) {
668 assert( neighb_triple.key1() == neighb_atom1 );
670 Size const neighb_atom2 = neighb_triple.key2();
671 Size const mmat3 = neighb_restype.atom( neighb_atom2 ).mm_atom_type_index();
673 Size const neighb_atom3 = neighb_triple.key3();
674 Size const mmat4 = neighb_restype.atom( neighb_atom3 ).mm_atom_type_index();
682 numeric::deriv::dihedral_p1_cosine_deriv(
684 neighb_res.xyz( neighb_atom1 ),
685 neighb_res.xyz( neighb_atom2 ),
686 neighb_res.xyz( neighb_atom3 ),
694 LF1 += dE_dtheta * f1;
695 LF2 += dE_dtheta * f2;