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

Process-wide singleton database of cross-linking modifications. More...

#include <OpenMS/CHEMISTRY/CrossLinksDB.h>

Inheritance diagram for CrossLinksDB:
[legend]
Collaboration diagram for CrossLinksDB:
[legend]

Public Member Functions

void getAllSearchModifications (std::vector< std::string > &modifications) const
 Returns the IDs of all cross-linker modifications that are usable for identification searches (i.e. carry a PSI-MOD accession).
 
- Public Member Functions inherited from ModificationsDB
 ModificationsDB (std::vector< std::unique_ptr< ModificationDataProvider > > providers)
 Construct from data providers (no file I/O performed by this constructor).
 
virtual ~ModificationsDB ()
 Destructor (public so non-singleton instances created via provider constructor can be destroyed)
 
Size getNumberOfModifications () const
 Returns the number of modifications read from the unimod.xml file.
 
const ResidueModification * getModification (Size index) const
 Returns the modification with the given index. note: out-of-bounds check is only performed in debug mode.
 
void searchModifications (std::set< const ResidueModification * > &mods, const std::string &mod_name, const std::string &residue="", ResidueModification::TermSpecificity term_spec=ResidueModification::NUMBER_OF_TERM_SPECIFICITY) const
 Collects all modifications which have the given name as synonym.
 
const ResidueModification * searchModification (const ResidueModification &mod_in) const
 Returns a pointer to an exact match of the given modification if present in the DB.
 
const ResidueModification * searchModificationsFast (const std::string &mod_name, bool &multiple_matches, const std::string &residue="", ResidueModification::TermSpecificity term_spec=ResidueModification::NUMBER_OF_TERM_SPECIFICITY) const
 Returns the modification which has the given name as synonym (fast version)
 
const ResidueModification * getModification (const std::string &mod_name, const std::string &residue="", ResidueModification::TermSpecificity term_spec=ResidueModification::NUMBER_OF_TERM_SPECIFICITY) const
 Returns the modification with the given name.
 
bool has (const std::string &modification) const
 Returns true if the modification exists.
 
const ResidueModification * addModification (std::unique_ptr< ResidueModification > new_mod) const
 Add a new modification to ModificationsDB. If the modification already exists (based on its fullID) it is not added.
 
const ResidueModification * addModification (const ResidueModification &new_mod) const
 Add a new modification to ModificationsDB. If the modification already exists (based on its fullID) it is not added. A copy will be made on the heap and added to the ModificationsDB otherwise.
 
Size findModificationIndex (const std::string &mod_name) const
 Returns the index of the modification in the mods_ vector; a unique name must be given.
 
void searchModificationsByDiffMonoMass (std::vector< std::string > &mods, double mass, double max_error, const std::string &residue="", ResidueModification::TermSpecificity term_spec=ResidueModification::NUMBER_OF_TERM_SPECIFICITY) const
 Collects all modifications with delta mass inside a tolerance window.
 
void searchModificationsByDiffMonoMass (std::vector< const ResidueModification * > &mods, double mass, double max_error, const std::string &residue="", ResidueModification::TermSpecificity term_spec=ResidueModification::NUMBER_OF_TERM_SPECIFICITY) const
 
void searchModificationsByDiffMonoMassSorted (std::vector< std::string > &mods, double mass, double max_error, const std::string &residue="", ResidueModification::TermSpecificity term_spec=ResidueModification::NUMBER_OF_TERM_SPECIFICITY) const
 Collects all modifications with delta mass inside a tolerance window and adds them sorted by mass difference.
 
void searchModificationsByDiffMonoMassSorted (std::vector< const ResidueModification * > &mods, double mass, double max_error, const std::string &residue="", ResidueModification::TermSpecificity term_spec=ResidueModification::NUMBER_OF_TERM_SPECIFICITY) const
 
const ResidueModification * getBestModificationByDiffMonoMass (double mass, double max_error, const std::string &residue="", ResidueModification::TermSpecificity term_spec=ResidueModification::NUMBER_OF_TERM_SPECIFICITY) const
 Returns the best matching modification for the given delta mass and residue.
 
void getAllSearchModifications (std::vector< std::string > &modifications) const
 Collects all modifications that can be used for identification searches.
 
void writeTSV (const std::string &filename) const
 Writes tab separated entries: FullId,FullName,Origin,AA,TerminusSpecificity,DiffMonoMass (including header) to TSV file.
 

Static Public Member Functions

static const CrossLinksDB * getInstance ()
 Returns the process-wide singleton instance.
 
- Static Public Member Functions inherited from ModificationsDB
static const ModificationsDB * getInstance ()
 
static const ModificationsDB * initializeModificationsDB (std::string unimod_file="CHEMISTRY/unimod.xml", std::string custommod_file="CHEMISTRY/custom_mods.xml", std::string psimod_file="CHEMISTRY/PSI-MOD.obo", std::string xlmod_file="CHEMISTRY/XLMOD.obo")
 Initializes the modification DB with non-default modification files (can only be done once)
 
