![]() |
Rosetta
2021.16
|
#include <MainchainScoreTable.hh>

Public Member Functions | |
| MainchainScoreTable () | |
| Default constructor. More... | |
| MainchainScoreTableOP | clone () const |
| Clone function: make a copy of this object and return an owning pointer to the copy. More... | |
| void | parse_rama_map_file_shapovalov (std::string const &filename, std::string const &file_contents, std::string const &res_type_name, bool const use_polycubic_interpolation) |
| Parse a Shapovalov-style rama database file and set up this MainchainScoreTable. More... | |
| void | clear () |
| Reset this object completely. More... | |
| void | initialize_for_de_novo_generation (core::chemical::ResidueType const &restype, utility::vector1< core::Size > const &dimensions, utility::vector1< core::Size > const &mainchain_torsions_covered, bool const symmetrize) |
| Initialize this object for on-the-fly generation of a mainchain scoretable. More... | |
| void | set_energy (utility::vector1< core::Size > const &coords, core::Real const &energy_in) |
| Set an entry in the energies tensor. More... | |
| bool | increment_energy_coords (utility::vector1< core::Size > &coords) const |
| Given coordinates in the energy tensor, increment the coordinates. More... | |
| void | finalize_de_novo_scoretable_from_energies (core::Real const &kbt, bool const normalize) |
| After the energies tensor has been populated, compute all derived data. More... | |
| void | write_mainchain_scoretable_to_stream (std::stringstream &outstream) const |
| After the mainchain scoretable has been finalized, write it to a scorefile. More... | |
| bool | initialized () const |
| Has this MainchainScoreTable been initialized? More... | |
| void | get_mainchain_torsions_from_coords (utility::vector1< core::Size > const &coords_in, utility::vector1< core::Real > &torsions_out, bool const offset_if_symmetric=true) const |
| Given a vector of coordinates, get the corresponding vector of mainchain torsions. More... | |
| core::Real const & | energy_tensor (utility::vector1< core::Size > const &coords) const |
| Access an entry in the energy tensor. More... | |
| core::Real | energy (utility::vector1< core::Real > coords) const |
| Access values in this MainchainScoreTable. More... | |
| void | gradient (utility::vector1< core::Real > coords_in, utility::vector1< core::Real > &gradient_out) const |
| Get the gradient with respect to x1,x2,x3,...xn for this MainchainScoreTable. More... | |
| void | set_symmetrize_gly (bool const setting_in) |
| Set whether we should symmetrize tables for glycine. More... | |
| bool | symmetrize_gly () const |
| Return whether we should symmetrize tables for glycine. More... | |
| void | draw_random_mainchain_torsion_values (utility::vector1< core::Real > &torsions) const |
| Given the cumulative distribution function (pre-calculated), draw a random set of mainchain torsion values biased by the probability distribution. More... | |
| utility::vector1< core::Size > const & | get_mainchain_torsions_covered () const |
| Get a const reference to the vector of mainchain torsions indices that this mainchain potential covers. More... | |
Private Member Functions | |
| void | set_initialized () |
| Sets the state of this MainchainScoreTable object to "initialized". More... | |
| void | set_dimension_and_ntorsions_for_restype (core::chemical::ResidueType const &restype, utility::vector1< core::Size > const &dimensions, utility::vector1< core::Size > mainchain_torsions_covered) |
| Given a residue type, set dimension_ and n_mainchain_torsions_total_, and resize all tensors appropriately. More... | |
| void | set_up_cumulative_distribution_function (numeric::MathNTensorBaseCOP< core::Real > probs, numeric::MathNTensorBaseOP< core::Real > cdf) const |
| Set up the cumulative distribution function. More... | |
| void | energies_from_probs (numeric::MathNTensorBaseOP< core::Real > energies, numeric::MathNTensorBaseCOP< core::Real > probs, core::Real const &kbt) const |
| Given a probabilities tensor, calculate the energies. More... | |
| void | check_linestream (std::istringstream const &linestream, std::string const &filename, bool const fail_on_eof=true) const |
| Check that the stringstream doesn't have bad or eof status, and throw an error message if it does. More... | |
| void | initialize_tensors (utility::vector1< core::Size > dimensions) |
| Initialize the energies_ and probabilities_ tensors to 0-containing N-tensors, of the dimensions given by the dimensions vector. More... | |
| void | iteratively_correct_energy_tensor (core::Real const &entropy) |
| Convert the energies from probabilities to Rosetta energy units, and add the entropic correction factor. More... | |
| bool | increment_coords (utility::vector1< core::Size > &coords, numeric::MathNTensorBaseCOP< core::Real > tensor) const |
| Given coordinates in the energy tensor, go to the next bin. More... | |
| void | get_opposite_coord (utility::vector1< core::Size > const &coord, numeric::MathNTensorBaseCOP< core::Real > tensor, utility::vector1< core::Size > &opposite_coord) const |
| Given a set of coordinates in a MathNTensor, get the opposite coordinates. More... | |
| void | set_up_polycubic_interpolation (utility::vector1< core::Real > const &offsets, utility::vector1< core::Size > const &dimensions) |
| Once the internal MathNTensor has been set up, set up polycubic interpolation. More... | |
| void | symmetrize_tensor (numeric::MathNTensorBaseOP< core::Real > tensor) const |
| Given a tensor, symmetrize it. More... | |
Private Attributes | |
| bool | initialized_ |
| Has this object been initialized? More... | |
| core::Size | dimension_ |
| Dimensionality of this MainchainScoreTable. More... | |
| utility::pointer::DeepCopyOP < numeric::MathNTensorBase < core::Real > > | energies_ |
| N-dimensional tensor for storing energies data. More... | |
| utility::pointer::DeepCopyOP < numeric::MathNTensorBase < core::Real > > | probabilities_ |
| N-dimensional tensor for storing probabilities data. More... | |
| utility::pointer::DeepCopyOP < numeric::MathNTensorBase < core::Real > > | cdf_ |
| N-dimensional tensor for storing the cumulative distribution function. More... | |
| bool | use_polycubic_interpolation_ |
| Is this MainchainScoreTable set up with polycubic interpolation? More... | |
| utility::pointer::DeepCopyOP < numeric::interpolation::spline::CubicSpline > | energies_spline_1D_ |
| Interpolation spline for the 1D case. More... | |
| utility::pointer::DeepCopyOP < numeric::interpolation::spline::BicubicSpline > | energies_spline_2D_ |
| Interpolation spline for the 2D case. More... | |
| utility::pointer::DeepCopyOP < numeric::interpolation::spline::PolycubicSplineBase > | energies_spline_ND_ |
| Interpolation spline for the N-dimensional case, where N > 2. More... | |
| core::Size | n_mainchain_torsions_total_ |
| What is the total number of mainchain torsions for this residue type? More... | |
| utility::vector1< core::Size > | mainchain_torsions_covered_ |
| If only a subset of mainchain torsions are provided, which ones are the relevant ones? More... | |
| bool | symmetrize_gly_ |
| Symmetrize glycine tables? More... | |
| core::chemical::mainchain_potential::MainchainScoreTable::MainchainScoreTable | ( | ) |
Default constructor.
References symmetrize_gly_.
|
private |
Check that the stringstream doesn't have bad or eof status, and throw an error message if it does.
Referenced by parse_rama_map_file_shapovalov().
| void core::chemical::mainchain_potential::MainchainScoreTable::clear | ( | ) |
Reset this object completely.
References cdf_, dimension_, energies_, energies_spline_1D_, energies_spline_2D_, energies_spline_ND_, initialized_, mainchain_torsions_covered_, n_mainchain_torsions_total_, probabilities_, symmetrize_gly_, and use_polycubic_interpolation_.
Referenced by initialize_for_de_novo_generation().
| MainchainScoreTableOP core::chemical::mainchain_potential::MainchainScoreTable::clone | ( | ) | const |
Clone function: make a copy of this object and return an owning pointer to the copy.
| void core::chemical::mainchain_potential::MainchainScoreTable::draw_random_mainchain_torsion_values | ( | utility::vector1< core::Real > & | torsions | ) | const |
Given the cumulative distribution function (pre-calculated), draw a random set of mainchain torsion values biased by the probability distribution.
output is in the range (-180, 180].
output is in the range (-180, 180].
References cdf_, protocols::simple_filters::coords(), increment_coords(), initialized(), mainchain_torsions_covered_, n_mainchain_torsions_total_, and core::scoring::rg.
|
private |
Given a probabilities tensor, calculate the energies.
Tensors must be the same size. Contents of the probabilities tensor are overwritten.
| [out] | energies | Tensor of energies. |
| [in] | probs | Tensor of probabilities. |
| [in] | kbt | Boltzmann temperature (k_B*T), in Rosetta energy units. |
References protocols::simple_filters::coords(), and increment_coords().
Referenced by finalize_de_novo_scoretable_from_energies(), and parse_rama_map_file_shapovalov().
| core::Real core::chemical::mainchain_potential::MainchainScoreTable::energy | ( | utility::vector1< core::Real > | coords | ) | const |
Access values in this MainchainScoreTable.
Note that the vector is deliberately not passed by reference. The function copies the vector and ensures that all coordinates are in the range [0, 360).
References dimension_, energies_spline_1D_, energies_spline_2D_, energies_spline_ND_, initialized(), mainchain_torsions_covered_, and n_mainchain_torsions_total_.
| core::Real const & core::chemical::mainchain_potential::MainchainScoreTable::energy_tensor | ( | utility::vector1< core::Size > const & | coords | ) | const |
Access an entry in the energy tensor.
Note that bounds checking only occurs in debug mode!
References energies_, and initialized().
| void core::chemical::mainchain_potential::MainchainScoreTable::finalize_de_novo_scoretable_from_energies | ( | core::Real const & | kbt, |
| bool const | normalize | ||
| ) |
After the energies tensor has been populated, compute all derived data.
If "normalize" is true, the probabilities are normalized to 1, and the energies adjusted accordingly. (This has the effect of raising or lowering all of the energies by some constant.) If "symmetrize_gly_" is true, the tensors are made symmetric.
References protocols::simple_filters::coords(), energies_, energies_from_probs(), increment_energy_coords(), initialized_, probabilities_, symmetrize_gly_, and symmetrize_tensor().
|
inline |
Get a const reference to the vector of mainchain torsions indices that this mainchain potential covers.
For example, for an oligourea, this would return {1, 2, 3}, since the Rama maps for oligoureas cover phi, theta, and psi (mainchain torsions 1, 2, and 3, respectively), but not mu or omega (mainchain torsions 4 and 5).
References mainchain_torsions_covered_.
| void core::chemical::mainchain_potential::MainchainScoreTable::get_mainchain_torsions_from_coords | ( | utility::vector1< core::Size > const & | coords_in, |
| utility::vector1< core::Real > & | torsions_out, | ||
| bool const | offset_if_symmetric = true |
||
| ) | const |
Given a vector of coordinates, get the corresponding vector of mainchain torsions.
Bounds-checking only in debug mode!
References energies_, and symmetrize_gly_.
Referenced by write_mainchain_scoretable_to_stream().
|
private |
Given a set of coordinates in a MathNTensor, get the opposite coordinates.
For example, in a 2D 5x5 tensor, (1, 3) would yield an opposite of (3, 1).
Referenced by symmetrize_tensor().
| void core::chemical::mainchain_potential::MainchainScoreTable::gradient | ( | utility::vector1< core::Real > | coords_in, |
| utility::vector1< core::Real > & | gradient_out | ||
| ) | const |
Get the gradient with respect to x1,x2,x3,...xn for this MainchainScoreTable.
| [in] | coords_in | The coordinates at which to evaluate the gradient. |
| [out] | gradient_out | The resulting gradient. |
References dimension_, energies_spline_1D_, energies_spline_2D_, energies_spline_ND_, initialized(), mainchain_torsions_covered_, and n_mainchain_torsions_total_.
|
private |
Given coordinates in the energy tensor, go to the next bin.
As row ends are reached, the row resets to 1 and the next column is selected (and so forth down the dimensions).
As row ends are reached, the row resets to 1 and the next column is selected (and so forth down the dimensions). Returns "true" if increment was successful, "false" if the end of the tensor has been reached.
Referenced by draw_random_mainchain_torsion_values(), energies_from_probs(), increment_energy_coords(), iteratively_correct_energy_tensor(), set_up_cumulative_distribution_function(), and symmetrize_tensor().
| bool core::chemical::mainchain_potential::MainchainScoreTable::increment_energy_coords | ( | utility::vector1< core::Size > & | coords | ) | const |
Given coordinates in the energy tensor, increment the coordinates.
References energies_, and increment_coords().
Referenced by finalize_de_novo_scoretable_from_energies(), and write_mainchain_scoretable_to_stream().
| void core::chemical::mainchain_potential::MainchainScoreTable::initialize_for_de_novo_generation | ( | core::chemical::ResidueType const & | restype, |
| utility::vector1< core::Size > const & | dimensions, | ||
| utility::vector1< core::Size > const & | mainchain_torsions_covered, | ||
| bool const | symmetrize | ||
| ) |
Initialize this object for on-the-fly generation of a mainchain scoretable.
Calls clear() first.
References clear(), set_dimension_and_ntorsions_for_restype(), and set_symmetrize_gly().
|
private |
Initialize the energies_ and probabilities_ tensors to 0-containing N-tensors, of the dimensions given by the dimensions vector.
References cdf_, dimension_, energies_, energies_spline_1D_, energies_spline_2D_, energies_spline_ND_, and probabilities_.
Referenced by parse_rama_map_file_shapovalov(), and set_dimension_and_ntorsions_for_restype().
|
inline |
Has this MainchainScoreTable been initialized?
False if no score table has been read yet; true otherwise.
References initialized_.
Referenced by draw_random_mainchain_torsion_values(), energy(), energy_tensor(), gradient(), parse_rama_map_file_shapovalov(), and set_initialized().
|
private |
Convert the energies from probabilities to Rosetta energy units, and add the entropic correction factor.
References protocols::simple_filters::coords(), energies_, and increment_coords().
Referenced by parse_rama_map_file_shapovalov().
| void core::chemical::mainchain_potential::MainchainScoreTable::parse_rama_map_file_shapovalov | ( | std::string const & | filename, |
| std::string const & | file_contents, | ||
| std::string const & | res_type_name, | ||
| bool const | use_polycubic_interpolation | ||
| ) |
Parse a Shapovalov-style rama database file and set up this MainchainScoreTable.
Sets initialized_ to true.
| [in] | filename | The name of the file that was read. (Just used for output messages – this function does not file read). |
| [in] | file_contents | The slurped contents of the file to parse. |
| [in] | res_type_name | The name of the ResidueType for which we're reading data. Data lines for other residue types will be ignored. |
| [in] | use_polycubic_interpolation | If true, uses polycubic interpolation; if false, uses polylinear interpolation. |
References cdf_, check_linestream(), energies_, energies_from_probs(), initialize_tensors(), initialized(), iteratively_correct_energy_tensor(), mainchain_torsions_covered_, n_mainchain_torsions_total_, probabilities_, protocols::noesy_assign::round(), set_initialized(), set_up_cumulative_distribution_function(), set_up_polycubic_interpolation(), symmetrize_gly_, symmetrize_tensor(), and use_polycubic_interpolation_.
|
private |
Given a residue type, set dimension_ and n_mainchain_torsions_total_, and resize all tensors appropriately.
Assumes that all data have already been cleared. Call clear() before invoking this method.
References core::chemical::ResidueTypeBase::base_name(), dimension_, initialize_tensors(), mainchain_torsions_covered_, n_mainchain_torsions_total_, and core::chemical::ResidueTypeBase::name().
Referenced by initialize_for_de_novo_generation().
| void core::chemical::mainchain_potential::MainchainScoreTable::set_energy | ( | utility::vector1< core::Size > const & | coords, |
| core::Real const & | energy_in | ||
| ) |
|
private |
Sets the state of this MainchainScoreTable object to "initialized".
Double-checks that it's not already initialized, and throws an error if it is.
References initialized(), and initialized_.
Referenced by parse_rama_map_file_shapovalov().
| void core::chemical::mainchain_potential::MainchainScoreTable::set_symmetrize_gly | ( | bool const | setting_in | ) |
Set whether we should symmetrize tables for glycine.
References symmetrize_gly_.
Referenced by initialize_for_de_novo_generation().
|
private |
Set up the cumulative distribution function.
The CDF is used for drawing random mainchain torsion values biased by the relative probabilities of mainchain torsion values.
| [in] | probs | Tensor of probabilities. Need not be normalized (sum to 1). |
| [out] | cdf | Tensor for the cumulative distribution function. |
References protocols::simple_filters::coords(), and increment_coords().
Referenced by parse_rama_map_file_shapovalov().
|
private |
Once the internal MathNTensor has been set up, set up polycubic interpolation.
This function includes special-case logic for setting up cubic interpolation in the 1D case and bicubic interpolation in the 2D case, since these are not handled by the PolycubicSpline class.
| [in] | offsets | Vector of offset values, from 0 to 1 – where centres are, as fraction of bin width. |
| [in] | dimensions | Vector of number of entries in each dimension. Bin widths are inferred from this: 36 entries would correspond to 10-degree bins. |
References dimension_, energies_, energies_spline_2D_, energies_spline_ND_, and probabilities_.
Referenced by parse_rama_map_file_shapovalov().
|
inline |
Return whether we should symmetrize tables for glycine.
References symmetrize_gly_.
|
private |
Given a tensor, symmetrize it.
Assumes that tensor stores probabilities; normalizes tensor in the process.
References get_opposite_coord(), increment_coords(), and protocols::hybridization::val.
Referenced by finalize_de_novo_scoretable_from_energies(), and parse_rama_map_file_shapovalov().
| void core::chemical::mainchain_potential::MainchainScoreTable::write_mainchain_scoretable_to_stream | ( | std::stringstream & | outstream | ) | const |
After the mainchain scoretable has been finalized, write it to a scorefile.
References protocols::simple_filters::coords(), dimension_, energies_, get_mainchain_torsions_from_coords(), increment_energy_coords(), mainchain_torsions_covered_, n_mainchain_torsions_total_, probabilities_, and protocols::noesy_assign::round().
|
private |
N-dimensional tensor for storing the cumulative distribution function.
This is used for drawing random mainchain torsion values biased by the relative probabilities of having a set of mainchain torsion values.
Referenced by clear(), draw_random_mainchain_torsion_values(), initialize_tensors(), and parse_rama_map_file_shapovalov().
|
private |
Dimensionality of this MainchainScoreTable.
Minimum 1, maximum 9. A value of 0 indicates that it is uninitialized.
Referenced by clear(), energy(), gradient(), initialize_tensors(), set_dimension_and_ntorsions_for_restype(), set_up_polycubic_interpolation(), and write_mainchain_scoretable_to_stream().
|
private |
N-dimensional tensor for storing energies data.
Referenced by clear(), energy_tensor(), finalize_de_novo_scoretable_from_energies(), get_mainchain_torsions_from_coords(), increment_energy_coords(), initialize_tensors(), iteratively_correct_energy_tensor(), parse_rama_map_file_shapovalov(), set_energy(), set_up_polycubic_interpolation(), and write_mainchain_scoretable_to_stream().
|
private |
Interpolation spline for the 1D case.
Only used if use_polycubic_interpolation_ is true and the energies_ MathNTensor is 1D. Null otherwise.
Referenced by clear(), energy(), gradient(), and initialize_tensors().
|
private |
Interpolation spline for the 2D case.
Only used if use_polycubic_interpolation_ is true and the energies_ MathNTensor is 2D. Null otherwise.
Referenced by clear(), energy(), gradient(), initialize_tensors(), and set_up_polycubic_interpolation().
|
private |
Interpolation spline for the N-dimensional case, where N > 2.
Only used if use_polycubic_interpolation_ is true and the energies_ MathNTensor is N-dimensional, where N > 2. Null otherwise.
Referenced by clear(), energy(), gradient(), initialize_tensors(), and set_up_polycubic_interpolation().
|
private |
Has this object been initialized?
Referenced by clear(), finalize_de_novo_scoretable_from_energies(), initialized(), and set_initialized().
|
private |
If only a subset of mainchain torsions are provided, which ones are the relevant ones?
For oligoureas, for example, this would be {1, 2, 3}, since only phi, theta, and psi are covered by the mainchain potential, and mu and theta (torsions 4 and 5) are covered by the omega score term.
Referenced by clear(), draw_random_mainchain_torsion_values(), energy(), get_mainchain_torsions_covered(), gradient(), parse_rama_map_file_shapovalov(), set_dimension_and_ntorsions_for_restype(), and write_mainchain_scoretable_to_stream().
|
private |
What is the total number of mainchain torsions for this residue type?
Could be different than the dimension of the tensors, if certain torsions are fixed. Note that this excludes omega (the inter-residue torsion), so for an alpha-amino acid, it should be "2". In the case of an oligourea, it is "3" instead of "4", since mu is fixed at 180 and enforced (along with omega) by the OmegaTetherEnergy.
Referenced by clear(), draw_random_mainchain_torsion_values(), energy(), gradient(), parse_rama_map_file_shapovalov(), set_dimension_and_ntorsions_for_restype(), and write_mainchain_scoretable_to_stream().
|
private |
N-dimensional tensor for storing probabilities data.
Referenced by clear(), finalize_de_novo_scoretable_from_energies(), initialize_tensors(), parse_rama_map_file_shapovalov(), set_up_polycubic_interpolation(), and write_mainchain_scoretable_to_stream().
|
private |
Symmetrize glycine tables?
Read from option system by default.
Referenced by clear(), finalize_de_novo_scoretable_from_energies(), get_mainchain_torsions_from_coords(), MainchainScoreTable(), parse_rama_map_file_shapovalov(), set_symmetrize_gly(), and symmetrize_gly().
|
private |
Is this MainchainScoreTable set up with polycubic interpolation?
Default true. If false, interpolation is linear.
Referenced by clear(), and parse_rama_map_file_shapovalov().
1.8.7