Mass++ Common Libraries v2.7.5
 All Classes Namespaces Files Functions Variables Enumerations Macros
Public Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
kome::objects::DataSet Class Reference

one or more spectra management class More...

#include <DataSet.h>

Inheritance diagram for kome::objects::DataSet:
Inheritance graph
[legend]
Collaboration diagram for kome::objects::DataSet:
Collaboration graph
[legend]

Public Member Functions

 DataSet ()
 constructor
 
 DataSet (DataGroupNode *group)
 constructor More...
 
virtual ~DataSet ()
 destructor
 
SamplegetSample ()
 gets sample More...
 
DataGroupNodegetGroup ()
 gets spectrum group More...
 
unsigned int getNumberOfSpectra ()
 gets the number of spectra More...
 
SpectrumgetSpectrum (const unsigned int index)
 gets the number of spectra More...
 
unsigned int getNumberOfChromatograms ()
 gets the number of chromatograms More...
 
ChromatogramgetChromatogram (const unsigned int index)
 gets chroamtogram More...
 
virtual void sortSpectra ()
 sorts spectra in retention time order
 
virtual void clearSpectra ()
 clears spectra
 
virtual void addSpectrum (Spectrum *spec)
 adds spectrum to group More...
 
virtual void removeSpectrum (Spectrum *spec)
 removes spectrum More...
 
virtual void insertSpectrum (Spectrum *spec, const int idx)
 inserts spectrum More...
 
virtual void clearChromatograms ()
 clears chromatograms
 
virtual void addChromatogram (Chromatogram *chrom)
 adds chromatogram More...
 
virtual void removeChromatogram (Chromatogram *chrom)
 removes chromatogram More...
 
virtual void insertChromatogram (Chromatogram *chrom, const int idx)
 inserts chromatogram More...
 

Static Protected Member Functions

static bool lessSpectrum (Spectrum *spec0, Spectrum *spec1)
 compare to sort spectra More...
 

Protected Attributes

Samplem_sample
 
DataGroupNodem_group
 
std::vector< Spectrum * > m_spectra
 
std::vector< Chromatogram * > m_chroms
 

Detailed Description

one or more spectra management class

Definition at line 31 of file DataSet.h.

Constructor & Destructor Documentation

kome::objects::DataSet::DataSet ( DataGroupNode group)

constructor

Parameters
[in]groupspectrum group

Definition at line 39 of file DataSet.cpp.

39  {
40  m_group = group;
41  m_sample = ( m_group == NULL ) ? NULL : group->getSample();
42 }
DataGroupNode * m_group
Definition: DataSet.h:57
#define NULL
Definition: CoreMacros.h:18
Sample * getSample()
gets sample
Definition: DataSet.cpp:49

Here is the call graph for this function:

Member Function Documentation

void kome::objects::DataSet::addChromatogram ( Chromatogram chrom)
virtual

adds chromatogram

Parameters
[in]chromchromatogram

Definition at line 217 of file DataSet.cpp.

217  {
218  insertChromatogram( chrom, (int)m_chroms.size() );
219 }
virtual void insertChromatogram(Chromatogram *chrom, const int idx)
inserts chromatogram
Definition: DataSet.cpp:239
std::vector< Chromatogram * > m_chroms
Definition: DataSet.h:63

Here is the call graph for this function:

void kome::objects::DataSet::addSpectrum ( Spectrum spec)
virtual

adds spectrum to group

Parameters
[in]specspectrum object to be added

Definition at line 167 of file DataSet.cpp.

167  {
168  insertSpectrum( spec, (int)m_spectra.size() );
169 }
virtual void insertSpectrum(Spectrum *spec, const int idx)
inserts spectrum
Definition: DataSet.cpp:189
std::vector< Spectrum * > m_spectra
Definition: DataSet.h:60

Here is the call graph for this function:

Chromatogram * kome::objects::DataSet::getChromatogram ( const unsigned int  index)

gets chroamtogram

Parameters
[in]indexchromatogram index
Returns
chromatogram (If NULL, the index is illegal.)

Definition at line 146 of file DataSet.cpp.

146  {
147  // check the index
148  if( index >= m_chroms.size() ) {
149  return NULL;
150  }
151  return m_chroms[ index ];
152 }
#define NULL
Definition: CoreMacros.h:18
std::vector< Chromatogram * > m_chroms
Definition: DataSet.h:63
DataGroupNode * kome::objects::DataSet::getGroup ( )

gets spectrum group

Returns
spectrum group

Definition at line 65 of file DataSet.cpp.

