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
121 static StringList getStandardFeatureSet(int min_charge, int max_charge);
122
129 static StringList getPinColumnNames(int min_charge, int max_charge);
130
168 static std::set<std::pair<size_t, size_t>> stampPinFeaturesOnHits(
169 PeptideIdentificationList& peptide_ids,
170 const std::string& enz,
171 int min_charge,
172 int max_charge);
173
189 static std::set<std::pair<size_t, size_t>> stampPinFeaturesOnHits(
190 PeptideIdentificationList& peptide_ids,
191 const std::string& enz,
192 int min_charge,
193 int max_charge,
194 PinFeatureMetaValueMap& added_meta_values);
195
213 static double getFeatureValue(const DataValue& value, const std::string& feature);
214
250 const StringList& features,
251 const std::string& enz,
252 int min_charge,
253 int max_charge,
254 RescoreInput& input,
255 std::vector<std::pair<size_t, size_t>>& rows);
256
274 const std::string& enz,
275 int min_charge,
276 int max_charge);
277
278 protected:
280 enum PinColumn_ : int
281 {
282 PIN_SPEC_ID, PIN_SCAN_NR, PIN_LABEL, PIN_CALC_MASS, PIN_EXP_MASS, PIN_DELTAMASS, PIN_RETENTIONTIME, PIN_MASS,
283 PIN_SCORE, PIN_PEPLEN, PIN_ENZ_N, PIN_ENZ_C, PIN_ENZ_INT, PIN_DM, PIN_ABSDM, PIN_PEPTIDE, PIN_PROTEINS,
284 PIN_CHARGE
285 };
286
288 enum PinLookup_ : int { LOOKUP_CALC_MASS, LOOKUP_ISOTOPE_ERROR_LEGACY, LOOKUP_ISOTOPE_ERROR };
289
292 static void warnWithoutScanNumber_(const std::vector<std::string>& without_scan, const std::vector<char>& stamped);
293
296 struct PinEnzyme_;
297
308 template <bool with_strings, typename Exists, typename Get, typename Put>
309 static double pinHitColumns_(const PeptideHit& hit, bool decoy, const std::string& spec_id, Int scan_number,
310 double exp_mass, double retention_time, const PinEnzyme_& enz, int min_charge, int max_charge,
311 Exists&& exists, Get&& get, Put&& put);
312
313 //id <tab> label <tab> scannr <tab> calcmass <tab> expmass <tab> feature1 <tab> ... <tab> featureN <tab> peptide <tab> proteinId1 <tab> .. <tab> proteinIdM
315 const PeptideIdentificationList& peptide_ids,
316 const StringList& feature_set,
317 const std::string& enz,
318 int min_charge,
319 int max_charge);
320
321 static bool isEnz_(const char& n, const char& c, const std::string& enz);
322
323 static Size countEnzymatic_(const std::string& peptide, const std::string& enz);
324
325 };
326} // 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 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:281
@ PIN_ABSDM
Definition PercolatorInfile.h:283
@ PIN_CALC_MASS
Definition PercolatorInfile.h:282
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:288
@ LOOKUP_CALC_MASS
Definition PercolatorInfile.h:288
Definition TextFile.h:21
int Int
Signed integer type.
Definition Types.h:72
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