48 #include <basic/Tracer.hh>
49 #include <basic/basic.hh>
50 #include <basic/database/open.hh>
53 #include <utility/string_util.hh>
54 #include <utility/io/izstream.hh>
57 #include <numeric/constants.hh>
58 #include <numeric/xyz.functions.hh>
59 #include <numeric/deriv/angle_deriv.hh>
60 #include <numeric/deriv/distance_deriv.hh>
61 #include <numeric/deriv/dihedral_deriv.hh>
62 #include <numeric/NumericTraits.hh>
63 #include <numeric/angle.functions.hh>
67 #include <basic/options/option.hh>
68 #include <basic/options/keys/score.OptionKeys.gen.hh>
69 #include <basic/options/keys/optE.OptionKeys.gen.hh>
70 #include <basic/options/keys/corrections.OptionKeys.gen.hh>
74 #include <boost/tuple/tuple.hpp>
75 #include <boost/algorithm/string.hpp>
77 #include <utility/vector1.hh>
89 boost::hash_combine(seed, e.get<0>());
90 boost::hash_combine(seed, e.get<1>());
91 boost::hash_combine(seed, e.get<2>());
92 boost::hash_combine(seed, e.get<3>());
93 boost::hash_combine(seed, e.get<4>());
98 boost::hash_combine(seed, e.get<0>());
99 boost::hash_combine(seed, e.get<1>());
100 boost::hash_combine(seed, e.get<2>());
101 boost::hash_combine(seed, e.get<3>());
105 std::size_t seed = 0;
106 boost::hash_combine(seed, e.get<0>());
107 boost::hash_combine(seed, e.get<1>());
108 boost::hash_combine(seed, e.get<2>());
112 std::size_t seed = 0;
113 boost::hash_combine(seed, e.get<0>());
114 boost::hash_combine(seed, e.get<1>());
119 return a.get<0>() == b.get<0>() && a.get<1>() == b.get<1>() &&
120 a.get<2>() == b.get<2>() && a.get<3>() == b.get<3>() &&
121 a.get<4>() == b.get<4>();
124 return a.get<0>() == b.get<0>() && a.get<1>() == b.get<1>() &&
125 a.get<2>() == b.get<2>() && a.get<3>() == b.get<3>();
128 return a.get<0>() == b.get<0>() && a.get<1>() == b.get<1>() &&
129 a.get<2>() == b.get<2>();
132 return a.get<0>() == b.get<0>() && a.get<1>() == b.get<1>();
145 static basic::Tracer
TR(
"core.scoring.CartesianBondedEnergy");
146 static basic::Tracer
GEOMETRIES(
"core.scoring.CartesianBondedEnergy.GEOMETRIES");
182 using namespace core::chemical;
184 return restype.
name3();
204 angle_params_.push_back( std::make_pair( atom_inds, params ));
274 if (basic::options::option[ basic::options::OptionKeys::score::bonded_params ].user())
275 params = basic::options::option[ basic::options::OptionKeys::score::bonded_params ]();
276 if ( k_len_in >= 0 ) {
278 }
else if (basic::options::option[ basic::options::OptionKeys::score::bonded_params ].user()) {
279 if (params.size() >= 1) k_len = params[1];
284 }
else if (basic::options::option[ basic::options::OptionKeys::score::bonded_params ].user()) {
285 if (params.size() >= 2) k_ang = params[2];
288 if (basic::options::option[ basic::options::OptionKeys::score::bonded_params ].user()) {
289 if (params.size() >= 3) k_tors = params[3];
290 if (params.size() >= 4) k_tors_prot = params[4];
291 if (params.size() >= 5) k_tors_improper = params[5];
295 if (k_tors_prot_in >= 0)
296 k_tors_prot = k_tors_prot_in;
297 if (k_tors_improper_in >= 0)
298 k_tors_improper = k_tors_improper_in;
301 init(k_len, k_ang, k_tors, k_tors_prot, k_tors_improper);
311 Real k_tors_improper_in
313 TR <<
"Initializing IdealParametersDatabase with default Ks="
314 << k_len_in <<
" , " << k_ang_in <<
" , " << k_tors_in <<
" , " << k_tors_prot_in <<
" , " << k_tors_improper_in << std::endl;
325 std::string libpath = basic::options::option[ basic::options::OptionKeys::score::bonded_params_dir ]();
326 bbdep_bond_params_ = basic::options::option[ basic::options::OptionKeys::corrections::score::bbdep_bond_params ]();
327 bbdep_bond_devs_ = basic::options::option[ basic::options::OptionKeys::corrections::score::bbdep_bond_devs ]();
330 utility::io::izstream instream;
332 basic::database::open( instream, libpath+
"/default-lengths.txt");
334 instream >> name3 >> atom1 >> atom2 >> mu_d >> K_d;
335 tuple = boost::make_tuple( name3, atom1, atom2 );
338 tuple = boost::make_tuple( name3, atom2, atom1 );
346 utility::io::izstream instream;
348 basic::database::open( instream, libpath+
"/default-angles.txt");
350 instream >> name3 >> atom1 >> atom2 >> atom3 >> mu_d >> K_d;
351 tuple = boost::make_tuple( name3, atom1, atom2, atom3 );
354 tuple = boost::make_tuple( name3, atom3, atom2, atom1 );
361 utility::io::izstream instream;
363 basic::database::open( instream, libpath+
"/default-torsions.txt");
365 instream >> name3 >> atom1 >> atom2 >> atom3 >> atom4 >> mu_d >> K_d >> period;
366 tuple = boost::make_tuple( name3, atom1, atom2, atom3, atom4 );
369 tuple = boost::make_tuple( name3, atom4, atom3, atom2, atom1 );
372 TR <<
"Read " <<
torsions_indep_.size() <<
" bb-independent lengths." << std::endl;
375 if (!bbdep_bond_params_)
return;
393 boost::unordered_map< atm_name_single, CartBondedParametersOP > &bondlengths,
394 boost::unordered_map< atm_name_pair, CartBondedParametersOP > &bondangles,
397 using numeric::constants::d::pi;
398 using namespace ObjexxFCL;
400 Real DEV_SCALE = 0.1;
403 utility::io::izstream instream;
404 basic::database::open( instream, filename );
410 core::Real phiL,phiH,psiL,psiH,phiAvg,phiDev,psiAvg,psiDev,OmegaAvg,OmegaDev;
411 core::Real CNavg,CNdev, NCAavg,NCAdev, CACBavg,CACBdev, CACavg,CACdev, COavg,COdev;
412 core::Real CNCAavg,CNCAdev, NCACBavg,NCACBdev, NCACavg,NCACdev, CBCACavg,CBCACdev;
413 core::Real CACOavg,CACOdev, CACNavg,CACNdev, OCNavg,OCNdev;
414 core::Real c1avg,c1dev,c2avg,c2dev,c3avg,c3dev,c4avg,c4dev,Zavg,Zdev;
423 core::Real CN_indep_avg=temp->mu(0,0),CN_indep_K=temp->K(0,0);
428 core::Real NCA_indep_avg=temp->mu(0,0),NCA_indep_K=temp->K(0,0);
433 core::Real CACB_indep_avg=temp->mu(0,0),CACB_indep_K=temp->K(0,0);
438 core::Real CAC_indep_avg=temp->mu(0,0),CAC_indep_K=temp->K(0,0);
443 core::Real CO_indep_avg=temp->mu(0,0),CO_indep_K=temp->K(0,0);
448 core::Real CNCA_indep_avg=temp->mu(0,0),CNCA_indep_K=temp->K(0,0);
453 core::Real NCACB_indep_avg=temp->mu(0,0),NCACB_indep_K=temp->K(0,0);
458 core::Real NCAC_indep_avg=temp->mu(0,0),NCAC_indep_K=temp->K(0,0);
463 core::Real CBCAC_indep_avg=temp->mu(0,0),CBCAC_indep_K=temp->K(0,0);
468 core::Real CACO_indep_avg=temp->mu(0,0),CACO_indep_K=temp->K(0,0);
473 core::Real CACN_indep_avg=temp->mu(0,0),CACN_indep_K=temp->K(0,0);
478 core::Real OCN_indep_avg=temp->mu(0,0),OCN_indep_K=temp->K(0,0);
481 FArray2D<core::Real> CNavg_tbl(36,36,0.0),CNdev_tbl(36,36,0.0);
482 FArray2D<core::Real> NCAavg_tbl(36,36,0.0),NCAdev_tbl(36,36,0.0);
483 FArray2D<core::Real> CACBavg_tbl(36,36,0.0),CACBdev_tbl(36,36,0.0);
484 FArray2D<core::Real> CACavg_tbl(36,36,0.0),CACdev_tbl(36,36,0.0);
485 FArray2D<core::Real> COavg_tbl(36,36,0.0),COdev_tbl(36,36,0.0);
486 FArray2D<core::Real> CNCAavg_tbl(36,36,0.0),CNCAdev_tbl(36,36,0.0);
487 FArray2D<core::Real> NCACBavg_tbl(36,36,0.0),NCACBdev_tbl(36,36,0.0);
488 FArray2D<core::Real> NCACavg_tbl(36,36,0.0),NCACdev_tbl(36,36,0.0);
489 FArray2D<core::Real> CBCACavg_tbl(36,36,0.0),CBCACdev_tbl(36,36,0.0);
490 FArray2D<core::Real> CACOavg_tbl(36,36,0.0),CACOdev_tbl(36,36,0.0);
491 FArray2D<core::Real> CACNavg_tbl(36,36,0.0),CACNdev_tbl(36,36,0.0);
492 FArray2D<core::Real> OCNavg_tbl(36,36,0.0),OCNdev_tbl(36,36,0.0);
493 FArray2D<core::Size> Ns(DynamicIndexRange(36),DynamicIndexRange(36),(
core::Size)0);
496 while(getline(instream, fileline)) {
497 if(fileline[0] ==
'#')
continue;
498 std::stringstream(fileline) >> phiL >> phiH >> psiL >> psiH >> nobs >> phiAvg >> phiDev >> psiAvg >> psiDev >> OmegaAvg >> OmegaDev >> CNavg >> CNdev
499 >> NCAavg >> NCAdev >> CACBavg >> CACBdev >> CACavg >> CACdev >> COavg >> COdev
500 >> CNCAavg >> CNCAdev >> NCACBavg >> NCACBdev >> NCACavg >> NCACdev >> CBCACavg >> CBCACdev
501 >> CACOavg >> CACOdev >> CACNavg >> CACNdev >> OCNavg >> OCNdev
502 >> c1avg >> c1dev >> c2avg >> c2dev >> c3avg >> c3dev >> c4avg >> c4dev >> Zavg >> Zdev;
504 Size phibin = (
Size)std::floor(phiL/10.0 + 0.5);
505 Size psibin = (
Size)std::floor(psiL/10.0 + 0.5);
507 CNavg_tbl(phibin+1,psibin+1) = CNavg;
508 NCAavg_tbl(phibin+1,psibin+1) = NCAavg;
509 CACBavg_tbl(phibin+1,psibin+1) = CACBavg;
510 CACavg_tbl(phibin+1,psibin+1) = CACavg;
511 COavg_tbl(phibin+1,psibin+1) = COavg;
512 CNCAavg_tbl(phibin+1,psibin+1) = CNCAavg * pi/180;
513 NCACBavg_tbl(phibin+1,psibin+1) = NCACBavg * pi/180;
514 NCACavg_tbl(phibin+1,psibin+1) = NCACavg * pi/180;
515 CBCACavg_tbl(phibin+1,psibin+1) = CBCACavg * pi/180;
516 CACOavg_tbl(phibin+1,psibin+1) = CACOavg * pi/180;
517 CACNavg_tbl(phibin+1,psibin+1) = CACNavg * pi/180;
518 OCNavg_tbl(phibin+1,psibin+1) = OCNavg * pi/180;
519 Ns(phibin+1,psibin+1) = nobs;
521 if (!
bbdep_bond_devs_ || nobs<=3 || CN_indep_K==0) CNdev_tbl(phibin+1,psibin+1) = CN_indep_K;
522 else CNdev_tbl(phibin+1,psibin+1) = 1.0 / ( (M*(1/CN_indep_K) + (nobs-1)*( (2*(CNdev)*(CNdev))/DEV_SCALE) )/ (M+nobs-1) );
524 if (!
bbdep_bond_devs_ || nobs<=3 || NCA_indep_K==0 ) NCAdev_tbl(phibin+1,psibin+1) = NCA_indep_K;
525 else NCAdev_tbl(phibin+1,psibin+1) = 1.0 / ( (M*(1/NCA_indep_K) + (nobs-1)*( (2*(NCAdev)*(NCAdev))/DEV_SCALE) )/ (M+nobs-1) );
527 if (!
bbdep_bond_devs_ || nobs<=3 || CACB_indep_K==0 ) CACBdev_tbl(phibin+1,psibin+1) = CACB_indep_K;
528 else CACBdev_tbl(phibin+1,psibin+1) = 1.0 / ( (M*(1/CACB_indep_K) + (nobs-1)*( (2*(CACBdev)*(CACBdev))/DEV_SCALE) )/ (M+nobs-1) );
530 if (!
bbdep_bond_devs_ || nobs<=3 || CAC_indep_K==0 ) CACdev_tbl(phibin+1,psibin+1) = CAC_indep_K;
531 else CACdev_tbl(phibin+1,psibin+1) = 1.0 / ( (M*(1/CAC_indep_K) + (nobs-1)*( (2*(CACdev)*(CACdev))/DEV_SCALE) )/ (M+nobs-1) );
533 if (!
bbdep_bond_devs_ || nobs<=3 || CO_indep_K==0 ) COdev_tbl(phibin+1,psibin+1) = CO_indep_K;
534 else COdev_tbl(phibin+1,psibin+1) = 1.0 / ( (M*(1/CO_indep_K) + (nobs-1)*( (2*(COdev)*(COdev))/DEV_SCALE) )/ (M+nobs-1) );
536 if (!
bbdep_bond_devs_ || nobs<=3 || CNCA_indep_K==0 ) CNCAdev_tbl(phibin+1,psibin+1) = CNCA_indep_K;
537 else CNCAdev_tbl(phibin+1,psibin+1) = 1.0 / ( (M*(1/CNCA_indep_K) + (nobs-1)*( (2*(CNCAdev*pi/180)*(CNCAdev*pi/180))/DEV_SCALE) )/ (M+nobs-1) );
539 if (!
bbdep_bond_devs_ || nobs<=3 || NCACB_indep_K==0 ) NCACBdev_tbl(phibin+1,psibin+1) = NCACB_indep_K;
540 else NCACBdev_tbl(phibin+1,psibin+1) = 1.0 / ( (M*(1/NCACB_indep_K) + (nobs-1)*( (2*(NCACBdev*pi/180)*(NCACBdev*pi/180))/DEV_SCALE) )/ (M+nobs-1) );
542 if (!
bbdep_bond_devs_ || nobs<=3 || NCAC_indep_K==0 ) NCACdev_tbl(phibin+1,psibin+1) = NCAC_indep_K;
543 else NCACdev_tbl(phibin+1,psibin+1) = 1.0 / ( (M*(1/NCAC_indep_K) + (nobs-1)*( (2*(NCACdev*pi/180)*(NCACdev*pi/180))/DEV_SCALE) )/ (M+nobs-1) );
545 if (!
bbdep_bond_devs_ || nobs<=3 || CBCAC_indep_K==0 ) CBCACdev_tbl(phibin+1,psibin+1) = CBCAC_indep_K;
546 else CBCACdev_tbl(phibin+1,psibin+1) = 1.0 / ( (M*(1/CBCAC_indep_K) + (nobs-1)*( (2*(CBCACdev*pi/180)*(CBCACdev*pi/180))/DEV_SCALE) )/ (M+nobs-1) );
548 if (!
bbdep_bond_devs_ || nobs<=3 || CACO_indep_K==0 ) CACOdev_tbl(phibin+1,psibin+1) = CACO_indep_K;
549 else CACOdev_tbl(phibin+1,psibin+1) = 1.0 / ( (M*(1/CACO_indep_K) + (nobs-1)*( (2*(CACOdev*pi/180)*(CACOdev*pi/180))/DEV_SCALE) )/ (M+nobs-1) );
551 if (!
bbdep_bond_devs_ || nobs<=3 || CACN_indep_K==0 ) CACNdev_tbl(phibin+1,psibin+1) = CACN_indep_K;
552 else CACNdev_tbl(phibin+1,psibin+1) = 1.0 / ( (M*(1/CACN_indep_K) + (nobs-1)*( (2*(CACNdev*pi/180)*(CACNdev*pi/180))/DEV_SCALE) )/ (M+nobs-1) );
554 if (!
bbdep_bond_devs_ || nobs<=3 || OCN_indep_K==0 ) OCNdev_tbl(phibin+1,psibin+1) = OCN_indep_K;
555 else OCNdev_tbl(phibin+1,psibin+1) = 1.0 / ( (M*(1/OCN_indep_K) + (nobs-1)*( (2*(OCNdev*pi/180)*(OCNdev*pi/180))/DEV_SCALE) )/ (M+nobs-1) );
559 for (
int i=1; i<=36; ++i) {
560 for (
int j=1; j<=36; ++j) {
562 CNavg_tbl(i,j) = CN_indep_avg; CNdev_tbl(i,j) = CN_indep_K;
563 NCAavg_tbl(i,j) = NCA_indep_avg; NCAdev_tbl(i,j) = NCA_indep_K;
564 CACBavg_tbl(i,j) = CACB_indep_avg; CACBdev_tbl(i,j) = CACB_indep_K;
565 CACavg_tbl(i,j) = CAC_indep_avg; CACdev_tbl(i,j) = CAC_indep_K;
566 COavg_tbl(i,j) = CO_indep_avg; COdev_tbl(i,j) = CO_indep_K;
567 CNCAavg_tbl(i,j) = CNCA_indep_avg; CNCAdev_tbl(i,j) = CNCA_indep_K;
568 NCACBavg_tbl(i,j) = NCACB_indep_avg; NCACBdev_tbl(i,j) = NCACB_indep_K;
569 NCACavg_tbl(i,j) = NCAC_indep_avg; NCACdev_tbl(i,j) = NCAC_indep_K;
570 CBCACavg_tbl(i,j) = CBCAC_indep_avg; CBCACdev_tbl(i,j) = CBCAC_indep_K;
571 CACOavg_tbl(i,j) = CACO_indep_avg; CACOdev_tbl(i,j) = CACO_indep_K;
572 CACNavg_tbl(i,j) = CACN_indep_avg; CACNdev_tbl(i,j) = CACN_indep_K;
573 OCNavg_tbl(i,j) = OCN_indep_avg; OCNdev_tbl(i,j) = OCN_indep_K;
579 bondlengths[boost::make_tuple(
"N",
"C")] = bondlengths[boost::make_tuple(
"C",
"N")] =
new BBDepCartBondedParameters(CNavg_tbl, CNdev_tbl ,
"C-N");
580 bondlengths[boost::make_tuple(
"CA",
"N")] = bondlengths[boost::make_tuple(
"N",
"CA")] =
new BBDepCartBondedParameters(NCAavg_tbl, NCAdev_tbl,
"CA-N");
581 bondlengths[boost::make_tuple(
"CB",
"CA")] = bondlengths[boost::make_tuple(
"CA",
"CB")] =
new BBDepCartBondedParameters(CACBavg_tbl, CACBdev_tbl,
"CB-CA");
582 bondlengths[boost::make_tuple(
"C",
"CA")] = bondlengths[boost::make_tuple(
"CA",
"C")] =
new BBDepCartBondedParameters(CACavg_tbl, CACdev_tbl,
"C-CA");
583 bondlengths[boost::make_tuple(
"O",
"C")] = bondlengths[boost::make_tuple(
"C",
"O")] =
new BBDepCartBondedParameters(COavg_tbl, COdev_tbl,
"C-O");
584 bondangles[boost::make_tuple(
"CA",
"N",
"C")] = bondangles[boost::make_tuple(
"C",
"N",
"CA")] =
new BBDepCartBondedParameters(CNCAavg_tbl, CNCAdev_tbl,
"C-N-CA");
585 bondangles[boost::make_tuple(
"CB",
"CA",
"N")] = bondangles[boost::make_tuple(
"N",
"CA",
"CB")] =
new BBDepCartBondedParameters(NCACBavg_tbl, NCACBdev_tbl,
"N-CA-CB");
586 bondangles[boost::make_tuple(
"C",
"CA",
"N")] = bondangles[boost::make_tuple(
"N",
"CA",
"C")] =
new BBDepCartBondedParameters(NCACavg_tbl, NCACdev_tbl,
"N-CA-C");
587 bondangles[boost::make_tuple(
"C",
"CA",
"CB")] = bondangles[boost::make_tuple(
"CB",
"CA",
"C")] =
new BBDepCartBondedParameters(CBCACavg_tbl, CBCACdev_tbl,
"CB-CA-C");
588 bondangles[boost::make_tuple(
"O",
"C",
"CA")] = bondangles[boost::make_tuple(
"CA",
"C",
"O")] =
new BBDepCartBondedParameters(CACOavg_tbl, CACOdev_tbl,
"CA-C-O");
589 bondangles[boost::make_tuple(
"N",
"C",
"CA")] = bondangles[boost::make_tuple(
"CA",
"C",
"N")] =
new BBDepCartBondedParameters(CACNavg_tbl, CACNdev_tbl,
"CA-C-N");
590 bondangles[boost::make_tuple(
"N",
"C",
"O")] = bondangles[boost::make_tuple(
"O",
"C",
"N")] =
new BBDepCartBondedParameters(OCNavg_tbl, OCNdev_tbl,
"O-C-N");
612 x = newres->atom( atm1 ).xyz();
614 x = newres->upper_connect().icoor().build( restype );
617 y = newres->atom( atm2 ).xyz();
620 z = newres->atom( atm3 ).xyz();
622 z = newres->lower_connect().icoor().build( restype );
625 theta0 = numeric::angle_radians ( x,y,z );
630 bool hasCD = (atm1>0 && restype.
atom_name(atm1)==
" CD ")
631 || (atm2>0 && restype.
atom_name(atm2)==
" CD ")
632 || (atm3>0 && restype.
atom_name(atm3)==
" CD ");
633 bool hasN = (atm1>0 && restype.
atom_name(atm1)==
" N ")
634 || (atm2>0 && restype.
atom_name(atm2)==
" N ")
635 || (atm3>0 && restype.
atom_name(atm3)==
" N ");
637 Ktheta = theta0 = 0.0;
642 ( (atm1>0 && restype.
atom_name(atm1) ==
" CEN") || (atm3>0 && restype.
atom_name(atm3) ==
" CEN") ) ) {
643 Ktheta = theta0 = 0.0;
648 ( (atm1>0 && restype.
atom_name(atm1) ==
"OVU1") || (atm3>0 && restype.
atom_name(atm3) ==
"OVU1") ) ) {
649 Ktheta = theta0 = 0.0;
652 ( (atm1>0 && restype.
atom_name(atm1) ==
"OVL1") || (atm3>0 && restype.
atom_name(atm3) ==
"OVL1") ) ) {
653 Ktheta = theta0 = 0.0;
675 x = newres->atom( atm1 ).xyz();
677 x = newres->upper_connect().icoor().build( restype );
681 y = newres->atom( atm2 ).xyz();
683 y = newres->lower_connect().icoor().build( restype );
690 (atm1>0 && atm2>0) &&
712 using namespace core::chemical;
720 atm_name_quad tuple1( restag, atm1_name,atm2_name,atm3_name,atm4_name );
721 boost::unordered_map<atm_name_quad,CartBondedParametersOP>::iterator b_it =
torsions_indep_.find( tuple1 );
726 atm_name_quad tuple2(
"*", atm1_name,atm2_name,atm3_name,atm4_name );
750 using namespace core::chemical;
757 boost::unordered_map< atm_name_pair, CartBondedParametersOP > *angle_table;
762 }
else if ( pre_proline ) {
770 boost::unordered_map<atm_name_pair,CartBondedParametersOP>::iterator a_it = angle_table->find( alt_tuple );
771 if ( a_it != angle_table->
end() ) {
776 boost::unordered_map<atm_name_triple,CartBondedParametersOP>::iterator b_it =
bondangles_indep_.find( tuple );
791 TR <<
"Adding undefined angle "
792 << tuple.get<0>() <<
": " << tuple.get<1>() <<
"," << tuple.get<2>() <<
"," << tuple.get<3>() <<
" to DB with"
793 <<
" theta0 = " << theta0 <<
" , Ktheta = " << Ktheta << std::endl;
816 boost::unordered_map< atm_name_single, CartBondedParametersOP > *length_table;
823 }
else if ( pre_proline ) {
830 boost::unordered_map<atm_name_single,CartBondedParametersOP>::iterator a_it = length_table->find( alt_tuple );
831 if ( a_it != length_table->end() ) {
836 boost::unordered_map<atm_name_pair,CartBondedParametersOP>::iterator b_it =
bondlengths_indep_.find( tuple );
851 TR <<
"Adding undefined length "
852 << tuple.get<0>() <<
": " << tuple.get<1>() <<
"," << tuple.get<2>() <<
"," <<
" to DB with"
853 <<
" d0 = " << d0 <<
" , Kd = " << Kd << std::endl;
873 using namespace core::chemical;
892 bool need_to_constrain=
true, proton_chi=
false;
895 if ( atm2 <= (
int)newres->last_backbone_atom() && atm3 <= (
int)newres->last_backbone_atom()) {
896 need_to_constrain =
false;
900 for (
Size j=1, j_end = restype.
nchi(); j<= j_end; ++j ) {
907 need_to_constrain =
false;
913 if ( !need_to_constrain ) {
919 x = newres->atom( atm1 ).xyz();
920 y = newres->atom( atm2 ).xyz();
921 z = newres->atom( atm3 ).xyz();
922 w = newres->atom( atm4 ).xyz();
924 phi0 = numeric::dihedral_radians ( x,y,z,w );
952 phi_step = numeric::constants::d::pi;
958 phi_step = 2.0*numeric::constants::d::pi/3.0;
964 phi0 = numeric::constants::d::deg2rad*v[1];
965 phi_step = std::fabs( numeric::constants::d::deg2rad*(v[2]-v[1]) );
982 using namespace core::chemical;
997 x = newres->atom( atm1 ).xyz();
1000 x = newres->residue_connection( -atm1 ).icoor().build( restype );
1003 y = newres->atom( atm2 ).xyz();
1006 y = newres->residue_connection( -atm2 ).icoor().build( restype );
1009 z = newres->atom( atm3 ).xyz();
1012 z = newres->residue_connection( -atm3 ).icoor().build( restype );
1015 theta0 = numeric::angle_radians ( x,y,z );
1019 bool hasCD = (atm1>0 && restype.atom_name(atm1)==
" CD ")
1020 || (atm2>0 && restype.atom_name(atm2)==
" CD ")
1021 || (atm3>0 && restype.atom_name(atm3)==
" CD ");
1022 bool hasN = (atm1>0 && restype.atom_name(atm1)==
" N ")
1023 || (atm2>0 && restype.atom_name(atm2)==
" N ")
1024 || (atm3>0 && restype.atom_name(atm3)==
" N ");
1026 Ktheta = theta0 = 0.0;
1030 ( (atm1>0 && restype.atom_name(atm1) ==
" CEN") || (atm3>0 && restype.atom_name(atm3) ==
" CEN") ) ) {
1031 Ktheta = theta0 = 0.0;
1034 ( (atm1>0 && restype.atom_name(atm1) ==
"OVU1") || (atm3>0 && restype.atom_name(atm3) ==
"OVU1") ) ) {
1035 Ktheta = theta0 = 0.0;
1038 ( (atm1>0 && restype.atom_name(atm1) ==
"OVL1") || (atm3>0 && restype.atom_name(atm3) ==
"OVL1") ) ) {
1039 Ktheta = theta0 = 0.0;
1057 using namespace core::chemical;
1069 x = newres->atom( atm1 ).xyz();
1072 x = newres->residue_connection( -atm1 ).icoor().build( restype );
1075 y = newres->atom( atm2 ).xyz();
1078 y = newres->residue_connection( -atm2 ).icoor().build( restype );
1081 d0 = (x-y).length();
1084 (atm1>0 && atm2>0) &&
1085 ( ( restype.atom_name(atm1) ==
" CD " && restype.atom_name(atm2) ==
" N ") ||
1086 ( restype.atom_name(atm2) ==
" CD " && restype.atom_name(atm1) ==
" N ") ) ) {
1099 std::map< chemical::ResidueType const *, ResidueCartBondedParametersOP >
const & resdatamap = prepro ?
1102 std::map< chemical::ResidueType const *, ResidueCartBondedParametersOP >::const_iterator iter = resdatamap.find( & restype );
1103 if ( iter == resdatamap.end() ) {
1105 std::map< chemical::ResidueType const *, ResidueCartBondedParametersOP >::const_iterator iter2 = resdatamap.find( & restype );
1106 assert ( iter2 != resdatamap.end() );
1107 return *iter2->second;
1109 return *iter->second;
1121 for (
Size dihe = 1; dihe <= rsd_type.
ndihe(); ++dihe ){
1128 ids[ 1 ] = rt1; ids[ 2 ] = rt2; ids[ 3 ] = rt3; ids[ 4 ] = rt4;
1136 atm1name,atm2name,atm3name,atm4name );
1138 if ( !tor_params || tor_params->is_null() )
continue;
1140 restype_params->add_torsion_parameter( ids, tor_params );
1150 ids[ 1 ] = rt1; ids[ 2 ] = rt2; ids[ 3 ] = rt3;
1157 atm1name,atm2name,atm3name, rt1,rt2,rt3 );
1159 if ( ang_params->is_null() )
continue;
1161 restype_params->add_angle_parameter( ids, ang_params );
1165 for (
Size atm_i=1; atm_i<=rsd_type.
natoms(); ++atm_i) {
1167 for (
Size j=1; j<=atm_nbrs.size(); ++j) {
1168 Size atm_j = atm_nbrs[j];
1169 if ( atm_i < atm_j ) {
1172 ids[1] = atm_i; ids[2] = atm_j;
1178 atm1name,atm2name, atm_i, atm_j );
1180 if ( len_params->is_null() )
continue;
1182 restype_params->add_length_parameter( ids, len_params );
1189 using namespace core::chemical;
1192 if (rsd_type.
aa() ==
aa_asp && rsd_type.
has(
"CB" ) && rsd_type.
has(
"CG" ) && rsd_type.
has(
"OD1" ) && rsd_type.
has(
"OD2" ) ) {
1194 atm1 =
"CB"; atm2 =
"CG"; atm3 =
"OD1"; atm4 =
"OD2";
1195 }
else if (rsd_type.
aa() ==
aa_glu && rsd_type.
has(
"CG" ) && rsd_type.
has(
"CD" ) && rsd_type.
has(
"OE1" ) && rsd_type.
has(
"OE2" )) {
1197 atm1 =
"CG"; atm2 =
"CD"; atm3 =
"OE1"; atm4 =
"OE2";
1198 }
else if (rsd_type.
aa() ==
aa_asn && rsd_type.
has(
"CB" ) && rsd_type.
has(
"CG" ) && rsd_type.
has(
"OD1" ) && rsd_type.
has(
"ND2" )) {
1200 atm1 =
"CB"; atm2 =
"CG"; atm3 =
"OD1"; atm4 =
"ND2";
1201 }
else if (rsd_type.
aa() ==
aa_gln && rsd_type.
has(
"CG" ) && rsd_type.
has(
"CD" ) && rsd_type.
has(
"OE1" ) && rsd_type.
has(
"NE2" )) {
1203 atm1 =
"CG"; atm2 =
"CD"; atm3 =
"OE1"; atm4 =
"NE2";
1214 if ( ! tor_params->is_null() ) {
1215 restype_params->add_improper_torsion_parameter( ids, tor_params );
1232 for (
int i=1; i<=5; ++i) {
1233 if (i==1 && is_nterm)
continue;
1238 if (i==1) { atm1=
"C"; atm2=
"N"; rt1 = 0; rt2 = rsd_type.
atom_index(
" N ");}
1239 if (i==2) { atm1=
"N"; atm2=
"CA"; rt1 = rsd_type.
atom_index(
" N "); rt2 = rsd_type.
atom_index(
" CA "); }
1240 if (i==3) { atm1=
"CA"; atm2=
"CB"; rt1 = rsd_type.
atom_index(
" CA "); rt2 = rsd_type.
atom_index(
" CB "); }
1241 if (i==4) { atm1=
"CA"; atm2=
"C"; rt1 = rsd_type.
atom_index(
" CA "); rt2 = rsd_type.
atom_index(
" C "); }
1242 if (i==5) { atm1=
"C"; atm2=
"O"; rt1 = rsd_type.
atom_index(
" C "); rt2 = rsd_type.
atom_index(
" O "); }
1245 ids[1] = rt1; ids[2] = rt2;
1248 restype_params->add_bbdep_length_parameter( ids, len_params );
1252 for (
int i=1; i<=7; ++i) {
1254 if (i==1 && is_nterm)
continue;
1255 if ((i==6 || i==7) && is_cterm)
continue;
1259 if (i==1) { atm1=
"C"; atm2=
"N"; atm3=
"CA"; rt1=0; rt2=rsd_type.
atom_index(
" N "); rt3=rsd_type.
atom_index(
" CA ");}
1264 if (i==6) { atm1=
"CA"; atm2=
"C"; atm3=
"N"; rt1=rsd_type.
atom_index(
" CA "); rt2=rsd_type.
atom_index(
" C "); rt3=0; }
1265 if (i==7) { atm1=
"O"; atm2=
"C"; atm3=
"N"; rt1=rsd_type.
atom_index(
" O "); rt2=rsd_type.
atom_index(
" C "); rt3=0; }
1268 ids[1] = rt1; ids[2] = rt2; ids[3] = rt3;
1271 restype_params->add_bbdep_angle_parameter( ids, ang_params );
1280 for (
Size ii = 1; ii <= upconn_ats.size(); ++ii ) {
1288 atm1name, atm2name, atm3name, upconn_ats[ii].key2(), upconn_ats[ii].key1(),
1291 inds[1] = upconn_ats[ii].key2();
1292 inds[2] = upconn_ats[ii].key1();
1294 restype_params->add_upper_connect_angle_params( inds, ang_params );
1304 for (
Size ii = 1; ii <= loconn_ats.size(); ++ii ) {
1312 atm1name, atm2name, atm3name, loconn_ats[ii].key2(), loconn_ats[ii].key1(),
1315 inds[1] = loconn_ats[ii].key2();
1316 inds[2] = loconn_ats[ii].key1();
1318 restype_params->add_lower_connect_angle_params( inds, ang_params );
1324 if ( rsd_type.
has(
"N" ) ) {
1325 restype_params->bb_N_index( rsd_type.
atom_index(
"N" ) );
1327 if ( rsd_type.
has(
"CA" ) ) {
1328 restype_params->bb_CA_index( rsd_type.
atom_index(
"CA" ) );
1330 if ( rsd_type.
has(
"C" ) ) {
1331 restype_params->bb_C_index( rsd_type.
atom_index(
"C" ) );
1333 if ( rsd_type.
has(
"O" ) ) {
1334 restype_params->bb_O_index( rsd_type.
atom_index(
"O" ) );
1336 if ( rsd_type.
has(
"H" ) ) {
1337 restype_params->bb_H_index( rsd_type.
atom_index(
"H" ) );
1341 if ( restype_params->bb_N_index() != 0 && restype_params->bb_H_index() != 0 && restype_params->bb_CA_index() != 0 ) {
1343 restype_params->ca_cprev_n_h_interres_torsion_params( tor_params );
1347 if ( restype_params->bb_C_index() != 0 && restype_params->bb_O_index() != 0 && restype_params->bb_CA_index() != 0 ) {
1349 restype_params->ca_nnext_c_o_interres_torsion_params( tor_params );
1353 if ( restype_params->bb_N_index() != 0 && rsd_type.
lower_connect_id() != 0 ) {
1355 assert( len_params );
1356 restype_params->cprev_n_bond_length_params( len_params );
1376 basic::options::option[ basic::options::OptionKeys::score::linear_bonded_potential ]() ||
1380 core::Real cartbonded_len, cartbonded_ang, cartbonded_tors, cartbonded_proton , cartbonded_improper;
1404 using namespace methods;
1409 bool create_new_lre_container(
false );
1411 if ( energies.long_range_container( lr_type ) == 0 ) {
1412 create_new_lre_container =
true;
1419 if ( dec->size() != nres ) {
1420 create_new_lre_container =
true;
1424 if ( create_new_lre_container ) {
1428 TR <<
"Creating new peptide-bonded energy container (" << nres <<
")" << std::endl;
1435 energies.set_long_range_container( lr_type, new_dec );
1446 return ( res1 == (res2+1) || res1 == (res2-1) );
1494 using namespace numeric;
1505 Real phi1=0,psi1=0,phi2=0,psi2=0;
1521 if (rsd2.
seqpos() == nres) {
1532 rsd1, rsd2, res1params, res2params, phi1, psi1,
1533 weights, r1_atom_derivs, r2_atom_derivs );
1536 rsd1, rsd2, res1params, res2params, phi2, psi2,
1537 weights, r1_atom_derivs, r2_atom_derivs );
1540 rsd1, rsd2, res1params, res2params, phi2, psi2,
1541 weights, r1_atom_derivs, r2_atom_derivs );
1556 using namespace numeric;
1557 using numeric::constants::d::pi;
1560 if (!
db_->bbdep_bond_params())
return 0.0;
1583 for (
Size ii = 1; ii <= lps.size(); ++ii ) {
1589 Vector at1xyz, at2xyz( rsd.
xyz( atids[2] ));
1590 if ( atids[1] == 0 ) {
1596 at1xyz = rsd.
xyz( atids[1] );
1599 Real const d = at1xyz.distance( at2xyz );
1610 dscore_dmu = -K * ((d - mu)>0 ? 1:-1);
1612 dscore_dmu = -K * (d - mu);
1614 if (
db_->bbdep_bond_devs()) {
1621 dscore_dK = 0.5*std::fabs(d - mu);
1623 dscore_dK = 0.5*(d - mu)*(d - mu);
1633 for (
Size ii = 1; ii <= aps.size(); ++ii ) {
1639 Vector at1xyz, at2xyz( rsd.
xyz( atids[2] )), at3xyz;
1640 if ( atids[1] == 0 ) {
1646 at1xyz = rsd.
xyz( atids[1] );
1648 if ( atids[3] == 0 ) {
1654 at3xyz = rsd.
xyz( atids[3] );
1657 Real const angle = numeric::angle_radians(at1xyz,at2xyz,at3xyz);
1668 dscore_dmu = -K * ((angle - mu)>0 ? 1:-1);
1670 dscore_dmu = -K * (angle - mu);
1673 if (
db_->bbdep_bond_devs()) {
1680 dscore_dK = 0.5*std::fabs(angle - mu);
1682 dscore_dK = 0.5*(angle - mu)*(angle - mu);
1813 return 180/pi * deriv;
1840 using namespace numeric;
1853 Real phi1=0,psi1=0,phi2=0,psi2=0;
1877 if ( is_cterm ) {
return; }
1893 using numeric::constants::d::pi;
1894 using namespace numeric;
1913 using namespace core::chemical;
1914 using numeric::constants::d::pi;
1919 for (
Size ii = 1, iiend = itps.size(); ii <= iiend; ++ii ) {
1922 Real Kphi = tor_params.
K(0,0);
1923 Real phi0 = tor_params.
mu(0,0);
1925 Real angle = numeric::dihedral_radians(
1926 rsd.
xyz( atids[1] ), rsd.
xyz( atids[2] ), rsd.
xyz( atids[3] ), rsd.
xyz( atids[4] ) );
1927 Real del_phi = basic::subtract_radian_angles( angle, phi0 );
1928 del_phi = basic::periodic_range( del_phi, phi_step );
1936 TR.Debug << pose.
pdb_info()->name() <<
" seqpos: " << rsd.
seqpos() <<
" pdbpos: " <<
1937 pose.
pdb_info()->number(rsd.
seqpos()) <<
" improper torsion: " <<
1938 rsd.
name() <<
" : " <<
1941 Kphi <<
") " << angle <<
" " << phi0 <<
" sc=" << energy_torsion << std::endl;
1960 using namespace core::chemical;
1961 using numeric::constants::d::pi;
1965 for (
Size ii = 1, iiend = tps.size(); ii <= iiend; ++ii ) {
1969 Real Kphi = tor_params.
K(phi,psi);
1970 Real phi0 = tor_params.
mu(phi,psi);
1971 Real phi_step = 2 * pi / tor_params.
period();
1972 Real angle = numeric::dihedral_radians(
1973 rsd.
xyz( atids[1] ), rsd.
xyz( atids[2] ), rsd.
xyz( atids[3] ), rsd.
xyz( atids[4] ) );
1974 Real del_phi = basic::subtract_radian_angles(angle, phi0);
1975 if ( phi_step > 0 ) del_phi = basic::periodic_range( del_phi, phi_step );
1983 TR.Debug << pose.
pdb_info()->name() <<
" seqpos: " << rsd.
seqpos() <<
" pdbpos: " <<
1984 pose.
pdb_info()->number(rsd.
seqpos()) <<
" intrares torsion: " <<
1985 rsd.
name() <<
" : " <<
1988 Kphi <<
") " << angle <<
" " << phi0 <<
" sc=" << energy_torsion << std::endl;
2007 using namespace core::chemical;
2011 for (
Size ii = 1, iiend = aps.size(); ii <= iiend; ++ii ) {
2014 Real Ktheta = ang_params.
K(phi,psi);
2015 Real theta0 = ang_params.
mu(phi,psi);
2016 Real angle = numeric::angle_radians( rsd.
xyz(atids[1]), rsd.
xyz(atids[2]), rsd.
xyz(atids[3]) );
2024 TR.Debug << pose.
pdb_info()->name() <<
" seqpos: " << rsd.
seqpos() <<
" pdbpos: " <<
2026 rsd.
name() <<
" : " <<
2029 Ktheta <<
") " << angle <<
" " << theta0 <<
" sc=" <<
2030 energy_angle << std::endl;
2050 using namespace core::chemical;
2054 for (
Size ii = 1, iiend = lps.size(); ii <= iiend; ++ii ) {
2057 Real const Kd = len_params.
K(phi,psi);
2058 Real const d0 = len_params.
mu(phi,psi);
2059 Real const d = rsd.
xyz(atids[1]).distance( rsd.
xyz( atids[2] ));
2066 TR.Debug << pose.
pdb_info()->name() <<
" seqpos: " << rsd.
seqpos() <<
" pdbpos: " << pose.
pdb_info()->number(rsd.
seqpos()) <<
" intrares angle: " <<
2069 << Kd <<
") " << d <<
" " << d0
2070 <<
" sc=" << energy_length << std::endl;
2113 using namespace core::chemical;
2122 for (
Size ii = 1, iiend = aps.size(); ii <= iiend; ++ii ) {
2125 Real Ktheta = ang_params.
K(phi1,psi1);
2126 Real theta0 = ang_params.
mu(phi1,psi1);
2127 Real angle = numeric::angle_radians(
2128 rsd1.
xyz(atids[1]), rsd1.
xyz(atids[2]),
2137 <<
" pdbpos: " << pose.
pdb_info()->number(rsd1.
seqpos()) <<
" angle rsd1: " << rsd1.
name()
2138 <<
":" << rsd1.
atom_name( atids[1] ) <<
" , "
2140 << Ktheta <<
") " << angle <<
" " << theta0
2141 <<
" sc=" << energy_angle << std::endl;
2159 for (
Size ii = 1; ii <= r1_resconn_ids.size(); ++ii ) {
2160 Size const resconn_id1( r1_resconn_ids[ii] );
2169 for (
Size jj = 1; jj <= rsd1_atoms_wi1_bond_of_ii.size(); ++jj ) {
2170 assert( rsd1_atoms_wi1_bond_of_ii[ jj ].key1() == resconn_atomno1 );
2171 Size const res1_lower_atomno = rsd1_atoms_wi1_bond_of_ii[ jj ].key2();
2173 Real const angle = numeric::angle_radians(
2174 rsd1.
atom( res1_lower_atomno ).
xyz(),
2175 rsd1.
atom( resconn_atomno1 ).
xyz(),
2176 rsd2.
atom( resconn_atomno2 ).
xyz() );
2183 atm1name, atm2name, atm3name, res1_lower_atomno, resconn_atomno1, -resconn_id1);
2184 if (ang_params->is_null())
continue;
2185 Real Ktheta=ang_params->K(phi1,psi1), theta0=ang_params->mu(phi1,psi1);
2194 <<
" pdbpos: " << pose.
pdb_info()->number(rsd1.
seqpos()) <<
" angle rsd1: " << rsd1.
name()
2195 <<
":" << rsd1.
atom_name( res1_lower_atomno ) <<
" , "
2196 << rsd1.
atom_name( resconn_atomno1 ) <<
" , " << rsd2.
atom_name( resconn_atomno2 )<<
" ("
2197 << Ktheta <<
") " << angle <<
" " << theta0
2198 <<
" sc=" << energy_angle << std::endl;
2221 using namespace core::chemical;
2230 for (
Size ii = 1, iiend = aps.size(); ii <= iiend; ++ii ) {
2233 Real Ktheta = ang_params.
K(phi2,psi2);
2234 Real theta0 = ang_params.
mu(phi2,psi2);
2235 Real angle = numeric::angle_radians(
2236 rsd2.
xyz(atids[1]), rsd2.
xyz(atids[2]),
2246 <<
" pdbpos: " << pose.
pdb_info()->number(rsd2.
seqpos()) <<
" angle rsd2: " << rsd2.
name()
2247 <<
":" << rsd2.
atom_name( atids[1] ) <<
" , "
2249 <<
" (" << Ktheta <<
") " << angle <<
" " << theta0
2250 <<
" sc=" << energy_angle << std::endl;
2268 for (
Size ii = 1; ii <= r1_resconn_ids.size(); ++ii ) {
2269 Size const resconn_id1( r1_resconn_ids[ii] );
2278 for (
Size jj = 1; jj <= rsd2_atoms_wi1_bond_of_ii.size(); ++jj ) {
2279 assert( rsd2_atoms_wi1_bond_of_ii[ jj ].key1() == resconn_atomno2 );
2280 Size const res2_lower_atomno = rsd2_atoms_wi1_bond_of_ii[ jj ].key2();
2288 atm1name, atm2name, atm3name, res2_lower_atomno, resconn_atomno2, -resconn_id2);
2289 if (ang_params->is_null())
continue;
2290 Real Ktheta=ang_params->K(phi2,psi2), theta0=ang_params->mu(phi2,psi2);
2292 if (Ktheta == 0.0)
continue;
2293 Real const angle = numeric::angle_radians(
2294 rsd2.
atom( res2_lower_atomno ).
xyz(),
2295 rsd2.
atom( resconn_atomno2 ).
xyz(),
2296 rsd1.
atom( resconn_atomno1 ).
xyz() );
2305 <<
" pdbpos: " << pose.
pdb_info()->number(rsd2.
seqpos()) <<
" angle rsd2: " << rsd2.
name()
2306 <<
":" << rsd2.
atom_name( res2_lower_atomno ) <<
" , "
2308 <<
" (" << Ktheta <<
") " << angle <<
" " << theta0
2309 <<
" sc=" << energy_angle << std::endl;
2333 using namespace core::chemical;
2348 if (len_params->is_null())
return;
2349 Real Kd=len_params->K(phi2,psi2), d0=len_params->mu(phi2,psi2);
2358 <<
" pdbpos rsd1: " << pose.
pdb_info()->number(rsd1.
seqpos()) <<
" length rsd1 rsd2: " << rsd1.
seqpos() <<
" -- " << rsd2.
seqpos() <<
" "
2360 << Kd <<
") " << length <<
" " << d0
2361 <<
" sc=" << energy_length << std::endl;
2378 for (
Size ii = 1; ii <= r1_resconn_ids.size(); ++ii ) {
2379 Size const resconn_id1( r1_resconn_ids[ii] );
2388 ( rsd2.
atom( resconn_atomno2 ).
xyz() - rsd1.
atom( resconn_atomno1 ).
xyz() ).length();
2395 atm1name, atm2name, resconn_atomno2, -resconn_id2);
2397 if (len_params->is_null())
continue;
2398 Real Kd=len_params->K(phi2,psi2), d0=len_params->mu(phi2,psi2);
2407 <<
" pdbpos rsd1: " << pose.
pdb_info()->number(rsd1.
seqpos()) <<
" length rsd1 rsd2: " << rsd1.
seqpos() <<
" -- " << rsd2.
seqpos() <<
" "
2408 << rsd1.
name() <<
":" << rsd1.
atom_name( resconn_atomno1 ) <<
" , " << rsd2.
atom_name( resconn_atomno2 )<<
" ("
2409 << Kd <<
") " << length <<
" " << d0
2410 <<
" sc=" << energy_length << std::endl;
2431 using namespace core::chemical;
2432 using numeric::constants::d::pi;
2441 if ( !tor_params->is_null() ) {
2442 Real const Kphi = tor_params->K(0,0);
2443 Real const phi0=tor_params->mu(0,0);
2444 Real const phi_step=2*pi/tor_params->period();
2445 Real angle = numeric::dihedral_radians(
2451 Real del_phi = basic::subtract_radian_angles(angle, phi0);
2452 del_phi = basic::periodic_range( del_phi, phi_step );
2460 TR.Debug << pose.
pdb_info()->name() <<
" seqpos: " << rsd1.
seqpos() <<
" pdbpos: " <<
2461 pose.
pdb_info()->number(rsd1.
seqpos()) <<
" improper torsion: " <<
2462 rsd1.
name() <<
" : " <<
2465 Kphi <<
") " << angle <<
" " << phi0 <<
" sc=" << energy_torsion << std::endl;
2477 if ( !tor_params->is_null() ) {
2478 Real const Kphi = tor_params->K(0,0);
2479 Real const phi0=tor_params->mu(0,0);
2480 Real const phi_step=2*pi/tor_params->period();
2481 Real angle = numeric::dihedral_radians(
2487 Real del_phi = basic::subtract_radian_angles(angle, phi0);
2488 del_phi = basic::periodic_range( del_phi, phi_step );
2496 TR.Debug << pose.
pdb_info()->name() <<
" seqpos: " << rsd1.
seqpos() <<
" pdbpos: " <<
2497 pose.
pdb_info()->number(rsd1.
seqpos()) <<
" improper torsion: " <<
2498 rsd1.
name() <<
" : " <<
2501 Kphi <<
") " << angle <<
" " << phi0 <<
" sc=" << energy_torsion << std::endl;
2522 using numeric::constants::d::pi;
2523 using namespace numeric;
2546 using namespace core::chemical;
2547 using numeric::constants::d::pi;
2553 for (
Size ii = 1, iiend = tps.size(); ii <= iiend; ++ii ) {
2555 Size const rt1( atids[1] ), rt2( atids[2] ), rt3( atids[3] ), rt4( atids[4] );
2558 Real Kphi = tor_params.
K(phi,psi);
2559 Real phi0 = tor_params.
mu(phi,psi);
2560 Real phi_step = 2 * pi / tor_params.
period();
2563 Real angle(0.0), dE_dphi;
2565 numeric::deriv::dihedral_p1_cosine_deriv( rsd.
xyz( rt1 ), rsd.
xyz( rt2 ), rsd.
xyz( rt3 ), rsd.
xyz( rt4 ), angle, f1, f2 );
2566 Real del_phi = basic::subtract_radian_angles(angle, phi0);
2567 if (phi_step>0) del_phi = basic::periodic_range( del_phi, phi_step );
2569 dE_dphi = weight * Kphi * (del_phi>0? 1 : -1);
2571 dE_dphi = weight * Kphi * del_phi;
2573 r_atom_derivs[ rt1 ].f1() += dE_dphi * f1;
2574 r_atom_derivs[ rt1 ].f2() += dE_dphi * f2;
2577 numeric::deriv::dihedral_p2_cosine_deriv( rsd.
xyz( rt1 ), rsd.
xyz( rt2 ), rsd.
xyz( rt3 ), rsd.
xyz( rt4 ), angle, f1, f2 );
2578 r_atom_derivs[ rt2 ].f1() += dE_dphi * f1;
2579 r_atom_derivs[ rt2 ].f2() += dE_dphi * f2;
2582 numeric::deriv::dihedral_p2_cosine_deriv( rsd.
xyz( rt4 ), rsd.
xyz( rt3 ), rsd.
xyz( rt2 ), rsd.
xyz( rt1 ), angle, f1, f2 );
2584 r_atom_derivs[ rt3 ].f1() += dE_dphi * f1;
2585 r_atom_derivs[ rt3 ].f2() += dE_dphi * f2;
2588 numeric::deriv::dihedral_p1_cosine_deriv( rsd.
xyz( rt4 ), rsd.
xyz( rt3 ), rsd.
xyz( rt2 ), rsd.
xyz( rt1 ), angle, f1, f2 );
2589 r_atom_derivs[ rt4 ].f1() += dE_dphi * f1;
2590 r_atom_derivs[ rt4 ].f2() += dE_dphi * f2;
2606 using namespace core::chemical;
2611 for (
Size ii = 1, iiend = aps.size(); ii <= iiend; ++ii ) {
2613 Size const rt1( atids[1] ), rt2( atids[2] ), rt3( atids[3] );
2615 if (ang_params.
is_null())
continue;
2616 Real Ktheta = ang_params.
K(phi,psi);
2617 Real theta0 = ang_params.
mu(phi,psi);
2620 Real theta(0.0), dE_dtheta;
2622 numeric::deriv::angle_p1_deriv( rsd.
xyz( rt1 ), rsd.
xyz( rt2 ), rsd.
xyz( rt3 ), theta, f1, f2 );
2624 dE_dtheta = weight * Ktheta * ((theta > theta0)>0? 1 : -1);
2626 dE_dtheta = weight * Ktheta * (theta - theta0);
2628 r_atom_derivs[ rt1 ].f1() += dE_dtheta * f1;
2629 r_atom_derivs[ rt1 ].f2() += dE_dtheta * f2;
2631 numeric::deriv::angle_p2_deriv( rsd.
xyz( rt1 ), rsd.
xyz( rt2 ), rsd.
xyz( rt3 ), theta, f1, f2 );
2632 r_atom_derivs[ rt2 ].f1() += dE_dtheta * f1;
2633 r_atom_derivs[ rt2 ].f2() += dE_dtheta * f2;
2635 numeric::deriv::angle_p1_deriv( rsd.
xyz( rt3 ), rsd.
xyz( rt2 ), rsd.
xyz( rt1 ), theta, f1, f2 );
2636 r_atom_derivs[ rt3 ].f1() += dE_dtheta * f1;
2637 r_atom_derivs[ rt3 ].f2() += dE_dtheta * f2;
2652 using namespace core::chemical;
2657 for (
Size ii = 1, iiend = lps.size(); ii <= iiend; ++ii ) {
2659 Size const rt1( atids[1] ), rt2( atids[2] );
2661 if (len_params.
is_null() )
continue;
2663 Real const Kd = len_params.
K(phi,psi);
2664 Real const d0 = len_params.
mu(phi,psi);
2669 numeric::deriv::distance_f1_f2_deriv( rsd.
xyz( rt1 ), rsd.
xyz( rt2 ), d, f1, f2 );
2671 dE_dd = weight * Kd * ((d - d0)>0? 1 : -1);
2673 dE_dd = weight * Kd * (d - d0);
2675 r_atom_derivs[ rt1 ].f1() += dE_dd * f1;
2676 r_atom_derivs[ rt1 ].f2() += dE_dd * f2;
2678 r_atom_derivs[ rt2 ].f1() -= dE_dd * f1;
2679 r_atom_derivs[ rt2 ].f2() -= dE_dd * f2;
2692 using namespace core::chemical;
2693 using numeric::constants::d::pi;
2699 for (
Size ii = 1, iiend = itps.size(); ii <= iiend; ++ii ) {
2701 Size const rt1( atids[1] ), rt2( atids[2] ), rt3( atids[3] ), rt4( atids[4] );
2703 Real Kphi = tor_params.
K(0,0);
2704 Real phi0 = tor_params.
mu(0,0);
2711 numeric::deriv::dihedral_p1_cosine_deriv(
2712 rsd.
xyz( rt1 ), rsd.
xyz( rt2 ), rsd.
xyz( rt3 ), rsd.
xyz( rt4 ),
phi, f1, f2 );
2713 Real del_phi = basic::subtract_radian_angles(phi, phi0);
2714 del_phi = basic::periodic_range( del_phi, phi_step );
2716 dE_dphi = weight * Kphi * (del_phi>0? 1 : -1);
2718 dE_dphi = weight * Kphi * del_phi;
2720 r_atom_derivs[ rt1 ].f1() += dE_dphi * f1;
2721 r_atom_derivs[ rt1 ].f2() += dE_dphi * f2;
2724 numeric::deriv::dihedral_p2_cosine_deriv(
2725 rsd.
xyz( rt1 ), rsd.
xyz( rt2 ), rsd.
xyz( rt3 ), rsd.
xyz( rt4 ),
phi, f1, f2 );
2726 r_atom_derivs[ rt2 ].f1() += dE_dphi * f1;
2727 r_atom_derivs[ rt2 ].f2() += dE_dphi * f2;
2730 numeric::deriv::dihedral_p2_cosine_deriv(
2731 rsd.
xyz( rt4 ), rsd.
xyz( rt3 ), rsd.
xyz( rt2 ), rsd.
xyz( rt1 ),
phi, f1, f2 );
2733 r_atom_derivs[ rt3 ].f1() += dE_dphi * f1;
2734 r_atom_derivs[ rt3 ].f2() += dE_dphi * f2;
2737 numeric::deriv::dihedral_p1_cosine_deriv(
2738 rsd.
xyz( rt4 ), rsd.
xyz( rt3 ), rsd.
xyz( rt2 ), rsd.
xyz( rt1 ),
phi, f1, f2 );
2739 r_atom_derivs[ rt4 ].f1() += dE_dphi * f1;
2740 r_atom_derivs[ rt4 ].f2() += dE_dphi * f2;
2759 using namespace core::chemical;
2768 for (
Size ii = 1, iiend = aps.size(); ii <= iiend; ++ii ) {
2771 Real Ktheta = ang_params.
K(phi1,psi1);
2772 Real theta0 = ang_params.
mu(phi1,psi1);
2775 Size const res1_lower_atomno = atids[1], resconn_atomno1 = atids[2], resconn_atomno2 = rsd2params.
bb_N_index();
2778 Real theta(0.0), dE_dtheta;
2779 numeric::deriv::angle_p1_deriv(
2780 rsd1.
xyz( res1_lower_atomno ), rsd1.
xyz( resconn_atomno1 ), rsd2.
xyz( resconn_atomno2 ), theta, f1, f2 );
2786 r1_atom_derivs[ res1_lower_atomno ].f1() += dE_dtheta * f1;
2787 r1_atom_derivs[ res1_lower_atomno ].f2() += dE_dtheta * f2;
2789 numeric::deriv::angle_p2_deriv(
2790 rsd1.
xyz( res1_lower_atomno ), rsd1.
xyz( resconn_atomno1 ), rsd2.
xyz( resconn_atomno2 ), theta, f1, f2 );
2791 r1_atom_derivs[ resconn_atomno1 ].f1() += dE_dtheta * f1;
2792 r1_atom_derivs[ resconn_atomno1 ].f2() += dE_dtheta * f2;
2794 numeric::deriv::angle_p1_deriv(
2795 rsd2.
xyz( resconn_atomno2 ), rsd1.
xyz( resconn_atomno1 ), rsd1.
xyz( res1_lower_atomno ), theta, f1, f2 );
2796 r2_atom_derivs[ resconn_atomno2 ].f1() += dE_dtheta * f1;
2797 r2_atom_derivs[ resconn_atomno2 ].f2() += dE_dtheta * f2;
2810 for (
Size ii = 1; ii <= r1_resconn_ids.size(); ++ii ) {
2811 Size const resconn_id1( r1_resconn_ids[ii] );
2820 for (
Size jj = 1; jj <= rsd1_atoms_wi1_bond_of_ii.size(); ++jj ) {
2821 assert( rsd1_atoms_wi1_bond_of_ii[ jj ].key1() == resconn_atomno1 );
2822 Size const res1_lower_atomno = rsd1_atoms_wi1_bond_of_ii[ jj ].key2();
2834 atm1name, atm2name, atm3name, res1_lower_atomno, resconn_atomno1, -resconn_id1);
2835 if (ang_params->is_null())
continue;
2836 Real Ktheta=ang_params->K(phi1,psi1), theta0=ang_params->mu(phi1,psi1);
2839 Real theta(0.0), dE_dtheta;
2840 numeric::deriv::angle_p1_deriv(
2841 rsd1.
xyz( res1_lower_atomno ), rsd1.
xyz( resconn_atomno1 ), rsd2.
xyz( resconn_atomno2 ), theta, f1, f2 );
2846 r1_atom_derivs[ res1_lower_atomno ].f1() += dE_dtheta * f1;
2847 r1_atom_derivs[ res1_lower_atomno ].f2() += dE_dtheta * f2;
2849 numeric::deriv::angle_p2_deriv(
2850 rsd1.
xyz( res1_lower_atomno ), rsd1.
xyz( resconn_atomno1 ), rsd2.
xyz( resconn_atomno2 ), theta, f1, f2 );
2851 r1_atom_derivs[ resconn_atomno1 ].f1() += dE_dtheta * f1;
2852 r1_atom_derivs[ resconn_atomno1 ].f2() += dE_dtheta * f2;
2854 numeric::deriv::angle_p1_deriv(
2855 rsd2.
xyz( resconn_atomno2 ), rsd1.
xyz( resconn_atomno1 ), rsd1.
xyz( res1_lower_atomno ), theta, f1, f2 );
2856 r2_atom_derivs[ resconn_atomno2 ].f1() += dE_dtheta * f1;
2857 r2_atom_derivs[ resconn_atomno2 ].f2() += dE_dtheta * f2;
2876 using namespace core::chemical;
2885 for (
Size ii = 1, iiend = aps.size(); ii <= iiend; ++ii ) {
2888 Real Ktheta = ang_params.
K(phi2,psi2);
2889 Real theta0 = ang_params.
mu(phi2,psi2);
2892 Size const res2_lower_atomno = atids[1], resconn_atomno2 = atids[2], resconn_atomno1 = rsd1params.
bb_C_index();
2895 Real theta(0.0), dE_dtheta;
2896 numeric::deriv::angle_p1_deriv(
2897 rsd2.
xyz( res2_lower_atomno ), rsd2.
xyz( resconn_atomno2 ), rsd1.
xyz( resconn_atomno1 ), theta, f1, f2 );
2903 r2_atom_derivs[ res2_lower_atomno ].f1() += dE_dtheta * f1;
2904 r2_atom_derivs[ res2_lower_atomno ].f2() += dE_dtheta * f2;
2906 numeric::deriv::angle_p2_deriv(
2907 rsd2.
xyz( res2_lower_atomno ), rsd2.
xyz( resconn_atomno2 ), rsd1.
xyz( resconn_atomno1 ), theta, f1, f2 );
2908 r2_atom_derivs[ resconn_atomno2 ].f1() += dE_dtheta * f1;
2909 r2_atom_derivs[ resconn_atomno2 ].f2() += dE_dtheta * f2;
2911 numeric::deriv::angle_p1_deriv(
2912 rsd1.
xyz( resconn_atomno1 ), rsd2.
xyz( resconn_atomno2 ), rsd2.
xyz( res2_lower_atomno ), theta, f1, f2 );
2913 r1_atom_derivs[ resconn_atomno1 ].f1() += dE_dtheta * f1;
2914 r1_atom_derivs[ resconn_atomno1 ].f2() += dE_dtheta * f2;
2927 for (
Size ii = 1; ii <= r1_resconn_ids.size(); ++ii ) {
2928 Size const resconn_id1( r1_resconn_ids[ii] );
2936 for (
Size jj = 1; jj <= rsd2_atoms_wi1_bond_of_ii.size(); ++jj ) {
2937 assert( rsd2_atoms_wi1_bond_of_ii[ jj ].key1() == resconn_atomno2 );
2938 Size const res2_lower_atomno = rsd2_atoms_wi1_bond_of_ii[ jj ].key2();
2946 atm1name, atm2name, atm3name, res2_lower_atomno, resconn_atomno2, -resconn_id2);
2947 if (ang_params->is_null())
continue;
2948 Real Ktheta=ang_params->K(phi2,psi2), theta0=ang_params->mu(phi2,psi2);
2951 Real theta(0.0), dE_dtheta;
2952 numeric::deriv::angle_p1_deriv(
2953 rsd2.
xyz( res2_lower_atomno ), rsd2.
xyz( resconn_atomno2 ), rsd1.
xyz( resconn_atomno1 ), theta, f1, f2 );
2958 r2_atom_derivs[ res2_lower_atomno ].f1() += dE_dtheta * f1;
2959 r2_atom_derivs[ res2_lower_atomno ].f2() += dE_dtheta * f2;
2961 numeric::deriv::angle_p2_deriv(
2962 rsd2.
xyz( res2_lower_atomno ), rsd2.
xyz( resconn_atomno2 ), rsd1.
xyz( resconn_atomno1 ), theta, f1, f2 );
2963 r2_atom_derivs[ resconn_atomno2 ].f1() += dE_dtheta * f1;
2964 r2_atom_derivs[ resconn_atomno2 ].f2() += dE_dtheta * f2;
2966 numeric::deriv::angle_p1_deriv(
2967 rsd1.
xyz( resconn_atomno1 ), rsd2.
xyz( resconn_atomno2 ), rsd2.
xyz( res2_lower_atomno ), theta, f1, f2 );
2968 r1_atom_derivs[ resconn_atomno1 ].f1() += dE_dtheta * f1;
2969 r1_atom_derivs[ resconn_atomno1 ].f2() += dE_dtheta * f2;
2988 using namespace core::chemical;
2999 if (len_params->is_null())
return;
3000 Real const Kd = len_params->K(phi2,psi2);
3001 Real const d0 = len_params->mu(phi2,psi2);
3009 numeric::deriv::distance_f1_f2_deriv( rsd2.
xyz( r2at ), rsd1.
xyz( r1at ), d, f1, f2 );
3015 r2_atom_derivs[ r2at ].f1() += dE_dd * f1;
3016 r2_atom_derivs[ r2at ].f2() += dE_dd * f2;
3018 r1_atom_derivs[ r1at ].f1() -= dE_dd * f1;
3019 r1_atom_derivs[ r1at ].f2() -= dE_dd * f2;
3032 for (
Size ii = 1; ii <= r1_resconn_ids.size(); ++ii ) {
3033 Size const resconn_id1( r1_resconn_ids[ii] );
3043 atm1name, atm2name, resconn_atomno2, -resconn_id2);
3045 if (len_params->is_null())
continue;
3046 Real Kd=len_params->K(phi2,psi2), d0=len_params->mu(phi2,psi2);
3051 numeric::deriv::distance_f1_f2_deriv( rsd2.
xyz( resconn_atomno2 ), rsd1.
xyz( resconn_atomno1 ), d, f1, f2 );
3056 r2_atom_derivs[ resconn_atomno2 ].f1() += dE_dd * f1;
3057 r2_atom_derivs[ resconn_atomno2 ].f2() += dE_dd * f2;
3059 numeric::deriv::distance_f1_f2_deriv( rsd1.
xyz( resconn_atomno1 ), rsd2.
xyz( resconn_atomno2 ), d, f1, f2 );
3060 r1_atom_derivs[ resconn_atomno1 ].f1() += dE_dd * f1;
3061 r1_atom_derivs[ resconn_atomno1 ].f2() += dE_dd * f2;
3077 using namespace core::chemical;
3078 using numeric::constants::d::pi;
3089 if ( !tor_params->is_null() ) {
3090 Real const Kphi = tor_params->K(0,0);
3091 Real const phi0=tor_params->mu(0,0);
3092 Real const phi_step=2*pi/tor_params->period();
3102 numeric::deriv::dihedral_p1_cosine_deriv(
3103 res2.
xyz( atm1 ), res1.
xyz( atm2 ), res2.
xyz( atm3 ), res2.
xyz( atm4 ),
phi, f1, f2 );
3104 Real del_phi = basic::subtract_radian_angles(phi, phi0);
3105 del_phi = basic::periodic_range( del_phi, phi_step );
3107 dE_dphi = weight * Kphi * (del_phi>0? 1 : -1);
3109 dE_dphi = weight * Kphi * del_phi;
3111 r2_atom_derivs[ atm1 ].f1() += dE_dphi * f1;
3112 r2_atom_derivs[ atm1 ].f2() += dE_dphi * f2;
3115 numeric::deriv::dihedral_p2_cosine_deriv(
3116 res2.
xyz( atm1 ), res1.
xyz( atm2 ), res2.
xyz( atm3 ), res2.
xyz( atm4 ),
phi, f1, f2 );
3117 r1_atom_derivs[ atm2 ].f1() += dE_dphi * f1;
3118 r1_atom_derivs[ atm2 ].f2() += dE_dphi * f2;
3121 numeric::deriv::dihedral_p2_cosine_deriv(
3122 res2.
xyz( atm4 ), res2.
xyz( atm3 ), res1.
xyz( atm2 ), res2.
xyz( atm1 ),
phi, f1, f2 );
3123 r2_atom_derivs[ atm3 ].f1() += dE_dphi * f1;
3124 r2_atom_derivs[ atm3 ].f2() += dE_dphi * f2;
3127 numeric::deriv::dihedral_p1_cosine_deriv(
3128 res2.
xyz( atm4 ), res2.
xyz( atm3 ), res1.
xyz( atm2 ), res2.
xyz( atm1 ),
phi, f1, f2 );
3129 r2_atom_derivs[ atm4 ].f1() += dE_dphi * f1;
3130 r2_atom_derivs[ atm4 ].f2() += dE_dphi * f2;
3137 if (!tor_params->is_null()) {
3143 Real const Kphi = tor_params->K(0,0);
3144 Real const phi0=tor_params->mu(0,0);
3145 Real const phi_step=2*pi/tor_params->period();
3150 numeric::deriv::dihedral_p1_cosine_deriv(
3151 res1.
xyz( atm1 ), res2.
xyz( atm2 ), res1.
xyz( atm3 ), res1.
xyz( atm4 ),
phi, f1, f2 );
3152 Real del_phi = basic::subtract_radian_angles(phi, phi0);
3153 del_phi = basic::periodic_range( del_phi, phi_step );
3159 r1_atom_derivs[ atm1 ].f1() += dE_dphi * f1;
3160 r1_atom_derivs[ atm1 ].f2() += dE_dphi * f2;
3163 numeric::deriv::dihedral_p2_cosine_deriv(
3164 res1.
xyz( atm1 ), res2.
xyz( atm2 ), res1.
xyz( atm3 ), res1.
xyz( atm4 ),
phi, f1, f2 );
3165 r2_atom_derivs[ atm2 ].f1() += dE_dphi * f1;
3166 r2_atom_derivs[ atm2 ].f2() += dE_dphi * f2;
3169 numeric::deriv::dihedral_p2_cosine_deriv(
3170 res1.
xyz( atm4 ), res1.
xyz( atm3 ), res2.
xyz( atm2 ), res1.
xyz( atm1 ),
phi, f1, f2 );
3171 r1_atom_derivs[ atm3 ].f1() += dE_dphi * f1;
3172 r1_atom_derivs[ atm3 ].f2() += dE_dphi * f2;
3175 numeric::deriv::dihedral_p1_cosine_deriv(
3176 res1.
xyz( atm4 ), res1.
xyz( atm3 ), res2.
xyz( atm2 ), res1.
xyz( atm1 ),
phi, f1, f2 );
3177 r1_atom_derivs[ atm4 ].f1() += dE_dphi * f1;
3178 r1_atom_derivs[ atm4 ].f2() += dE_dphi * f2;
3191 Real const absdiff = std::fabs(val-val0);
3193 return 0.5 * K * absdiff;
3195 return 0.5 * K * absdiff * absdiff;