19 #include "AccessionManager.h"
23 using namespace kome::io::mzml;
28 #define new new( _NORMAL_BLOCK, __FILE__, __LINE__ )
29 #define malloc( s ) _malloc_dbg( s, _NORMAL_BLOCK, __FILE__, __LINE__ )
34 #define MACHINE_ACC "MS:1000031"
35 #define ARRAY_ACC "MS:1000513"
36 #define MZ_ARRAY_ACC "MS:1000514"
37 #define RT_ARRAY_ACC "MS:1000595"
38 #define INT_ARRAY_ACC "MS:1000515"
39 #define SPEC_TYPE_ACC "MS:1000559"
40 #define SOFTWARE_ACC "MS:1000531"
42 #define CVPARAM_TAG_NAME "cvParam"
43 #define SRC_FILE_TAG_NAME "sourceFile"
44 #define SOFTWARE_TAG_NAME "software"
45 #define PARAM_GROUP_TAG_NAME "referenceableParamGroup"
46 #define SPEC_TAG_NAME "spectrum"
47 #define PRECURSOR_TAG_NAME "precursor"
48 #define PRODUCT_TAG_NAME "product"
49 #define CHROM_TAG_NAME "chromatogram"
50 #define ION_SELECTION_TAG_NAME "ionSelection"
51 #define USR_PARAM_TAG_NAME "userParam"
52 #define OFFSET_TAG_NAME "offset"
53 #define REF_TAG_NAME "referenceableParamGroupRef"
56 #define CV_ACC_ATTR_NAME "accession"
57 #define CV_NAME_ATTR_NAME "name"
58 #define CV_VALUE_ATTR_NAME "value"
59 #define CV_UNIT_ATTR_NAME "unitAccession"
60 #define SRC_FILE_ATTR_NAME "name"
61 #define SRC_LOC_ATTR_NAME "location"
62 #define SOFTWARE_ID_ATTR_NAME "id"
63 #define SOFTWARE_VER_ATTR_NAME "version"
64 #define PARAM_GROUP_ID_ATTR_NAME "id"
65 #define SPEC_ID_ATTR_NAME "id"
66 #define SPEC_SCAN_NUM_ATTR_NAME "scanNumber"
67 #define PREC_SPEC_ATTR_NAME "spectrumRef"
68 #define CHROM_ID_ATTR_NAME "id"
69 #define SPEC_MS_LEVEL_ATTR_NAME "msLevel"
70 #define USR_PARAM_NAME_ATTR_NAME "name"
71 #define USR_PARAM_VAL_ATTR_NAME "value"
72 #define OFFSET_SCAN_ATTR_NAME "scanNumber"
73 #define OFFSET_IDREF_ATTR_NAME "idRef"
74 #define REF_REF_ATTR_NAME "ref"
98 std::string n = trimstring( name );
108 s->polarity = kome::objects::Spectrum::POLARITY_UNKNOWN;
109 s->mzLowerLimit = -1.0;
110 s->mzUpperLimit = -1.0;
117 s->collisionEnergy.clear();
125 if( info->stage > 0 ) {
126 spec->setMsStage( info->stage );
129 if( info->centroid == 0 || info->centroid == 1 ) {
130 spec->setCentroidMode( info->centroid == 1 );
133 if( info->polarity != kome::objects::Spectrum::POLARITY_UNKNOWN ) {
134 spec->setPolarity( info->polarity );
137 if( info->mzLowerLimit >= 0.0 ) {
138 spec->setMinX( info->mzLowerLimit );
141 if( info->mzUpperLimit >= 0.0 ) {
142 spec->setMaxX( info->mzUpperLimit );
145 if( info->tic >= 0.0 ) {
146 spec->setTotalIntensity( info->tic );
149 if( info->bpi >= 0.0 ) {
150 spec->setMaxIntensity( info->bpi );
153 if( info->prec >= 0.0 ) {
154 spec->setPrecursor( info->prec );
157 if( !info->collisionEnergy.empty() ) {
158 spec->setCollisionEnergy( info->collisionEnergy.c_str() );
161 for(
unsigned int i = 0; i < info->props.size(); i++ ) {
162 spec->getProperties().setValue( info->props.at( i ).first.c_str(), info->props.at( i ).second.c_str() );
200 if( strcmp( name, CVPARAM_TAG_NAME ) == 0 ) {
201 const char* a = attrs.getStringValue( CV_ACC_ATTR_NAME,
"" );
202 const char* n = attrs.getStringValue( CV_NAME_ATTR_NAME,
"" );
203 const char* v = attrs.getStringValue( CV_VALUE_ATTR_NAME,
"" );
205 if( strcmp( a,
"MS:1000511" ) == 0 ) {
206 int stage = toint( v, 10, 1 );
214 else if( strcmp( a,
"MS:1000521" ) == 0 ) {
217 else if( strcmp( a,
"MS:1000523" ) == 0 ) {
220 else if( strcmp( a,
"MS:1000576" ) == 0 ) {
223 else if( strcmp( a,
"MS:1000574" ) == 0 ) {
226 else if( strcmp( a,
"MS:1000127" ) == 0 ) {
234 else if( strcmp( a,
"MS:1000128" ) == 0 ) {
242 else if( strcmp( a,
"MS:1000129" ) == 0 ) {
244 m_currSpecInfo->polarity = kome::objects::Spectrum::POLARITY_NEGATIVE;
247 m_currSpec->setPolarity( kome::objects::Spectrum::POLARITY_NEGATIVE );
250 else if( strcmp( a,
"MS:1000130" ) == 0 ) {
252 m_currSpecInfo->polarity = kome::objects::Spectrum::POLARITY_POSITIVE;
255 m_currSpec->setPolarity( kome::objects::Spectrum::POLARITY_POSITIVE );
258 else if( strcmp( a,
"MS:1000501" ) == 0 ) {
259 double lowMz = todouble( v, -1.0 );
267 else if( strcmp( a,
"MS:1000500" ) == 0 ) {
268 double upMz = todouble( v, -1.0 );
276 else if( strcmp( a,
"MS:1000285" ) == 0 ) {
277 double tic = todouble( v, -1.0 );
285 else if( strcmp( a,
"MS:1000504" ) == 0 ) {
286 double bpm = todouble( v, -1.0 );
294 else if( strcmp( a,
"MS:1000505" ) == 0 ) {
295 double bpi = todouble( v, -1.0 );
303 else if( strcmp( a,
"MS:1000016" ) == 0 ) {
304 double rt = todouble( v, -1.0 );
305 const char* unit = attrs.getStringValue( CV_UNIT_ATTR_NAME,
"" );
306 if( strcmp( unit,
"UO:0000031" ) != 0 ) {
318 else if( strcmp( a,
"MS:1000744" ) == 0 ) {
319 double prec = todouble( v, -1.0 );
327 else if( strcmp( a,
"MS:1000512" ) == 0 ) {
332 m_currSpec->getProperties().setValue(
"Filter", v );
335 else if( strcmp( a,
"MS:1000040" ) == 0 ) {
336 double mz = todouble( v, -1.0 );
341 else if( strcmp( a,
"MS:1000827" ) == 0 ) {
343 std::string name =
"Isolation Window Target m/z";
345 name =
"Precursor Target";
348 name =
"Product Target";
352 m_currSpecInfo->props.push_back( std::make_pair( name.c_str(), v ) );
355 m_currSpec->getProperties().setValue( name.c_str(), v );
360 double mz = todouble( v, -1.0 );
371 else if( strcmp( a,
"MS:1000045" ) == 0 ) {
372 const char* unitId = attrs.getStringValue(
"unitAccession",
"" );
374 if( strcmp( unitId,
"UO:0000266" ) == 0 ) {
375 ce = FMT(
"%s eV", v );
394 m_file.setInstrument( n );
398 const char* u = attrs.getStringValue( CV_UNIT_ATTR_NAME,
"" );
402 if( strcmp( a, MZ_ARRAY_ACC ) == 0 ) {
405 else if( strcmp( a, RT_ARRAY_ACC ) == 0 ) {
407 if( strcmp( u,
"UO:0000031" ) != 0 ) {
411 else if( strcmp( a, INT_ARRAY_ACC ) == 0 ) {
421 m_currSpecInfo->props.push_back( std::make_pair(
"Spectrum Type", n ) );
424 m_currSpec->getProperties().setValue(
"Spectrum Type", n );
432 else if( strcmp( name, SRC_FILE_TAG_NAME ) == 0 ) {
434 std::string file = attrs.getStringValue( SRC_FILE_ATTR_NAME,
"" );
435 std::string location = attrs.getStringValue( SRC_LOC_ATTR_NAME,
"" );
437 if( !location.empty() ) {
438 if( location[ (
int)location.length() - 1 ] !=
'/' ) {
439 location.append(
"/" );
442 location.append( file );
446 else if( strcmp( name, SOFTWARE_TAG_NAME ) == 0 ) {
450 else if( strcmp( name, PARAM_GROUP_TAG_NAME ) == 0 ) {
451 m_arrayInfo.name = attrs.getStringValue( PARAM_GROUP_ID_ATTR_NAME,
"" );
461 else if( strcmp( name, SPEC_TAG_NAME ) == 0 ) {
463 const char*
id = attrs.getStringValue( SPEC_ID_ATTR_NAME,
"Scan" );
466 long long pos =
m_pos;
478 int scanNum = attrs.getIntValue( SPEC_SCAN_NUM_ATTR_NAME,
m_scanNum );
483 int stage = attrs.getIntValue( SPEC_MS_LEVEL_ATTR_NAME, dfSpec->stage );
488 std::string strSpotID = attrs.getStringValue(
"spotID",
"" );
489 if ( !strSpotID.empty( ) )
494 else if( strcmp( name, PRECURSOR_TAG_NAME ) == 0 ) {
496 const char*
id = attrs.getStringValue( PREC_SPEC_ATTR_NAME, NULL );
497 kome::objects::Spectrum* parent = NULL;
509 else if( strcmp( name, PRODUCT_TAG_NAME ) == 0 ) {
512 else if( strcmp( name, CHROM_TAG_NAME ) == 0 ) {
514 const char*
id = attrs.getStringValue( CHROM_ID_ATTR_NAME,
"Chromatogram" );
521 else if( strcmp( name, ION_SELECTION_TAG_NAME ) == 0 ) {
524 else if( strcmp( name, USR_PARAM_TAG_NAME ) == 0 ) {
526 std::string n = attrs.getStringValue( USR_PARAM_NAME_ATTR_NAME,
"" );
527 std::string v = attrs.getStringValue( USR_PARAM_VAL_ATTR_NAME,
"" );
531 kome::core::Properties* props = &
m_file.getRootDataGroupNode()->getProperties();
541 props->setValue( n.c_str(), v.c_str() );
545 else if( strcmp( name, OFFSET_TAG_NAME ) == 0 ) {
546 m_offsetScan = attrs.getIntValue( OFFSET_SCAN_ATTR_NAME, -1 );
547 m_offsetId = attrs.getStringValue( OFFSET_IDREF_ATTR_NAME,
"" );
549 else if( strcmp( name, REF_TAG_NAME ) == 0 ) {
550 std::string
id = attrs.getStringValue( REF_REF_ATTR_NAME,
"" );
563 if( strcmp( name, SOFTWARE_TAG_NAME ) == 0 ) {
564 if( strlen(
m_file.getSoftwareName() ) == 0 ) {
571 else if( strcmp( name, SPEC_TAG_NAME ) == 0 ) {
574 else if( strcmp( name, CHROM_TAG_NAME ) == 0 ) {
579 if( q1 >= 0.0 && q3 >= 0.0 ) {
585 else if( strcmp( name, PARAM_GROUP_TAG_NAME ) == 0 ) {
597 else if( strcmp( name, ION_SELECTION_TAG_NAME ) == 0 ) {
600 else if( strcmp( name, PRECURSOR_TAG_NAME ) == 0 ) {
603 else if( strcmp( name, PRODUCT_TAG_NAME ) == 0 ) {
606 else if( strcmp( name, OFFSET_TAG_NAME ) == 0 ) {
608 long long offset = toint64( text, 10, -1 );
628 if( chrom != NULL ) {
638 m_pos = getPosition();
std::string m_currSoftwareName
std::map< int, MzmlSpectrum * > m_specScanMap
static AccessionManager & getInstance()
gets accession manager object (This is the only object.)
MzmlChromatogram * m_currChrom
SpecInfo * getSpecInfo(const char *name)
gets the spectrum information
SpecInfo * m_currSpecInfo
interfaces of MzmlSample class
const char * getName()
gets accession name
Accession * m_softwareAcc
Accession * getOrigin()
gets origin accesion
void setOffset(const long long offset)
sets data offset
std::map< std::string, SpecInfo > m_specMap
MzmlSample::ArrayInfo m_arrayInfo
virtual void onEndDocument()
This method is called by endDocument method. (override method)
std::map< std::string, MzmlChromatogram * > m_chromIdMap
interfaces of Accession class
virtual void onEndElement(const char *name, const char *text)
This method is called by end element method. (override method)
virtual void onStartDocument()
This method is called by startDocument method. (override method)
Accession * getAccession(const unsigned int idx)
gets accession
virtual void onStartElement(const char *name, kome::core::Properties &attrs)
This method is called by startElement method. (override method)
std::map< std::string, MzmlSpectrum * > m_specIdMap
accession object management class
std::string m_currSoftwareVersion
mzml sample spectrum class
accession information class
interfaces of MzmlHandler class
interfaces of MzmlChromatogram class
mzml sample spectrum class
void setSpecInfo(kome::objects::Spectrum *spec, SpecInfo *info)
sets the spectrum information
MzmlHandler(MzmlSample &file)
constructor
interfaces of MzmlSpectrum class
void setOffset(const long long offset)
sets data offset
void addArrayInfo(const char *name, const int bits, const bool compressed, const double scale, const bool isY)
adds array information
virtual ~MzmlHandler()
destructor
MzmlSpectrum * m_currSpec
void addParentFile(const char *path)
adds parent files