Mass++ mzML IO Plugin v2.7.5
 All Classes Namespaces Files Functions Variables Enumerations
MzmlSample.cpp
Go to the documentation of this file.
1 
12 #include "stdafx.h"
13 #include "MzmlSample.h"
14 
15 #include "MzmlSampleSet.h"
16 #include "MzmlHandler.h"
17 
18 
19 using namespace kome::io::mzml;
20 
21 
22 #include <crtdbg.h>
23 #ifdef _DEBUG
24  #define new new( _NORMAL_BLOCK, __FILE__, __LINE__ )
25  #define malloc( s ) _malloc_dbg( s, _NORMAL_BLOCK, __FILE__, __LINE__ )
26 #endif // _DEBUG
27 
28 
29 
30 // constructor
31 MzmlSample::MzmlSample( MzmlSampleSet* sampleSet ) : kome::objects::Sample( sampleSet ) {
32  // initialize
33  m_sampleSet = sampleSet;
34 
35  setParallelReadable( true );
36 }
37 
38 // destructor
40 }
41 
42 // add parent file
43 void MzmlSample::addParentFile( const char* path ) {
44  // string object
45  std::string p = NVL( path, "" );
46 
47  // check
48  for( unsigned int i = 0; i < m_parentFiles.size(); i++ ) {
49  if( p.compare( m_parentFiles[ i ] ) == 0 ) {
50  return;
51  }
52  }
53 
54  // property
55  kome::core::Properties& props = getRootDataGroupNode()->getProperties();
56 
57  std::string key = FMT( "Parent File %d", m_parentFiles.size() );
58  props.setValue( key.c_str(), p.c_str() );
59 
60  // add
61  m_parentFiles.push_back( p );
62 }
63 
64 // mzML sample set object
66  return m_sampleSet;
67 }
68 
69 // get the number of parent files
71  return m_parentFiles.size();
72 }
73 
74 // get parent file path
75 const char* MzmlSample::getParentFilePath( const unsigned int index ) {
76  if( index >= m_parentFiles.size() ) {
77  return NULL;
78  }
79  return m_parentFiles[ index ].c_str();
80 }
81 
82 // add array information
84  const char* name,
85  const int bits,
86  const bool compressed,
87  const double scale,
88  const bool isY
89 ) {
90  // check the name
91  if( name == NULL ) {
92  return;
93  }
94 
95  // get array information
96  ArrayInfo* info = getArrayInfo( name );
97  if( info == NULL ) {
98  m_arrayInfo.resize( m_arrayInfo.size() + 1 );
99  info = &( m_arrayInfo.back() );
100  }
101 
102  // set values
103  info->name = name;
104  info->bits = bits;
105  info->compressed = compressed;
106  info->scale = scale;
107  info->isY = isY;
108 }
109 
110 // get array information
112  // check the name
113  if( name == NULL ) {
114  return NULL;
115  }
116 
117  // search
118  ArrayInfo* info = NULL;
119  for( unsigned int i = 0; i < m_arrayInfo.size() && info == NULL; i++ ) {
120  ArrayInfo* tmp = &( m_arrayInfo[ i ] );
121  if( tmp->name.compare( name ) == 0 ) {
122  info = tmp;
123  }
124  }
125 
126  return info;
127 }
128 
129 // on open
130 bool MzmlSample::onOpenSample( kome::objects::DataGroupNode* rootGroup, kome::core::Progress* progress ) {
131  // handler
132  MzmlHandler handler( *this );
133  handler.parse( m_sampleSet->getFilePath() );
134 
135  return !handler.isError();
136 }
137 
138 // on close sample
140  return true;
141 }
MzmlSampleSet * getMzmlSampleSet()
gets mzML sample set object
Definition: MzmlSample.cpp:65
virtual bool onOpenSample(kome::objects::DataGroupNode *rootGroup, kome::core::Progress *progress=NULL)
This method is called by openTreatment method. (override method)
Definition: MzmlSample.cpp:130
std::vector< ArrayInfo > m_arrayInfo
Definition: MzmlSample.h:63
MzmlSampleSet * m_sampleSet
Definition: MzmlSample.h:43
XML handler class to read mzML file.
Definition: MzmlHandler.h:33
interfaces of MzmlSample class
mzML sample set class
Definition: MzmlSampleSet.h:24
ArrayInfo * getArrayInfo(const char *name)
gets array information
Definition: MzmlSample.cpp:111
common header file
unsigned int getNumberOfParentFiles()
gets the number of parent files
Definition: MzmlSample.cpp:70
std::vector< std::string > m_parentFiles
Definition: MzmlSample.h:46
const char * getParentFilePath(const unsigned int index)
gets parent file path
Definition: MzmlSample.cpp:75
interfaces of MzmlHandler class
interfaces of MzmlSampleSet class
virtual bool onCloseSample()
This method is called by closeTreatment method. (override method)
Definition: MzmlSample.cpp:139
void addArrayInfo(const char *name, const int bits, const bool compressed, const double scale, const bool isY)
adds array information
Definition: MzmlSample.cpp:83
virtual ~MzmlSample()
destructor
Definition: MzmlSample.cpp:39
MzmlSample(MzmlSampleSet *sampleSet)
constructor
Definition: MzmlSample.cpp:31
void addParentFile(const char *path)
adds parent files
Definition: MzmlSample.cpp:43