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
16
17#include <map>
18#include <set>
19#include <utility>
20#include <vector>
21
22namespace OpenMS
23{
24
35 class OPENMS_DLLAPI PercolatorInfile
36 {
37 public:
39 using PinFeatureMetaValueMap = std::map<std::pair<size_t, size_t>, std::set<std::string>>;
40
53 static void store(const std::string& pin_file,
54 const PeptideIdentificationList& peptide_ids,
55 const StringList& feature_set,
56 const std::string& enz,
57 int min_charge,
58 int max_charge);
59
60
88 static PeptideIdentificationList load(const std::string& pin_file,
89 bool higher_score_better,
90 const std::string& score_name,
91 const StringList& extra_scores,
92 StringList& filenames,
93 std::string decoy_prefix = "",
94 double threshold = 0.01,
95 bool SageAnnotation = false);
96
97 // uses spectrum_reference, if empty uses spectrum_id, if also empty fall back to using index
98 static std::string getScanIdentifier(const PeptideIdentification& pid, size_t index);
99
109 static std::string getFileIdentifier(const PeptideIdentification& pid);
110
117 static std::string getFileIdentifier(const PeptideIdentification& pid, UInt file_origin_index, UInt id_merge_index_index);
118
131 static StringList getStandardFeatureSet(int min_charge, int max_charge);
132
143 int min_charge, int max_charge);
144
151 static StringList getPinColumnNames(int min_charge, int max_charge);
152
190 static std::set<std::pair<size_t, size_t>> stampPinFeaturesOnHits(
191 PeptideIdentificationList& peptide_ids,
192 const std::string& enz,
193 int min_charge,
194 int max_charge);
195
211 static std::set<std::pair<size_t, size_t>> stampPinFeaturesOnHits(
212 PeptideIdentificationList& peptide_ids,
213 const std::string& enz,
214 int min_charge,
215 int max_charge,
216 PinFeatureMetaValueMap& added_meta_values);
217
235 static double getFeatureValue(const DataValue& value, const std::string& feature);
236
272 const StringList& features,
273 const std::string& enz,
274 int min_charge,
275 int max_charge,
276 RescoreInput& input,
277 std::vector<std::pair<size_t, size_t>>& rows);
278
296 const std::string& enz,
297 int min_charge,
298 int max_charge);
299
300 protected:
302 enum PinColumn_ : int
303 {
304 PIN_SPEC_ID, PIN_SCAN_NR, PIN_LABEL, PIN_CALC_MASS, PIN_EXP_MASS, PIN_DELTAMASS, PIN_RETENTIONTIME, PIN_MASS,
305 PIN_SCORE, PIN_PEPLEN, PIN_ENZ_N, PIN_ENZ_C, PIN_ENZ_INT, PIN_DM, PIN_ABSDM, PIN_PEPTIDE, PIN_PROTEINS,
306 PIN_CHARGE
307 };
308
310 enum PinLookup_ : int { LOOKUP_CALC_MASS, LOOKUP_ISOTOPE_ERROR_LEGACY, LOOKUP_ISOTOPE_ERROR };
311
314 static void warnWithoutScanNumber_(const std::vector<std::string>& without_scan, const std::vector<char>& stamped);
315
318 struct PinEnzyme_;
319
330 template <bool with_strings, typename Exists, typename Get, typename Put>
331 static double pinHitColumns_(const PeptideHit& hit, bool decoy, const std::string& spec_id, Int scan_number,
332 double exp_mass, double retention_time, const PinEnzyme_& enz, int min_charge, int max_charge,
333 Exists&& exists, Get&& get, Put&& put);
334
335 //id <tab> label <tab> scannr <tab> calcmass <tab> expmass <tab> feature1 <tab> ... <tab> featureN <tab> peptide <tab> proteinId1 <tab> .. <tab> proteinIdM
337 const PeptideIdentificationList& peptide_ids,
338 const StringList& feature_set,
339 const std::string& enz,
340 int min_charge,
341 int max_charge);
342
343 static bool isEnz_(const char& n, const char& c, const std::string& enz);
344
345 static Size countEnzymatic_(const std::string& peptide, const std::string& enz);
346
347 };
348} // 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:36
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:39
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 StringList getFeatureSet(const ProteinIdentification::SearchParameters &search_parameters, int min_charge, int max_charge)
The feature columns of the .pin file of the PSMs of a search run: getStandardFeatureSet(),...
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:303
@ PIN_ABSDM
Definition PercolatorInfile.h:305
@ PIN_CALC_MASS
Definition PercolatorInfile.h:304
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:310
@ LOOKUP_CALC_MASS
Definition PercolatorInfile.h:310
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
Search parameters of the DB search.
Definition ProteinIdentification.h:194
Input to domain-agnostic Percolator::rescore.
Definition PercolatorTypes.h:28