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

Two-way mapping from ms-run-path to protID|pepID-identifier. More...

#include <OpenMS/METADATA/IdentifierMSRunMapper.h>

Public Member Functions

 IdentifierMSRunMapper ()=default
 
 IdentifierMSRunMapper (const std::vector< ProteinIdentification > &prot_ids)
 Construct mapping from a vector of ProteinIdentifications.
 
void create (const std::vector< ProteinIdentification > &prot_ids)
 Create/update mapping from a vector of ProteinIdentifications.
 
std::string getPrimaryMSRunPath (const PeptideIdentification &pepid) const
 Get the primary MS run path for a PeptideIdentification (using id_merge_index metadata)
 
void validateMergeIndex (const PeptideIdentification &pep_id, size_t psm_index) const
 Refuse a PSM of a merged run that cannot be attributed to an origin file.
 
bool hasIdentifier (const std::string &identifier) const
 Check if the mapping contains an entry for the given identifier.
 
const std::string & getIdentifier (const StringList &ms_run_paths) const
 Get the identifier for a given MS run path list (throws if not found)
 
bool empty () const
 Check if the mapping is empty.
 
Size size () const
 Get the number of identifier mappings.
 
const StringList & getMSRunPaths (const std::string &identifier) const
 Get the MS run paths for a given identifier (returns empty list if not found)
 
std::vector< std::string > getIdentifiers () const
 Get all identifiers in this mapping.
 
bool hasRunPath (const StringList &ms_run_paths) const
 Check if the mapping contains an entry for the given MS run paths.
 
bool tryGetIdentifier (const StringList &ms_run_paths, std::string &identifier) const
 Try to get identifier for a given MS run path list (returns false if not found)
 

Private Attributes

std::map< std::string, StringList > identifier_to_msrunpath_
 
std::map< StringList, std::string > runpath_to_identifier_
 

Static Private Attributes

static const StringList empty_stringlist_
 Empty list returned by getMSRunPaths when identifier not found.
 

Detailed Description

Two-way mapping from ms-run-path to protID|pepID-identifier.

This class encapsulates the mapping between protein identification identifiers and their associated MS run paths. It is used to resolve the correct source file for peptide identifications, especially in merged identification results.

Usage example:

// Create mapping from protein identifications
IdentifierMSRunMapper mapping(protein_ids);
// Get the source file for a peptide identification
std::string source_file = mapping.getPrimaryMSRunPath(pep_id);
// Build a USI using the mapping
USI usi = pep_id.buildUSI(mapping, "PXD000561");
Two-way mapping from ms-run-path to protID|pepID-identifier.
Definition IdentifierMSRunMapper.h:51
Utility class for handling Universal Spectrum Identifiers (USI).
Definition USI.h:54
Note
The internal data structures are private to avoid exposing nested containers that are difficult to wrap in Python bindings.
See also
ProteinIdentification, PeptideIdentification

Constructor & Destructor Documentation

◆ IdentifierMSRunMapper() [1/2]

IdentifierMSRunMapper ( )
default

◆ IdentifierMSRunMapper() [2/2]

IdentifierMSRunMapper ( const std::vector< ProteinIdentification > &  prot_ids)
explicit

Construct mapping from a vector of ProteinIdentifications.

Member Function Documentation

◆ create()

void create ( const std::vector< ProteinIdentification > &  prot_ids)

Create/update mapping from a vector of ProteinIdentifications.

Referenced by MQMsms::exportFeatureMap(), and MQEvidence::exportFeatureMap().

◆ empty()

bool empty ( ) const

Check if the mapping is empty.

◆ getIdentifier()

const std::string & getIdentifier ( const StringList &  ms_run_paths) const

Get the identifier for a given MS run path list (throws if not found)

◆ getIdentifiers()

std::vector< std::string > getIdentifiers ( ) const

Get all identifiers in this mapping.

◆ getMSRunPaths()

const StringList & getMSRunPaths ( const std::string &  identifier) const

Get the MS run paths for a given identifier (returns empty list if not found)

◆ getPrimaryMSRunPath()

std::string getPrimaryMSRunPath ( const PeptideIdentification &  pepid) const

Get the primary MS run path for a PeptideIdentification (using id_merge_index metadata)

◆ hasIdentifier()

bool hasIdentifier ( const std::string &  identifier) const

Check if the mapping contains an entry for the given identifier.

◆ hasRunPath()

bool hasRunPath ( const StringList &  ms_run_paths) const

Check if the mapping contains an entry for the given MS run paths.

◆ size()

Size size ( ) const

Get the number of identifier mappings.

◆ tryGetIdentifier()

bool tryGetIdentifier ( const StringList &  ms_run_paths,
std::string &  identifier 
) const

Try to get identifier for a given MS run path list (returns false if not found)

◆ validateMergeIndex()

void validateMergeIndex ( const PeptideIdentification &  pep_id,
size_t  psm_index 
) const

Refuse a PSM of a merged run that cannot be attributed to an origin file.

A run with several spectra_data entries resolves per PSM only through id_merge_index. Without a usable one, getPrimaryMSRunPath() falls back to the run's first file, silently labelling every PSM of the run with it. Callers that use the resolved path as a key – QPX run_file_name is a primary-key component of the psm, feature and pg views – must refuse such input rather than publish it, so run this as a preflight before any output is opened.

Runs with 0 or 1 path are exempt: unmerged input has nothing to disambiguate, and resolution cannot be wrong.

Parameters
[in]pep_idThe PSM to check
[in]psm_indexOnly used to make the diagnostic locatable
Exceptions
Exception::MissingInformationif the run is merged and id_merge_index is missing, is not an integer, or is out of range

Member Data Documentation

◆ empty_stringlist_

const StringList empty_stringlist_
staticprivate

Empty list returned by getMSRunPaths when identifier not found.

◆ identifier_to_msrunpath_

std::map<std::string, StringList> identifier_to_msrunpath_
private

◆ runpath_to_identifier_

std::map<StringList, std::string> runpath_to_identifier_
private