| OpenMS 2.5.0

AScore.h
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
2 // OpenMS -- Open-Source Mass Spectrometry
3 // --------------------------------------------------------------------------
4 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5 // ETH Zurich, and Freie Universitaet Berlin 2002-2020.
6 //
7 // This software is released under a three-clause BSD license:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of any author or any participating institution
14 // may be used to endorse or promote products derived from this software
15 // without specific prior written permission.
16 // For a full list of authors, refer to the file AUTHORS.
17 // --------------------------------------------------------------------------
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // --------------------------------------------------------------------------
31 // $Maintainer: Petra Gutenbrunner $
32 // $Authors: David Wojnar, Timo Sachsenberg, Petra Gutenbrunner $
33 // --------------------------------------------------------------------------
34
35 #pragma once
36
37 #include <OpenMS/CONCEPT/Types.h>
38 #include <OpenMS/DATASTRUCTURES/DefaultParamHandler.h>
39 #include <OpenMS/DATASTRUCTURES/String.h>
40 #include <OpenMS/KERNEL/StandardTypes.h>
41 #include <OpenMS/KERNEL/MSSpectrum.h>
42 #include <OpenMS/ANALYSIS/RNPXL/PScore.h>
43
44 #include <limits>
45 #include <vector>
46
47 namespace OpenMS
48 {
49 class PeptideHit;
50 class AASequence;
51
52 struct ProbablePhosphoSites
53 {
54 Size first;
55 Size second;
56 Size seq_1;
57 Size seq_2;
58 Size peak_depth;
59 Size AScore;
60 };
61
70 class OPENMS_DLLAPI AScore: public DefaultParamHandler
71 {
72 friend struct PScore;
73
74 public:
76 AScore();
77
79 ~AScore() override;
80
91 PeptideHit compute(const PeptideHit& hit, PeakSpectrum& real_spectrum);
92
93 protected:
94 int compareMZ_(double mz1, double mz2) const;
95
99 template <class InputIterator1, class InputIterator2, class OutputIterator>
100 OutputIterator getSpectrumDifference_(InputIterator1 first1, InputIterator1 last1,
101 InputIterator2 first2, InputIterator2 last2, OutputIterator result) const
102 {
103 while (first1 != last1 && first2 != last2)
104 {
105 double mz1 = first1->getMZ();
106 double mz2 = first2->getMZ();
107 int val = compareMZ_(mz1, mz2);
108
109 if (val == -1)
110 {
111 *result = *first1;
112 ++result;
113 ++first1;
114 }
115 else if (val == 1)
116 {
117 ++first2;
118 }
119 else // check if more ions are within the same tolerance. If so, these can not be site determining ions
120 {
121 //check mz2 until no match
122 ++first2;
123 if (first2 != last2)
124 {
125 int ret = compareMZ_(mz1, first2->getMZ());
126 while (ret == 0 && first2 != last2)
127 {
128 ++first2;
129 ret = compareMZ_(mz1, first2->getMZ());
130 }
131 }
132
133 //check mz1 until no match
134 ++first1;
135 if (first1 != last1)
136 {
137 int ret = compareMZ_(first1->getMZ(), mz2);
138 while (ret == 0 && first1 != last1)
139 {
140 ++first1;
141 ret = compareMZ_(first1->getMZ(), mz2);
142 }
143 }
144 }
145 }
146 return std::copy(first1, last1, result);
147 }
148
150 void computeSiteDeterminingIons_(const std::vector<PeakSpectrum>& th_spectra, const ProbablePhosphoSites& candidates, std::vector<PeakSpectrum>& site_determining_ions) const;
151
153 std::vector<Size> getSites_(const AASequence& without_phospho) const;
154
156 std::vector<std::vector<Size>> computePermutations_(const std::vector<Size>& sites, Int n_phosphorylation_events) const;
157
159 Size numberOfMatchedIons_(const PeakSpectrum& th, const PeakSpectrum& windows, Size depth) const;
160
162 double peptideScore_(const std::vector<double>& scores) const;
163
168 void determineHighestScoringPermutations_(const std::vector<std::vector<double>>& peptide_site_scores, std::vector<ProbablePhosphoSites>& sites, const std::vector<std::vector<Size>>& permutations, std::multimap<double, Size>& ranking) const;
169
171 double computeBaseProbability_(double ppm_reference_mz) const;
172
174 double computeCumulativeScore_(Size N, Size n, double p) const;
175
177 Size numberOfPhosphoEvents_(const String& sequence) const;
178
180 AASequence removePhosphositesFromSequence_(const String& sequence) const;
181
183 std::vector<PeakSpectrum> createTheoreticalSpectra_(const std::vector<std::vector<Size>>& permutations, const AASequence& seq_without_phospho) const;
184
186 std::vector<PeakSpectrum> peakPickingPerWindowsInSpectrum_(PeakSpectrum& real_spectrum) const;
187
189 std::vector<std::vector<double>> calculatePermutationPeptideScores_(std::vector<PeakSpectrum>& th_spectra, const std::vector<PeakSpectrum>& windows_top10) const;
190
192 std::multimap<double, Size> rankWeightedPermutationPeptideScores_(const std::vector<std::vector<double>>& peptide_site_scores) const;
193
195 void updateMembers_() override;
196
197 // variables:
198 double fragment_mass_tolerance_;
199 bool fragment_tolerance_ppm_;
200 Size max_peptide_length_;
201 Size max_permutations_;
202 double unambiguous_score_;
203 double base_match_probability_;
204
205 };
206
207 } // namespace OpenMS
208
209
OpenMS::PScore
Implementation of the PScore PSM scoring algorithm.
Definition: PScore.h:49
OpenMS::String
A more convenient string class.
Definition: String.h:58
OpenMS::DefaultParamHandler
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:91
OpenMS::ProbablePhosphoSites::AScore
Size AScore
Definition: AScore.h:59
OpenMS::ProbablePhosphoSites::seq_2
Size seq_2
index of permutation with site in unphosphorylated state
Definition: AScore.h:57
OpenMS::ProbablePhosphoSites
Definition: AScore.h:52
StandardTypes.h
OpenMS::AScore::fragment_tolerance_ppm_
bool fragment_tolerance_ppm_
Is fragment mass tolerance given in ppm (or Da)?
Definition: AScore.h:199
OpenMS::AScore::getSpectrumDifference_
OutputIterator getSpectrumDifference_(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator result) const
Definition: AScore.h:100
Types.h
PScore.h
OpenMS::AScore::unambiguous_score_
double unambiguous_score_
Score for unambiguous assignments (all sites phosphorylated)
Definition: AScore.h:202
OpenMS::ProbablePhosphoSites::first
Size first
Definition: AScore.h:54
OpenMS::AASequence
Representation of a peptide/protein sequence.
Definition: AASequence.h:113
OpenMS::MSSpectrum
The representation of a 1D spectrum.
Definition: MSSpectrum.h:67
String.h
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
OpenMS::PeptideHit
Representation of a peptide hit.
Definition: PeptideHit.h:54
OpenMS::AScore::fragment_mass_tolerance_
double fragment_mass_tolerance_
Fragment mass tolerance for spectrum comparisons.
Definition: AScore.h:198
OpenMS::AScore::base_match_probability_
double base_match_probability_
Probability of a match at a peak depth of 1.
Definition: AScore.h:203
OpenMS::AScore::max_permutations_
Size max_permutations_
Limit for number of sequence permutations that can be handled.
Definition: AScore.h:201
DefaultParamHandler.h
MSSpectrum.h
OpenMS::AScore
Implementation of the Ascore For a given peptide sequence and its MS/MS spectrum it identifies the mo...
Definition: AScore.h:70
int
OpenMS::AScore::max_peptide_length_
Size max_peptide_length_
Limit for peptide lengths that can be analyzed.
Definition: AScore.h:200
OpenMS::ProbablePhosphoSites::second
Size second
Definition: AScore.h:55
OpenMS::ProbablePhosphoSites::seq_1
Size seq_1
index of best permutation with site in phosphorylated state
Definition: AScore.h:56
OpenMS::ProbablePhosphoSites::peak_depth
Size peak_depth
filtering level that gave rise to maximum discriminatory score
Definition: AScore.h:58
OpenMS::Size
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127