Rosetta
Public Member Functions | Private Member Functions | Private Attributes | List of all members
protocols::ligand_evolution::Scorer Class Reference

: The Scorer computes the score of each Individual in a Population. It applies a list of movers, calculates a variety of score terms and combines them. The scorer also collects statistics and summarizes information. More...

#include <Scorer.hh>

Public Member Functions

 Scorer (FragmentLibrary &library, core::Size n_runs, char ligand_chain)
 
void initialize_from_options (EvolutionOptionsCOP options, protocols::rosetta_scripts::XmlObjectsCOP rosetta_script, core::Size rank)
 
void score_population (Population &pop)
 Sets the score for all individuals in the population, calculates it where needed. More...
 
void score_individual (Individual &individual)
 Checks if this individuals ligand was already scores, scores it if not, and sets the score for the individual. More...
 
void score_ligand (LigandIdentifier const &ligand, std::string const &smiles="", core::Size save_n_scores=0)
 Sets the current ligand and calls all steps to score it completely. More...
 
void add_mover (moves::MoverOP const &mover)
 Adds a mover. More...
 
void set_ligand (LigandIdentifier const &ligand, std::string const &smiles="")
 Sets the current ligand on which should be worked. More...
 
bool has_ligand () const
 Checks if a ligand is currently set. More...
 
bool next_step (core::Size save_n_scores=0)
 Performs the next scoring step on the current individual. Returns true, if this was the last step. More...
 
bool is_scored (LigandIdentifier const &ligand) const
 Returns true if the ligand was already scored. More...
 
std::map< std::string, core::Real > const & get_scores (LigandIdentifier const &ligand) const
 Returns all scores in a map with a string identifier. More...
 
void set_main_term (std::string const &score_term)
 Sets which term should be used for optimization. More...
 
void set_base_similarity_penalty (core::Real base_penalty)
 Sets the penalty for ligands which are appear more than once within a population. More...
 
void set_pose_path (std::string const &path)
 Sets the path where poses should be saved. Leave it empty to save in the current working directory. More...
 
void set_score_function (core::scoring::ScoreFunctionOP score_function)
 Sets the desired score function. More...
 
void set_scores (LigandIdentifier const &identifier, std::map< std::string, core::Real > const &scores)
 Sets all score terms for an identifier if not set yet. More...
 
core::Size n_score_terms () const
 Return how many score terms are calculated. More...
 
utility::vector1< core::Realget_raw_scores (LigandIdentifier const &identifier) const
 Returns the raw scores of an identifier for mpi communication. More...
 
void load_scores (std::string const &path)
 Loads scores for combinations of reagents and reactions from file. These are used during the run instead of rescoring. Format is the output format of RLE. More...
 
void set_raw_scores (LigandIdentifier const &identifier, double const *raw_scores)
 Transforms raw double scores into a proper map and calls set_scores @detail Expects scores in the same order as score_terms. More...
 
void save_results () const
 Writes all results to disk. More...
 
void save_external_scoring_results (core::Size rank)
 Writes multiple scores per ligand to disk. More...
 
std::map< LigandIdentifier, std::set< core::Size > > const & expose_id_memory () const
 For debugging and benchmarking purposes. More...
 
bool check_memory (LigandIdentifier const &ligand)
 Checks if score for this ligand is available in memory and loads it if possible. More...
 
utility::vector1< LigandIdentifierget_best_loaded (core::Size size) const
 Returns a list of LigandIdentifiers for loaded scores sorted by their main term score. More...
 
void set_similarity_penalty_threshold (core::Real threshold)
 

Private Member Functions

void create_pose ()
 Creates a pose and rotamers for the current ligand. More...
 
void apply_movers ()
 Applies all movers in order to the current ligands pose. More...
 
void calculate_scores (core::Size save_n_scores=0)
 Calculates all scores for the current ligand and saves them if lower than the old ones. More...
 
void dump_pose ()
 Dumps the current best pose to disk with the ligand identifier as name. More...
 
utility::vector1< std::string > ligand_line (LigandIdentifier const &identifier) const
 

Private Attributes

char ligand_chain_ = 'X'
 
std::string pose_path_
 
std::string main_score_term_
 