65  {
66  // check the member
67  if( m_group != NULL ) {
68  return m_group;
69  }
70 
71  // groups
72  std::set< DataGroupNode* > groupSet;
73 
74  for( unsigned int i = 0; i < m_spectra.size(); i++ ) {
75  Spectrum* spec = m_spectra[ i ];
76  DataGroupNode* g = spec->getGroup();
77  if( g == NULL ) {
78  return NULL;
79  }
80  else {
81  groupSet.insert( g );
82  }
83  }
84 
85  for( unsigned int i = 0; i < m_chroms.size(); i++ ) {
86  Chromatogram* chrom = m_chroms[ i ];
87  DataGroupNode* g = chrom->getGroup();
88  if( g == NULL ) {
89  return NULL;
90  }
91  else {
92  groupSet.insert( g );
93  }
94  }
95 
96  // common group
97  DataGroupNode* group = NULL;
98  for( std::set< DataGroupNode* >::iterator it = groupSet.begin();
99  it != groupSet.end(); it++ ) {
100  DataGroupNode* g = *it;
101 
102  if( group == NULL ) {
103  group = g;
104  }
105  else {
106  while( group != NULL && group->getLevel() > g->getLevel() ) {
107  group = group->getParentGroup();
108  }
109  while( g != NULL && g->getLevel() > group->getLevel() ) {
110  g = g->getParentGroup();
111  }
112 
113  while( group != NULL && g != NULL && g != group ) {
114  group = group->getParentGroup();
115  g = g->getParentGroup();
116  }
117 
118  if( group == NULL || g == NULL ) {
119  return NULL;
120  }
121  }
122  }
123 
124  return group;
125 }
group of spectrum management class
Definition: DataGroupNode.h:33
DataGroupNode * getGroup()
gets spectrum group
unsigned int getLevel()
gets group level
DataGroupNode * m_group
Definition: DataSet.h:57
DataGroupNode * getParentGroup()
get parent spectrum group
#define NULL
Definition: CoreMacros.h:18
DataGroupNode * getGroup()
gets spectrum group
Definition: Spectrum.cpp:898
std::vector< Spectrum * > m_spectra
Definition: DataSet.h:60
spectrum information management class
Definition: Spectrum.h:30
chromatogram information management class
Definition: Chromatogram.h:33
std::vector< Chromatogram * > m_chroms
Definition: DataSet.h:63

Here is the call graph for this function:

unsigned int kome::objects::DataSet::getNumberOfChromatograms ( )

gets the number of chromatograms

Returns
the number of chromatograms

Definition at line 141 of file DataSet.cpp.

141  {
142  return m_chroms.size();
143 }
std::vector< Chromatogram * > m_chroms
Definition: DataSet.h:63
unsigned int kome::objects::DataSet::getNumberOfSpectra ( )

gets the number of spectra

Returns
the number of spectra

Definition at line 128 of file DataSet.cpp.

128  {
129  return m_spectra.size();
130 }
std::vector< Spectrum * > m_spectra
Definition: DataSet.h:60
Sample * kome::objects::DataSet::getSample ( )

gets sample

Returns
sample

Definition at line 49 of file DataSet.cpp.

49  {
50  // check the member
51  if( m_sample != NULL ) {
52  return m_sample;
53  }
54 
55  // group
56  DataGroupNode* group = getGroup();
57  if( group == NULL ) {
58  return NULL;
59  }
60 
61  return group->getSample();
62 }
group of spectrum management class
Definition: DataGroupNode.h:33
#define NULL
Definition: CoreMacros.h:18
DataGroupNode * getGroup()
gets spectrum group
Definition: DataSet.cpp:65
Sample * getSample()
gets sample
Definition: DataSet.cpp:49

Here is the call graph for this function:

Spectrum * kome::objects::DataSet::getSpectrum ( const unsigned int  index)

gets the number of spectra

Returns
the numbe of spectra

Definition at line 133 of file DataSet.cpp.

133  {
134  if( index >= m_spectra.size() ) {
135  return NULL;
136  }
137  return m_spectra[ index ];
138 }
#define NULL
Definition: CoreMacros.h:18
std::vector< Spectrum * > m_spectra
Definition: DataSet.h:60
void kome::objects::DataSet::insertChromatogram ( Chromatogram chrom,
const int  idx 
)
virtual

inserts chromatogram

Parameters
[in]chromchromatogram to be inserted
[in]idxinsert position

Reimplemented in kome::objects::DataGroupNode.

Definition at line 239 of file DataSet.cpp.

239  {
240  // check the parameter
241  if( chrom == NULL ) {
242  return;
243  }
244 
245  // check group
246  bool flg = false;
247  DataGroupNode* group = chrom->getGroup();
248  while( group != NULL && !flg ) {
249  if( m_group == group ) {
250  flg = true;
251  }
252  group = group->getParentGroup();
253  }
254 
255  // insert
256  if( m_group == NULL || flg ) {
257  m_chroms.insert( m_chroms.begin() + idx, chrom );
258  }
259 }
group of spectrum management class
Definition: DataGroupNode.h:33
DataGroupNode * getGroup()
gets spectrum group
DataGroupNode * m_group
Definition: DataSet.h:57
DataGroupNode * getParentGroup()
get parent spectrum group
#define NULL
Definition: CoreMacros.h:18
std::vector< Chromatogram * > m_chroms
Definition: DataSet.h:63

