Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
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-2017.
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 #ifndef OPENMS_ANALYSIS_ID_ASCORE_H
36 #define OPENMS_ANALYSIS_ID_ASCORE_H
37 
38 #include <OpenMS/CONCEPT/Types.h>
43 
44 #include <limits>
45 #include <vector>
46 
47 namespace OpenMS
48 {
49 class PeptideHit;
50 class AASequence;
52 {
55  Size seq_1; // index of best permutation with site in phosphorylated state
56  Size seq_2; // index of permutation with site in unphosphorylated state
57  Size peak_depth; // filtering level that gave rise to maximum discriminatory score
59 };
67 class OPENMS_DLLAPI AScore
68 {
69  friend struct PScore;
70  public:
72  AScore();
73 
75  ~AScore();
76 
87  PeptideHit compute(const PeptideHit & hit, PeakSpectrum &real_spectrum, double fragment_mass_tolerance, bool fragment_mass_unit_ppm, Size max_peptide_len = 60, Size max_num_perm = 16384);
88 
89  protected:
90  int compareMZ_(double mz1, double mz2, double fragment_mass_tolerance, bool fragment_mass_unit_ppm) const;
91 
95  template <class InputIterator1, class InputIterator2, class OutputIterator>
96  OutputIterator getSpectrumDifference_(InputIterator1 first1, InputIterator1 last1,
97  InputIterator2 first2, InputIterator2 last2, OutputIterator result, double fragment_mass_tolerance, bool fragment_mass_unit_ppm) const
98  {
99  while (first1 != last1 && first2 != last2)
100  {
101  double mz1 = first1->getMZ();
102  double mz2 = first2->getMZ();
103  int val = compareMZ_(mz1, mz2, fragment_mass_tolerance, fragment_mass_unit_ppm);
104 
105  if (val == -1)
106  {
107  *result = *first1;
108  ++result;
109  ++first1;
110  }
111  else if (val == 1)
112  {
113  ++first2;
114  }
115  else // check if more ions are within the same tolerance. If so, these can not be site determining ions
116  {
117  //check mz2 until no match
118  ++first2;
119  if (first2 != last2)
120  {
121  int ret = compareMZ_(mz1, first2->getMZ(), fragment_mass_tolerance, fragment_mass_unit_ppm);
122  while (ret == 0 && first2 != last2)
123  {
124  ++first2;
125  ret = compareMZ_(mz1, first2->getMZ(), fragment_mass_tolerance, fragment_mass_unit_ppm);
126  }
127  }
128 
129  //check mz1 until no match
130  ++first1;
131  if (first1 != last1)
132  {
133  int ret = compareMZ_(first1->getMZ(), mz2, fragment_mass_tolerance, fragment_mass_unit_ppm);
134  while (ret == 0 && first1 != last1)
135  {
136  ++first1;
137  ret = compareMZ_(first1->getMZ(), mz2, fragment_mass_tolerance, fragment_mass_unit_ppm);
138  }
139  }
140  }
141  }
142  return std::copy(first1, last1, result);
143  }
144 
146  void computeSiteDeterminingIons_(const std::vector<PeakSpectrum> & th_spectra, const ProbablePhosphoSites & candidates, std::vector<PeakSpectrum> & site_determining_ions, double fragment_mass_tolerance, bool fragment_mass_unit_ppm) const;
147 
149  std::vector<Size> getSites_(const AASequence & without_phospho) const;
150 
152  std::vector<std::vector<Size> > computePermutations_(const std::vector<Size> & sites, Int n_phosphorylation_events) const;
153 
155  Size numberOfMatchedIons_(const PeakSpectrum & th, const PeakSpectrum & windows, Size depth, double fragment_mass_tolerance, bool fragment_mass_tolerance_ppm = false) const;
156 
158  double peptideScore_(const std::vector<double> & scores) const;
159 
164  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;
165 
167  double computeCumulativeScore_(Size N, Size n, double p) const;
168 
170  Size numberOfPhosphoEvents_(const String sequence) const;
171 
173  AASequence removePhosphositesFromSequence_(const String sequence) const;
174 
176  std::vector<PeakSpectrum> createTheoreticalSpectra_(const std::vector<std::vector<Size> > & permutations, const AASequence & seq_without_phospho) const;
177 
179  std::vector<PeakSpectrum> peakPickingPerWindowsInSpectrum_(PeakSpectrum & real_spectrum) const;
180 
182  std::vector<std::vector<double> > calculatePermutationPeptideScores_(std::vector<PeakSpectrum> & th_spectra, const std::vector<PeakSpectrum> & windows_top10, double fragment_mass_tolerance, bool fragment_mass_unit_ppm) const;
183 
185  std::multimap<double, Size> rankWeightedPermutationPeptideScores_(const std::vector<std::vector<double> > & peptide_site_scores) const;
186 };
187 
188 } // namespace OpenMS
189 
190 #endif // OPENMS_ANALYSIS_ID_ASCORE_H
191 
Implementation of the Ascore For a given peptide sequence and its MS/MS spectrum it identifies the mo...
Definition: AScore.h:67
A more convenient string class.
Definition: String.h:57
Size first
Definition: AScore.h:53
Size second
Definition: AScore.h:54
OutputIterator getSpectrumDifference_(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator result, double fragment_mass_tolerance, bool fragment_mass_unit_ppm) const
Definition: AScore.h:96
Representation of a peptide/protein sequence.
Definition: AASequence.h:108
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
Size peak_depth
Definition: AScore.h:57
The representation of a 1D spectrum.
Definition: MSSpectrum.h:67
Representation of a peptide hit.
Definition: PeptideHit.h:55
Size seq_1
Definition: AScore.h:55
Implementation of the PScore PSM scoring algorithm.
Definition: PScore.h:50
Definition: AScore.h:51
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:128
Size seq_2
Definition: AScore.h:56
int Int
Signed integer type.
Definition: Types.h:103
Size AScore
Definition: AScore.h:58

OpenMS / TOPP release 2.3.0 Documentation generated on Tue Jan 9 2018 18:21:59 using doxygen 1.8.13