Rosetta  2020.37
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
core::chemical::ResidueTypeSetCache Class Reference

#include <ResidueTypeSetCache.hh>

Inheritance diagram for core::chemical::ResidueTypeSetCache:
Inheritance graph
[legend]

Public Member Functions

 ResidueTypeSetCache (ResidueTypeSet const &rsd_type_set)
 
 ~ResidueTypeSetCache () override
 
ResidueTypeSetCacheOP clone (ResidueTypeSet const &rsd_type_set) const
 
ResidueTypeCOP name_map (std::string const &name_in) const
 
ResidueTypeCOP name_map_or_null (std::string const &name_in) const
 
void add_residue_type (ResidueTypeCOP residue_type)
 
void add_pass_through (ResidueTypeCOP residue_type)
 Add a ResidueType to the cache which isn't strictly in the associated ResidueTypeSet, but is included here for efficiency/convenience. More...
 
bool is_pass_through (std::string const &name_in)
 Is the ResidueType one of the pass-through convenience types? More...
 
void remove_residue_type (std::string const &name)
 
void update_residue_type (ResidueTypeCOP residue_type_original, ResidueTypeCOP residue_type_new)
 
bool has_generated_residue_type (ResidueTypeCOP rsd_type) const
 
bool has_generated_residue_type (std::string const &rsd_name) const
 
void add_prohibited (std::string const &rsd_name)
 
bool is_prohibited (std::string const &rsd_name) const
 
bool all_types_with_variants_aa_already_cached (AA aa, utility::vector1< std::string > const &variants, utility::vector1< VariantType > const &exceptions) const
 Returns whether or not the all_types_with_variants_aa map already has an entry for the given combination of aa, variants, and exceptions. If so, then the cached data may be directly retrieved. More...
 
void cache_all_types_with_variants_aa (AA aa, utility::vector1< std::string > const &variants, utility::vector1< VariantType > const &exceptions, ResidueTypeCOPs cached_types)
 
ResidueTypeCOPs retrieve_all_types_with_variants_aa (AA aa, utility::vector1< std::string > const &variants, utility::vector1< VariantType > const &exceptions) const
 
bool all_types_with_variants_residuetypecops_already_cached (ResidueTypeCOP base_type, utility::vector1< VariantType > const &variants, utility::vector1< std::string > const &variant_strings, utility::vector1< VariantType > const &exceptions, bool const no_metapatches) const
 Have we already cached this combination of base type, variants, and exceptions? More...
 
void cache_all_types_with_variants_residuetypecops (ResidueTypeCOP base_type, utility::vector1< VariantType > const &variants, utility::vector1< std::string > const &variant_strings, utility::vector1< VariantType > const &exceptions, bool const no_metapatches, ResidueTypeCOPs const &types_to_cache)
 Cache this combination of base type, variants, and exceptions. More...
 
ResidueTypeCOPs retrieve_all_types_with_variants_residuetypecops (ResidueTypeCOP base_type, utility::vector1< VariantType > const &variants, utility::vector1< std::string > const &variant_strings, utility::vector1< VariantType > const &exceptions, bool const no_metapatches) const
 Retrieve this combination of base type, variants, and exceptions. NOTE THAT THIS ASSUMES THIS INFORMATION WAS ALREADY CACHED! More...
 
void clear_cached_maps ()
 
bool maps_up_to_date () const
 The RTSC performs just-in-time updates on data members that are accessed through two of its methods – before calling these methods, the ResidueTypeSet may need to obtain a write lock on the RTSC. Thse are: More...
 
std::map< std::string,
std::set< std::string >
> const & 
name3_generated_by_base_residue_name ()
 information on residue types whose name3's can be changed by patches. More...
 
std::map< std::string,
std::set< std::string >
> const & 
interchangeability_group_generated_by_base_residue_name ()
 interchangeability groups that appear upon patch application. More...
 
bool has_restype_with_name3 (std::string const &name3) const
 Does this cache already have a residue with the given name3 This is likely to be slow, as it looks at all the generated residue types. More...
 

Private Member Functions

void regenerate_cached_maps ()
 
 ResidueTypeSetCache ()=delete
 
 ResidueTypeSetCache (ResidueTypeSetCache const &)=delete
 

Private Attributes

ResidueTypeSet const & rsd_type_set_
 
std::map< std::string,
ResidueTypeCOP
name_map_
 map to ResidueType pointers by unique residue id More...
 
std::set< std::string > pass_throughs_
 ResidueTypes which don't directly belong to the associated ResidueTypeSet, but are included in the cache for efficiency. More...
 
std::set< std::string > prohibited_types_
 annotation about types which theoretically may exist but we don't want More...
 
