Mass++ Common Libraries v2.7.5
 All Classes Namespaces Files Functions Variables Enumerations Macros
Alignment.cpp
Go to the documentation of this file.
1 
12 #include "stdafx.h"
13 #include "Alignment.h"
14 
15 
16 using namespace kome::operation;
17 
18 
19 #include <crtdbg.h>
20 #ifdef _DEBUG
21  #define new new( _NORMAL_BLOCK, __FILE__, __LINE__ )
22  #define malloc( s ) _malloc_dbg( s, _NORMAL_BLOCK, __FILE__, __LINE__ )
23 #endif // _DEBUG
24 
25 
26 
27 // constructor
29  // initialize
30  m_standard = NULL;
31  m_treatment = NULL;
32 
33  // manager
35  mgr.addAlignment( this );
36 }
37 
38 // destructor
40  // manager
42  mgr.removeAlignment( this );
43 }
44 
45 // get standard sample
47  return m_standard;
48 }
49 
50 // get treatment sample
52  return m_treatment;
53 }
54 
55 // prepare
57  // set
58  m_standard = standard;
59  m_treatment = treatment;
60 
61  // progress
62  if( progress == NULL ) {
64  }
65 
66  // prepare
67  onPrepare( standard, treatment, progress );
68 }
69 
70 // convert RT
71 double Alignment::convertRt( const double rt, const double mz ) {
72  // samples
75  if( standard == treatment || standard == NULL || treatment == NULL ) {
76  return rt;
77  }
78 
79  return onConvertRt( rt, mz );
80 }
81 
82 // convert m/z
83 double Alignment::convertMz( const double rt, const double mz ) {
84  // samples
87  if( standard == treatment || standard == NULL || treatment == NULL ) {
88  return mz;
89  }
90 
91  return onConvertMz( rt, mz );
92 }
93 
94 // invert RT
95 double Alignment::invertRt( const double rt, const double mz ) {
96  // samples
99  if( standard == treatment || standard == NULL || treatment == NULL ) {
100  return rt;
101  }
102 
103  return onInvertRt( rt, mz );
104 }
105 
106 // invert m/z
107 double Alignment::invertMz( const double rt, const double mz ) {
108  // samples
111  if( standard == treatment || standard == NULL || treatment == NULL ) {
112  return mz;
113  }
114 
115  return onInvertMz( rt, mz );
116 }
117 
118 // get default alignment
120  // create object
121  static DefaultAlignment align;
122 
123  // remove from set
125  mgr.removeAlignment( &align );
126 
127  return align;
128 }
129 
130 
131 //
132 // Default Alignment
133 //
134 
135 // constructor
137 }
138 
139 // destructor
141 }
142 
143 // on prepare
145  // nothing to do
146 }
147 
148 // on convert RT
149 double DefaultAlignment::onConvertRt( const double rt, const double mz ) {
150  return rt;
151 }
152 
153 // on convert m/z
154 double DefaultAlignment::onConvertMz( const double rt, const double mz ) {
155  return mz;
156 }
157 
158 // on invert RT
159 double DefaultAlignment::onInvertRt( const double rt, const double mz ) {
160  return rt;
161 }
162 
163 // on invert m/z
164 double DefaultAlignment::onInvertMz( const double rt, const double mz ) {
165  return mz;
166 }
167 
168 
169 //
170 // AlignmentManager
171 //
172 
173 // constructor
175 }
176 
177 // destructor
179  while( m_alignSet.size() > 0 ) {
180  delete *( m_alignSet.begin() );
181  }
182 }
183 
184 // add alignment
186  if( align != NULL ) {
187  m_alignSet.insert( align );
188  }
189 }
190 
191 // remove alignment
193  if( align != NULL ) {
194  m_alignSet.erase( align );
195  }
196 }
197 
198 // get instance
200  // create object (This is the only object.)
201  static AlignmentManager mgr;
202 
203  return mgr;
204 }
alignment class
Definition: Alignment.h:26
default alignment class
Definition: Alignment.h:167
virtual double onInvertMz(const double rt, const double mz)=0
This method is called by invertMz method. (abstract method)
static Progress & getIgnoringProgress()
gets progress object. But this object does nothing even if a method is called.
Definition: Progress.cpp:343
virtual double onConvertMz(const double rt, const double mz)=0
This method is called by convertMz method. (abstract method)
virtual ~AlignmentManager()
destructor
Definition: Alignment.cpp:178
double invertMz(const double rt, const double mz)
gets m/z before alignment
Definition: Alignment.cpp:107
double convertRt(const double rt, const double mz)
gets aligned RT
Definition: Alignment.cpp:71
alignment object management class
Definition: Alignment.h:233
kome::objects::Sample * getTreatmentSample()
gets the treatment sample
Definition: Alignment.cpp:51
sample information management class
Definition: Sample.h:34
virtual double onInvertMz(const double rt, const double mz)
This method is called by invertMz method. (override method)
Definition: Alignment.cpp:164
std::set< Alignment * > m_alignSet
Definition: Alignment.h:264
virtual double onConvertRt(const double rt, const double mz)
This method is called by convertRt method. (override method)
Definition: Alignment.cpp:149
virtual double onConvertRt(const double rt, const double mz)=0
This method is called by convertRt method. (abstract method)
void addAlignment(Alignment *align)
adds alignment object
Definition: Alignment.cpp:185
progress display abstract class
Definition: Progress.h:31
double invertRt(const double rt, const double mz)
gets RT before alignment
Definition: Alignment.cpp:95
kome::objects::Sample * getStandardSample()
gets the standard sample
Definition: Alignment.cpp:46
kome::objects::Sample * m_standard
Definition: Alignment.h:42
#define NULL
Definition: CoreMacros.h:18
double convertMz(const double rt, const double mz)
gets aligned m/z
Definition: Alignment.cpp:83
static Alignment & getDefaultAlignment()
gets default alignment
Definition: Alignment.cpp:119
virtual ~Alignment()
destructor
Definition: Alignment.cpp:39
virtual void onPrepare(kome::objects::Sample *standard, kome::objects::Sample *treatment, kome::core::Progress *progress)
This method is called by prepare method. (override method)
Definition: Alignment.cpp:144
virtual ~DefaultAlignment()
destructor
Definition: Alignment.cpp:140
interfaces of Alignment class
void removeAlignment(Alignment *align)
removes alignment object
Definition: Alignment.cpp:192
static AlignmentManager & getInstance()
gets alignment manager object (This is the only object.)
Definition: Alignment.cpp:199
virtual double onConvertMz(const double rt, const double mz)
This method is called by convertMz method. (override method)
Definition: Alignment.cpp:154
virtual double onInvertRt(const double rt, const double mz)=0
This method is called by invertRt method. (abstract method)
kome::objects::Sample * m_treatment
Definition: Alignment.h:45
virtual double onInvertRt(const double rt, const double mz)
This method is called by invertRt method. (override method)
Definition: Alignment.cpp:159
void prepare(kome::objects::Sample *standard, kome::objects::Sample *treatment, kome::core::Progress *progress)
prepares alignment
Definition: Alignment.cpp:56
virtual void onPrepare(kome::objects::Sample *standard, kome::objects::Sample *treatment, kome::core::Progress *progress)=0
This method is called by prepare method. (abstract method)