core::Size n_runs_ = 0
 
core::Size current_runs_ = 0
 
LigandIdentifier current_ligand_
 
std::string current_ligand_smiles_
 
FragmentLibrarylibrary_
 
core::pose::PoseOP basic_pose_ = nullptr
 
core::pose::PoseOP best_pose_ = nullptr
 
core::pose::PoseOP working_pose_
 
utility::vector1< moves::MoverOPmover_
 
std::map< LigandIdentifier, std::map< std::string, core::Real > > score_memory_
 
std::map< std::string, std::map< utility::vector1< std::string >, std::map< std::string, core::Real > > > loaded_score_memory_
 Important! LigendIdentifier here is NOT the same as in the rest of the program. This uses the real names from reactions and reagents. More...
 
std::map< LigandIdentifier, std::set< core::Size > > id_memory_
 
bool score_next_ = false
 
core::scoring::ScoreFunctionOP score_function_ = nullptr
 
core::Real base_similarity_penalty_ = 0.2
 
core::Real similarity_penalty_threshold_ = 0.95
 

Detailed Description

: The Scorer computes the score of each Individual in a Population. It applies a list of movers, calculates a variety of score terms and combines them. The scorer also collects statistics and summarizes information.

Constructor & Destructor Documentation

◆ Scorer()

protocols::ligand_evolution::Scorer::Scorer ( FragmentLibrary library,
core::Size  n_runs,
char  ligand_chain 
)

Member Function Documentation

◆ add_mover()

void protocols::ligand_evolution::Scorer::add_mover ( moves::MoverOP const &  mover)

Adds a mover.

References mover_, and protocols::TR().

Referenced by initialize_from_options().

◆ apply_movers()

void protocols::ligand_evolution::Scorer::apply_movers ( )
private

Applies all movers in order to the current ligands pose.

References basic_pose_, mover_, and working_pose_.

Referenced by next_step().

◆ calculate_scores()

void protocols::ligand_evolution::Scorer::calculate_scores ( core::Size  save_n_scores = 0)
private

Calculates all scores for the current ligand and saves them if lower than the old ones.

If save_all_scores is set, all scores are save in memory. This should only be used for external smiles scoring since it overrides a lot of otherwise needed and/or desired features.

References basic_pose_, best_pose_, current_ligand_, current_runs_, protocols::ligand_docking::get_interface_deltas(), is_scored(), ligand_chain_, main_score_term_, protocols::hybridization::score, score_function_, score_memory_, protocols::ligand_evolution::score_terms_, protocols::TR(), and working_pose_.

Referenced by next_step().

◆ check_memory()

bool protocols::ligand_evolution::Scorer::check_memory ( LigandIdentifier const &  ligand)

Checks if score for this ligand is available in memory and loads it if possible.

References library_, loaded_score_memory_, protocols::ligand_evolution::FragmentLibrary::reaction_id(), protocols::ligand_evolution::FragmentLibrary::reagent_id(), score_memory_, and protocols::TR().

Referenced by score_ligand().

◆ create_pose()

void protocols::ligand_evolution::Scorer::create_pose ( )
private

◆ dump_pose()

void protocols::ligand_evolution::Scorer::dump_pose ( )
private

Dumps the current best pose to disk with the ligand identifier as name.

References best_pose_, current_ligand_, pose_path_, and protocols::TR().

Referenced by next_step().

◆ expose_id_memory()

std::map< LigandIdentifier, std::set< core::Size > > const & protocols::ligand_evolution::Scorer::expose_id_memory ( ) const

For debugging and benchmarking purposes.

References id_memory_.

◆ get_best_loaded()

utility::vector1< LigandIdentifier > protocols::ligand_evolution::Scorer::get_best_loaded ( core::Size  size) const

◆ get_raw_scores()

utility::vector1< core::Real > protocols::ligand_evolution::Scorer::get_raw_scores ( LigandIdentifier const &  identifier) const

Returns the raw scores of an identifier for mpi communication.

References score_memory_, and protocols::ligand_evolution::score_terms_.

◆ get_scores()

std::map< std::string, core::Real > const & protocols::ligand_evolution::Scorer::get_scores ( LigandIdentifier const &  ligand) const

