35 #ifndef OPENMS_FORMAT_HANDLERS_MZXMLHANDLER_H
36 #define OPENMS_FORMAT_HANDLERS_MZXMLHANDLER_H
50 class MetaInfoInterface;
61 template <
typename MapType>
105 virtual void endElement(
const XMLCh*
const uri,
const XMLCh*
const local_name,
const XMLCh*
const qname);
108 virtual void startElement(
const XMLCh*
const uri,
const XMLCh*
const local_name,
const XMLCh*
const qname,
const xercesc::Attributes& attributes);
111 virtual void characters(
const XMLCh*
const chars,
const XMLSize_t length);
114 void writeTo(std::ostream& os);
147 String(
";Quadrupole;Quadrupole Ion Trap;;;TOF;Magnetic Sector;FT-ICR;").
split(
';',
cv_terms_[3]);
231 std::vector<String> keys;
234 for (std::vector<String>::const_iterator it = keys.begin(); it != keys.end(); ++it)
269 std::vector<double> data;
289 spectrum_data.
spectrum.push_back(peak);
295 std::vector<float> data;
314 spectrum_data.
spectrum.push_back(peak);
334 #pragma omp parallel for
346 spectrum_data_[i].spectrum.sortByPosition();
351 #pragma omp critical(HandleException)
363 for (
Size i = 0; i < spectrum_data_.size(); i++)
365 if (consumer_ != NULL)
370 exp_->addSpectrum(spectrum_data_[i].spectrum);
375 exp_->addSpectrum(spectrum_data_[i].spectrum);
380 spectrum_data_.clear();
425 static bool init(
false);
428 s_value_ = xercesc::XMLString::transcode(
"value");
429 s_count_ = xercesc::XMLString::transcode(
"scanCount");
430 s_type_ = xercesc::XMLString::transcode(
"type");
431 s_name_ = xercesc::XMLString::transcode(
"name");
432 s_version_ = xercesc::XMLString::transcode(
"version");
433 s_filename_ = xercesc::XMLString::transcode(
"fileName");
434 s_filetype_ = xercesc::XMLString::transcode(
"fileType");
435 s_filesha1_ = xercesc::XMLString::transcode(
"fileSha1");
436 s_completiontime_ = xercesc::XMLString::transcode(
"completionTime");
437 s_precision_ = xercesc::XMLString::transcode(
"precision");
438 s_byteorder_ = xercesc::XMLString::transcode(
"byteOrder");
439 s_pairorder_ = xercesc::XMLString::transcode(
"pairOrder");
440 s_compressionType_ = xercesc::XMLString::transcode(
"compressionType");
441 s_precursorintensity_ = xercesc::XMLString::transcode(
"precursorIntensity");
442 s_precursorcharge_ = xercesc::XMLString::transcode(
"precursorCharge");
443 s_windowwideness_ = xercesc::XMLString::transcode(
"windowWideness");
444 s_mslevel_ = xercesc::XMLString::transcode(
"msLevel");
445 s_peakscount_ = xercesc::XMLString::transcode(
"peaksCount");
446 s_polarity_ = xercesc::XMLString::transcode(
"polarity");
447 s_scantype_ = xercesc::XMLString::transcode(
"scanType");
448 s_filterline_ = xercesc::XMLString::transcode(
"filterLine");
449 s_retentiontime_ = xercesc::XMLString::transcode(
"retentionTime");
450 s_startmz_ = xercesc::XMLString::transcode(
"startMz");
451 s_endmz_ = xercesc::XMLString::transcode(
"endMz");
452 s_first_ = xercesc::XMLString::transcode(
"first");
453 s_last_ = xercesc::XMLString::transcode(
"last");
454 s_phone_ = xercesc::XMLString::transcode(
"phone");
455 s_email_ = xercesc::XMLString::transcode(
"email");
456 s_uri_ = xercesc::XMLString::transcode(
"URI");
457 s_num_ = xercesc::XMLString::transcode(
"num");
458 s_intensitycutoff_ = xercesc::XMLString::transcode(
"intensityCutoff");
459 s_centroided_ = xercesc::XMLString::transcode(
"centroided");
460 s_deisotoped_ = xercesc::XMLString::transcode(
"deisotoped");
461 s_chargedeconvoluted_ = xercesc::XMLString::transcode(
"chargeDeconvoluted");
473 template <
typename MapType>
475 template <
typename MapType>
477 template <
typename MapType>
479 template <
typename MapType>
481 template <
typename MapType>
483 template <
typename MapType>
485 template <
typename MapType>
487 template <
typename MapType>
489 template <
typename MapType>
491 template <
typename MapType>
493 template <
typename MapType>
495 template <
typename MapType>
497 template <
typename MapType>
499 template <
typename MapType>
501 template <
typename MapType>
503 template <
typename MapType>
505 template <
typename MapType>
507 template <
typename MapType>
509 template <
typename MapType>
511 template <
typename MapType>
513 template <
typename MapType>
515 template <
typename MapType>
517 template <
typename MapType>
519 template <
typename MapType>
521 template <
typename MapType>
523 template <
typename MapType>
525 template <
typename MapType>
527 template <
typename MapType>
529 template <
typename MapType>
531 template <
typename MapType>
533 template <
typename MapType>
535 template <
typename MapType>
537 template <
typename MapType>
539 template <
typename MapType>
542 template <
typename MapType>
544 const XMLCh*
const ,
const XMLCh*
const qname,
545 const xercesc::Attributes& attributes)
549 static bool init_static_members(
false);
550 if (!init_static_members)
552 initStaticMembers_();
555 String tag = sm_.convert(qname);
556 open_tags_.push_back(tag);
560 if (skip_spectrum_ && tag !=
"scan")
566 optionalAttributeAsInt_(count, attributes, s_count_);
567 exp_->reserve(count);
568 logger_.startProgress(0, count,
"loading mzXML file");
570 data_processing_.clear();
573 else if (tag ==
"parentFile")
576 sf.
setNameOfFile(attributeAsString_(attributes, s_filename_));
577 sf.
setFileType(attributeAsString_(attributes, s_filetype_));
579 exp_->getSourceFiles().push_back(sf);
581 else if (tag ==
"software")
583 String& parent_tag = *(open_tags_.end() - 2);
584 if (parent_tag ==
"dataProcessing")
586 data_processing_.back().getSoftware().setVersion(attributeAsString_(attributes, s_version_));
587 data_processing_.back().getSoftware().setName(attributeAsString_(attributes, s_name_));
588 data_processing_.back().setMetaValue(
"#type",
String(attributeAsString_(attributes, s_type_)));
591 optionalAttributeAsString_(time, attributes, s_completiontime_);
592 data_processing_.back().setCompletionTime(asDateTime_(time));
594 else if (parent_tag ==
"msInstrument")
596 exp_->getInstrument().getSoftware().setVersion(attributeAsString_(attributes, s_version_));
597 exp_->getInstrument().getSoftware().setName(attributeAsString_(attributes, s_name_));
600 else if (tag ==
"peaks")
603 spectrum_data_.back().precision_ =
"32";
604 optionalAttributeAsString_(spectrum_data_.back().precision_, attributes, s_precision_);
605 if (spectrum_data_.back().precision_ !=
"32" && spectrum_data_.back().precision_ !=
"64")
607 error(LOAD,
String(
"Invalid precision '") + spectrum_data_.back().precision_ +
"' in element 'peaks'");
610 String byte_order =
"network";
611 optionalAttributeAsString_(byte_order, attributes, s_byteorder_);
612 if (byte_order !=
"network")
614 error(LOAD,
String(
"Invalid or missing byte order '") + byte_order +
"' in element 'peaks'. Must be 'network'!");
617 String pair_order =
"m/z-int";
618 optionalAttributeAsString_(pair_order, attributes, s_pairorder_);
619 if (pair_order !=
"m/z-int")
621 error(LOAD,
String(
"Invalid or missing pair order '") + pair_order +
"' in element 'peaks'. Must be 'm/z-int'!");
624 spectrum_data_.back().compressionType_ =
"none";
625 optionalAttributeAsString_(spectrum_data_.back().compressionType_, attributes, s_compressionType_);
626 if (spectrum_data_.back().compressionType_ !=
"none" && spectrum_data_.back().compressionType_ !=
"zlib")
628 error(LOAD,
String(
"Invalid compression type ") + spectrum_data_.back().compressionType_ +
"in elements 'peaks'. Must be 'none' or 'zlib'! ");
631 else if (tag ==
"precursorMz")
634 spectrum_data_.back().spectrum.getPrecursors().push_back(
Precursor());
638 spectrum_data_.back().spectrum.getPrecursors().back().setIntensity(attributeAsDouble_(attributes, s_precursorintensity_));
642 error(LOAD,
"Mandatory attribute 'precursorIntensity' of tag 'precursorMz' not found! Setting precursor intensity to zero!");
646 if (optionalAttributeAsInt_(charge, attributes, s_precursorcharge_))
648 spectrum_data_.back().spectrum.getPrecursors().back().setCharge(charge);
652 if (optionalAttributeAsDouble_(window, attributes, s_windowwideness_))
654 spectrum_data_.back().spectrum.getPrecursors().back().setIsolationWindowLowerOffset(window);
657 else if (tag ==
"scan")
659 skip_spectrum_ =
false;
662 if (options_.getMetadataOnly())
666 UInt ms_level = attributeAsInt_(attributes, s_mslevel_);
669 warning(LOAD,
String(
"Invalid 'msLevel' attribute with value '0' in 'scan' element found. Assuming ms level 1!"));
674 double retention_time = 0.0;
676 if (optionalAttributeAsString_(time_string, attributes, s_retentiontime_))
678 time_string = time_string.
suffix(
'T');
680 if (time_string.
has(
'H'))
682 retention_time += 3600 * asDouble_(time_string.
prefix(
'H'));
683 time_string = time_string.
suffix(
'H');
686 if (time_string.
has(
'M'))
688 retention_time += 60 * asDouble_(time_string.
prefix(
'M'));
689 time_string = time_string.
suffix(
'M');
692 if (time_string.
has(
'S'))
694 retention_time += asDouble_(time_string.
prefix(
'S'));
695 time_string = time_string.
suffix(
'S');
700 logger_.setProgress(scan_count_);
702 if ((options_.hasRTRange() && !options_.getRTRange().encloses(
DPosition<1>(retention_time)))
703 || (options_.hasMSLevels() && !options_.containsMSLevel(ms_level))
704 || options_.getSizeOnly())
707 skip_spectrum_ =
true;
713 spectrum_data_.resize(spectrum_data_.size() + 1);
714 spectrum_data_.back().peak_count_ = 0;
716 spectrum_data_.back().spectrum.setMSLevel(ms_level);
717 spectrum_data_.back().spectrum.setRT(retention_time);
718 spectrum_data_.back().spectrum.setNativeID(
String(
"scan=") + attributeAsString_(attributes, s_num_));
720 spectrum_data_.back().peak_count_ = attributeAsInt_(attributes, s_peakscount_);
721 spectrum_data_.back().spectrum.reserve(spectrum_data_.back().peak_count_ / 2 + 1);
722 spectrum_data_.back().spectrum.setDataProcessing(data_processing_);
728 optionalAttributeAsDouble_(window.
begin, attributes, s_startmz_);
729 optionalAttributeAsDouble_(window.
end, attributes, s_endmz_);
730 if (window.
begin != 0.0 || window.
end != 0.0)
732 spectrum_data_.back().spectrum.getInstrumentSettings().getScanWindows().push_back(window);
736 optionalAttributeAsString_(polarity, attributes, s_polarity_);
737 spectrum_data_.back().spectrum.getInstrumentSettings().setPolarity((
IonSource::Polarity) cvStringToEnum_(0, polarity,
"polarity"));
741 optionalAttributeAsString_(filterLine, attributes, s_filterline_);
742 if (!filterLine.empty())
744 spectrum_data_.back().spectrum.setMetaValue(
"filter string", filterLine);
748 optionalAttributeAsString_(type, attributes, s_scantype_);
753 else if (type ==
"zoom")
755 spectrum_data_.back().spectrum.getInstrumentSettings().setZoomScan(
true);
758 else if (type ==
"Full")
765 else if (type ==
"SIM")
769 else if (type ==
"SRM" || type ==
"MRM")
773 else if (type ==
"CRM")
777 else if (type ==
"Q1")
781 else if (type ==
"Q3")
785 else if (type ==
"EMS")
789 else if (type ==
"EPI")
792 spectrum_data_.back().spectrum.setMSLevel(2);
794 else if (type ==
"ER")
796 spectrum_data_.back().spectrum.getInstrumentSettings().setZoomScan(
true);
802 warning(LOAD,
String(
"Unknown scan mode '") + type +
"'. Assuming full scan");
807 else if (tag ==
"operator")
809 exp_->getContacts().resize(1);
810 exp_->getContacts().back().setFirstName(attributeAsString_(attributes, s_first_));
811 exp_->getContacts().back().setLastName(attributeAsString_(attributes, s_last_));
814 optionalAttributeAsString_(tmp, attributes, s_email_);
815 exp_->getContacts().back().setEmail(tmp);
818 optionalAttributeAsString_(tmp, attributes, s_phone_);
821 exp_->getContacts().back().setMetaValue(
"#phone", tmp);
825 optionalAttributeAsString_(tmp, attributes, s_uri_);
826 exp_->getContacts().back().setURL(tmp);
828 else if (tag ==
"msManufacturer")
830 exp_->getInstrument().setVendor(attributeAsString_(attributes, s_value_));
832 else if (tag ==
"msModel")
834 exp_->getInstrument().setModel(attributeAsString_(attributes, s_value_));
836 else if (tag ==
"msIonisation")
838 exp_->getInstrument().getIonSources().resize(1);
839 exp_->getInstrument().getIonSources()[0].setIonizationMethod((
IonSource::IonizationMethod) cvStringToEnum_(2, attributeAsString_(attributes, s_value_),
"msIonization"));
841 else if (tag ==
"msMassAnalyzer")
843 exp_->getInstrument().getMassAnalyzers().resize(1);
844 exp_->getInstrument().getMassAnalyzers()[0].setType((
MassAnalyzer::AnalyzerType) cvStringToEnum_(3, attributeAsString_(attributes, s_value_),
"msMassAnalyzer"));
846 else if (tag ==
"msDetector")
848 exp_->getInstrument().getIonDetectors().resize(1);
849 exp_->getInstrument().getIonDetectors()[0].setType((
IonDetector::Type) cvStringToEnum_(4, attributeAsString_(attributes, s_value_),
"msDetector"));
851 else if (tag ==
"msResolution")
853 exp_->getInstrument().getMassAnalyzers()[0].setResolutionMethod((
MassAnalyzer::ResolutionMethod) cvStringToEnum_(5, attributeAsString_(attributes, s_value_),
"msResolution"));
855 else if (tag ==
"dataProcessing")
860 optionalAttributeAsString_(
boolean, attributes, s_deisotoped_);
861 if (
boolean ==
"true" ||
boolean ==
"1")
867 optionalAttributeAsString_(
boolean, attributes, s_chargedeconvoluted_);
868 if (
boolean ==
"true" ||
boolean ==
"1")
874 optionalAttributeAsDouble_(cutoff, attributes, s_intensitycutoff_);
877 data_processing_.back().setMetaValue(
"#intensity_cutoff", cutoff);
881 optionalAttributeAsString_(
boolean, attributes, s_centroided_);
882 if (
boolean ==
"true" ||
boolean ==
"1")
887 else if (tag ==
"nameValue")
890 optionalAttributeAsString_(name, attributes, s_name_);
895 optionalAttributeAsString_(value, attributes, s_value_);
897 String& parent_tag = *(open_tags_.end() - 2);
899 if (parent_tag ==
"msInstrument")
901 exp_->getInstrument().setMetaValue(name, value);
903 else if (parent_tag ==
"scan")
905 spectrum_data_.back().spectrum.setMetaValue(name, value);
909 std::cout <<
" Warning: Unexpected tag 'nameValue' in tag '" << parent_tag <<
"'" <<
"\n";
912 else if (tag ==
"processingOperation")
915 optionalAttributeAsString_(name, attributes, s_name_);
920 optionalAttributeAsString_(value, attributes, s_value_);
922 data_processing_.back().setMetaValue(name, value);
928 template <
typename MapType>
935 static const XMLCh* s_mzxml = xercesc::XMLString::transcode(
"mzXML");
936 static const XMLCh* s_scan = xercesc::XMLString::transcode(
"scan");
938 open_tags_.pop_back();
940 if (equal_(qname, s_mzxml))
943 populateSpectraWithData_();
946 logger_.endProgress();
948 else if (equal_(qname, s_scan))
955 if (nesting_level_ == 0 && spectrum_data_.size() >= options_.getMaxDataPoolSize())
957 populateSpectraWithData_();
964 template <
typename MapType>
971 if (open_tags_.back() ==
"peaks")
974 if (options_.getFillData())
977 sm_.appendASCII(chars, length, spectrum_data_.back().char_rest_);
980 else if (open_tags_.back() ==
"offset" || open_tags_.back() ==
"indexOffset" || open_tags_.back() ==
"sha1")
984 else if (open_tags_.back() ==
"precursorMz")
986 char* transcoded_chars = sm_.convert(chars);
987 double mz_pos = asDouble_(transcoded_chars);
989 spectrum_data_.back().spectrum.getPrecursors().back().setMZ(mz_pos);
991 double window_width = spectrum_data_.back().spectrum.getPrecursors().back().getIsolationWindowLowerOffset();
992 if (window_width != 0.0)
994 spectrum_data_.back().spectrum.getPrecursors().back().setIsolationWindowLowerOffset(0.5 * window_width);
995 spectrum_data_.back().spectrum.getPrecursors().back().setIsolationWindowUpperOffset(0.5 * window_width);
998 else if (open_tags_.back() ==
"comment")
1000 char* transcoded_chars = sm_.convert(chars);
1001 String parent_tag = *(open_tags_.end() - 2);
1004 if (parent_tag ==
"msInstrument")
1006 exp_->getInstrument().setMetaValue(
"#comment",
String(transcoded_chars));
1008 else if (parent_tag ==
"dataProcessing")
1012 else if (parent_tag ==
"scan")
1014 spectrum_data_.back().spectrum.setComment(transcoded_chars);
1016 else if (
String(transcoded_chars).trim() !=
"")
1018 warning(LOAD,
String(
"Unhandled comment '") + transcoded_chars +
"' in element '" + open_tags_.back() +
"'");
1023 char* transcoded_chars = sm_.convert(chars);
1024 if (
String(transcoded_chars).trim() !=
"")
1026 warning(LOAD,
String(
"Unhandled character content '") + transcoded_chars +
"' in element '" + open_tags_.back() +
"'");
1031 template <
typename MapType>
1035 UInt count_tmp_ = 0;
1036 for (
Size s = 0; s < cexp_->size(); s++)
1039 if (spec.size() != 0)
1042 if (count_tmp_ == 0)
1044 logger_.startProgress(0, cexp_->size(),
"storing mzXML file");
1045 os <<
"<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n"
1046 <<
"<mzXML xmlns=\"http://sashimi.sourceforge.net/schema_revision/mzXML_2.1\" "
1047 <<
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
1048 <<
"xsi:schemaLocation=\"http://sashimi.sourceforge.net/schema_revision/mzXML_2.1 "
1049 <<
"http://sashimi.sourceforge.net/schema_revision/mzXML_2.1/mzXML_idx_2.1.xsd\">\n"
1050 <<
"\t<msRun scanCount=\"" << count_tmp_ <<
"\">\n";
1055 if (cexp_->getSourceFiles().empty())
1057 os <<
"\t\t<parentFile fileName=\"\" fileType=\"processedData\" fileSha1=\"0000000000000000000000000000000000000000\"/>\n";
1061 for (
Size i = 0; i < cexp_->getSourceFiles().size(); ++i)
1063 const SourceFile& sf = cexp_->getSourceFiles()[i];
1064 os <<
"\t\t<parentFile fileName=\"" << sf.
getNameOfFile() <<
"\" fileType=\"";
1074 os <<
"processedData";
1077 os <<
"\" fileSha1=\"";
1081 os <<
"0000000000000000000000000000000000000000";
1094 if (cexp_->getInstrument() !=
Instrument() || cexp_->getContacts().size() != 0)
1096 const Instrument& inst = cexp_->getInstrument();
1097 os <<
"\t\t<msInstrument>\n"
1098 <<
"\t\t\t<msManufacturer category=\"msManufacturer\" value=\"" << inst.
getVendor() <<
"\"/>\n" <<
"\t\t\t<msModel category=\"msModel\" value=\"" << inst.
getModel() <<
"\"/>\n";
1101 os <<
"\t\t\t<msIonisation category=\"msIonisation\" value=\"\"/>\n";
1105 os <<
"\t\t\t<msIonisation category=\"msIonisation\" value=\"" << cv_terms_[2][inst.
getIonSources()[0].getIonizationMethod()] <<
"\"/>\n";
1108 if (analyzers.empty() || !analyzers[0].getResolutionMethod())
1110 os <<
"\t\t\t<msMassAnalyzer category=\"msMassAnalyzer\" value=\"\"/>\n";
1114 os <<
"\t\t\t<msMassAnalyzer category=\"msMassAnalyzer\" value=\"" << cv_terms_[3][analyzers[0].getType()] <<
"\"/>\n";
1118 os <<
"\t\t\t<msDetector category=\"msDetector\" value=\"\"/>\n";
1122 os <<
"\t\t\t<msDetector category=\"msDetector\" value=\"" << cv_terms_[4][inst.
getIonDetectors()[0].getType()] <<
"\"/>\n";
1125 if (analyzers.empty() || !analyzers[0].getResolutionMethod())
1127 os <<
"\t\t\t<msResolution category=\"msResolution\" value=\"\"/>\n";
1131 os <<
"\t\t\t<msResolution category=\"msResolution\" value=\"" << cv_terms_[5][analyzers[0].getResolutionMethod()] <<
"\"/>\n";
1134 if (cexp_->getContacts().size() > 0)
1142 os <<
" email=\"" << cont.
getEmail() <<
"\"";
1147 os <<
" URI=\"" << cont.
getURL() <<
"\"";
1157 writeUserParam_(os, inst, 3);
1161 os <<
"\t\t\t<comment>" << writeXMLEscape(inst.
getMetaValue(
"#comment")) <<
"</comment>\n";
1164 os <<
"\t\t</msInstrument>\n";
1170 if (cexp_->size() == 0 || (*cexp_)[0].getDataProcessing().empty())
1172 os <<
"\t\t<dataProcessing>\n"
1173 <<
"\t\t\t<software type=\"processing\" name=\"\" version=\"\"/>\n"
1174 <<
"\t\t</dataProcessing>\n";
1178 for (
Size i = 0; i < (*cexp_)[0].getDataProcessing().size(); ++i)
1180 const DataProcessing& data_processing = (*cexp_)[0].getDataProcessing()[i];
1181 os <<
"\t\t<dataProcessing deisotoped=\""
1183 <<
"\" chargeDeconvoluted=\""
1185 <<
"\" centroided=\""
1190 os <<
" intensityCutoff=\"" << writeXMLEscape(data_processing.
getMetaValue(
"#intensity_cutoff").
toString()) <<
"\"";
1193 <<
"\t\t\t<software type=\"";
1208 os <<
"\" completionTime=\"" << data_processing.
getCompletionTime().
get().substitute(
' ',
'T');
1211 writeUserParam_(os, data_processing, 3,
"processingOperation");
1213 os <<
"\t\t</dataProcessing>\n";
1219 bool all_numbers =
true;
1220 bool all_empty =
true;
1221 bool all_prefixed_numbers =
true;
1222 for (
Size s = 0; s < cexp_->size(); s++)
1224 String native_id = (*cexp_)[s].getNativeID();
1227 all_prefixed_numbers =
false;
1231 native_id = native_id.
substr(5);
1239 all_numbers =
false;
1240 all_prefixed_numbers =
false;
1241 if (native_id !=
"")
1248 if (!all_numbers && !all_empty)
1250 warning(STORE,
"Not all spectrum native IDs are numbers or correctly prefixed with 'scan='. The spectra are renumbered and the native IDs are lost!");
1254 std::stack<UInt> open_scans;
1255 for (
Size s = 0; s < cexp_->size(); s++)
1257 logger_.setProgress(s);
1261 open_scans.push(ms_level);
1263 Size spectrum_id = s + 1;
1264 if (all_prefixed_numbers)
1268 else if (all_numbers)
1273 os <<
String(ms_level + 1,
'\t')
1274 <<
"<scan num=\"" << spectrum_id <<
"\" msLevel=\""
1275 << ms_level <<
"\" peaksCount=\""
1276 << spec.size() <<
"\" polarity=\"";
1301 os <<
"\" scanType=\"zoom";
1305 os <<
"\" scanType=\"Full";
1310 os <<
"\" scanType=\"SIM";
1314 os <<
"\" scanType=\"SRM";
1318 os <<
"\" scanType=\"CRM";
1322 os <<
"\" scanType=\"Full";
1329 os <<
"\" filterLine=\"";
1335 os <<
"\" basePeakMz=\"";
1336 double basePeakInt = 0;
1337 double basePeakMz = 0;
1338 for (
Size j = 0; j < spec.size(); j++)
1340 if (spec[j].getIntensity() > basePeakInt)
1342 basePeakInt = spec[j].getIntensity();
1343 basePeakMz = spec[j].getMZ();
1349 os <<
"\" retentionTime=\"";
1350 if (spec.
getRT() < 0)
1352 os <<
"PT" << std::fabs(spec.
getRT()) <<
"S\"";
1359 warning(STORE,
"The MzXML format can store only one scan window for each scan. Only the first one is stored!");
1370 os <<
String(ms_level + 2,
'\t') <<
"<precursorMz precursorIntensity=\"" << precursor.
getIntensity();
1373 os <<
"\" precursorCharge=\"" << precursor.
getCharge();
1378 os <<
"\">" << precursor.
getMZ() <<
"</precursorMz>\n";
1383 os <<
String(ms_level + 2,
'\t') <<
"<peaks precision=\"32\"" <<
" byteOrder=\"network\" pairOrder=\"m/z-int\">";
1386 std::vector<float> tmp;
1387 for (
Size i = 0; i < spec.size(); i++)
1389 tmp.push_back(spec[i].getMZ());
1390 tmp.push_back(spec[i].getIntensity());
1395 os << encoded <<
"</peaks>\n";
1399 os <<
String(ms_level + 2,
'\t') <<
"<peaks precision=\"32\"" <<
" byteOrder=\"network\" pairOrder=\"m/z-int\" xsi:nil=\"true\"/>\n";
1402 writeUserParam_(os, spec, ms_level + 2);
1405 os <<
String(ms_level + 2,
'\t') <<
"<comment>" << spec.
getComment() <<
"</comment>\n";
1409 UInt next_ms_level = 0;
1410 if (s < cexp_->size() - 1)
1412 next_ms_level = ((*cexp_)[s + 1]).getMSLevel();
1415 if (next_ms_level <= ms_level)
1417 for (
Size i = 0; i <= ms_level - next_ms_level && !open_scans.empty(); ++i)
1419 os <<
String(ms_level - i + 1,
'\t') <<
"</scan>\n";
1425 os <<
"\t</msRun>\n"
1426 <<
"\t<indexOffset>0</indexOffset>\n"
1429 logger_.endProgress();
1430 spec_write_counter_ = 1;
Description of the applied preprocessing steps.
Definition: DataProcessing.h:51
ChecksumType getChecksumType() const
returns the checksum type
void writeUserParam_(std::ostream &os, const MetaInfoInterface &meta, int indent=4, String tag="nameValue")
write metaInfo to xml (usually in nameValue-tag)
Definition: MzXMLHandler.h:229
Big endian type.
Definition: Base64.h:78
Description of a MS instrument.
Definition: Instrument.h:64
bool hasMZRange() const
returns true if an MZ range has been set
double getIsolationWindowLowerOffset() const
Returns the lower offset from the target m/z.
const String & getNameOfFile() const
returns the file name
const Software & getSoftware() const
returns a const reference to the instrument software
static const XMLCh * s_count_
Definition: MzXMLHandler.h:388
A more convenient string class.
Definition: String.h:57
Precursor meta information.
Definition: Precursor.h:56
Class to encode and decode Base64.
Definition: Base64.h:64
Exception that is thrown if the parsing is ended by some event (e.g. if only a prefix of the XML file...
Definition: XMLHandler.h:104
const std::vector< IonSource > & getIonSources() const
returns a const reference to the ion source list
bool getAlwaysAppendData() const
returns whether or not to always append the data to the given map (even if a consumer is given) ...
static const XMLCh * s_peakscount_
Definition: MzXMLHandler.h:404
bool encloses(const PositionType &position) const
Checks whether this range contains a certain point.
Definition: DRange.h:172
UInt getMSLevel() const
Returns the MS level.
Definition: MSSpectrum.h:259
static const XMLCh * s_name_
Definition: MzXMLHandler.h:390
bool hasIntensityRange() const
returns true if an intensity range has been set
IntensityType getIntensity() const
Definition: Peak1D.h:109
static const XMLCh * s_first_
Definition: MzXMLHandler.h:411
static const XMLCh * s_phone_
Definition: MzXMLHandler.h:413
static const XMLCh * s_centroided_
Definition: MzXMLHandler.h:418
static const XMLCh * s_filterline_
Definition: MzXMLHandler.h:407
UInt spec_write_counter_
spectrum counter (spectra without peaks are not written)
Definition: MzXMLHandler.h:217
void setMSDataConsumer(Interfaces::IMSDataConsumer< MapType > *consumer)
Set the IMSDataConsumer consumer which will consume the read data.
Definition: MzXMLHandler.h:129
const std::set< ProcessingAction > & getProcessingActions() const
returns a const reference to the applied processing actions
static const XMLCh * s_precursorcharge_
Definition: MzXMLHandler.h:401
static const XMLCh * s_filesha1_
Definition: MzXMLHandler.h:394
UInt peak_count_
Definition: MzXMLHandler.h:201
const DRange< 1 > & getIntensityRange() const
returns the intensity range
const String & getComment() const
returns the free-text comment
#define OPENMS_PRECONDITION(condition, message)
Precondition macro.
Definition: openms/include/OpenMS/CONCEPT/Macros.h:107
const std::vector< MassAnalyzer > & getMassAnalyzers() const
returns a const reference to the mass analyzer list
String toString() const
Conversion to String.
void setFileType(const String &file_type)
sets the file type
XML handlers for MzXMLFile.
Definition: MzXMLHandler.h:62
CoordinateType getMZ() const
Non-mutable access to m/z.
Definition: Peak1D.h:114
Int getCharge() const
Non-mutable access to the charge.
virtual void startElement(const XMLCh *const uri, const XMLCh *const local_name, const XMLCh *const qname, const xercesc::Attributes &attributes)
Parsing method for opening tags.
Definition: MzXMLHandler.h:543
Base class for XML handlers.
Definition: XMLHandler.h:99
bool getSortSpectraByMZ() const
gets whether or not peaks in spectra should be sorted
ptrdiff_t SignedSize
Signed Size type e.g. used as pointer difference.
Definition: Types.h:128
const std::vector< IonDetector > & getIonDetectors() const
returns a const reference to the ion detector list
Description of a file location, used to store the origin of (meta) data.
Definition: SourceFile.h:47
static const XMLCh * s_retentiontime_
Definition: MzXMLHandler.h:408
double begin
Begin of the window.
Definition: ScanWindow.h:62
XMLHandler()
Not implemented.
bool has(Byte byte) const
true if String contains the byte, false otherwise
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
void setMZ(CoordinateType mz)
Mutable access to m/z.
Definition: Peak1D.h:120
void setIntensity(IntensityType intensity)
Mutable access to the data point intensity (height)
Definition: Peak1D.h:111
void setChecksum(const String &checksum, ChecksumType type)
sets the file's checksum
static const XMLCh * s_scantype_
Definition: MzXMLHandler.h:406
static String writeXMLEscape(const String &to_escape)
Escapes a string and returns the escaped string.
Definition: XMLHandler.h:169
const MapType * cexp_
map pointer for writing
Definition: MzXMLHandler.h:182
double getIsolationWindowUpperOffset() const
Returns the upper offset from the target m/z.
bool getZoomScan() const
return if this scan is a zoom (enhanced resolution) scan
ScanMode getScanMode() const
returns the scan mode
MSExperiment< Peak1D > MapType
Definition: PeakPickerIterative.cpp:87
void get(UInt &month, UInt &day, UInt &year, UInt &hour, UInt &minute, UInt &second) const
Fills the arguments with the date and the time.
static const XMLCh * s_polarity_
Definition: MzXMLHandler.h:405
virtual ~MzXMLHandler()
Destructor.
Definition: MzXMLHandler.h:101
String precision_
Definition: MzXMLHandler.h:202
Int toInt() const
Conversion to int.
void init_()
initialize members (call from C'tor)
Definition: MzXMLHandler.h:136
const std::vector< ScanWindow > & getScanWindows() const
returns a const reference to the m/z scan windows
static const XMLCh * s_byteorder_
Definition: MzXMLHandler.h:397
Interfaces::IMSDataConsumer< MapType > * consumer_
Consumer class to work on spectra.
Definition: MzXMLHandler.h:220
static const XMLCh * s_completiontime_
Definition: MzXMLHandler.h:395
UInt getScanCount()
Gets the scan count.
Definition: MzXMLHandler.h:123
String & toLower()
Converts the string to lowercase.
bool hasSubstring(const String &string) const
true if String contains the string, false otherwise
PeakFileOptions options_
Options for loading and storing.
Definition: MzXMLHandler.h:185
static const XMLCh * s_num_
Definition: MzXMLHandler.h:416
const String & getModel() const
returns the instrument model
A 1-dimensional raw data point or peak.
Definition: Peak1D.h:55
Scan window description.
Definition: ScanWindow.h:47
double getRT() const
Definition: MSSpectrum.h:243
const String & getVendor() const
returns the instrument vendor
void setOptions(const PeakFileOptions &options)
Sets the options.
Definition: MzXMLHandler.h:117
static const XMLCh * s_value_
Definition: MzXMLHandler.h:387
String file_
File name.
Definition: XMLHandler.h:187
const Software & getSoftware() const
returns a const reference to the software used for processing
Int nesting_level_
Definition: MzXMLHandler.h:190
const String & getName() const
returns the name of the software
static const XMLCh * s_pairorder_
Definition: MzXMLHandler.h:398
void populateSpectraWithData_()
Populate all spectra on the stack with data from input.
Definition: MzXMLHandler.h:326
std::vector< DataProcessing > data_processing_
data processing auxiliary variable
Definition: MzXMLHandler.h:244
Invalid conversion exception.
Definition: Exception.h:363
void setNameOfFile(const String &name_of_file)
sets the file name
double end
End of the window.
Definition: ScanWindow.h:64
PeakType PeakType
Peak type.
Definition: MSSpectrum.h:105
String compressionType_
Definition: MzXMLHandler.h:203
static const XMLCh * s_version_
Definition: MzXMLHandler.h:391
std::vector< SpectrumData > spectrum_data_
Vector of spectrum data stored for later parallel processing.
Definition: MzXMLHandler.h:210
const String & getFileType() const
returns the file type
bool getFillData() const
returns whether to fill the actual data into the container (spectrum/chromatogram) ...
MapType::PeakType PeakType
Peak type.
Definition: MzXMLHandler.h:175
static const XMLCh * s_last_
Definition: MzXMLHandler.h:412
SpectrumType spectrum
Definition: MzXMLHandler.h:205
UInt scan_count_
Consumer class to work on spectra.
Definition: MzXMLHandler.h:223
const String & getVersion() const
returns the software version
const DateTime & getCompletionTime() const
returns the time of completion of the processing
IonSource::Polarity getPolarity() const
returns the polarity
MzXMLHandler(const MapType &exp, const String &filename, const String &version, const ProgressLogger &logger)
Constructor for a write-only handler.
Definition: MzXMLHandler.h:85
String & removeWhitespaces()
removes whitespaces (space, tab, line feed, carriage return)
MSSpectrum< PeakType > SpectrumType
Spectrum type.
Definition: MzXMLHandler.h:177
The interface of a consumer of spectra and chromatograms.
Definition: IMSDataConsumer.h:68
String prefix(SizeType length) const
returns the prefix of length length
const String & getChecksum() const
returns the file's checksum
DateTime Class.
Definition: DateTime.h:55
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:55
String char_rest_
Definition: MzXMLHandler.h:204
String substr(size_t pos=0, size_t n=npos) const
Wrapper for the STL substr() method. Returns a String object with its contents initialized to a subst...
bool skip_spectrum_
Flag that indicates whether this spectrum should be skipped (due to options)
Definition: MzXMLHandler.h:214
virtual void consumeSpectrum(SpectrumType &s)=0
Consume a spectrum.
Data necessary to generate a single spectrum.
Definition: MzXMLHandler.h:199
const InstrumentSettings & getInstrumentSettings() const
returns a const reference to the instrument settings of the current spectrum
void doPopulateSpectraWithData_(SpectrumData &spectrum_data)
Fill a single spectrum with data from input.
Definition: MzXMLHandler.h:253
static const XMLCh * s_startmz_
Definition: MzXMLHandler.h:409
Base64 decoder_
Definition: MzXMLHandler.h:189
static const XMLCh * s_type_
Definition: MzXMLHandler.h:389
const DRange< 1 > & getMZRange() const
returns the MZ range
const std::vector< Precursor > & getPrecursors() const
returns a const reference to the precursors
Options for loading files containing peak data.
Definition: PeakFileOptions.h:48
std::vector< std::vector< String > > cv_terms_
Array of CV term lists (one sublist denotes one term and it's children)
Definition: XMLHandler.h:220
virtual void endElement(const XMLCh *const uri, const XMLCh *const local_name, const XMLCh *const qname)
Parsing method for closing tags.
Definition: MzXMLHandler.h:929
const ProgressLogger & logger_
Progress logging class.
Definition: MzXMLHandler.h:226
static const std::string NamesOfScanMode[SIZE_OF_SCANMODE]
Names of scan modes.
Definition: InstrumentSettings.h:74
const String & getNativeID() const
returns the native identifier for the spectrum, used by the acquisition software. ...
static const XMLCh * s_filename_
Definition: MzXMLHandler.h:392
virtual void characters(const XMLCh *const chars, const XMLSize_t length)
Parsing method for character data.
Definition: MzXMLHandler.h:965
String suffix(SizeType length) const
returns the suffix of length length
bool skip_data
Definition: MzXMLHandler.h:206
void initStaticMembers_()
Definition: MzXMLHandler.h:423
int Int
Signed integer type.
Definition: Types.h:96
MapType * exp_
map pointer for reading
Definition: MzXMLHandler.h:180
static const XMLCh * s_endmz_
Definition: MzXMLHandler.h:410
static const XMLCh * s_deisotoped_
Definition: MzXMLHandler.h:419
bool split(const char splitter, std::vector< String > &substrings, bool quote_protect=false) const
Splits a string into substrings using splitter as delimiter.
static const XMLCh * s_uri_
Definition: MzXMLHandler.h:415
MzXMLHandler()
Not implemented.
void writeTo(std::ostream &os)
Write the contents to a stream.
Definition: MzXMLHandler.h:1032
static const XMLCh * s_filetype_
Definition: MzXMLHandler.h:393
static const XMLCh * s_intensitycutoff_
Definition: MzXMLHandler.h:417
void decode(const String &in, ByteOrder from_byte_order, std::vector< ToType > &out, bool zlib_compression=false)
Decodes a Base64 string to a vector of floating point numbers.
Definition: Base64.h:334
static const XMLCh * s_mslevel_
Definition: MzXMLHandler.h:403
static const XMLCh * s_email_
Definition: MzXMLHandler.h:414
static const XMLCh * s_precursorintensity_
Definition: MzXMLHandler.h:400
static const XMLCh * s_compressionType_
Definition: MzXMLHandler.h:399
bool hasPrefix(const String &string) const
true if String begins with string, false otherwise
Parse Error exception.
Definition: Exception.h:608
static const XMLCh * s_windowwideness_
Definition: MzXMLHandler.h:402
static const XMLCh * s_chargedeconvoluted_
Definition: MzXMLHandler.h:420
static const XMLCh * s_precision_
Definition: MzXMLHandler.h:396