static bool isInstantiated ()
 Check whether ModificationsDB was instantiated before.
 

Private Member Functions

Constructors and Destructors
 CrossLinksDB ()
 Private default constructor: parses the XLMOD ontology and forwards the resulting providers to ModificationsDB. Called once via getInstance.
 
 CrossLinksDB (const CrossLinksDB &residue_db)
 Private copy constructor (singleton — copying is not permitted).
 
 ~CrossLinksDB () override
 Destructor. Never invoked in practice because the singleton is allocated with new and outlives the process.
 

Assignment

CrossLinksDB & operator= (const CrossLinksDB &aa)
 Private assignment operator (singleton — assignment is not permitted).
 
static std::vector< std::unique_ptr< ModificationDataProvider > > makeCrossLinkProviders_ ()
 Builds the OBO data provider list used by the base-class constructor. Loads CHEMISTRY/XLMOD.obo with the cross_links_only flag set.
 

Additional Inherited Members

- Protected Member Functions inherited from ModificationsDB
bool residuesMatch_ (const char residue, const ResidueModification *curr_mod) const
 Helper function to check if a residue matches the origin for a modification.
 
- Protected Attributes inherited from ModificationsDB
std::vector< ResidueModification * > mods_
 Stores the modifications (mutable: the singleton interns runtime-encountered mods through a const API; see getInstance())
 
std::unordered_map< std::string, std::set< const ResidueModification * > > modification_names_
 Stores the mappings of (unique) names to the modifications (mutable; see mods_)
 
- Static Protected Attributes inherited from ModificationsDB
static bool is_instantiated_
 Stores whether ModificationsDB was instantiated before.
 

Detailed Description

Process-wide singleton database of cross-linking modifications.

CrossLinksDB is a specialization of ModificationsDB that loads cross-linker definitions from the PSI XLMOD ontology (CHEMISTRY/XLMOD.obo, shipped with OpenMS) instead of the general-purpose UniMod/PSI-MOD modifications. It exposes the same lookup, iteration, and matching interface as the base class but its underlying pool contains only entries flagged as cross-links by the OBO provider.

Singleton model

Like ModificationsDB, CrossLinksDB is a singleton: there is at most one instance per process. Obtain it via getInstance — the constructors, destructor, and assignment operator are intentionally private so callers cannot create additional copies. Loading of the XLMOD ontology happens once on the first call to getInstance.

Typical use

// Use any ModificationsDB API to look up cross-linkers by name,
// origin, mass, or accession:
const ResidueModification* mod = db->getModification("DSS");
// Or enumerate the searchable subset for ID-search UIs:
std::vector<String> ids;
db->getAllSearchModifications(ids);
static const CrossLinksDB * getInstance()
Returns the process-wide singleton instance.
Definition CrossLinksDB.h:70
Representation of a modification on an amino acid residue.
Definition ResidueModification.h:55

Currently in OpenMS this database is used by MzIdentMLHandler when serialising cross-link identifications, by the pyOpenMS chemistry bindings, and by tests; new cross-link search algorithms should pull their candidate modification list from here rather than from the general ModificationsDB.

See also
ModificationsDB

Constructor & Destructor Documentation

◆ CrossLinksDB() [1/2]

CrossLinksDB ( )
private

Private default constructor: parses the XLMOD ontology and forwards the resulting providers to ModificationsDB. Called once via getInstance.

◆ CrossLinksDB() [2/2]

CrossLinksDB ( const CrossLinksDB &  residue_db)
private

Private copy constructor (singleton — copying is not permitted).

◆ ~CrossLinksDB()

~CrossLinksDB ( )
overrideprivate

Destructor. Never invoked in practice because the singleton is allocated with new and outlives the process.

Member Function Documentation

◆ getAllSearchModifications()

void getAllSearchModifications ( std::vector< std::string > &  modifications) const

Returns the IDs of all cross-linker modifications that are usable for identification searches (i.e. carry a PSI-MOD accession).

The list is sorted ascending and contains ResidueModification::getFullId values, suitable for offering to the user in a search-engine GUI dropdown or for passing to a cross-link-aware search engine.

Parameters
[out]modificationsSorted list of search-eligible modification full-IDs. Any previous contents are cleared.

◆ getInstance()

static const CrossLinksDB * getInstance ( )
inlinestatic

Returns the process-wide singleton instance.

First call lazily constructs the instance and populates it from CHEMISTRY/XLMOD.obo. Subsequent calls return the same pointer. The returned pointer is owned by the database and must not be deleted by the caller.

◆ makeCrossLinkProviders_()

static std::vector< std::unique_ptr< ModificationDataProvider > > makeCrossLinkProviders_ ( )
staticprivate

Builds the OBO data provider list used by the base-class constructor. Loads CHEMISTRY/XLMOD.obo with the cross_links_only flag set.

◆ operator=()

CrossLinksDB & operator= ( const CrossLinksDB &  aa)
private

Private assignment operator (singleton — assignment is not permitted).