Returns all scores in a map with a string identifier.

References protocols::sewing::data_storage::ligand, and score_memory_.

◆ has_ligand()

bool protocols::ligand_evolution::Scorer::has_ligand ( ) const

Checks if a ligand is currently set.

References current_ligand_.

◆ initialize_from_options()

void protocols::ligand_evolution::Scorer::initialize_from_options ( EvolutionOptionsCOP  options,
protocols::rosetta_scripts::XmlObjectsCOP  rosetta_script,
core::Size  rank 
)

◆ is_scored()

bool protocols::ligand_evolution::Scorer::is_scored ( LigandIdentifier const &  ligand) const

Returns true if the ligand was already scored.

References protocols::sewing::data_storage::ligand, and score_memory_.

Referenced by calculate_scores(), score_ligand(), set_ligand(), and set_scores().

◆ ligand_line()

utility::vector1< std::string > protocols::ligand_evolution::Scorer::ligand_line ( LigandIdentifier const &  identifier) const
private

◆ load_scores()

void protocols::ligand_evolution::Scorer::load_scores ( std::string const &  path)

Loads scores for combinations of reagents and reactions from file. These are used during the run instead of rescoring. Format is the output format of RLE.

References library_, loaded_score_memory_, main_score_term_, protocols::ligand_evolution::FragmentLibrary::max_positions(), protocols::hybridization::path, protocols::ligand_evolution::score_terms_, core::id::to_string(), and protocols::TR().

Referenced by initialize_from_options().

◆ n_score_terms()

core::Size protocols::ligand_evolution::Scorer::n_score_terms ( ) const

Return how many score terms are calculated.

References protocols::ligand_evolution::score_terms_.

◆ next_step()

bool protocols::ligand_evolution::Scorer::next_step ( core::Size  save_n_scores = 0)

Performs the next scoring step on the current individual. Returns true, if this was the last step.

References apply_movers(), basic_pose_, best_pose_, calculate_scores(), create_pose(), current_ligand_, current_ligand_smiles_, current_runs_, dump_pose(), n_runs_, score_next_, protocols::ligand_evolution::score_terms_, set_scores(), and protocols::TR().

Referenced by score_ligand().

◆ save_external_scoring_results()

void protocols::ligand_evolution::Scorer::save_external_scoring_results ( core::Size  rank)

◆ save_results()

void protocols::ligand_evolution::Scorer::save_results ( ) const

◆ score_individual()

void protocols::ligand_evolution::Scorer::score_individual ( Individual individual)

◆ score_ligand()

void protocols::ligand_evolution::Scorer::score_ligand ( LigandIdentifier const &  ligand,
std::string const &  smiles = "",
core::Size  save_n_scores = 0 
)

Sets the current ligand and calls all steps to score it completely.

References check_memory(), is_scored(), protocols::sewing::data_storage::ligand, next_step(), set_ligand(), and protocols::TR().

Referenced by score_individual().

◆ score_population()

void protocols::ligand_evolution::Scorer::score_population ( Population pop)

◆ set_base_similarity_penalty()

void protocols::ligand_evolution::Scorer::set_base_similarity_penalty ( core::Real  base_penalty)

Sets the penalty for ligands which are appear more than once within a population.

The penalty is a relative fraction of the current main score for each ligand. It starts at 0 and increases with each additional ligand by the base penalty

References base_similarity_penalty_.

Referenced by initialize_from_options().

◆ set_ligand()

void protocols::ligand_evolution::Scorer::set_ligand ( LigandIdentifier const &  ligand,
std::string const &  smiles = "" 
)

Sets the current ligand on which should be worked.

References current_ligand_, current_ligand_smiles_, current_runs_, is_scored(), protocols::sewing::data_storage::ligand, and protocols::TR().

Referenced by score_ligand().

◆ set_main_term()

void protocols::ligand_evolution::Scorer::set_main_term ( std::string const &  score_term)

Sets which term should be used for optimization.

References main_score_term_, protocols::ligand_evolution::score_terms_, and protocols::TR().

Referenced by initialize_from_options().

◆ set_pose_path()

void protocols::ligand_evolution::Scorer::set_pose_path ( std::string const &  path)

