19 #include <boost/function.hpp>
20 #include <boost/bind.hpp>
21 #include <xercesc/framework/MemBufInputSource.hpp>
24 using namespace kome::io::mzml;
29 #define new new( _NORMAL_BLOCK, __FILE__, __LINE__ )
30 #define malloc( s ) _malloc_dbg( s, _NORMAL_BLOCK, __FILE__, __LINE__ )
37 : kome::objects::Chromatogram( file ) {
65 FILE* fp = sampleSet->
getFile();
75 int readSize = fread( buff, 1, 1023, fp );
79 buff[ readSize ] =
'\0';
84 unsigned int pos = tag.find(
"</chromatogram>" );
85 if( pos != (
unsigned int)tag.npos ) {
89 tag = tag.substr( 0, pos );
90 tag.append(
"</chromatogram>" );
94 if( readSize < 1023 ) {
99 unsigned int pos = tag.find(
"<chromatogram" );
100 if( pos != (
unsigned int)tag.npos ) {
101 tag = tag.substr( pos );
106 xercesc::MemBufInputSource source( (
const XMLByte*)tag.c_str(), tag.size(),
"memory_buffer", false );
107 parser->parse( source );
110 LOG_WARN( FMT(
"Failed to get the chromatogram tag." ) );
115 parser->parse( sampleSet->getFilePath() );
122 if( xyData == NULL ) {
127 kome::core::DataPoints dps;
130 xercesc::SAX2XMLReader* parser = kome::xml::XercesTool::getParser( NULL );
131 parser->setFeature( xercesc::XMLUni::fgXercesSchema,
false );
132 parser->setFeature( xercesc::XMLUni::fgXercesSchemaFullChecking,
false );
137 parser->setContentHandler( &handler );
138 parser->setErrorHandler( &handler );
143 for(
unsigned int i = 0; i < dps.getLength(); i++ ) {
144 xyData->addPoint( dps.getX( i ), dps.getY( i ) );
147 catch(
const xercesc::XMLException& e ) {
148 LOG_ERROR( FMT(
"XML Exception: %s", kome::xml::XercesTool::transcode( e.getMessage() ).c_str() ) );
149 handler.setError(
true );
151 catch(
const xercesc::SAXParseException& e ) {
152 LOG_ERROR( FMT(
"SAX Parse Exception: %s", kome::xml::XercesTool::transcode( e.getMessage() ).c_str() ) );
153 handler.setError(
true );
156 LOG_ERROR( FMT(
"Unexpected Exception" ) );
157 handler.setError(
true );
163 kome::objects::DataSet& dataSet,
164 const double startRt,
166 const kome::objects::SearchType startSearch,
167 const kome::objects::SearchType endSearch
MzmlSampleSet * getMzmlSampleSet()
gets mzML sample set object
interfaces of MzmlDataHandler class
MzmlSample * m_mzmlSample
virtual void onGetXYData(kome::core::XYData *const xyData)
This method is called by getXYData method (override method)
interfaces of MzmlSample class
void setOffset(const long long offset)
sets data offset
virtual double onGetMass(const unsigned int index)
This method is called by getMass method (override method)
XML data handler to get spectrum data points.
virtual int onGetMsStage(const unsigned int index)
This method is called by getMsStage method (override method)
virtual ~MzmlChromatogram()
destructor
interfaces of MzmlChromatogram class
long long getOffset()
gets data offset
interfaces of MzmlSampleSet class
void parse(xercesc::SAX2XMLReader *parser)
parse XML data
FILE * getFile()
gets file descriptor
virtual double onGetPrecursor(const unsigned int index)
This method is called by getPrecursor method (override method)
MzmlChromatogram(MzmlSample *file)
constructor
virtual void onGetSpectra(kome::objects::DataSet &dataSet, const double startRt, const double endRt, const kome::objects::SearchType startSearch, const kome::objects::SearchType endSearch)
This method is called by searchSpectrum or getSpectra method (overriede method)