OpenMS
Loading...
Searching...
No Matches
PercolatorInfile.h
Go to the documentation of this file.
1// Copyright (c) 2002-present, OpenMS Inc. -- EKU Tuebingen, ETH Zurich, and FU Berlin
2// SPDX-License-Identifier: BSD-3-Clause
3//
4// --------------------------------------------------------------------------
5// $Maintainer: Timo Sachsenberg $
6// $Authors: Timo Sachsenberg $
7// --------------------------------------------------------------------------
8
9#pragma once
10
15
16#include <map>
17#include <set>
18#include <utility>
19#include <vector>
20
21namespace OpenMS
22{
23
34 class OPENMS_DLLAPI PercolatorInfile
35 {
36 public:
38 using PinFeatureMetaValueMap = std::map<std::pair<size_t, size_t>, std::set<std::string>>;
39
52 static void store(const std::string& pin_file,
53 const PeptideIdentificationList& peptide_ids,
54 const StringList& feature_set,
55 const std::string& enz,
56 int min_charge,
57 int max_charge);
58
59
87 static PeptideIdentificationList load(const std::string& pin_file,
88 bool higher_score_better,
89 const std::string& score_name,
90 const StringList& extra_scores,
91 StringList& filenames,
92 std::string decoy_prefix = "",
93 double threshold = 0.01,
94 bool SageAnnotation = false);
95
96 // uses spectrum_reference, if empty uses spectrum_id, if also empty fall back to using index
97 static std::string getScanIdentifier(const PeptideIdentification& pid, size_t index);
98
108 static std::string getFileIdentifier(const PeptideIdentification& pid);
109
116 static std::string getFileIdentifier(const PeptideIdentification& pid, UInt file_origin_index, UInt id_merge_index_index);
117
129 static StringList getStandardFeatureSet(int min_charge, int max_charge);
130
137 static StringList getPinColumnNames(int min_charge, int max_charge);
138
176 static std::set<std::pair<size_t, size_t>> stampPinFeaturesOnHits(
177 PeptideIdentificationList& peptide_ids,
178 const std::string& enz,
179 int min_charge,
180 int max_charge);
181
197 static std::set<std::pair<size_t, size_t>> stampPinFeaturesOnHits(
198 PeptideIdentificationList& peptide_ids,
199 const std::string& enz,
200 int min_charge,
201 int max_charge,
202 PinFeatureMetaValueMap& added_meta_values);
203
221 static double getFeatureValue(const DataValue& value, const std::string& feature);
222
258 const StringList& features,
259 const std::string& enz,
260 int min_charge,
261 int max_charge,
262 RescoreInput& input,
263 std::vector<std::pair<size_t, size_t>>& rows);
264
282 const std::string& enz,
283 int min_charge,
284 int max_charge);
285
286 protected:
288 enum PinColumn_ : int
289 {
290 PIN_SPEC_ID, PIN_SCAN_NR, PIN_LABEL, PIN_CALC_MASS, PIN_EXP_MASS, PIN_DELTAMASS, PIN_RETENTIONTIME, PIN_MASS,
291 PIN_SCORE, PIN_PEPLEN, PIN_ENZ_N, PIN_ENZ_C, PIN_ENZ_INT, PIN_DM, PIN_ABSDM, PIN_PEPTIDE, PIN_PROTEINS,
292 PIN_CHARGE
293 };
294
296 enum PinLookup_ : int { LOOKUP_CALC_MASS, LOOKUP_ISOTOPE_ERROR_LEGACY, LOOKUP_ISOTOPE_ERROR };
297
300 static void warnWithoutScanNumber_(const std::vector<std::string>& without_scan, const std::vector<char>& stamped);
301
304 struct PinEnzyme_;
305
316 template <bool with_strings, typename Exists, typename Get, typename Put>
317 static double pinHitColumns_(const PeptideHit& hit, bool decoy, const std::string& spec_id, Int scan_number,
318 double exp_mass, double retention_time, const PinEnzyme_& enz, int min_charge, int max_charge,
319 Exists&& exists, Get&& get, Put&& put);
320
321 //id <tab> label <tab> scannr <tab> calcmass <tab> expmass <tab> feature1 <tab> ... <tab> featureN <tab> peptide <tab> proteinId1 <tab> .. <tab> proteinIdM
323 const PeptideIdentificationList& peptide_ids,
324 const StringList& feature_set,
325 const std::string& enz,
326 int min_charge,
327 int max_charge);
328
329 static bool isEnz_(const char& n, const char& c, const std::string& enz);
330
331 static Size countEnzymatic_(const std::string& peptide, const std::string& enz);
332
333 };
334} // namespace OpenMS
Class to hold strings, numeric values, lists of strings and lists of numeric values.
Definition DataValue.h:33
Represents a single spectrum match (candidate) for a specific tandem mass spectrum (MS/MS).
Definition PeptideHit.h:52
Container for peptide identifications from multiple spectra.
Definition PeptideIdentificationList.h:66
Represents the set of candidates (SpectrumMatches) identified for a single precursor spectrum.
Definition PeptideIdentification.h:66
Class for storing Percolator tab-delimited input files.
Definition PercolatorInfile.h:35
static double getFeatureValue(const DataValue &value, const std::string &feature)
Numeric value of a PIN feature, as the percolator executable reads it.
static double pinHitColumns_(const PeptideHit &hit, bool decoy, const std::string &spec_id, Int scan_number, double exp_mass, double retention_time, const PinEnzyme_ &enz, int min_charge, int max_charge, Exists &&exists, Get &&get, Put &&put)
The PIN columns of one hit: the formulas of the .pin file, shared by stamping and buildFeatureMatrix.
static Size countEnzymatic_(const std::string &peptide, const std::string &enz)
static void store(const std::string &pin_file, const PeptideIdentificationList &peptide_ids, const StringList &feature_set, const std::string &enz, int min_charge, int max_charge)
Writes the PSMs of peptide_ids as a Percolator input file.
std::map< std::pair< size_t, size_t >, std::set< std::string > > PinFeatureMetaValueMap
PIN meta values added to each hit, keyed by (peptide ID index, hit index).
Definition PercolatorInfile.h:38
static std::string getScanIdentifier(const PeptideIdentification &pid, size_t index)
static TextFile preparePin_(const PeptideIdentificationList &peptide_ids, const StringList &feature_set, const std::string &enz, int min_charge, int max_charge)
static std::string getFileIdentifier(const PeptideIdentification &pid, UInt file_origin_index, UInt id_merge_index_index)
getFileIdentifier() with the registry indices of 'file_origin' and 'id_merge_index' looked up once (M...
static bool isEnz_(const char &n, const char &c, const std::string &enz)
static Size buildFeatureMatrix(const PeptideIdentificationList &peptide_ids, const StringList &features, const std::string &enz, int min_charge, int max_charge, RescoreInput &input, std::vector< std::pair< size_t, size_t > > &rows)
The feature matrix of in-process rescoring: the PIN columns of the PSMs as Percolator reads them from...
static std::set< std::pair< size_t, size_t > > stampPinFeaturesOnHits(PeptideIdentificationList &peptide_ids, const std::string &enz, int min_charge, int max_charge)
Compute and stamp PIN-equivalent meta values on every PeptideHit.
static StringList getPinColumnNames(int min_charge, int max_charge)
The names of all PIN columns (meta values) that stampPinFeaturesOnHits sets on a hit.
static void refreshPinMetaValues(PeptideIdentificationList &peptide_ids, const std::string &enz, int min_charge, int max_charge)
Sets the PIN columns that the hits already carry as meta values to their PIN values,...
static void warnWithoutScanNumber_(const std::vector< std::string > &without_scan, const std::vector< char > &stamped)
static std::string getFileIdentifier(const PeptideIdentification &pid)
The spectrum file of a PSM: its 'file_origin' (empty if not set), followed by '|' and its 'id_merge_i...
PinColumn_
Fixed PIN columns as computed by pinHitColumns_ (the charge{N} columns follow from PIN_CHARGE on)
Definition PercolatorInfile.h:289
@ PIN_ABSDM
Definition PercolatorInfile.h:291
@ PIN_CALC_MASS
Definition PercolatorInfile.h:290
static StringList getStandardFeatureSet(int min_charge, int max_charge)
Returns the standard Percolator feature columns every .pin file should declare.
static PeptideIdentificationList load(const std::string &pin_file, bool higher_score_better, const std::string &score_name, const StringList &extra_scores, StringList &filenames, std::string decoy_prefix="", double threshold=0.01, bool SageAnnotation=false)
Loads peptide identifications from a Percolator input file.
static std::set< std::pair< size_t, size_t > > stampPinFeaturesOnHits(PeptideIdentificationList &peptide_ids, const std::string &enz, int min_charge, int max_charge, PinFeatureMetaValueMap &added_meta_values)
Compute and stamp PIN-equivalent meta values, recording newly added keys.
PinLookup_
Meta values of a hit that pinHitColumns_ reads.
Definition PercolatorInfile.h:296
@ LOOKUP_CALC_MASS
Definition PercolatorInfile.h:296
Definition TextFile.h:21
int Int
Signed integer type.
Definition Types.h:72
unsigned int UInt
Unsigned integer type.
Definition Types.h:64
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition Types.h:97
std::vector< std::string > StringList
Vector of String.
Definition TypeAliases.h:39
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
Input to domain-agnostic Percolator::rescore.
Definition PercolatorTypes.h:28