std::map
< AA_VariantsExceptions,
ResidueTypeCOPs
cached_aa_variants_map_
 map to ResidueType pointers by AA enum – may deprecate soon. More...
 
std::map
< Restype_Variants_VariantStrings_Exceptions,
ResidueTypeCOPs
cached_restype_variants_map_
 Caching queries based on ResidueTypeCOP and variants to avoid recomputation with ResidueTypeFinder. More...
 
bool cache_up_to_date_ = false
 True if the (batch) computed cached data is up to date. More...
 
std::map< std::string,
std::set< std::string > > 
name3_generated_by_base_residue_name_
 information on residue types whose name3's can be changed by patches. More...
 
std::map< std::string,
std::set< std::string > > 
interchangeability_group_generated_by_base_residue_name_
 interchangeability groups that appear upon patch application. More...
 

Constructor & Destructor Documentation

core::chemical::ResidueTypeSetCache::ResidueTypeSetCache ( ResidueTypeSet const &  rsd_type_set)
core::chemical::ResidueTypeSetCache::~ResidueTypeSetCache ( )
overridedefault
core::chemical::ResidueTypeSetCache::ResidueTypeSetCache ( )
privatedelete

Referenced by clone().

core::chemical::ResidueTypeSetCache::ResidueTypeSetCache ( ResidueTypeSetCache const &  )
privatedelete

Member Function Documentation

void core::chemical::ResidueTypeSetCache::add_pass_through ( ResidueTypeCOP  residue_type)

Add a ResidueType to the cache which isn't strictly in the associated ResidueTypeSet, but is included here for efficiency/convenience.

Must be write-locked by calling function

References add_residue_type(), and pass_throughs_.

void core::chemical::ResidueTypeSetCache::add_prohibited ( std::string const &  rsd_name)

Needs to be write-locked by calling function

References prohibited_types_.

void core::chemical::ResidueTypeSetCache::add_residue_type ( ResidueTypeCOP  residue_type)

Must be write-locked by calling function

References name_map_, and core::chemical::TR().

Referenced by add_pass_through().

bool core::chemical::ResidueTypeSetCache::all_types_with_variants_aa_already_cached ( AA  aa,
utility::vector1< std::string > const &  variants,
utility::vector1< VariantType > const &  exceptions 
) const

Returns whether or not the all_types_with_variants_aa map already has an entry for the given combination of aa, variants, and exceptions. If so, then the cached data may be directly retrieved.

References cached_aa_variants_map_.

bool core::chemical::ResidueTypeSetCache::all_types_with_variants_residuetypecops_already_cached ( ResidueTypeCOP  base_type,
utility::vector1< VariantType > const &  variants,
utility::vector1< std::string > const &  variant_strings,
utility::vector1< VariantType > const &  exceptions,
bool const  no_metapatches 
) const

Have we already cached this combination of base type, variants, and exceptions?

