OpenMS
Loading...
Searching...
No Matches
ResidueDB Class Reference

OpenMS stores a central database of all residues in the ResidueDB. All (unmodified) residues are added to the database on construction. Modified residues get created and added if getModifiedResidue is called. More...

#include <OpenMS/CHEMISTRY/ResidueDB.h>

Collaboration diagram for ResidueDB:
[legend]

Public Member Functions

Constructors and Destructors
virtual ~ResidueDB ()
 destructor
 
Accessors
Size getNumberOfResidues () const
 returns the number of residues stored
 
Size getNumberOfModifiedResidues () const
 returns the number of modified residues stored
 
const ResiduegetResidue (const std::string &name) const
 returns a pointer to the residue with name, 3 letter code or 1 letter code name
 
const ResiduegetResidue (const unsigned char &one_letter_code) const
 returns a pointer to the residue with 1 letter code name
 
const ResiduegetModifiedResidue (const std::string &name) const
 Returns a pointer to a modified residue given a modification name.
 
const ResiduegetModifiedResidue (const Residue *residue, const std::string &name) const
 Returns a pointer to a modified residue given a residue and a modification name.
 
const ResiduegetModifiedResidue (const Residue *residue, const ResidueModification *mod) const
 Returns a pointer to a modified residue given a residue and a pointer to a modification from the ModificationsDB.
 
const std::set< const Residue * > getResidues (const std::string &residue_set="All") const
 returns a set of all residues stored in this residue db
 
const std::set< std::string > getResidueSets () const
 returns all residue sets that are registered which this instance
 

Static Public Member Functions

static const ResidueDBgetInstance ()
 singleton
 

Protected Member Functions

Private Constructors
 ResidueDB ()
 default constructor
 
 ResidueDB (const ResidueDB &residue_db)
 copy constructor
 

Assignment

std::map< std::string, std::map< std::string, const Residue * > > residue_mod_names_
 cache of name -> modification-name -> modified residue (lazily filled by getModifiedResidue)
 
std::set< const Residue * > const_residues_
 all (unmodified) residues
 
std::set< const Residue * > const_modified_residues_
 all modified residues (lazily filled by getModifiedResidue)
 
std::set< std::string > residue_sets_
 
std::unordered_map< std::string, const Residue * > residue_names_
 lookup from name to residue
 
std::array< const Residue *, 256 > residue_by_one_letter_code_ = {{nullptr}}
 fast lookup table for residues

 
std::map< std::string, std::set< const Residue * > > residues_by_set_
 
ResidueDBoperator= (const ResidueDB &aa)=delete
 assignment operator
 
void buildResidues_ ()
 
void insertResidueAndAssociateWithResidueSet_ (Residue *residue, const std::vector< std::string > &residue_sets)
 creates and adds residues to a lookup table including the residue set
 
void addModifiedResidue_ (Residue *residue) const
 
void addResidueNames_ (const Residue *)
 adds names of single residue to the index
 
void addModifiedResidueNames_ (const Residue *) const
 adds names of single modified residue to the index
 

Predicates

bool hasResidue (const std::string &name) const
 returns true if the db contains a residue with the given name
 
bool hasResidue (const Residue *residue) const
 returns true if the db contains the residue of the given pointer
 
void initResidues_ ()
 initializes all residues by building
 

Detailed Description

OpenMS stores a central database of all residues in the ResidueDB. All (unmodified) residues are added to the database on construction. Modified residues get created and added if getModifiedResidue is called.

Note
The database is immutable from a caller's perspective: getInstance() returns a const pointer and every public accessor is const. getModifiedResidue() does lazily create and cache modified residues, but this is a transparent memoization (the same inputs always yield the same result); the cache members are therefore declared mutable and the mutation is internally synchronized (see the ResidueDB OpenMP critical section). No public method changes the observable state of the singleton.

Constructor & Destructor Documentation

◆ ~ResidueDB()

virtual ~ResidueDB ( )
virtual

destructor

◆ ResidueDB() [1/2]

ResidueDB ( )
protected

default constructor

◆ ResidueDB() [2/2]

ResidueDB ( const ResidueDB residue_db)
protected

copy constructor

Member Function Documentation

◆ addModifiedResidue_()

void addModifiedResidue_ ( Residue residue) const
protected

lazily register a freshly created modified residue and its names in the cache (logically const memoization; only the mutable cache members are touched)

◆ addModifiedResidueNames_()

void addModifiedResidueNames_ ( const Residue ) const
protected

adds names of single modified residue to the index

◆ addResidueNames_()