Here is the call graph for this function:

void kome::objects::DataSet::insertSpectrum ( Spectrum spec,
const int  idx 
)
virtual

inserts spectrum

Parameters
[in]specspectrum to be inserted.
[in]idxinsert position

Reimplemented in kome::objects::DataGroupNode.

Definition at line 189 of file DataSet.cpp.

189  {
190  // check the parameter
191  if( spec == NULL ) {
192  return;
193  }
194 
195  // check group
196  bool flg = false;
197  DataGroupNode* group = spec->getGroup();
198  while( group != NULL && !flg ) {
199  if( m_group == group ) {
200  flg = true;
201  }
202  group = group->getParentGroup();
203  }
204 
205  // add
206  if( m_group == NULL || flg ) {
207  m_spectra.insert( m_spectra.begin() + idx, spec );
208  }
209 }
group of spectrum management class
Definition: DataGroupNode.h:33
DataGroupNode * m_group
Definition: DataSet.h:57
DataGroupNode * getParentGroup()
get parent spectrum group
#define NULL
Definition: CoreMacros.h:18
DataGroupNode * getGroup()
gets spectrum group
Definition: Spectrum.cpp:898
std::vector< Spectrum * > m_spectra
Definition: DataSet.h:60

Here is the call graph for this function:

static bool kome::objects::DataSet::lessSpectrum ( Spectrum spec0,
Spectrum spec1 
)
staticprotected

compare to sort spectra

Parameters
[in]spec0spectrum object to be compared
[in]spec1spectrum object to compare
Returns
If spec0 sorts before spec1, this method returns true.

Definition at line 262 of file DataSet.cpp.

262  {
263  // @date 2013.11.11 <Del> M.Izumi ->
265  //const int s0 = spec0->getScanNumber();
266  //const int s1 = spec1->getScanNumber();
267  //if( s0 >= 0 && s1 >= 0 ) {
268  // if( s0 < s1 ) {
269  // return true;
270  // }
271  // return false;
272  //}
273  // @date 2013.11.11 <Del> M.Izumi <-
274 
275  // RT
276  const double rt0 = spec0->getRt();
277  const double rt1 = spec1->getRt();
278 
279  if( rt0 < rt1 ) {
280  return true;
281  }
282  else if( rt0 > rt1 ) {
283  return false;
284  }
285 
286  return false;
287 }
double getRt()
gets retention time
Definition: Spectrum.cpp:184

Here is the call graph for this function:

void kome::objects::DataSet::removeChromatogram ( Chromatogram chrom)
virtual

removes chromatogram

Parameters
[in]chromchromatogram to be removed

Definition at line 222 of file DataSet.cpp.

222  {
223  // search
224  int idx = -1;
225  for( unsigned int i = 0; i < m_chroms.size() && idx < 0; i++ ) {
227  if( tmp == chrom ) {
228  idx = (int)i;
229  }
230  }
231 
232  // remove
233  if( idx >= 0 ) {
234  m_chroms.erase( m_chroms.begin() + idx );
235  }
236 }
chromatogram information management class
Definition: Chromatogram.h:33
std::vector< Chromatogram * > m_chroms
Definition: DataSet.h:63
void kome::objects::DataSet::removeSpectrum ( Spectrum spec)
virtual

removes spectrum

Parameters
[in]specspectrum to be removed

Definition at line 172 of file DataSet.cpp.

172  {
173  // search
174  int idx = -1;
175  for( unsigned int i = 0; i < m_spectra.size() && idx < 0; i++ ) {
176  Spectrum* tmp = m_spectra[ i ];
177  if( tmp == spec ) {
178  idx = (int)i;
179  }
180  }
181 
182  // remove
183  if( idx >= 0 ) {
184  m_spectra.erase( m_spectra.begin() + idx );
185  }
186 }
std::vector< Spectrum * > m_spectra
Definition: DataSet.h:60
spectrum information management class
Definition: Spectrum.h:30

Member Data Documentation

std::vector< Chromatogram* > kome::objects::DataSet::m_chroms
protected

chromatograms

Definition at line 63 of file DataSet.h.

DataGroupNode* kome::objects::DataSet::m_group
protected

group

Definition at line 57 of file DataSet.h.

Sample* kome::objects::DataSet::m_sample
protected

sample

Definition at line 54 of file DataSet.h.

std::vector< Spectrum* > kome::objects::DataSet::m_spectra
protected

spectrum array

Definition at line 60 of file DataSet.h.


The documentation for this class was generated from the following files: