19 #include <basic/database/open.hh>
20 #include <basic/options/option.hh>
21 #include <basic/options/keys/score.OptionKeys.gen.hh>
22 #include <basic/options/keys/corrections.OptionKeys.gen.hh>
23 #include <basic/options/keys/OptionKeys.hh>
29 #include <numeric/conversions.hh>
30 #include <numeric/numeric.functions.hh>
31 #include <numeric/interpolation/periodic_range/full/interpolation.hh>
32 #include <numeric/interpolation/periodic_range/half/interpolation.hh>
34 #include <numeric/interpolation/spline/Bicubic_spline.hh>
38 #include <ObjexxFCL/FArray2D.hh>
39 #include <ObjexxFCL/format.hh>
42 #include <utility/io/izstream.hh>
47 #include <utility/vector1.hh>
82 using namespace core::chemical;
87 utility::io::izstream stream;
88 basic::database::open( stream,
"scoring/score_functions/P_AA_pp/P_AA" );
93 using namespace ObjexxFCL::fmt;
94 stream >> bite( 3,
id ) >> skip( 1 ) >> bite( 9, probability ) >> skip;
99 probability_sum += probability;
100 P_AA_[ aa ] = probability;
117 using namespace core::chemical;
123 utility::io::izstream stream;
124 basic::database::open( stream,
"scoring/score_functions/P_AA_pp/P_AA_n" );
130 using namespace ObjexxFCL::fmt;
131 stream >> bite( 3,
id ) >> skip( 1 ) >> bite( 2, n ) >> skip( 1 ) >> bite( 9, probability ) >> skip;
133 assert( ( n >= 1 ) && ( n <= 14 ) );
138 P_AA_n_[ aa ][ n ] = probability;
145 for (
int n = 1; n <= 14; ++n ) {
147 for ( Probability_AA_n::ConstIterator i =
P_AA_n_.begin(), e =
P_AA_n_.end(); i != e ; ++i ) {
148 probability_sum += (*i)[ n ];
164 using namespace core::chemical;
165 using namespace basic::options;
166 using namespace basic::options::OptionKeys::score;
167 using namespace basic::options::OptionKeys::corrections::score;
168 typedef FArray2D_Probability::IR IR;
174 utility::io::izstream stream;
177 stream.open( option[
p_aa_pp ] );
179 if ( !stream.good() ) {
181 basic::database::open( stream, option[ p_aa_pp ] );
184 if ( !stream.good() ) utility_exit_with_message(
"Unable to open p_aa_pp map!" );
191 using namespace ObjexxFCL::fmt;
193 stream >> bite( 4,
phi ) >> skip( 1 ) >> bite( 4,
psi ) >> skip( 1 )
194 >> bite( 3,
id ) >> skip( 17 ) >> bite( 7, probability ) >> skip;
204 if ( option[ p_aa_pp_nogridshift ] ) {
205 int const i_phi( numeric::mod( 36 + numeric::nint(
phi /
Angle( 10.0 ) ), 36 ) );
206 int const i_psi( numeric::mod( 36 + numeric::nint(
psi /
Angle( 10.0 ) ), 36 ) );
208 if ( probability ==
Probability( 0.0 ) ) probability = 1e-6;
209 P_AA_pp_[ aa ]( i_phi, i_psi ) = probability;
212 int const i_phi( numeric::mod( 36 + numeric::nint( (
phi /
Angle( 10.0 ) ) -
Angle( 0.5 ) ), 36 ) );
213 int const i_psi( numeric::mod( 36 + numeric::nint( (
psi /
Angle( 10.0 ) ) -
Angle( 0.5 ) ), 36 ) );
215 if ( probability ==
Probability( 0.0 ) ) probability = .001;
216 P_AA_pp_[ aa ]( i_phi, i_psi ) = probability;
240 if ( basic::options::option[ basic::options::OptionKeys::corrections::score::use_bicubic_interpolation ] ) {
243 using namespace numeric;
244 using namespace numeric::interpolation::spline;
247 BicubicSpline paappEspline;
248 MathMatrix< Real > energy_vals( 36, 36 );
249 for (
Size jj = 0; jj < 36; ++jj ) {
250 for (
Size kk = 0; kk < 36; ++kk ) {
251 energy_vals( jj, kk ) = -std::log(
P_AA_pp_[ ii ]( jj, kk ) /
P_AA_[ ii ] );
254 BorderFlag periodic_boundary[2] = { e_Periodic, e_Periodic };
256 if ( basic::options::option[ basic::options::OptionKeys::corrections::score::p_aa_pp_nogridshift ] ) {
257 start_vals[0] = start_vals[1] = 0.0;
259 start_vals[0] = start_vals[1] = 5.0;
261 Real deltas[2] = {10.0, 10.0};
262 bool lincont[2] = {
false,
false};
263 std::pair< Real, Real > unused[2];
264 unused[0] = std::make_pair( 0.0, 0.0 );
265 unused[1] = std::make_pair( 0.0, 0.0 );
266 paappEspline.train( periodic_boundary, start_vals, deltas, energy_vals, lincont, unused );
277 using namespace core::chemical;
278 using numeric::conversions::degrees;
280 AA const aa( res.
aa());
287 if ( basic::options::option[ basic::options::OptionKeys::corrections::score::use_bicubic_interpolation ] ) {
290 if ( basic::options::option[ basic::options::OptionKeys::corrections::score::p_aa_pp_nogridshift ] ) {
291 using numeric::interpolation::periodic_range::full::bilinearly_interpolated;
294 using numeric::interpolation::periodic_range::half::bilinearly_interpolated;
308 using numeric::interpolation::periodic_range::half::bilinearly_interpolated;
312 if ( basic::options::option[ basic::options::OptionKeys::corrections::score::p_aa_pp_nogridshift ] ) {
313 return -std::log( numeric::interpolation::periodic_range::full::bilinearly_interpolated( phi, psi,
Angle( 10.0 ), 36,
P_AA_pp_[ aa ] ) /
P_AA_[ aa ] );
317 numeric::MathVector< Real > args(2);
335 using namespace core::chemical;
336 using numeric::conversions::degrees;
337 using numeric::interpolation::periodic_range::half::bilinearly_interpolated;
339 AA const aa( res.
aa() );
344 Size const phi_id = 1;
345 Size const psi_id = 2;
354 if ( basic::options::option[ basic::options::OptionKeys::corrections::score::use_bicubic_interpolation ] ) {
364 if ( basic::options::option[ basic::options::OptionKeys::corrections::score::p_aa_pp_nogridshift ] ) {
365 Probability const interp_p = numeric::interpolation::periodic_range::full::bilinearly_interpolated(
phi,
psi,
Angle( 10.0 ), 36,
P_AA_pp_[ aa ], dp_dphi, dp_dpsi );
369 return -( 1.0 / interp_p ) * dp_dphi;
break;
371 return -( 1.0 / interp_p ) * dp_dpsi;
break;
376 Real const interp_p = bilinearly_interpolated(
phi,
psi,
Angle( 10.0 ), 36,
P_AA_pp_[ aa ], dp_dphi, dp_dpsi );
379 return -( 1.0 / interp_p ) * dp_dphi;
break;
381 return -( 1.0 / interp_p ) * dp_dpsi;
break;
399 using namespace core::chemical;
401 AA const aa( res.
aa());
405 return -std::log(
P_AA_[ aa ] );