Sets the path where poses should be saved. Leave it empty to save in the current working directory.

References protocols::hybridization::path, and pose_path_.

Referenced by initialize_from_options().

◆ set_raw_scores()

void protocols::ligand_evolution::Scorer::set_raw_scores ( LigandIdentifier const &  identifier,
double const *  raw_scores 
)

Transforms raw double scores into a proper map and calls set_scores @detail Expects scores in the same order as score_terms.

References protocols::ligand_evolution::score_terms_, and set_scores().

◆ set_score_function()

void protocols::ligand_evolution::Scorer::set_score_function ( core::scoring::ScoreFunctionOP  score_function)

Sets the desired score function.

References score_function_.

Referenced by initialize_from_options().

◆ set_scores()

void protocols::ligand_evolution::Scorer::set_scores ( LigandIdentifier const &  identifier,
std::map< std::string, core::Real > const &  scores 
)

Sets all score terms for an identifier if not set yet.

This functions expects that the scores were calculated by another instance of a Scorer which took care of all runs and wrote the best pose to disk

References is_scored(), score_memory_, and protocols::TR().

Referenced by next_step(), and set_raw_scores().

◆ set_similarity_penalty_threshold()

void protocols::ligand_evolution::Scorer::set_similarity_penalty_threshold ( core::Real  threshold)

Member Data Documentation

◆ base_similarity_penalty_

core::Real protocols::ligand_evolution::Scorer::base_similarity_penalty_ = 0.2
private

◆ basic_pose_

core::pose::PoseOP protocols::ligand_evolution::Scorer::basic_pose_ = nullptr
private

◆ best_pose_

core::pose::PoseOP protocols::ligand_evolution::Scorer::best_pose_ = nullptr
private

◆ current_ligand_

LigandIdentifier protocols::ligand_evolution::Scorer::current_ligand_
private

◆ current_ligand_smiles_

std::string protocols::ligand_evolution::Scorer::current_ligand_smiles_
private

Referenced by create_pose(), next_step(), and set_ligand().

◆ current_runs_

core::Size protocols::ligand_evolution::Scorer::current_runs_ = 0
private

◆ id_memory_

std::map< LigandIdentifier, std::set< core::Size > > protocols::ligand_evolution::Scorer::id_memory_
private

◆ library_

FragmentLibrary& protocols::ligand_evolution::Scorer::library_
private

◆ ligand_chain_

char protocols::ligand_evolution::Scorer::ligand_chain_ = 'X'
private

Referenced by calculate_scores(), and create_pose().

◆ loaded_score_memory_

std::map< std::string, std::map< utility::vector1< std::string >, std::map< std::string, core::Real > > > protocols::ligand_evolution::Scorer::loaded_score_memory_
private

Important! LigendIdentifier here is NOT the same as in the rest of the program. This uses the real names from reactions and reagents.

Referenced by check_memory(), get_best_loaded(), and load_scores().

◆ main_score_term_

std::string protocols::ligand_evolution::Scorer::main_score_term_
private

◆ mover_

utility::vector1< moves::MoverOP > protocols::ligand_evolution::Scorer::mover_
private

Referenced by add_mover(), and apply_movers().

◆ n_runs_

core::Size protocols::ligand_evolution::Scorer::n_runs_ = 0
private

Referenced by next_step().

◆ pose_path_

std::string protocols::ligand_evolution::Scorer::pose_path_
private

Referenced by dump_pose(), and set_pose_path().

◆ score_function_

core::scoring::ScoreFunctionOP protocols::ligand_evolution::Scorer::score_function_ = nullptr
private

◆ score_memory_

std::map< LigandIdentifier, std::map< std::string, core::Real > > protocols::ligand_evolution::Scorer::score_memory_
private

◆ score_next_

bool protocols::ligand_evolution::Scorer::score_next_ = false
private

Referenced by next_step().

◆ similarity_penalty_threshold_

core::Real protocols::ligand_evolution::Scorer::similarity_penalty_threshold_ = 0.95
private

◆ working_pose_

core::pose::PoseOP protocols::ligand_evolution::Scorer::working_pose_
private

Referenced by apply_movers(), and calculate_scores().


The documentation for this class was generated from the following files: