OpenMS
Loading...
Searching...
No Matches
OPXLDataStructs.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: Eugen Netz $
6// $Authors: Eugen Netz $
7// --------------------------------------------------------------------------
8
9#pragma once
10
18#include <functional>
19//#include <numeric>
20
21namespace OpenMS
22{
49 class OPENMS_DLLAPI OPXLDataStructs
50 {
51
52 public:
53
64 {
65 CROSS = 0,
66 MONO = 1,
67 LOOP = 2,
68 NUMBER_OF_CROSS_LINK_TYPES
69 };
70
81 {
82 const AASequence *alpha = nullptr;
83 const AASequence *beta = nullptr;
84 std::pair<SignedSize, SignedSize> cross_link_position;
85 double cross_linker_mass = 0;
86 std::string cross_linker_name;
87 ResidueModification::TermSpecificity term_spec_alpha = ResidueModification::TermSpecificity::ANYWHERE;
88 ResidueModification::TermSpecificity term_spec_beta = ResidueModification::TermSpecificity::ANYWHERE;
89 int precursor_correction = 0;
90
92 {
93 if (beta && !beta->empty()) return CROSS;
94
95 if (cross_link_position.second == -1) return MONO;
96
97 return LOOP;
98 }
99
100 bool operator==(const ProteinProteinCrossLink & other) const
101 {
102 return alpha == other.alpha &&
103 beta == other.beta &&
104 cross_link_position == other.cross_link_position &&
105 cross_linker_mass == other.cross_linker_mass &&
106 cross_linker_name == other.cross_linker_name &&
107 term_spec_alpha == other.term_spec_alpha &&
108 term_spec_beta == other.term_spec_beta &&
109 precursor_correction == other.precursor_correction;
110 }
111 };
112
121 {
124
126 Size scan_index_light = 0;
127 Size scan_index_heavy = 0;
128
130 double score = 0;
131
133 Size rank = 0;
134
136 double xquest_score = 0;
137 double pre_score = 0;
138 double percTIC = 0;
139 double wTIC = 0;
140 double wTICold = 0;
141 double int_sum = 0;
142 double intsum_alpha = 0;
143 double intsum_beta = 0;
144 double total_current = 0;
145 double precursor_error_ppm = 0;
146
147 double match_odds = 0;
148 double match_odds_alpha = 0;
149 double match_odds_beta = 0;
150 double log_occupancy = 0;
151 double log_occupancy_alpha = 0;
152 double log_occupancy_beta = 0;
153 double xcorrx_max = 0;
154 double xcorrc_max = 0;
155 Size matched_linear_alpha = 0;
156 Size matched_linear_beta = 0;
157 Size matched_xlink_alpha = 0;
158 Size matched_xlink_beta = 0;
159
160 double num_iso_peaks_mean = 0;
161 double num_iso_peaks_mean_linear_alpha = 0;
162 double num_iso_peaks_mean_linear_beta = 0;
163 double num_iso_peaks_mean_xlinks_alpha = 0;
164 double num_iso_peaks_mean_xlinks_beta = 0;
165
166 double ppm_error_abs_sum_linear_alpha = 0;
167 double ppm_error_abs_sum_linear_beta = 0;
168 double ppm_error_abs_sum_xlinks_alpha = 0;
169 double ppm_error_abs_sum_xlinks_beta = 0;
170 double ppm_error_abs_sum_linear = 0;
171 double ppm_error_abs_sum_xlinks = 0;
172 double ppm_error_abs_sum_alpha = 0;
173 double ppm_error_abs_sum_beta = 0;
174 double ppm_error_abs_sum = 0;
175
176 int precursor_correction = 0;
177
178 double precursor_total_intensity = 0;
179 double precursor_target_intensity = 0;
180 double precursor_signal_proportion = 0;
181 Size precursor_target_peak_count = 0;
182 Size precursor_residual_peak_count = 0;
183
184 std::vector<PeptideHit::PeakAnnotation> frag_annotations;
185
186 Size peptide_id_index = 0;
187 };
188
194 {
195 bool operator() (const CrossLinkSpectrumMatch& a, const CrossLinkSpectrumMatch& b)
196 {
197 if (a.score == b.score)
198 {
199 // in rare cases when the sequences are the same, multiple candidates with different cross-linked positions can have the same score
200 // that leads to ambiguous sorting and may cause differences between compilers
201 // in those cases we prefer higher positions (just like the score),
202 // because the lower position might be an N-term link, which is usually less likely and all other positions are equal (because the score is equal)
204 {
206 }
208 }
209 return a.score < b.score;
210 }
211 };
212
224 {
225 float precursor_mass{};
226 unsigned int alpha_index = 0;
227 unsigned int beta_index = 0;
228 std::string alpha_seq;
229 std::string beta_seq;
230 };
231
232 // comparator for sorting XLPrecursor vectors and using upper_bound and lower_bound using only a precursor mass
239 {
240 bool operator() (const XLPrecursor& a, const XLPrecursor& b) const
241 {
242 return a.precursor_mass < b.precursor_mass;
243 }
244 bool operator() (const XLPrecursor& a, const double& b) const
245 {
246 return a.precursor_mass < b;
247 }
248 bool operator() (const double& a, const XLPrecursor& b) const
249 {
250 return a < b.precursor_mass;
251 }
252 };
253
262 {
264 C_TERM = 1,
265 N_TERM = 2
266 };
267
279 {
280 double peptide_mass = 0;
282 PeptidePosition position = PeptidePosition::INTERNAL;
283 std::string unmodified_seq;
284 };
285
292 {
293 bool operator() (const AASeqWithMass& a, const AASeqWithMass& b) const
294 {
295 return a.peptide_mass < b.peptide_mass;
296 }
297 bool operator() (const AASeqWithMass& a, const double& b) const
298 {
299 return a.peptide_mass < b;
300 }
301 bool operator() (const double& a, const AASeqWithMass& b) const
302 {
303 return a < b.peptide_mass;
304 }
305 };
306
314 {
315
319
320 // pre-initialize so we can simply std::swap the spectra (no synchronization in multi-threading context needed as we get no reallocation of the PeakMaps).
322 {
323 for (Size i = 0; i != size; ++i)
324 {
325 spectra_linear_peaks.addSpectrum(PeakSpectrum());
326 spectra_xlink_peaks.addSpectrum(PeakSpectrum());
327 spectra_all_peaks.addSpectrum(PeakSpectrum());
328 }
329 }
330 };
331
332 }; // class
333} // namespace OpenMS
334
335namespace std
336{
338 template<>
339 struct hash<OpenMS::OPXLDataStructs::ProteinProteinCrossLink>
340 {
341 std::size_t operator()(const OpenMS::OPXLDataStructs::ProteinProteinCrossLink& link) const noexcept
342 {
343 std::size_t seed = 0;
344
345 // Hash pointers (alpha and beta) - these are compared by pointer value in operator==
346 OpenMS::hash_combine(seed, OpenMS::hash_int(reinterpret_cast<std::uintptr_t>(link.alpha)));
347 OpenMS::hash_combine(seed, OpenMS::hash_int(reinterpret_cast<std::uintptr_t>(link.beta)));
348
349 // Hash cross_link_position (pair of SignedSize)
350 OpenMS::hash_combine(seed, OpenMS::hash_int(link.cross_link_position.first));
351 OpenMS::hash_combine(seed, OpenMS::hash_int(link.cross_link_position.second));
352
353 // Hash cross_linker_mass (double)
354 OpenMS::hash_combine(seed, OpenMS::hash_float(link.cross_linker_mass));
355
356 // Hash cross_linker_name (String, which is std::string)
357 OpenMS::hash_combine(seed, OpenMS::fnv1a_hash_string(link.cross_linker_name));
358
359 // Hash term_spec_alpha and term_spec_beta (enums)
360 OpenMS::hash_combine(seed, OpenMS::hash_int(static_cast<int>(link.term_spec_alpha)));
361 OpenMS::hash_combine(seed, OpenMS::hash_int(static_cast<int>(link.term_spec_beta)));
362
363 // Hash precursor_correction (int)
364 OpenMS::hash_combine(seed, OpenMS::hash_int(link.precursor_correction));
365
366 return seed;
367 }
368 };
369} // namespace std
Representation of a peptide/protein sequence.
Definition AASequence.h:88
bool empty() const
check if sequence is empty
In-Memory representation of a mass spectrometry run.
Definition MSExperiment.h:49
void addSpectrum(const MSSpectrum &spectrum)
adds a spectrum to the list
The representation of a 1D spectrum.
Definition MSSpectrum.h:44
Namespace-style container holding the data types shared across the OpenPepXL cross-linking pipeline.
Definition OPXLDataStructs.h:50
double score
final score
Definition OPXLDataStructs.h:130
std::string beta_seq
Sequence string of the beta peptide (empty for mono- or loop-links)
Definition OPXLDataStructs.h:229
std::string unmodified_seq
Plain-string view of the peptide without modifications (cached for fast comparison / lookup)
Definition OPXLDataStructs.h:283
ProteinProteinCrossLinkType
Kind of cross-linking reaction product.
Definition OPXLDataStructs.h:64
float precursor_mass
Mass of (alpha + beta + cross-linker), in Da; the key used to filter candidates against an experiment...
Definition OPXLDataStructs.h:225
AASequence peptide_seq
The peptide itself, including any modifications carried over from the digest.
Definition OPXLDataStructs.h:281
double peptide_mass
Pre-computed monoisotopic mass of peptide_seq (Da); used as the sort/search key during pair enumerati...
Definition OPXLDataStructs.h:280
ProteinProteinCrossLink cross_link
structure of the cross-link
Definition OPXLDataStructs.h:123
PeptidePosition
Where the peptide came from in its parent protein after in-silico digestion.
Definition OPXLDataStructs.h:262
std::vector< PeptideHit::PeakAnnotation > frag_annotations
Definition OPXLDataStructs.h:184
std::string alpha_seq
Sequence string of the alpha peptide (cached to avoid re-lookup during scoring)
Definition OPXLDataStructs.h:228
The AASeqWithMass struct represents a normal peptide with its precomputed mass.
Definition OPXLDataStructs.h:279
The CrossLinkSpectrumMatch struct represents a PSM between a ProteinProteinCrossLink and a spectrum i...
Definition OPXLDataStructs.h:121
The XLPrecursor struct represents a cross-link candidate in the process of filtering candidates by pr...
Definition OPXLDataStructs.h:224
TermSpecificity
Position where the modification is allowed to occur.
Definition ResidueModification.h:74
@ INTERNAL
Internal fragment (m)
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition Types.h:97
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
std::size_t hash_int(T value) noexcept
Hash for an integer type.
Definition HashUtils.h:107
void hash_combine(std::size_t &seed, std::size_t value) noexcept
Combine a hash value with additional data using golden ratio mixing.
Definition HashUtils.h:87
std::size_t hash_float(T value) noexcept
Hash for a floating point type (float or double).
Definition HashUtils.h:142
std::size_t fnv1a_hash_string(const std::string &s) noexcept
FNV-1a hash for a string.
Definition HashUtils.h:70
STL namespace.
The AASeqWithMassComparator is a comparator for AASeqWithMass objects.
Definition OPXLDataStructs.h:292
Comparator to sort CrossLinkSpectrumMatches by the main score.
Definition OPXLDataStructs.h:194
The PreprocessedPairSpectra struct represents the result of comparing a light and a heavy labeled spe...
Definition OPXLDataStructs.h:314
PreprocessedPairSpectra(Size size)
Definition OPXLDataStructs.h:321
MSExperiment spectra_all_peaks
Definition OPXLDataStructs.h:318
MSExperiment spectra_xlink_peaks
Xlink peaks in the light spectrum (linear peaks between spectra_light_different and spectra heavy_to_...
Definition OPXLDataStructs.h:317
MSExperiment spectra_linear_peaks
merge spectrum of linear peaks (present in both spectra)
Definition OPXLDataStructs.h:316
The XLPrecursorComparator is a comparator for XLPrecursors, that allows direct comparison of the XLPr...
Definition OPXLDataStructs.h:239