Note
This function is not threadsafe. It is assumed that thread locking will be handled by whatever is calling this.
Parameters
[in]base_typeA ResidueTypeCOP to a base residue type, used for looking up the variant.
[in]variantsA list of VariantTypes that the returned ResidueTypes must have, used for looking up the variant.
[in]variant_stringsA list of custom VariantTypes (that don't have enums) that the returned ResidueTypes must have, used for looking up the variant.
[in]exceptionsA list of VariantTypes that are ignored in matching.
[in]no_metapatchesIf true, metapatches are ignored.
Returns
TRUE if we have cached this combination, FALSE otherwise.
Author
Vikram K. Mulligan (vmull.nosp@m.igan.nosp@m.@flat.nosp@m.iron.nosp@m.insti.nosp@m.tute.nosp@m..org).

References cached_restype_variants_map_.

void core::chemical::ResidueTypeSetCache::cache_all_types_with_variants_aa ( AA  aa,
utility::vector1< std::string > const &  variants,
utility::vector1< VariantType > const &  exceptions,
ResidueTypeCOPs  cached_types 
)
void core::chemical::ResidueTypeSetCache::cache_all_types_with_variants_residuetypecops ( ResidueTypeCOP  base_type,
utility::vector1< VariantType > const &  variants,
utility::vector1< std::string > const &  variant_strings,
utility::vector1< VariantType > const &  exceptions,
bool const  no_metapatches,
ResidueTypeCOPs const &  types_to_cache 
)

Cache this combination of base type, variants, and exceptions.

Note
This function is not threadsafe. It is assumed that thread locking will be handled by whatever is calling this.
Parameters
[in]base_typeA ResidueTypeCOP to a base residue type, used for looking up the variant.
[in]variantsA list of VariantTypes that the returned ResidueTypes must have, used for looking up the variant.
[in]variant_stringsA list of custom VariantTypes (that don't have enums) that the returned ResidueTypes must have, used for looking up the variant.
[in]exceptionsA list of VariantTypes that are ignored in matching.
[in]no_metapatchesIf true, metapatches are ignored.
[in]types_to_cacheA vector of ResidueTypeCOPs to associate with the key defined by the five variables above.
Returns
Nothing.
Author
Vikram K. Mulligan (vmull.nosp@m.igan.nosp@m.@flat.nosp@m.iron.nosp@m.insti.nosp@m.tute.nosp@m..org).

References cached_restype_variants_map_.

void core::chemical::ResidueTypeSetCache::clear_cached_maps ( )
ResidueTypeSetCacheOP core::chemical::ResidueTypeSetCache::clone ( ResidueTypeSet const &  rsd_type_set) const
bool core::chemical::ResidueTypeSetCache::has_generated_residue_type ( ResidueTypeCOP  residue_type) const

Must be read-locked by calling function

References name_map_.

bool core::chemical::ResidueTypeSetCache::has_generated_residue_type ( std::string const &  rsd_name) const

Must be read-locked by calling function

References name_map_.

bool core::chemical::ResidueTypeSetCache::has_restype_with_name3 ( std::string const &  name3) const

Does this cache already have a residue with the given name3 This is likely to be slow, as it looks at all the generated residue types.

References name_map_, and core::scoring::pair.

std::map< std::string, std::set< std::string > > const & core::chemical::ResidueTypeSetCache::interchangeability_group_generated_by_base_residue_name ( )

interchangeability groups that appear upon patch application.

To call this function, the ResidueTypeSet will need to obtain a write lock if the maps_up_to_date function returns false. Otherwise, a read lock will suffice.

References cache_up_to_date_, interchangeability_group_generated_by_base_residue_name_, and regenerate_cached_maps().

bool core::chemical::ResidueTypeSetCache::is_pass_through ( std::string const &  name_in)

Is the ResidueType one of the pass-through convenience types?

Must be read-locked by calling function

References pass_throughs_.

bool core::chemical::ResidueTypeSetCache::is_prohibited ( std::string const &  rsd_name) const

Needs to be read-locked by calling function

References prohibited_types_.

bool core::chemical::ResidueTypeSetCache::maps_up_to_date ( ) const
inline

The RTSC performs just-in-time updates on data members that are accessed through two of its methods – before calling these methods, the ResidueTypeSet may need to obtain a write lock on the RTSC. Thse are:

  • name3_generated_by_base_residue_name, and
  • interchangeability_group_generated_by_base_residue_name

References cache_up_to_date_.

std::map< std::string, std::set< std::string > > const & core::chemical::ResidueTypeSetCache::name3_generated_by_base_residue_name ( )

information on residue types whose name3's can be changed by patches.

To call this function, the ResidueTypeSet will need to obtain a write lock if the maps_up_to_date function returns false. Otherwise, a read lock will suffice.

References cache_up_to_date_, name3_generated_by_base_residue_name_, and regenerate_cached_maps().

ResidueTypeCOP core::chemical::ResidueTypeSetCache::name_map ( std::string const &  name_in) const

Main accessor function into ResidueTypeSetCache

Main accessor function into ResidueTypeSetCache. Must be read locked by calling function.

References name_map_.

ResidueTypeCOP core::chemical::ResidueTypeSetCache::name_map_or_null ( std::string const &  name_in) const

Like name_map, but returns a nullptr rather than raising an error if the entry can't be found

Must be read locked by calling function.

References name_map_.

void core::chemical::ResidueTypeSetCache::regenerate_cached_maps ( )
private

following assumes that all new name3 and interchangeability groups for residue types can be discovered by applying patches to base residue types – i.e. on the 'first patch'. Probably should set up a runtime_assert in ResidueTypeFinder to check this assumption.

References core::chemical::ResidueTypeSet::base_residue_types(), cache_up_to_date_, interchangeability_group_generated_by_base_residue_name_, name3_generated_by_base_residue_name_, core::chemical::ResidueTypeSet::patches(), and rsd_type_set_.

Referenced by interchangeability_group_generated_by_base_residue_name(), and name3_generated_by_base_residue_name().

void core::chemical::ResidueTypeSetCache::remove_residue_type ( std::string const &  name)

Danger Danger Danger. Unsafe in a multi-threaded environment.

References clear_cached_maps(), name_map_, and pass_throughs_.

ResidueTypeCOPs core::chemical::ResidueTypeSetCache::retrieve_all_types_with_variants_aa ( AA  aa,
utility::vector1< std::string > const &  variants,
utility::vector1< VariantType > const &  exceptions 
) const
ResidueTypeCOPs core::chemical::ResidueTypeSetCache::retrieve_all_types_with_variants_residuetypecops ( ResidueTypeCOP  base_type,
utility::vector1< VariantType > const &  variants,
utility::vector1< std::string > const &  variant_strings,
utility::vector1< VariantType > const &  exceptions,
bool const  no_metapatches 
) const

Retrieve this combination of base type, variants, and exceptions. NOTE THAT THIS ASSUMES THIS INFORMATION WAS ALREADY CACHED!

Note
This function is not threadsafe. It is assumed that thread locking will be handled by whatever is calling this.
Parameters
[in]base_typeA ResidueTypeCOP to a base residue type, used for looking up the variant.
[in]variantsA list of VariantTypes that the returned ResidueTypes must have, used for looking up the variant.
[in]variant_stringsA list of custom VariantTypes (that don't have enums) that the returned ResidueTypes must have, used for looking up the variant.
[in]exceptionsA list of VariantTypes that are ignored in matching.
[in]no_metapatchesIf true, metapatches are ignored.
Returns
A vector of ResidueTypeCOPs with the given base type and the associated variant types.
Author
Vikram K. Mulligan (vmull.nosp@m.igan.nosp@m.@flat.nosp@m.iron.nosp@m.insti.nosp@m.tute.nosp@m..org).

References cached_restype_variants_map_.

void core::chemical::ResidueTypeSetCache::update_residue_type ( ResidueTypeCOP  residue_type_original,
ResidueTypeCOP  residue_type_new 
)

Danger Danger Danger. Unsafe in a multi-threaded environment

References clear_cached_maps(), and name_map_.

Member Data Documentation

bool core::chemical::ResidueTypeSetCache::cache_up_to_date_ = false
private
std::map< AA_VariantsExceptions, ResidueTypeCOPs > core::chemical::ResidueTypeSetCache::cached_aa_variants_map_
private

map to ResidueType pointers by AA enum – may deprecate soon.

map to ResidueType pointers by 3-letter string name – may deprecate soon. caching queries based on aa & variants to avoid recomputation with ResidueTypeFinder

Referenced by all_types_with_variants_aa_already_cached(), cache_all_types_with_variants_aa(), clear_cached_maps(), and retrieve_all_types_with_variants_aa().

std::map< Restype_Variants_VariantStrings_Exceptions, ResidueTypeCOPs > core::chemical::ResidueTypeSetCache::cached_restype_variants_map_
private

Caching queries based on ResidueTypeCOP and variants to avoid recomputation with ResidueTypeFinder.

The key is a tuple of < BASE residue type COP, included variant list (enum and string), excluded variant list (enum and string) >.

Author
Vikram K. Mulligan (vmull.nosp@m.igan.nosp@m.@flat.nosp@m.iron.nosp@m.insti.nosp@m.tute.nosp@m..org).

Referenced by all_types_with_variants_residuetypecops_already_cached(), cache_all_types_with_variants_residuetypecops(), clear_cached_maps(), and retrieve_all_types_with_variants_residuetypecops().

std::map< std::string, std::set< std::string > > core::chemical::ResidueTypeSetCache::interchangeability_group_generated_by_base_residue_name_
private

interchangeability groups that appear upon patch application.

Referenced by clear_cached_maps(), interchangeability_group_generated_by_base_residue_name(), and regenerate_cached_maps().

std::map< std::string, std::set< std::string > > core::chemical::ResidueTypeSetCache::name3_generated_by_base_residue_name_
private

information on residue types whose name3's can be changed by patches.

Referenced by clear_cached_maps(), name3_generated_by_base_residue_name(), and regenerate_cached_maps().

std::map< std::string, ResidueTypeCOP > core::chemical::ResidueTypeSetCache::name_map_
private
std::set< std::string > core::chemical::ResidueTypeSetCache::pass_throughs_
private

ResidueTypes which don't directly belong to the associated ResidueTypeSet, but are included in the cache for efficiency.

Referenced by add_pass_through(), clone(), is_pass_through(), and remove_residue_type().

std::set< std::string > core::chemical::ResidueTypeSetCache::prohibited_types_
private

annotation about types which theoretically may exist but we don't want

For example, for PDB components which duplicate standard types.

Referenced by add_prohibited(), clone(), and is_prohibited().

ResidueTypeSet const& core::chemical::ResidueTypeSetCache::rsd_type_set_
private

Referenced by regenerate_cached_maps().


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