libpappsomspp
Library for mass spectrometry
xic.cpp
Go to the documentation of this file.
1 /*
2  * *******************************************************************************
3  * * Copyright (c) 2015 Olivier Langella <Olivier.Langella@moulon.inra.fr>.
4  * *
5  * * This file is part of MassChroqPRM.
6  * *
7  * * MassChroqPRM is free software: you can redistribute it and/or modify
8  * * it under the terms of the GNU General Public License as published by
9  * * the Free Software Foundation, either version 3 of the License, or
10  * * (at your option) any later version.
11  * *
12  * * MassChroqPRM is distributed in the hope that it will be useful,
13  * * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * * GNU General Public License for more details.
16  * *
17  * * You should have received a copy of the GNU General Public License
18  * * along with MassChroqPRM. If not, see <http://www.gnu.org/licenses/>.
19  * *
20  * * Contributors:
21  * * Olivier Langella <Olivier.Langella@moulon.inra.fr> - initial API and
22  * implementation
23  * ******************************************************************************/
24 
25 #include <QDebug>
26 #include "xic.h"
27 #include <algorithm>
28 #include <cmath>
29 #include "../exception/exceptionoutofrange.h"
30 
31 namespace pappso
32 {
33 
34 
36 {
37  qDebug() << "Xic::Xic begin";
38  qDebug() << "Xic::Xic end";
39 }
40 
42 {
43 }
44 
45 
48 {
49  return std::make_shared<const Xic>(*this);
50 }
51 
52 XicSPtr
54 {
55  return std::make_shared<Xic>(*this);
56 }
57 
58 void
60 {
61  for(auto &&peak : *this)
62  {
63  qDebug() << "rt = " << peak.x << ", int = " << peak.y;
64  }
65 }
66 
67 const DataPoint &
69 {
70  for(auto &&peak : *this)
71  {
72  if(peak.y == rt)
73  return peak;
74  }
75  throw ExceptionOutOfRange(
76  QObject::tr("no intensity for this retention time"));
77 }
78 
79 unsigned int
81 {
82  if(rt_first > rt_second)
83  {
84  std::swap(rt_first, rt_second);
85  }
86  unsigned int distance = 0;
87  auto it = this->begin();
88  auto itend = this->end();
89 
90  while((it->x < rt_first) && (it != itend))
91  {
92  it++;
93  }
94  while((rt_second > it->x) && (it != itend))
95  {
96  qDebug() << "Xic::getMsPointDistance " << rt_first << " it->rt " << it->x
97  << " rt_second " << rt_second << distance;
98  distance++;
99  it++;
100  }
101 
102 
103  return distance;
104 }
105 
106 void
108 {
109  sortX();
110 }
111 
112 } // namespace pappso
pappso::pappso_double
double pappso_double
A type definition for doubles.
Definition: types.h:48
pappso::XicSPtr
std::shared_ptr< Xic > XicSPtr
Definition: xic.h:39
pappso
tries to keep as much as possible monoisotopes, removing any possible C13 peaks
Definition: aa.cpp:39
xic.h
pappso::DataPoint
Definition: datapoint.h:21
pappso::Xic::atRetentionTime
const DataPoint & atRetentionTime(pappso_double rt) const
get the DataPoint at the given retention time
Definition: xic.cpp:68
pappso::Xic::sortByRetentionTime
void sortByRetentionTime()
sort peaks by retention time
Definition: xic.cpp:107
pappso::ExceptionOutOfRange
Definition: exceptionoutofrange.h:32
pappso::XicCstSPtr
std::shared_ptr< const Xic > XicCstSPtr
Definition: xic.h:37
pappso::Trace::sortX
void sortX()
Definition: trace.cpp:790
pappso::Xic::makeXicSPtr
XicSPtr makeXicSPtr() const
Definition: xic.cpp:53
pappso::Xic::debugPrintValues
void debugPrintValues() const
Definition: xic.cpp:59
pappso::Xic::~Xic
virtual ~Xic()
Definition: xic.cpp:41
pappso::Xic::makeXicCstSPtr
XicCstSPtr makeXicCstSPtr() const
Definition: xic.cpp:47
pappso::Xic::getMsPointDistance
unsigned int getMsPointDistance(pappso_double rt, pappso_double rt_other) const
get the number of MS measurement between 2 retention times on this xic
Definition: xic.cpp:80
pappso::Xic::Xic
Xic()
Definition: xic.cpp:35