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 <QObject>
27 
28 #include "xic.h"
29 #include <algorithm>
30 #include <cmath>
31 #include "../exception/exceptionoutofrange.h"
32 
33 namespace pappso
34 {
35 
36 
38 {
39  qDebug() << "Xic::Xic begin";
40  qDebug() << "Xic::Xic end";
41 }
42 
43 Xic::Xic(const Trace &other) : Trace(other)
44 {
45 }
46 
48 {
49 }
50 
51 
54 {
55  return std::make_shared<const Xic>(*this);
56 }
57 
58 XicSPtr
60 {
61  return std::make_shared<Xic>(*this);
62 }
63 
64 void
66 {
67  for(auto &&peak : *this)
68  {
69  qDebug() << "rt = " << peak.x << ", int = " << peak.y;
70  }
71 }
72 
73 const DataPoint &
75 {
76  for(auto &&peak : *this)
77  {
78  if(peak.y == rt)
79  return peak;
80  }
81  throw ExceptionOutOfRange(
82  QObject::tr("no intensity for this retention time"));
83 }
84 
85 unsigned int
87 {
88  if(rt_first > rt_second)
89  {
90  std::swap(rt_first, rt_second);
91  }
92  unsigned int distance = 0;
93  auto it = this->begin();
94  auto itend = this->end();
95 
96  while((it->x < rt_first) && (it != itend))
97  {
98  it++;
99  }
100  while((rt_second > it->x) && (it != itend))
101  {
102  qDebug() << "Xic::getMsPointDistance " << rt_first << " it->rt " << it->x
103  << " rt_second " << rt_second << distance;
104  distance++;
105  it++;
106  }
107 
108 
109  return distance;
110 }
111 
112 void
114 {
115  sortX();
116 }
117 
118 } // namespace pappso
A simple container of DataPoint instances.
Definition: trace.h:148
void sortX()
Definition: trace.cpp:956
const DataPoint & atRetentionTime(pappso_double rt) const
get the DataPoint at the given retention time
Definition: xic.cpp:74
void sortByRetentionTime()
sort peaks by retention time
Definition: xic.cpp:113
XicCstSPtr makeXicCstSPtr() const
Definition: xic.cpp:53
void debugPrintValues() const
Definition: xic.cpp:65
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:86
XicSPtr makeXicSPtr() const
Definition: xic.cpp:59
virtual ~Xic()
Definition: xic.cpp:47
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition: aa.cpp:39
std::shared_ptr< const Xic > XicCstSPtr
Definition: xic.h:37
double pappso_double
A type definition for doubles.
Definition: types.h:49
std::shared_ptr< Xic > XicSPtr
Definition: xic.h:39
@ rt
Retention time.