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

Inference engine for PeptDeep MS2 Fragment Intensity prediction. More...

#include <OpenMS/ML/PEPTDEEP/PeptDeepMS2Inference.h>

Public Types

enum  Channel : size_t { B_Z1 = 0 , B_Z2 = 1 , Y_Z1 = 2 , Y_Z2 = 3 }
 The channels of a cleavage position: [b_z1, b_z2, y_z1, y_z2, b_modloss_z1, b_modloss_z2, y_modloss_z1, y_modloss_z2]. More...
 

Public Member Functions

 PeptDeepMS2Inference (const std::string &model_path, int threads=4, size_t batch_size=500)
 Constructor initializes the ONNX session with the specified model graph.
 
 ~PeptDeepMS2Inference ()
 Destructor.
 
std::vector< std::vector< float > > predictMS2 (const std::vector< std::string > &peptides, const std::vector< float > &charges, const std::vector< float > &nces, const std::vector< int64_t > &instrument_indices)
 Predicts MS2 fragment intensities for a batch of peptide sequences.
 

Static Public Member Functions

static size_t ionIndex (size_t length, char type, size_t ordinal, int charge, size_t channels=ION_CHANNELS)
 The index into a prediction of predictMS2() of the b or y ion of a peptide.
 

Static Public Attributes

static constexpr size_t ION_CHANNELS = 8
 The values per cleavage position of a prediction of predictMS2(), in this order (Channel)
 
static constexpr size_t NO_ION = static_cast<size_t>(-1)
 ionIndex() of an ion the prediction does not have
 

Private Attributes

ONNXPredictorBase model_
 
size_t batch_size_
 

Detailed Description

Inference engine for PeptDeep MS2 Fragment Intensity prediction.

This class parses and tokenizes raw peptide string sequences into structural integer arrays and evaluates them through the ONNX Runtime backend to predict fragment intensities.

Member Enumeration Documentation

◆ Channel

enum Channel : size_t

The channels of a cleavage position: [b_z1, b_z2, y_z1, y_z2, b_modloss_z1, b_modloss_z2, y_modloss_z1, y_modloss_z2].

Enumerator
B_Z1 
B_Z2 
Y_Z1 
Y_Z2 

Constructor & Destructor Documentation

◆ PeptDeepMS2Inference()

PeptDeepMS2Inference ( const std::string &  model_path,
int  threads = 4,
size_t  batch_size = 500 
)
explicit

Constructor initializes the ONNX session with the specified model graph.

Parameters
model_pathAbsolute or relative path to the PeptDeep MS2 ONNX model file.
threadsThe model runs (of at most batch_size peptides of one length each) that run at once, each on one thread (default 4).
batch_sizeMaximum number of peptides to process in a single ONNX run (default 500).
Exceptions
Exception::BaseExceptionif the model file cannot be found or loaded by the runtime.

◆ ~PeptDeepMS2Inference()

Destructor.

Member Function Documentation

◆ ionIndex()

static size_t ionIndex ( size_t  length,
char  type,
size_t  ordinal,
int  charge,
size_t  channels = ION_CHANNELS 
)
static

The index into a prediction of predictMS2() of the b or y ion of a peptide.

Cleavage position pos (0-based) carries b(pos + 1) and y(length - 1 - pos), with channels values each.

Parameters
lengthThe peptide's length (residues)
type'b' or 'y'
ordinalThe ion's ordinal, 1 to length - 1
charge1 or 2
channelsThe values per cleavage position (ION_CHANNELS, unless a model has another layout)
Returns
The index, NO_ION for another ion type, ordinal or charge

◆ predictMS2()

std::vector< std::vector< float > > predictMS2 ( const std::vector< std::string > &  peptides,
const std::vector< float > &  charges,
const std::vector< float > &  nces,
const std::vector< int64_t > &  instrument_indices 
)

Predicts MS2 fragment intensities for a batch of peptide sequences.

Parameters
peptidesA vector of peptide strings. Supports OpenMS AASequence modification notation (e.g., "PEPTIDEK", "M(Oxidation)PEP").
chargesA vector of precursor charge states (must match peptides size).
ncesA vector of normalized collision energies (must match peptides size).
instrument_indicesOne peptdeep instrument index per peptide. Derive these with ML::instrumentIndex() rather than writing literals: the encoding is positional and belongs to peptdeep (ML::ALPHAPEPTDEEP_INSTRUMENTS), where 0 is QE and 1 is Lumos. Indices outside [0, ML::PEPTDEEP_MAX_INSTRUMENT_NUM) are rejected, because the model's OneHot would otherwise answer them with an all-off row.
Returns
A vector of flattened fragment intensity arrays, one for each peptide. Each cleavage position contains eight contiguous AlphaPeptDeep channels in this order: [b_z1, b_z2, y_z1, y_z2, b_modloss_z1, b_modloss_z2, y_modloss_z1, y_modloss_z2].
Exceptions
Exception::IllegalArgumentif peptides is empty, size constraints fail, or a sequence is chemically invalid.

Member Data Documentation

◆ batch_size_

size_t batch_size_
private

◆ ION_CHANNELS

constexpr size_t ION_CHANNELS = 8
staticconstexpr

The values per cleavage position of a prediction of predictMS2(), in this order (Channel)

◆ model_

ONNXPredictorBase model_
private

◆ NO_ION

constexpr size_t NO_ION = static_cast<size_t>(-1)
staticconstexpr

ionIndex() of an ion the prediction does not have