void addResidueNames_ ( const Residue )
protected

adds names of single residue to the index

◆ buildResidues_()

void buildResidues_ ( )
protected

◆ getInstance()

static const ResidueDB * getInstance ( )
static

singleton

◆ getModifiedResidue() [1/3]

const Residue * getModifiedResidue ( const Residue residue,
const ResidueModification mod 
) const

Returns a pointer to a modified residue given a residue and a pointer to a modification from the ModificationsDB.

The modified residue is added to the database if it doesn't exist yet. The origin of the modification has to match the residue and the term has to be ResidueModification::Anywhere.

Exceptions
Exception::IllegalArgumentif the residue was not found

◆ getModifiedResidue() [2/3]

const Residue * getModifiedResidue ( const Residue residue,
const std::string &  name 
) const

Returns a pointer to a modified residue given a residue and a modification name.

The modified residue is added to the database if it doesn't exist yet.

Exceptions
Exception::IllegalArgumentif the residue was not found
Exception::InvalidValueif no matching modification was found (via ModificationsDB::getModification)

◆ getModifiedResidue() [3/3]

const Residue * getModifiedResidue ( const std::string &  name) const

Returns a pointer to a modified residue given a modification name.

The "base" residue is looked up in ModificationsDB using the modification name. The modified residue is added to the database if it doesn't exist yet.

Note
Logically const: the lazily created modified residue is memoized in the (mutable) cache; repeated calls return the same pointer.

◆ getNumberOfModifiedResidues()

Size getNumberOfModifiedResidues ( ) const

returns the number of modified residues stored

◆ getNumberOfResidues()

Size getNumberOfResidues ( ) const

returns the number of residues stored

◆ getResidue() [1/2]

const Residue * getResidue ( const std::string &  name) const

returns a pointer to the residue with name, 3 letter code or 1 letter code name

◆ getResidue() [2/2]

const Residue * getResidue ( const unsigned char &  one_letter_code) const

returns a pointer to the residue with 1 letter code name

◆ getResidues()

const std::set< const Residue * > getResidues ( const std::string &  residue_set = "All") const

returns a set of all residues stored in this residue db

Following sets are available: All - all residues Natural20 - default 20 naturally occurring residues Natural19WithoutI - default natural amino acids, excluding isoleucine (isobaric to leucine) Natural19WithoutL - default natural amino acids, excluding leucine (isobaric to isoleucine) Natural19J - default natural amino acids, (isobaric leucine/isoleucine are marked by 'J') AmbiguousWithoutX - all amino acids, including ambiguous ones: B (asparagine or aspartate), Z (glutamine or glutamate), J (isoleucine or leucine) Ambiguous - all amino acids including all ambiguous ones (X can be every other amino acid) AllNatural - naturally occurring residues, including selenocysteine (U)

returns an empty set if the specified residue set is not defined

◆ getResidueSets()

const std::set< std::string > getResidueSets ( ) const

returns all residue sets that are registered which this instance

◆ hasResidue() [1/2]

bool hasResidue ( const Residue residue) const

returns true if the db contains the residue of the given pointer

◆ hasResidue() [2/2]

bool hasResidue ( const std::string &  name) const

returns true if the db contains a residue with the given name

◆ initResidues_()

void initResidues_ ( )
protected

initializes all residues by building

◆ insertResidueAndAssociateWithResidueSet_()

void insertResidueAndAssociateWithResidueSet_ ( Residue residue,
const std::vector< std::string > &  residue_sets 
)
protected

creates and adds residues to a lookup table including the residue set

◆ operator=()

ResidueDB & operator= ( const ResidueDB aa)
protecteddelete

assignment operator

Member Data Documentation

◆ const_modified_residues_

std::set<const Residue*> const_modified_residues_
mutableprotected

all modified residues (lazily filled by getModifiedResidue)

◆ const_residues_

std::set<const Residue*> const_residues_
protected

all (unmodified) residues

◆ residue_by_one_letter_code_

std::array<const Residue*, 256> residue_by_one_letter_code_ = {{nullptr}}
protected

fast lookup table for residues

◆ residue_mod_names_

std::map<std::string, std::map<std::string, const Residue*> > residue_mod_names_
mutableprotected

cache of name -> modification-name -> modified residue (lazily filled by getModifiedResidue)

◆ residue_names_

std::unordered_map<std::string, const Residue*> residue_names_
protected

lookup from name to residue

◆ residue_sets_

std::set<std::string> residue_sets_
protected

◆ residues_by_set_

std::map<std::string, std::set<const Residue*> > residues_by_set_
protected