Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
MzDataHandler.h
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
2 // OpenMS -- Open-Source Mass Spectrometry
3 // --------------------------------------------------------------------------
4 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5 // ETH Zurich, and Freie Universitaet Berlin 2002-2015.
6 //
7 // This software is released under a three-clause BSD license:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of any author or any participating institution
14 // may be used to endorse or promote products derived from this software
15 // without specific prior written permission.
16 // For a full list of authors, refer to the file AUTHORS.
17 // --------------------------------------------------------------------------
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // --------------------------------------------------------------------------
31 // $Maintainer: Andreas Bertsch $
32 // $Authors: Marc Sturm $
33 // --------------------------------------------------------------------------
34 
35 #ifndef OPENMS_FORMAT_HANDLERS_MZDATAHANDLER_H
36 #define OPENMS_FORMAT_HANDLERS_MZDATAHANDLER_H
37 
42 #include <OpenMS/FORMAT/Base64.h>
44 
45 #include <sstream>
46 
47 namespace OpenMS
48 {
49  namespace Internal
50  {
59  template <typename MapType>
60  class MzDataHandler :
61  public XMLHandler
62  {
63 public:
66  MzDataHandler(MapType & exp, const String & filename, const String & version, ProgressLogger & logger) :
68  XMLHandler(filename, version),
69  exp_(&exp),
70  cexp_(0),
71  peak_count_(0),
73  decoder_(),
74  skip_spectrum_(false),
75  logger_(logger)
76  {
77  init_();
78  }
79 
81  MzDataHandler(const MapType & exp, const String & filename, const String & version, const ProgressLogger & logger) :
82  XMLHandler(filename, version),
83  exp_(0),
84  cexp_(&exp),
85  peak_count_(0),
87  decoder_(),
88  skip_spectrum_(false),
89  logger_(logger)
90  {
91  init_();
92  }
93 
95  virtual ~MzDataHandler()
96  {
97  }
98 
100 
101 
102  // Docu in base class
103  virtual void endElement(const XMLCh * const /*uri*/, const XMLCh * const /*local_name*/, const XMLCh * const qname);
104 
105  // Docu in base class
106  virtual void startElement(const XMLCh * const /*uri*/, const XMLCh * const /*local_name*/, const XMLCh * const qname, const xercesc::Attributes & attributes);
107 
108  // Docu in base class
109  virtual void characters(const XMLCh * const chars, const XMLSize_t length);
110 
112  void writeTo(std::ostream & os);
113 
115  void setOptions(const PeakFileOptions & options)
116  {
117  options_ = options;
118  }
119 
120 private:
121  void init_()
122  {
123  cv_terms_.resize(19);
124  // SampleState
125  String(";Solid;Liquid;Gas;Solution;Emulsion;Suspension").split(';', cv_terms_[0]);
126  // IonizationMode
127  String(";PositiveIonMode;NegativeIonMode").split(';', cv_terms_[1]);
128  // ResolutionMethod
129  String(";FWHM;TenPercentValley;Baseline").split(';', cv_terms_[2]);
130  // ResolutionType
131  String(";Constant;Proportional").split(';', cv_terms_[3]);
132  // ScanFunction
133  // is no longer used cv_terms_[4] is empty now
134  // ScanDirection
135  String(";Up;Down").split(';', cv_terms_[5]);
136  // ScanLaw
137  String(";Exponential;Linear;Quadratic").split(';', cv_terms_[6]);
138  // PeakProcessing
139  String(";CentroidMassSpectrum;ContinuumMassSpectrum").split(';', cv_terms_[7]);
140  // ReflectronState
141  String(";On;Off;None").split(';', cv_terms_[8]);
142  // AcquisitionMode
143  String(";PulseCounting;ADC;TDC;TransientRecorder").split(';', cv_terms_[9]);
144  // IonizationType
145  String(";ESI;EI;CI;FAB;TSP;LD;FD;FI;PD;SI;TI;API;ISI;CID;CAD;HN;APCI;APPI;ICP").split(';', cv_terms_[10]);
146  // InletType
147  String(";Direct;Batch;Chromatography;ParticleBeam;MembraneSeparator;OpenSplit;JetSeparator;Septum;Reservoir;MovingBelt;MovingWire;FlowInjectionAnalysis;ElectrosprayInlet;ThermosprayInlet;Infusion;ContinuousFlowFastAtomBombardment;InductivelyCoupledPlasma").split(';', cv_terms_[11]);
148  // TandemScanningMethod
149  // is no longer used cv_terms_[12] is empty now
150  // DetectorType
151  String(";EM;Photomultiplier;FocalPlaneArray;FaradayCup;ConversionDynodeElectronMultiplier;ConversionDynodePhotomultiplier;Multi-Collector;ChannelElectronMultiplier").split(';', cv_terms_[13]);
152  // AnalyzerType
153  String(";Quadrupole;PaulIonTrap;RadialEjectionLinearIonTrap;AxialEjectionLinearIonTrap;TOF;Sector;FourierTransform;IonStorage").split(';', cv_terms_[14]);
154  // EnergyUnits
155  // is no longer used cv_terms_[15] is empty now
156  // ScanMode
157  // is no longer used cv_terms_[16] is empty now
158  // Polarity
159  // is no longer used cv_terms_[17] is empty now
160  // ActivationMethod
161  String("CID;PSD;PD;SID").split(';', cv_terms_[18]);
162  }
163 
164 protected:
165 
167  typedef typename MapType::PeakType PeakType;
170 
174  const MapType * cexp_;
175 
178 
184  SpectrumType spec_;
186  std::vector<std::pair<String, MetaInfoDescription> > meta_id_descs_;
188  std::vector<String> data_to_decode_;
190  std::vector<float> data_to_encode_;
191  std::vector<std::vector<float> > decoded_list_;
192  std::vector<std::vector<double> > decoded_double_list_;
193  std::vector<String> precisions_;
194  std::vector<String> endians_;
196 
199 
202 
205 
207  void fillData_();
208 
210 
211 
222  inline void writeCVS_(std::ostream & os, double value, const String & acc, const String & name, UInt indent = 4) const
223  {
224  if (value != 0.0)
225  {
226  os << String(indent, '\t') << "<cvParam cvLabel=\"psi\" accession=\"PSI:" << acc << "\" name=\"" << name << "\" value=\"" << value << "\"/>\n";
227  }
228  }
229 
241  inline void writeCVS_(std::ostream & os, const String & value, const String & acc, const String & name, UInt indent = 4) const
242  {
243  if (value != "")
244  {
245  os << String(indent, '\t') << "<cvParam cvLabel=\"psi\" accession=\"PSI:" << acc << "\" name=\"" << name << "\" value=\"" << value << "\"/>\n";
246  }
247  }
248 
262  inline void writeCVS_(std::ostream & os, UInt value, UInt map, const String & acc, const String & name, UInt indent = 4)
263  {
264  //abort when receiving a wrong map index
265  if (map >= cv_terms_.size())
266  {
267  warning(STORE, String("Cannot find map '") + map + "' needed to write CV term '" + name + "' with accession '" + acc + "'.");
268  return;
269  }
270  //abort when receiving a wrong term index
271  if (value >= cv_terms_[map].size())
272  {
273  warning(STORE, String("Cannot find value '") + value + "' needed to write CV term '" + name + "' with accession '" + acc + "'.");
274  return;
275  }
276  writeCVS_(os, cv_terms_[map][value], acc, name, indent);
277  }
278 
280  inline void writeUserParam_(std::ostream & os, const MetaInfoInterface & meta, UInt indent = 4)
281  {
282  std::vector<String> keys;
283  meta.getKeys(keys);
284  for (std::vector<String>::const_iterator it = keys.begin(); it != keys.end(); ++it)
285  {
286  if ((*it)[0] != '#') // internally used meta info start with '#'
287  {
288  os << String(indent, '\t') << "<userParam name=\"" << *it << "\" value=\"" << meta.getMetaValue(*it) << "\"/>\n";
289  }
290  }
291  }
292 
300  void cvParam_(const String & name, const String & value);
302 
308  inline void writeBinary_(std::ostream & os, Size size, const String & tag, const String & name = "", SignedSize id = -1)
309  {
310  os << "\t\t\t<" << tag;
311  if (tag == "supDataArrayBinary" || tag == "supDataArray")
312  {
313  os << " id=\"" << id << "\"";
314  }
315  os << ">\n";
316  if (tag == "supDataArrayBinary" || tag == "supDataArray")
317  {
318  os << "\t\t\t\t<arrayName>" << name << "</arrayName>\n";
319  }
320 
321  String str;
322  decoder_.encode(data_to_encode_, Base64::BYTEORDER_LITTLEENDIAN, str);
323  data_to_encode_.clear();
324  os << "\t\t\t\t<data precision=\"32\" endian=\"little\" length=\""
325  << size << "\">"
326  << str
327  << "</data>\n\t\t\t</" << tag << ">\n";
328  }
329 
330  //Data processing auxiliary variable
332 
333  };
334 
335  //--------------------------------------------------------------------------------
336 
337  template <typename MapType>
338  void MzDataHandler<MapType>::characters(const XMLCh * const chars, const XMLSize_t /*length*/)
339  {
340  // skip current spectrum
341  if (skip_spectrum_)
342  return;
343 
344  char * transcoded_chars = sm_.convert(chars);
345 
346  //current tag
347  const String & current_tag = open_tags_.back();
348 
349  //determine the parent tag
350  String parent_tag;
351  if (open_tags_.size() > 1)
352  parent_tag = *(open_tags_.end() - 2);
353 
354 
355  if (current_tag == "sampleName")
356  {
357  exp_->getSample().setName(sm_.convert(chars));
358  }
359  else if (current_tag == "instrumentName")
360  {
361  exp_->getInstrument().setName(sm_.convert(chars));
362  }
363  else if (current_tag == "version")
364  {
365  data_processing_.getSoftware().setVersion(sm_.convert(chars));
366  }
367  else if (current_tag == "institution")
368  {
369  exp_->getContacts().back().setInstitution(sm_.convert(chars));
370  }
371  else if (current_tag == "contactInfo")
372  {
373  exp_->getContacts().back().setContactInfo(sm_.convert(chars));
374  }
375  else if (current_tag == "name" && parent_tag == "contact")
376  {
377  exp_->getContacts().back().setName(sm_.convert(chars));
378  }
379  else if (current_tag == "name" && parent_tag == "software")
380  {
381  data_processing_.getSoftware().setName(sm_.convert(chars));
382  }
383  else if (current_tag == "comments" && parent_tag == "software")
384  {
385  data_processing_.getSoftware().setMetaValue("comment", String(sm_.convert(chars)));
386  }
387  else if (current_tag == "comments" && parent_tag == "spectrumDesc")
388  {
389  spec_.setComment(transcoded_chars);
390  }
391  else if (current_tag == "data")
392  {
393  //chars may be split to several chunks => concatenate them
394  data_to_decode_.back() += transcoded_chars;
395  }
396  else if (current_tag == "arrayName" && parent_tag == "supDataArrayBinary")
397  {
398  spec_.getFloatDataArrays().back().setName(transcoded_chars);
399  }
400  else if (current_tag == "nameOfFile" && parent_tag == "sourceFile")
401  {
402  exp_->getSourceFiles().back().setNameOfFile(sm_.convert(chars));
403  }
404  else if (current_tag == "nameOfFile" && parent_tag == "supSourceFile")
405  {
406  //ignored
407  }
408  else if (current_tag == "pathToFile" && parent_tag == "sourceFile")
409  {
410  exp_->getSourceFiles().back().setPathToFile(sm_.convert(chars));
411  }
412  else if (current_tag == "pathToFile" && parent_tag == "supSourceFile")
413  {
414  //ignored
415  }
416  else if (current_tag == "fileType" && parent_tag == "sourceFile")
417  {
418  exp_->getSourceFiles().back().setFileType(sm_.convert(chars));
419  }
420  else if (current_tag == "fileType" && parent_tag == "supSourceFile")
421  {
422  //ignored
423  }
424  else
425  {
426  String trimmed_transcoded_chars = transcoded_chars;
427  trimmed_transcoded_chars.trim();
428  if (trimmed_transcoded_chars != "")
429  {
430  warning(LOAD, String("Unhandled character content in tag '") + current_tag + "': " + trimmed_transcoded_chars);
431  }
432  }
433  }
434 
435  template <typename MapType>
436  void MzDataHandler<MapType>::startElement(const XMLCh * const /*uri*/, const XMLCh * const /*local_name*/, const XMLCh * const qname, const xercesc::Attributes & attributes)
437  {
438  static const XMLCh * s_name = xercesc::XMLString::transcode("name");
439  static const XMLCh * s_accession = xercesc::XMLString::transcode("accession");
440  static const XMLCh * s_value = xercesc::XMLString::transcode("value");
441  static const XMLCh * s_id = xercesc::XMLString::transcode("id");
442  static const XMLCh * s_count = xercesc::XMLString::transcode("count");
443  static const XMLCh * s_spectrumtype = xercesc::XMLString::transcode("spectrumType");
444  static const XMLCh * s_methodofcombination = xercesc::XMLString::transcode("methodOfCombination");
445  static const XMLCh * s_acqnumber = xercesc::XMLString::transcode("acqNumber");
446  static const XMLCh * s_mslevel = xercesc::XMLString::transcode("msLevel");
447  static const XMLCh * s_mzrangestart = xercesc::XMLString::transcode("mzRangeStart");
448  static const XMLCh * s_mzrangestop = xercesc::XMLString::transcode("mzRangeStop");
449  static const XMLCh * s_supdataarrayref = xercesc::XMLString::transcode("supDataArrayRef");
450  static const XMLCh * s_precision = xercesc::XMLString::transcode("precision");
451  static const XMLCh * s_endian = xercesc::XMLString::transcode("endian");
452  static const XMLCh * s_length = xercesc::XMLString::transcode("length");
453  static const XMLCh * s_comment = xercesc::XMLString::transcode("comment");
454  static const XMLCh * s_accessionnumber = xercesc::XMLString::transcode("accessionNumber");
455 
456  String tag = sm_.convert(qname);
457  open_tags_.push_back(tag);
458  //std::cout << "Start: '" << tag << "'" << std::endl;
459 
460  //determine the parent tag
461  String parent_tag;
462  if (open_tags_.size() > 1)
463  parent_tag = *(open_tags_.end() - 2);
464 
465  //do nothing until a new spectrum is reached
466  if (tag != "spectrum" && skip_spectrum_)
467  return;
468 
469 
470  // Do something depending on the tag
471  if (tag == "sourceFile")
472  {
473  exp_->getSourceFiles().push_back(SourceFile());
474  }
475  if (tag == "contact")
476  {
477  exp_->getContacts().resize(exp_->getContacts().size() + 1);
478  }
479  else if (tag == "source")
480  {
481  exp_->getInstrument().getIonSources().resize(1);
482  }
483  else if (tag == "detector")
484  {
485  exp_->getInstrument().getIonDetectors().resize(1);
486  }
487  else if (tag == "analyzer")
488  {
489  exp_->getInstrument().getMassAnalyzers().resize(exp_->getInstrument().getMassAnalyzers().size() + 1);
490  }
491  else if (tag == "software")
492  {
493  data_processing_ = DataProcessing();
494  if (attributes.getIndex(sm_.convert("completionTime")) != -1)
495  {
496  data_processing_.setCompletionTime(asDateTime_(sm_.convert(attributes.getValue(sm_.convert("completionTime")))));
497  }
498  }
499  else if (tag == "precursor")
500  {
501  spec_.getPrecursors().push_back(Precursor());
502  }
503  else if (tag == "cvParam")
504  {
505  String accession = attributeAsString_(attributes, s_accession);
506  String value = "";
507  optionalAttributeAsString_(value, attributes, s_value);
508  cvParam_(accession, value);
509  }
510  else if (tag == "supDataDesc")
511  {
512  String comment;
513  if (optionalAttributeAsString_(comment, attributes, s_comment))
514  {
515  meta_id_descs_.back().second.setMetaValue("comment", comment);
516  }
517  }
518  else if (tag == "userParam")
519  {
520  String name = attributeAsString_(attributes, s_name);
521  String value = "";
522  optionalAttributeAsString_(value, attributes, s_value);
523 
524  if (parent_tag == "spectrumInstrument")
525  {
526  spec_.getInstrumentSettings().setMetaValue(name, value);
527  }
528  else if (parent_tag == "acquisition")
529  {
530  spec_.getAcquisitionInfo().back().setMetaValue(name, value);
531  }
532  else if (parent_tag == "ionSelection")
533  {
534  spec_.getPrecursors().back().setMetaValue(name, value);
535  }
536  else if (parent_tag == "activation")
537  {
538  spec_.getPrecursors().back().setMetaValue(name, value);
539  }
540  else if (parent_tag == "supDataDesc")
541  {
542  meta_id_descs_.back().second.setMetaValue(name, value);
543  }
544  else if (parent_tag == "detector")
545  {
546  exp_->getInstrument().getIonDetectors().back().setMetaValue(name, value);
547  }
548  else if (parent_tag == "source")
549  {
550  exp_->getInstrument().getIonSources().back().setMetaValue(name, value);
551  }
552  else if (parent_tag == "sampleDescription")
553  {
554  exp_->getSample().setMetaValue(name, value);
555  }
556  else if (parent_tag == "analyzer")
557  {
558  exp_->getInstrument().getMassAnalyzers().back().setMetaValue(name, value);
559  }
560  else if (parent_tag == "additional")
561  {
562  exp_->getInstrument().setMetaValue(name, value);
563  }
564  else if (parent_tag == "processingMethod")
565  {
566  data_processing_.setMetaValue(name, value);
567  }
568  else
569  {
570  warning(LOAD, "Invalid userParam: name=\"" + name + ", value=\"" + value + "\"");
571  }
572  }
573  else if (tag == "supDataArrayBinary")
574  {
575 
576  //create FloatDataArray
577  typename MapType::SpectrumType::FloatDataArray mda;
578  //Assign the right MetaInfoDescription ("supDesc" tag)
579  String id = attributeAsString_(attributes, s_id);
580  for (Size i = 0; i < meta_id_descs_.size(); ++i)
581  {
582  if (meta_id_descs_[i].first == id)
583  {
584  mda.MetaInfoDescription::operator=(meta_id_descs_[i].second);
585  break;
586  }
587  }
588  //append FloatDataArray
589  spec_.getFloatDataArrays().push_back(mda);
590  }
591  else if (tag == "spectrum")
592  {
593  spec_ = SpectrumType();
594  spec_.setNativeID(String("spectrum=") + attributeAsString_(attributes, s_id));
595  spec_.getDataProcessing().push_back(data_processing_);
596  }
597  else if (tag == "spectrumList")
598  {
599  if (options_.getMetadataOnly())
600  throw EndParsingSoftly(__FILE__, __LINE__, __PRETTY_FUNCTION__);
601  //std::cout << Date::now() << " Reserving space for spectra" << std::endl;
602  UInt count = attributeAsInt_(attributes, s_count);
603  exp_->reserve(count);
604  logger_.startProgress(0, count, "loading mzData file");
605  //std::cout << Date::now() << " done" << std::endl;
606  }
607  else if (tag == "mzData")
608  {
609  //handle file id
610  exp_->setIdentifier(attributeAsString_(attributes, s_accessionnumber));
611  }
612  else if (tag == "acqSpecification")
613  {
614  String tmp_type = attributeAsString_(attributes, s_spectrumtype);
615  if (tmp_type == "discrete")
616  {
617  spec_.setType(SpectrumSettings::PEAKS);
618  }
619  else if (tmp_type == "continuous")
620  {
621  spec_.setType(SpectrumSettings::RAWDATA);
622  }
623  else
624  {
625  spec_.setType(SpectrumSettings::UNKNOWN);
626  warning(LOAD, String("Invalid spectrum type '") + tmp_type + "'.");
627  }
628 
629  spec_.getAcquisitionInfo().setMethodOfCombination(attributeAsString_(attributes, s_methodofcombination));
630  }
631  else if (tag == "acquisition")
632  {
633  spec_.getAcquisitionInfo().insert(spec_.getAcquisitionInfo().end(), Acquisition());
634  spec_.getAcquisitionInfo().back().setIdentifier(attributeAsString_(attributes, s_acqnumber));
635  }
636  else if (tag == "spectrumInstrument" || tag == "acqInstrument")
637  {
638  spec_.setMSLevel(attributeAsInt_(attributes, s_mslevel));
639  ScanWindow window;
640  optionalAttributeAsDouble_(window.begin, attributes, s_mzrangestart);
641  optionalAttributeAsDouble_(window.end, attributes, s_mzrangestop);
642  if (window.begin != 0.0 || window.end != 0.0)
643  {
644  spec_.getInstrumentSettings().getScanWindows().push_back(window);
645  }
646 
647  if (options_.hasMSLevels() && !options_.containsMSLevel(spec_.getMSLevel()))
648  {
649  skip_spectrum_ = true;
650  }
651  }
652  else if (tag == "supDesc")
653  {
654  meta_id_descs_.push_back(std::make_pair(attributeAsString_(attributes, s_supdataarrayref), MetaInfoDescription()));
655  }
656  else if (tag == "data")
657  {
658  // store precision for later
659  precisions_.push_back(attributeAsString_(attributes, s_precision));
660  endians_.push_back(attributeAsString_(attributes, s_endian));
661 
662  //reserve enough space in spectrum
663  if (parent_tag == "mzArrayBinary")
664  {
665  peak_count_ = attributeAsInt_(attributes, s_length);
666  spec_.reserve(peak_count_);
667  }
668  }
669  else if (tag == "mzArrayBinary")
670  {
671  data_to_decode_.resize(data_to_decode_.size() + 1);
672  }
673  else if (tag == "intenArrayBinary")
674  {
675  data_to_decode_.resize(data_to_decode_.size() + 1);
676  }
677  else if (tag == "arrayName" && parent_tag == "supDataArrayBinary")
678  {
679  // Note: name is set in closing tag as it is CDATA
680  data_to_decode_.resize(data_to_decode_.size() + 1);
681  }
682  //std::cout << "end startelement" << std::endl;
683  }
684 
685  template <typename MapType>
686  void MzDataHandler<MapType>::endElement(const XMLCh * const /*uri*/, const XMLCh * const /*local_name*/, const XMLCh * const qname)
687  {
688  static UInt scan_count = 0;
689 
690  static const XMLCh * s_spectrum = xercesc::XMLString::transcode("spectrum");
691  static const XMLCh * s_mzdata = xercesc::XMLString::transcode("mzData");
692 
693  open_tags_.pop_back();
694  //std::cout << "End: '" << sm_.convert(qname) << "'" << std::endl;
695 
696  if (equal_(qname, s_spectrum))
697  {
698  if (!skip_spectrum_)
699  {
700  fillData_();
701  exp_->addSpectrum(spec_);
702  }
703  skip_spectrum_ = false;
704  logger_.setProgress(++scan_count);
705  decoded_list_.clear();
706  decoded_double_list_.clear();
707  data_to_decode_.clear();
708  precisions_.clear();
709  endians_.clear();
710  meta_id_descs_.clear();
711  }
712  else if (equal_(qname, s_mzdata))
713  {
714  logger_.endProgress();
715  scan_count = 0;
716  }
717 
718  sm_.clear();
719  }
720 
721  template <typename MapType>
723  {
724  std::vector<float> decoded;
725  std::vector<double> decoded_double;
726 
727  // data_to_decode is an encoded spectrum, represented as
728  // vector of base64-encoded strings:
729  // Each string represents one property (e.g. mzData) and decodes
730  // to a vector of property values - one value for every peak in the spectrum.
731  for (Size i = 0; i < data_to_decode_.size(); ++i)
732  {
733  //remove whitespaces from binary data
734  //this should not be necessary, but linebreaks inside the base64 data are unfortunately no exception
735  data_to_decode_[i].removeWhitespaces();
736 
737  if (precisions_[i] == "64") // precision 64 Bit
738  {
739  if (endians_[i] == "big")
740  {
741  //std::cout << "nr. " << i << ": decoding as high-precision big endian" << std::endl;
742  decoder_.decode(data_to_decode_[i], Base64::BYTEORDER_BIGENDIAN, decoded_double);
743  }
744  else
745  {
746  //std::cout << "nr. " << i << ": decoding as high-precision little endian" << std::endl;
747  decoder_.decode(data_to_decode_[i], Base64::BYTEORDER_LITTLEENDIAN, decoded_double);
748  }
749  // push_back the decoded double data - and an empty one into
750  // the dingle-precision vector, so that we don't mess up the index
751  //std::cout << "list size: " << decoded_double.size() << std::endl;
752  decoded_double_list_.push_back(decoded_double);
753  decoded_list_.push_back(std::vector<float>());
754  }
755  else // precision 32 Bit
756  {
757  if (endians_[i] == "big")
758  {
759  //std::cout << "nr. " << i << ": decoding as low-precision big endian" << std::endl;
760  decoder_.decode(data_to_decode_[i], Base64::BYTEORDER_BIGENDIAN, decoded);
761  }
762  else
763  {
764  //std::cout << "nr. " << i << ": decoding as low-precision little endian" << std::endl;
765  decoder_.decode(data_to_decode_[i], Base64::BYTEORDER_LITTLEENDIAN, decoded);
766  }
767  //std::cout << "list size: " << decoded.size() << std::endl;
768  decoded_list_.push_back(decoded);
769  decoded_double_list_.push_back(std::vector<double>());
770  }
771  }
772 
773  // this works only if MapType::PeakType is a Peak1D or derived from it
774  {
775  //store what precision is used for intensity and m/z
776  bool mz_precision_64 = true;
777  if (precisions_[0] == "32")
778  {
779  mz_precision_64 = false;
780  }
781  bool int_precision_64 = true;
782  if (precisions_[1] == "32")
783  {
784  int_precision_64 = false;
785  }
786 
787  //reserve space for meta data arrays (peak count)
788  for (Size i = 0; i < spec_.getFloatDataArrays().size(); ++i)
789  {
790  spec_.getFloatDataArrays()[i].reserve(peak_count_);
791  }
792 
793  //push_back the peaks into the container
794  for (Size n = 0; n < peak_count_; ++n)
795  {
796  double mz = mz_precision_64 ? decoded_double_list_[0][n] : decoded_list_[0][n];
797  double intensity = int_precision_64 ? decoded_double_list_[1][n] : decoded_list_[1][n];
798  if ((!options_.hasMZRange() || options_.getMZRange().encloses(DPosition<1>(mz)))
799  && (!options_.hasIntensityRange() || options_.getIntensityRange().encloses(DPosition<1>(intensity))))
800  {
801  PeakType tmp;
802  tmp.setIntensity(intensity);
803  tmp.setMZ(mz);
804  spec_.push_back(tmp);
805  //load data from meta data arrays
806  for (Size i = 0; i < spec_.getFloatDataArrays().size(); ++i)
807  {
808  spec_.getFloatDataArrays()[i].push_back(precisions_[2 + i] == "64" ? decoded_double_list_[2 + i][n] : decoded_list_[2 + i][n]);
809  }
810  }
811  }
812  }
813  }
814 
815  template <typename MapType>
816  void MzDataHandler<MapType>::writeTo(std::ostream & os)
817  {
818  logger_.startProgress(0, cexp_->size(), "storing mzData file");
819 
820  os << "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n"
821  << "<mzData version=\"1.05\" accessionNumber=\"" << cexp_->getIdentifier() << "\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"http://psidev.sourceforge.net/ms/xml/mzdata/mzdata.xsd\">\n";
822 
823  //---------------------------------------------------------------------------------------------------
824  //DESCRIPTION
825  const Sample & sm = cexp_->getSample();
826  os << "\t<description>\n"
827  << "\t\t<admin>\n"
828  << "\t\t\t<sampleName>"
829  << sm.getName()
830  << "</sampleName>\n";
831 
832 #pragma clang diagnostic push
833 #pragma clang diagnostic ignored "-Wconversion"
834  if (sm.getNumber() != "" || sm.getState() || sm.getMass() || sm.getVolume() || sm.getConcentration() || !sm.isMetaEmpty())
835 #pragma clang diagnostic pop
836  {
837  os << "\t\t\t<sampleDescription>\n";
838  writeCVS_(os, sm.getNumber(), "1000001", "SampleNumber");
839  writeCVS_(os, sm.getState(), 0, "1000003", "SampleState");
840  writeCVS_(os, sm.getMass(), "1000004", "SampleMass");
841  writeCVS_(os, sm.getVolume(), "1000005", "SampleVolume");
842  writeCVS_(os, sm.getConcentration(), "1000006", "SampleConcentration");
843  writeUserParam_(os, cexp_->getSample());
844  os << "\t\t\t</sampleDescription>\n";
845  }
846 
847  if (cexp_->getSourceFiles().size() >= 1)
848  {
849  os << "\t\t\t<sourceFile>\n"
850  << "\t\t\t\t<nameOfFile>" << cexp_->getSourceFiles()[0].getNameOfFile() << "</nameOfFile>\n"
851  << "\t\t\t\t<pathToFile>" << cexp_->getSourceFiles()[0].getPathToFile() << "</pathToFile>\n";
852  if (cexp_->getSourceFiles()[0].getFileType() != "")
853  os << "\t\t\t\t<fileType>" << cexp_->getSourceFiles()[0].getFileType() << "</fileType>\n";
854  os << "\t\t\t</sourceFile>\n";
855  }
856  if (cexp_->getSourceFiles().size() > 1)
857  {
858  warning(STORE, "The MzData format can store only one source file. Only the first one is stored!");
859  }
860 
861  for (Size i = 0; i < cexp_->getContacts().size(); ++i)
862  {
863  os << "\t\t\t<contact>\n"
864  << "\t\t\t\t<name>" << cexp_->getContacts()[i].getFirstName() << " " << cexp_->getContacts()[i].getLastName() << "</name>\n"
865  << "\t\t\t\t<institution>" << cexp_->getContacts()[i].getInstitution() << "</institution>\n";
866  if (cexp_->getContacts()[i].getContactInfo() != "")
867  os << "\t\t\t\t<contactInfo>" << cexp_->getContacts()[i].getContactInfo() << "</contactInfo>\n";
868  os << "\t\t\t</contact>\n";
869  }
870  //no contacts given => add empty entry as there must be a contact entry
871  if (cexp_->getContacts().empty())
872  {
873  os << "\t\t\t<contact>\n"
874  << "\t\t\t\t<name></name>\n"
875  << "\t\t\t\t<institution></institution>\n";
876  os << "\t\t\t</contact>\n";
877  }
878 
879  os << "\t\t</admin>\n";
880  const Instrument & inst = cexp_->getInstrument();
881  os << "\t\t<instrument>\n"
882  << "\t\t\t<instrumentName>" << inst.getName() << "</instrumentName>\n"
883  << "\t\t\t<source>\n";
884  if (inst.getIonSources().size() >= 1)
885  {
886  writeCVS_(os, inst.getIonSources()[0].getInletType(), 11, "1000007", "InletType");
887  writeCVS_(os, inst.getIonSources()[0].getIonizationMethod(), 10, "1000008", "IonizationType");
888  writeCVS_(os, inst.getIonSources()[0].getPolarity(), 1, "1000009", "IonizationMode");
889  writeUserParam_(os, inst.getIonSources()[0]);
890  }
891  if (inst.getIonSources().size() > 1)
892  {
893  warning(STORE, "The MzData format can store only one ion source. Only the first one is stored!");
894  }
895  os << "\t\t\t</source>\n";
896 
897  //no analyzer given => add empty entry as there must be one entry
898  if (inst.getMassAnalyzers().empty())
899  {
900  os << "\t\t\t<analyzerList count=\"1\">\n"
901  << "\t\t\t\t<analyzer>\n"
902  << "\t\t\t\t</analyzer>\n";
903  }
904  else
905  {
906  os << "\t\t\t<analyzerList count=\"" << inst.getMassAnalyzers().size() << "\">\n";
907  for (Size i = 0; i < inst.getMassAnalyzers().size(); ++i)
908  {
909  os << "\t\t\t\t<analyzer>\n";
910  const MassAnalyzer & ana = inst.getMassAnalyzers()[i];
911  writeCVS_(os, ana.getType(), 14, "1000010", "AnalyzerType", 5);
912  writeCVS_(os, ana.getResolution(), "1000011", "MassResolution", 5);
913  writeCVS_(os, ana.getResolutionMethod(), 2, "1000012", "ResolutionMethod", 5);
914  writeCVS_(os, ana.getResolutionType(), 3, "1000013", "ResolutionType", 5);
915  writeCVS_(os, ana.getAccuracy(), "1000014", "Accuracy", 5);
916  writeCVS_(os, ana.getScanRate(), "1000015", "ScanRate", 5);
917  writeCVS_(os, ana.getScanTime(), "1000016", "ScanTime", 5);
918  writeCVS_(os, ana.getScanDirection(), 5, "1000018", "ScanDirection", 5);
919  writeCVS_(os, ana.getScanLaw(), 6, "1000019", "ScanLaw", 5);
920  writeCVS_(os, ana.getReflectronState(), 8, "1000021", "ReflectronState", 5);
921  writeCVS_(os, ana.getTOFTotalPathLength(), "1000022", "TOFTotalPathLength", 5);
922  writeCVS_(os, ana.getIsolationWidth(), "1000023", "IsolationWidth", 5);
923  writeCVS_(os, ana.getFinalMSExponent(), "1000024", "FinalMSExponent", 5);
924  writeCVS_(os, ana.getMagneticFieldStrength(), "1000025", "MagneticFieldStrength", 5);
925  writeUserParam_(os, ana, 5);
926  os << "\t\t\t\t</analyzer>\n";
927  }
928  }
929  os << "\t\t\t</analyzerList>\n";
930 
931  os << "\t\t\t<detector>\n";
932  if (inst.getIonDetectors().size() >= 1)
933  {
934  writeCVS_(os, inst.getIonDetectors()[0].getType(), 13, "1000026", "DetectorType");
935  writeCVS_(os, inst.getIonDetectors()[0].getAcquisitionMode(), 9, "1000027", "DetectorAcquisitionMode");
936  writeCVS_(os, inst.getIonDetectors()[0].getResolution(), "1000028", "DetectorResolution");
937  writeCVS_(os, inst.getIonDetectors()[0].getADCSamplingFrequency(), "1000029", "SamplingFrequency");
938  writeUserParam_(os, inst.getIonDetectors()[0]);
939  }
940  if (inst.getIonDetectors().size() > 1)
941  {
942  warning(STORE, "The MzData format can store only one ion detector. Only the first one is stored!");
943  }
944  os << "\t\t\t</detector>\n";
945  if (inst.getVendor() != "" || inst.getModel() != "" || inst.getCustomizations() != "")
946  {
947  os << "\t\t\t<additional>\n";
948  writeCVS_(os, inst.getVendor(), "1000030", "Vendor");
949  writeCVS_(os, inst.getModel(), "1000031", "Model");
950  writeCVS_(os, inst.getCustomizations(), "1000032", "Customization");
951  writeUserParam_(os, inst);
952  os << "\t\t\t</additional>\n";
953  }
954  os << "\t\t</instrument>\n";
955 
956  //the data processing information of the first spectrum is used for the whole file
957  if (cexp_->size() == 0 || (*cexp_)[0].getDataProcessing().empty())
958  {
959  os << "\t\t<dataProcessing>\n"
960  << "\t\t\t<software>\n"
961  << "\t\t\t\t<name></name>\n"
962  << "\t\t\t\t<version></version>\n"
963  << "\t\t\t</software>\n"
964  << "\t\t</dataProcessing>\n";
965  }
966  else
967  {
968  const DataProcessing & data_processing = (*cexp_)[0].getDataProcessing()[0];
969  os << "\t\t<dataProcessing>\n"
970  << "\t\t\t<software";
971  if (data_processing.getCompletionTime() != DateTime())
972  {
973  os << " completionTime=\"" << data_processing.getCompletionTime().get().substitute(' ', 'T') << "\"";
974  }
975  os << ">\n"
976  << "\t\t\t\t<name>" << data_processing.getSoftware().getName() << "</name>\n"
977  << "\t\t\t\t<version>" << data_processing.getSoftware().getVersion() << "</version>\n";
978  os << "\t\t\t</software>\n"
979  << "\t\t\t<processingMethod>\n";
980  if (data_processing.getProcessingActions().count(DataProcessing::DEISOTOPING) == 1)
981  {
982  os << "\t\t\t\t<cvParam cvLabel=\"psi\" name=\"Deisotoping\" accession=\"PSI:1000033\" />\n";
983  }
984  if (data_processing.getProcessingActions().count(DataProcessing::CHARGE_DECONVOLUTION) == 1)
985  {
986  os << "\t\t\t\t<cvParam cvLabel=\"psi\" name=\"ChargeDeconvolution\" accession=\"PSI:1000034\" />\n";
987  }
988  if (data_processing.getProcessingActions().count(DataProcessing::PEAK_PICKING) == 1)
989  {
990  os << "\t\t\t\t<cvParam cvLabel=\"psi\" name=\"Centroid Mass Spectrum\" accession=\"PSI:1000127\"/>\n";
991  }
992  writeUserParam_(os, data_processing);
993  os << "\t\t\t</processingMethod>\n"
994  << "\t\t</dataProcessing>\n";
995  }
996  os << "\t</description>\n";
997 
998  //---------------------------------------------------------------------------------------------------
999  //ACTUAL DATA
1000  if (cexp_->size() != 0)
1001  {
1002  //check if the nativeID of all spectra are numbers or numbers prefixed with 'spectrum='
1003  //If not we need to renumber all spectra.
1004  bool all_numbers = true;
1005  bool all_empty = true;
1006  bool all_prefixed_numbers = true;
1007  for (Size s = 0; s < cexp_->size(); s++)
1008  {
1009  String native_id = (*cexp_)[s].getNativeID();
1010  if (!native_id.hasPrefix("spectrum="))
1011  {
1012  all_prefixed_numbers = false;
1013  }
1014  else
1015  {
1016  native_id = native_id.substr(9);
1017  }
1018  try
1019  {
1020  native_id.toInt();
1021  }
1022  catch (Exception::ConversionError &)
1023  {
1024  all_numbers = false;
1025  all_prefixed_numbers = false;
1026  if (native_id != "")
1027  {
1028  all_empty = false;
1029  }
1030  }
1031  }
1032  //If we need to renumber and the nativeIDs were not empty, warn the user
1033  if (!all_numbers && !all_empty)
1034  {
1035  warning(STORE, "Not all spectrum native IDs are numbers or correctly prefixed with 'spectrum='. The spectra are renumbered and the native IDs are lost!");
1036  }
1037  //Map to store the last spectrum ID for each MS level (needed to find precursor spectra)
1038  Map<Int, Size> level_id;
1039 
1040  os << "\t<spectrumList count=\"" << cexp_->size() << "\">\n";
1041  for (Size s = 0; s < cexp_->size(); ++s)
1042  {
1043  logger_.setProgress(s);
1044  const SpectrumType & spec = (*cexp_)[s];
1045 
1046  Size spectrum_id = s + 1;
1047  if (all_prefixed_numbers)
1048  {
1049  spectrum_id = spec.getNativeID().substr(9).toInt();
1050  }
1051  else if (all_numbers)
1052  {
1053  spectrum_id = spec.getNativeID().toInt();
1054  }
1055  os << "\t\t<spectrum id=\"" << spectrum_id << "\">\n"
1056  << "\t\t\t<spectrumDesc>\n"
1057  << "\t\t\t\t<spectrumSettings>\n";
1058 
1059  if (!spec.getAcquisitionInfo().empty())
1060  {
1061  os << "\t\t\t\t\t<acqSpecification spectrumType=\"";
1062  if (spec.getType() == SpectrumSettings::PEAKS)
1063  {
1064  os << "discrete";
1065  }
1066  else if (spec.getType() == SpectrumSettings::RAWDATA)
1067  {
1068  os << "continuous";
1069  }
1070  else
1071  {
1072  warning(STORE, "Spectrum type is unknown, assuming 'discrete'");
1073  os << "discrete";
1074  }
1075 
1076  os << "\" methodOfCombination=\"" << spec.getAcquisitionInfo().getMethodOfCombination() << "\""
1077  << " count=\"" << spec.getAcquisitionInfo().size() << "\">\n";
1078  for (Size i = 0; i < spec.getAcquisitionInfo().size(); ++i)
1079  {
1080  const Acquisition & ac = spec.getAcquisitionInfo()[i];
1081  Int acq_number = 0;
1082  try
1083  {
1084  if (ac.getIdentifier() != "")
1085  {
1086  acq_number = ac.getIdentifier().toInt();
1087  }
1088  }
1089  catch (...)
1090  {
1091  warning(STORE, String("Could not convert acquisition identifier '") + ac.getIdentifier() + "' to an integer. Using '0' instead!");
1092  acq_number = 0;
1093  }
1094  os << "\t\t\t\t\t\t<acquisition acqNumber=\"" << acq_number << "\">\n";
1095  writeUserParam_(os, ac, 7);
1096  os << "\t\t\t\t\t\t</acquisition>\n";
1097  }
1098  os << "\t\t\t\t\t</acqSpecification>\n";
1099  }
1100 
1101  const InstrumentSettings & iset = spec.getInstrumentSettings();
1102  os << "\t\t\t\t\t<spectrumInstrument msLevel=\"" << spec.getMSLevel() << "\"";
1103  level_id[spec.getMSLevel()] = spectrum_id;
1104 
1105  if (!iset.getScanWindows().empty())
1106  {
1107  os << " mzRangeStart=\"" << iset.getScanWindows()[0].begin << "\" mzRangeStop=\"" << iset.getScanWindows()[0].end << "\"";
1108  }
1109  if (iset.getScanWindows().size() > 1)
1110  {
1111  warning(STORE, "The MzData format can store only one scan window for each scan. Only the first one is stored!");
1112  }
1113  os << ">\n";
1114 
1115  //scan mode
1116  switch (iset.getScanMode())
1117  {
1119  //do nothing here
1120  break;
1121 
1125  if (iset.getZoomScan())
1126  {
1127  os << "\t\t\t\t\t\t<cvParam cvLabel=\"psi\" accession=\"PSI:1000036\" name=\"ScanMode\" value=\"Zoom\"/>\n";
1128  }
1129  else
1130  {
1131  os << "\t\t\t\t\t\t<cvParam cvLabel=\"psi\" accession=\"PSI:1000036\" name=\"ScanMode\" value=\"MassScan\"/>\n";
1132  }
1133  break;
1134 
1136  os << "\t\t\t\t\t\t<cvParam cvLabel=\"psi\" accession=\"PSI:1000036\" name=\"ScanMode\" value=\"SelectedIonDetection\"/>\n";
1137  break;
1138 
1140  os << "\t\t\t\t\t\t<cvParam cvLabel=\"psi\" accession=\"PSI:1000036\" name=\"ScanMode\" value=\"SelectedReactionMonitoring\"/>\n";
1141  break;
1142 
1144  os << "\t\t\t\t\t\t<cvParam cvLabel=\"psi\" accession=\"PSI:1000036\" name=\"ScanMode\" value=\"ConsecutiveReactionMonitoring\"/>\n";
1145  break;
1146 
1148  os << "\t\t\t\t\t\t<cvParam cvLabel=\"psi\" accession=\"PSI:1000036\" name=\"ScanMode\" value=\"ConstantNeutralGainScan\"/>\n";
1149  break;
1150 
1152  os << "\t\t\t\t\t\t<cvParam cvLabel=\"psi\" accession=\"PSI:1000036\" name=\"ScanMode\" value=\"ConstantNeutralLossScan\"/>\n";
1153  break;
1154 
1156  os << "\t\t\t\t\t\t<cvParam cvLabel=\"psi\" accession=\"PSI:1000036\" name=\"ScanMode\" value=\"PrecursorIonScan\"/>\n";
1157  break;
1158 
1160  os << "\t\t\t\t\t\t<cvParam cvLabel=\"psi\" accession=\"PSI:1000036\" name=\"ScanMode\" value=\"PhotodiodeArrayDetector\"/>\n";
1161  break;
1162 
1164  os << "\t\t\t\t\t\t<cvParam cvLabel=\"psi\" accession=\"PSI:1000036\" name=\"ScanMode\" value=\"EnhancedMultiplyChargedScan\"/>\n";
1165  break;
1166 
1168  os << "\t\t\t\t\t\t<cvParam cvLabel=\"psi\" accession=\"PSI:1000036\" name=\"ScanMode\" value=\"TimeDelayedFragmentationScan\"/>\n";
1169  break;
1170 
1171  default:
1172  os << "\t\t\t\t\t\t<cvParam cvLabel=\"psi\" accession=\"PSI:1000036\" name=\"ScanMode\" value=\"MassScan\"/>\n";
1173  warning(STORE, String("Scan mode '") + InstrumentSettings::NamesOfScanMode[iset.getScanMode()] + "' not supported by mzData. Using 'MassScan' scan mode!");
1174  }
1175 
1176  //scan polarity
1178  {
1179  os << String(6, '\t') << "<cvParam cvLabel=\"psi\" accession=\"PSI:1000037\" name=\"Polarity\" value=\"Positive\"/>\n";
1180  }
1182  {
1183  os << String(6, '\t') << "<cvParam cvLabel=\"psi\" accession=\"PSI:1000037\" name=\"Polarity\" value=\"Negative\"/>\n";
1184  }
1185 
1186  //Retention time already in TimeInSeconds
1187  writeCVS_(os, spec.getRT(), "1000039", "TimeInSeconds", 6);
1188  writeUserParam_(os, spec.getInstrumentSettings(), 6);
1189  os << "\t\t\t\t\t</spectrumInstrument>\n\t\t\t\t</spectrumSettings>\n";
1190 
1191  if (spec.getPrecursors().size() != 0)
1192  {
1193  Int precursor_ms_level = spec.getMSLevel() - 1;
1194  SignedSize precursor_id = -1;
1195  if (level_id.has(precursor_ms_level))
1196  {
1197  precursor_id = level_id[precursor_ms_level];
1198  }
1199  os << "\t\t\t\t<precursorList count=\"" << spec.getPrecursors().size() << "\">\n";
1200  for (Size i = 0; i < spec.getPrecursors().size(); ++i)
1201  {
1202  const Precursor & precursor = spec.getPrecursors()[i];
1203  os << "\t\t\t\t\t<precursor msLevel=\"" << precursor_ms_level << "\" spectrumRef=\"" << precursor_id << "\">\n";
1204  os << "\t\t\t\t\t\t<ionSelection>\n";
1205  if (precursor != Precursor())
1206  {
1207  writeCVS_(os, precursor.getMZ(), "1000040", "MassToChargeRatio", 7);
1208  writeCVS_(os, precursor.getCharge(), "1000041", "ChargeState", 7);
1209  writeCVS_(os, precursor.getIntensity(), "1000042", "Intensity", 7);
1210  os << "\t\t\t\t\t\t\t<cvParam cvLabel=\"psi\" accession=\"PSI:1000043\" name=\"IntensityUnit\" value=\"NumberOfCounts\"/>\n";
1211  writeUserParam_(os, precursor, 7);
1212  }
1213  os << "\t\t\t\t\t\t</ionSelection>\n";
1214  os << "\t\t\t\t\t\t<activation>\n";
1215  if (precursor != Precursor())
1216  {
1217  if (precursor.getActivationMethods().size() > 0)
1218  {
1219  writeCVS_(os, *(precursor.getActivationMethods().begin()), 18, "1000044", "ActivationMethod", 7);
1220  }
1221  writeCVS_(os, precursor.getActivationEnergy(), "1000045", "CollisionEnergy", 7);
1222  os << "\t\t\t\t\t\t\t<cvParam cvLabel=\"psi\" accession=\"PSI:1000046\" name=\"EnergyUnit\" value=\"eV\"/>\n";
1223  }
1224  os << "\t\t\t\t\t\t</activation>\n";
1225  os << "\t\t\t\t\t</precursor>\n";
1226  }
1227  os << "\t\t\t\t</precursorList>\n";
1228  }
1229  os << "\t\t\t</spectrumDesc>\n";
1230 
1231  // write the supplementary data?
1232  if (options_.getWriteSupplementalData())
1233  {
1234  //write meta data array descriptions
1235  for (Size i = 0; i < spec.getFloatDataArrays().size(); ++i)
1236  {
1237  const MetaInfoDescription & desc = spec.getFloatDataArrays()[i];
1238  os << "\t\t\t<supDesc supDataArrayRef=\"" << (i + 1) << "\">\n";
1239  if (!desc.isMetaEmpty())
1240  {
1241  os << "\t\t\t\t<supDataDesc>\n";
1242  writeUserParam_(os, desc, 5);
1243  os << "\t\t\t\t</supDataDesc>\n";
1244  }
1245  os << "\t\t\t</supDesc>\n";
1246  }
1247  }
1248 
1249  //write m/z and intensity arrays
1250  data_to_encode_.clear();
1251  for (Size i = 0; i < spec.size(); i++)
1252  {
1253  data_to_encode_.push_back(spec[i].getPosition()[0]);
1254  }
1255 
1256  writeBinary_(os, spec.size(), "mzArrayBinary");
1257 
1258  // intensity
1259  data_to_encode_.clear();
1260  for (Size i = 0; i < spec.size(); i++)
1261  {
1262  data_to_encode_.push_back(spec[i].getIntensity());
1263  }
1264 
1265  writeBinary_(os, spec.size(), "intenArrayBinary");
1266 
1267  // write the supplementary data?
1268  if (options_.getWriteSupplementalData())
1269  {
1270  //write supplemental data arrays
1271  for (Size i = 0; i < spec.getFloatDataArrays().size(); ++i)
1272  {
1273  const typename MapType::SpectrumType::FloatDataArray & mda = spec.getFloatDataArrays()[i];
1274  //check if spectrum and meta data array have the same length
1275  if (mda.size() != spec.size())
1276  {
1277  error(LOAD, String("Length of meta data array (index:'") + i + "' name:'" + mda.getName() + "') differs from spectrum length. meta data array: " + mda.size() + " / spectrum: " + spec.size() + " .");
1278  }
1279  //encode meta data array
1280  data_to_encode_.clear();
1281  for (Size j = 0; j < mda.size(); j++)
1282  {
1283  data_to_encode_.push_back(mda[j]);
1284  }
1285  //write meta data array
1286  writeBinary_(os, mda.size(), "supDataArrayBinary", mda.getName(), i + 1);
1287  }
1288  }
1289 
1290  os << "\t\t</spectrum>\n";
1291  }
1292  }
1293  else
1294  {
1295  os << "\t<spectrumList count=\"1\">\n";
1296  os << "\t\t<spectrum id=\"1\">\n";
1297  os << "\t\t\t<spectrumDesc>\n";
1298  os << "\t\t\t\t<spectrumSettings>\n";
1299  os << "\t\t\t\t\t<spectrumInstrument msLevel=\"1\"/>\n";
1300  os << "\t\t\t\t</spectrumSettings>\n";
1301  os << "\t\t\t</spectrumDesc>\n";
1302  os << "\t\t\t<mzArrayBinary>\n";
1303  os << "\t\t\t\t<data length=\"0\" endian=\"little\" precision=\"32\"></data>\n";
1304  os << "\t\t\t</mzArrayBinary>\n";
1305  os << "\t\t\t<intenArrayBinary>\n";
1306  os << "\t\t\t\t<data length=\"0\" endian=\"little\" precision=\"32\"></data>\n";
1307  os << "\t\t\t</intenArrayBinary>\n";
1308  os << "\t\t</spectrum>\n";
1309  }
1310  os << "\t</spectrumList>\n</mzData>\n";
1311 
1312  logger_.endProgress();
1313  }
1314 
1315  template <typename MapType>
1316  void MzDataHandler<MapType>::cvParam_(const String & accession, const String & value)
1317  {
1318  String error = "";
1319 
1320  //determine the parent tag
1321  String parent_tag;
1322  if (open_tags_.size() > 1)
1323  parent_tag = *(open_tags_.end() - 2);
1324 
1325  if (parent_tag == "spectrumInstrument")
1326  {
1327  if (accession == "PSI:1000036") //Scan Mode
1328  {
1329  if (value == "Zoom")
1330  {
1331  spec_.getInstrumentSettings().setZoomScan(true);
1332  spec_.getInstrumentSettings().setScanMode(InstrumentSettings::MASSSPECTRUM);
1333  }
1334  else if (value == "MassScan")
1335  {
1336  spec_.getInstrumentSettings().setScanMode(InstrumentSettings::MASSSPECTRUM);
1337  }
1338  else if (value == "SelectedIonDetection")
1339  {
1340  spec_.getInstrumentSettings().setScanMode(InstrumentSettings::SIM);
1341  }
1342  else if (value == "SelectedReactionMonitoring")
1343  {
1344  spec_.getInstrumentSettings().setScanMode(InstrumentSettings::SRM);
1345  }
1346  else if (value == "ConsecutiveReactionMonitoring")
1347  {
1348  spec_.getInstrumentSettings().setScanMode(InstrumentSettings::CRM);
1349  }
1350  else if (value == "ConstantNeutralGainScan")
1351  {
1352  spec_.getInstrumentSettings().setScanMode(InstrumentSettings::CNG);
1353  }
1354  else if (value == "ConstantNeutralLossScan")
1355  {
1356  spec_.getInstrumentSettings().setScanMode(InstrumentSettings::CNL);
1357  }
1358  else if (value == "ProductIonScan")
1359  {
1360  spec_.getInstrumentSettings().setScanMode(InstrumentSettings::MSNSPECTRUM);
1361  spec_.setMSLevel(2);
1362  }
1363  else if (value == "PrecursorIonScan")
1364  {
1365  spec_.getInstrumentSettings().setScanMode(InstrumentSettings::PRECURSOR);
1366  }
1367  else if (value == "EnhancedResolutionScan")
1368  {
1369  spec_.getInstrumentSettings().setZoomScan(true);
1370  spec_.getInstrumentSettings().setScanMode(InstrumentSettings::MASSSPECTRUM);
1371  }
1372  else
1373  {
1374  if (spec_.getMSLevel() >= 2)
1375  {
1376  exp_->getSpectra().back().getInstrumentSettings().setScanMode(InstrumentSettings::MSNSPECTRUM);
1377  }
1378  else
1379  {
1380  spec_.getInstrumentSettings().setScanMode(InstrumentSettings::MASSSPECTRUM);
1381  warning(LOAD, String("Unknown scan mode '") + value + "'. Assuming full scan");
1382  }
1383  }
1384  }
1385  else if (accession == "PSI:1000038") //Time in minutes
1386  {
1387  spec_.setRT(asDouble_(value) * 60); //Minutes to seconds
1388  if (options_.hasRTRange() && !options_.getRTRange().encloses(DPosition<1>(spec_.getRT())))
1389  {
1390  skip_spectrum_ = true;
1391  }
1392  }
1393  else if (accession == "PSI:1000039") //Time in seconds
1394  {
1395  spec_.setRT(asDouble_(value));
1396  if (options_.hasRTRange() && !options_.getRTRange().encloses(DPosition<1>(spec_.getRT())))
1397  {
1398  skip_spectrum_ = true;
1399  }
1400  }
1401  else if (accession == "PSI:1000037") //Polarity
1402  {
1403  if (value == "Positive" || value == "positive" || value == "+") //be flexible here, actually only the first one is correct
1404  {
1405  spec_.getInstrumentSettings().setPolarity(IonSource::POSITIVE);
1406  }
1407  else if (value == "Negative" || value == "negative" || value == "-") //be flexible here, actually only the first one is correct
1408  {
1409  spec_.getInstrumentSettings().setPolarity(IonSource::NEGATIVE);
1410  }
1411  else
1412  {
1413  warning(LOAD, String("Invalid scan polarity (PSI:1000037) detected: \"") + value + "\". Valid are 'Positive' or 'Negative'.");
1414  }
1415  }
1416  else
1417  {
1418  error = "SpectrumDescription.SpectrumSettings.SpectrumInstrument";
1419  }
1420  }
1421  else if (parent_tag == "ionSelection")
1422  {
1423  if (accession == "PSI:1000040") //m/z
1424  {
1425  spec_.getPrecursors().back().setMZ(asDouble_(value));
1426  }
1427  else if (accession == "PSI:1000041") //Charge
1428  {
1429  if (spec_.getPrecursors().back().getCharge() != 0)
1430  {
1431  warning(LOAD, String("Multiple precursor charges detected, expected only one! Ignoring this charge settings! accession=\"") + accession + "\", value=\"" + value + "\"");
1432  spec_.getPrecursors().back().setCharge(0);
1433  }
1434  else
1435  {
1436  spec_.getPrecursors().back().setCharge(asInt_(value));
1437  }
1438  }
1439  else if (accession == "PSI:1000042") //Intensity
1440  {
1441  spec_.getPrecursors().back().setIntensity(asDouble_(value));
1442  }
1443  else if (accession == "PSI:1000043") //Intensity unit
1444  {
1445  //ignored
1446  }
1447  else
1448  {
1449  error = "PrecursorList.Precursor.IonSelection.UserParam";
1450  }
1451  }
1452  else if (parent_tag == "activation")
1453  {
1454  if (accession == "PSI:1000044") //activationmethod
1455  {
1456  spec_.getPrecursors().back().getActivationMethods().insert((Precursor::ActivationMethod)cvStringToEnum_(18, value, "activation method"));
1457  }
1458  else if (accession == "PSI:1000045") //Energy
1459  {
1460  spec_.getPrecursors().back().setActivationEnergy(asDouble_(value));
1461  }
1462  else if (accession == "PSI:1000046") //Energy unit
1463  {
1464  //ignored - we assume electronvolt
1465  }
1466  else
1467  {
1468  error = "PrecursorList.Precursor.Activation.UserParam";
1469  }
1470  }
1471  else if (parent_tag == "supDataDesc")
1472  {
1473  //no terms defined in ontology
1474  error = "supDataDesc.UserParam";
1475  }
1476  else if (parent_tag == "acquisition")
1477  {
1478  //no terms defined in ontology
1479  error = "spectrumDesc.spectrumSettings.acquisitionSpecification.acquisition.UserParam";
1480  }
1481  else if (parent_tag == "detector")
1482  {
1483  if (accession == "PSI:1000026")
1484  {
1485  exp_->getInstrument().getIonDetectors().back().setType((IonDetector::Type)cvStringToEnum_(13, value, "detector type"));
1486  }
1487  else if (accession == "PSI:1000028")
1488  {
1489  exp_->getInstrument().getIonDetectors().back().setResolution(asDouble_(value));
1490  }
1491  else if (accession == "PSI:1000029")
1492  {
1493  exp_->getInstrument().getIonDetectors().back().setADCSamplingFrequency(asDouble_(value));
1494  }
1495  else if (accession == "PSI:1000027")
1496  {
1497  exp_->getInstrument().getIonDetectors().back().setAcquisitionMode((IonDetector::AcquisitionMode)cvStringToEnum_(9, value, "acquisition mode"));
1498  }
1499  else
1500  {
1501  error = "Description.Instrument.Detector.UserParam";
1502  }
1503  }
1504  else if (parent_tag == "source")
1505  {
1506  if (accession == "PSI:1000008")
1507  {
1508  exp_->getInstrument().getIonSources().back().setIonizationMethod((IonSource::IonizationMethod)cvStringToEnum_(10, value, "ion source"));
1509  }
1510  else if (accession == "PSI:1000007")
1511  {
1512  exp_->getInstrument().getIonSources().back().setInletType((IonSource::InletType)cvStringToEnum_(11, value, "inlet type"));
1513  }
1514  else if (accession == "PSI:1000009")
1515  {
1516  exp_->getInstrument().getIonSources().back().setPolarity((IonSource::Polarity)cvStringToEnum_(1, value, "polarity"));
1517  }
1518  else
1519  {
1520  error = "Description.Instrument.Source.UserParam";
1521  }
1522  }
1523  else if (parent_tag == "sampleDescription")
1524  {
1525  if (accession == "PSI:1000001")
1526  {
1527  exp_->getSample().setNumber(value);
1528  }
1529  else if (accession == "PSI:1000003")
1530  {
1531  exp_->getSample().setState((Sample::SampleState)cvStringToEnum_(0, value, "sample state"));
1532  }
1533  else if (accession == "PSI:1000004")
1534  {
1535  exp_->getSample().setMass(asDouble_(value));
1536  }
1537  else if (accession == "PSI:1000005")
1538  {
1539  exp_->getSample().setVolume(asDouble_(value));
1540  }
1541  else if (accession == "PSI:1000006")
1542  {
1543  exp_->getSample().setConcentration(asDouble_(value));
1544  }
1545  else
1546  {
1547  error = "Description.Admin.SampleDescription.UserParam";
1548  }
1549  }
1550  else if (parent_tag == "analyzer")
1551  {
1552  if (accession == "PSI:1000010")
1553  {
1554  exp_->getInstrument().getMassAnalyzers().back().setType((MassAnalyzer::AnalyzerType)cvStringToEnum_(14, value, "analyzer type"));
1555  }
1556  else if (accession == "PSI:1000011")
1557  {
1558  exp_->getInstrument().getMassAnalyzers().back().setResolution(asDouble_(value));
1559  }
1560  else if (accession == "PSI:1000012")
1561  {
1562  exp_->getInstrument().getMassAnalyzers().back().setResolutionMethod((MassAnalyzer::ResolutionMethod)cvStringToEnum_(2, value, "resolution method"));
1563  }
1564  else if (accession == "PSI:1000013")
1565  {
1566  exp_->getInstrument().getMassAnalyzers().back().setResolutionType((MassAnalyzer::ResolutionType)cvStringToEnum_(3, value, "resolution type"));
1567  }
1568  else if (accession == "PSI:1000014")
1569  {
1570  exp_->getInstrument().getMassAnalyzers().back().setAccuracy(asDouble_(value));
1571  }
1572  else if (accession == "PSI:1000015")
1573  {
1574  exp_->getInstrument().getMassAnalyzers().back().setScanRate(asDouble_(value));
1575  }
1576  else if (accession == "PSI:1000016")
1577  {
1578  exp_->getInstrument().getMassAnalyzers().back().setScanTime(asDouble_(value));
1579  }
1580  else if (accession == "PSI:1000018")
1581  {
1582  exp_->getInstrument().getMassAnalyzers().back().setScanDirection((MassAnalyzer::ScanDirection)cvStringToEnum_(5, value, "scan direction"));
1583  }
1584  else if (accession == "PSI:1000019")
1585  {
1586  exp_->getInstrument().getMassAnalyzers().back().setScanLaw((MassAnalyzer::ScanLaw)cvStringToEnum_(6, value, "scan law"));
1587  }
1588  else if (accession == "PSI:1000020")
1589  {
1590  // ignored
1591  }
1592  else if (accession == "PSI:1000021")
1593  {
1594  exp_->getInstrument().getMassAnalyzers().back().setReflectronState((MassAnalyzer::ReflectronState)cvStringToEnum_(8, value, "reflectron state"));
1595  }
1596  else if (accession == "PSI:1000022")
1597  {
1598  exp_->getInstrument().getMassAnalyzers().back().setTOFTotalPathLength(asDouble_(value));
1599  }
1600  else if (accession == "PSI:1000023")
1601  {
1602  exp_->getInstrument().getMassAnalyzers().back().setIsolationWidth(asDouble_(value));
1603  }
1604  else if (accession == "PSI:1000024")
1605  {
1606  exp_->getInstrument().getMassAnalyzers().back().setFinalMSExponent(asInt_(value));
1607  }
1608  else if (accession == "PSI:1000025")
1609  {
1610  exp_->getInstrument().getMassAnalyzers().back().setMagneticFieldStrength(asDouble_(value));
1611  }
1612  else if (accession == "PSI:1000017")
1613  {
1614  //ignored
1615  }
1616  else
1617  {
1618  error = "AnalyzerList.Analyzer.UserParam";
1619  }
1620  }
1621  else if (parent_tag == "additional")
1622  {
1623  if (accession == "PSI:1000030")
1624  {
1625  exp_->getInstrument().setVendor(value);
1626  }
1627  else if (accession == "PSI:1000031")
1628  {
1629  exp_->getInstrument().setModel(value);
1630  }
1631  else if (accession == "PSI:1000032")
1632  {
1633  exp_->getInstrument().setCustomizations(value);
1634  }
1635  else
1636  {
1637  error = "Description.Instrument.Additional";
1638  }
1639  }
1640  else if (parent_tag == "processingMethod")
1641  {
1642  if (accession == "PSI:1000033")
1643  {
1644  data_processing_.getProcessingActions().insert(DataProcessing::DEISOTOPING);
1645  }
1646  else if (accession == "PSI:1000034")
1647  {
1648  data_processing_.getProcessingActions().insert(DataProcessing::CHARGE_DECONVOLUTION);
1649  }
1650  else if (accession == "PSI:1000127")
1651  {
1652  data_processing_.getProcessingActions().insert(DataProcessing::PEAK_PICKING);
1653  }
1654  else if (accession == "PSI:1000035")
1655  {
1656  //ignored
1657  }
1658  else
1659  {
1660  error = "DataProcessing.DataProcessing.UserParam";
1661  }
1662  }
1663  else
1664  {
1665  warning(LOAD, String("Unexpected cvParam: accession=\"") + accession + "\" value=\"" + value + "\" in tag " + parent_tag);
1666  }
1667 
1668  if (error != "")
1669  {
1670  warning(LOAD, String("Invalid cvParam: accession=\"") + accession + "\" value=\"" + value + "\" in " + error);
1671  }
1672  //std::cout << "End of MzDataHander::cvParam_" << std::endl;
1673  }
1674 
1675  } // namespace Internal
1676 
1677 } // namespace OpenMS
1678 
1679 #endif
const DataValue & getMetaValue(const String &name) const
returns the value corresponding to a string
general spectrum type
Definition: InstrumentSettings.h:56
Description of the applied preprocessing steps.
Definition: DataProcessing.h:51
const String & getCustomizations() const
returns a description of customizations
double getIsolationWidth() const
returns the isolation width i.e. in which m/z range the precursor ion is selected for MS to the n (in...
Big endian type.
Definition: Base64.h:78
Description of a MS instrument.
Definition: Instrument.h:64
Peak picking (conversion from raw to peak data)
Definition: DataProcessing.h:67
XML handler for MzDataFile.
Definition: MzDataHandler.h:60
Description of the settings a MS Instrument was run with.
Definition: InstrumentSettings.h:48
ActivationMethod
Method of activation.
Definition: Precursor.h:64
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
const ProgressLogger & logger_
Progress logger.
Definition: MzDataHandler.h:204
const String & getNumber() const
returns the sample number (default: "")
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
void warning(const xercesc::SAXParseException &exception)
const std::vector< IonSource > & getIonSources() const
returns a const reference to the ion source list
ResolutionType
Resolution type.
Definition: MassAnalyzer.h:92
UInt getMSLevel() const
Returns the MS level.
Definition: MSSpectrum.h:259
void setOptions(const PeakFileOptions &options)
Sets the options.
Definition: MzDataHandler.h:115
void writeCVS_(std::ostream &os, UInt value, UInt map, const String &acc, const String &name, UInt indent=4)
write cvParam element to stream
Definition: MzDataHandler.h:262
IntensityType getIntensity() const
Definition: Peak1D.h:109
ScanDirection getScanDirection() const
returns the direction of scanning
bool skip_spectrum_
Flag that indicates whether this spectrum should be skipped (due to options)
Definition: MzDataHandler.h:201
std::vector< std::pair< String, MetaInfoDescription > > meta_id_descs_
An array of pairs MetaInfodescriptions and their ids.
Definition: MzDataHandler.h:186
Polarity
Polarity of the ion source.
Definition: IonSource.h:140
bool has(const Key &key) const
Test whether the map contains the given key.
Definition: Map.h:109
const std::set< ProcessingAction > & getProcessingActions() const
returns a const reference to the applied processing actions
double getMass() const
returns the mass (in gram) (default: 0.0)
std::vector< String > data_to_decode_
encoded data which is read and has to be decoded
Definition: MzDataHandler.h:188
virtual void characters(const XMLCh *const chars, const XMLSize_t length)
Parsing method for character data.
Definition: MzDataHandler.h:338
DataProcessing data_processing_
Definition: MzDataHandler.h:331
const std::vector< MassAnalyzer > & getMassAnalyzers() const
returns a const reference to the mass analyzer list
Unknown scan method.
Definition: InstrumentSettings.h:55
Enhanced multiply charged scan.
Definition: InstrumentSettings.h:65
InletType
inlet type
Definition: IonSource.h:52
const AcquisitionInfo & getAcquisitionInfo() const
returns a const reference to the acquisition info
void writeBinary_(std::ostream &os, Size size, const String &tag, const String &name="", SignedSize id=-1)
write binary data to stream (first one)
Definition: MzDataHandler.h:308
CoordinateType getMZ() const
Non-mutable access to m/z.
Definition: Peak1D.h:114
Negative polarity.
Definition: IonSource.h:144
AnalyzerType getType() const
returns the analyzer type
Int getCharge() const
Non-mutable access to the charge.
ReflectronState
Reflectron state.
Definition: MassAnalyzer.h:126
Base class for XML handlers.
Definition: XMLHandler.h:99
Base64 decoder_
Decoder/Encoder for Base64-data in MzData.
Definition: MzDataHandler.h:198
bool isMetaEmpty() const
returns if the MetaInfo is empty
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
void writeCVS_(std::ostream &os, const String &value, const String &acc, const String &name, UInt indent=4) const
write cvParam containing strings to stream
Definition: MzDataHandler.h:241
Constant neutral loss scan Synonyms: 'CNG scan'.
Definition: InstrumentSettings.h:63
double begin
Begin of the window.
Definition: ScanWindow.h:62
double getAccuracy() const
returns the mass accuracy i.e. how much the theoretical mass may differ from the measured mass (in pp...
MS2+ mass spectrum, is a "mass spectrum".
Definition: InstrumentSettings.h:58
XMLHandler()
Not implemented.
Raw data (also called profile data)
Definition: SpectrumSettings.h:75
Little endian type.
Definition: Base64.h:79
Time-delayed fragmentation scan.
Definition: InstrumentSettings.h:66
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 init_()
Definition: MzDataHandler.h:121
double getResolution() const
returns the resolution
PeakFileOptions options_
Options that can be set for loading/storing.
Definition: MzDataHandler.h:177
Description of the meta data arrays of MSSpectrum.
Definition: MetaInfoDescription.h:49
std::vector< std::vector< double > > decoded_double_list_
Definition: MzDataHandler.h:192
double getActivationEnergy() const
returns the activation energy (in electronvolt)
SpectrumType getType() const
returns the spectrum type
const String & getIdentifier() const
return the identifier/index/number of the acquisition
bool getZoomScan() const
return if this scan is a zoom (enhanced resolution) scan
ScanMode getScanMode() const
returns the scan mode
double getTOFTotalPathLength() const
returns the path length for a TOF mass analyzer (in meter)
const std::set< ActivationMethod > & getActivationMethods() const
returns a const reference to the activation methods
void writeUserParam_(std::ostream &os, const MetaInfoInterface &meta, UInt indent=4)
Writing the MetaInfo as UserParam to the file.
Definition: MzDataHandler.h:280
ScanLaw getScanLaw() const
returns the scan law
MSExperiment< Peak1D > MapType
Definition: PeakPickerIterative.cpp:87
Selected reaction monitoring scan Synonyms: 'Multiple reaction monitoring scan', 'SRM scan', 'MRM scan'.
Definition: InstrumentSettings.h:60
void get(UInt &month, UInt &day, UInt &year, UInt &hour, UInt &minute, UInt &second) const
Fills the arguments with the date and the time.
double getMagneticFieldStrength() const
returns the strength of the magnetic field (in T)
virtual void startElement(const XMLCh *const , const XMLCh *const , const XMLCh *const qname, const xercesc::Attributes &attributes)
Parsing method for opening tags.
Definition: MzDataHandler.h:436
Int toInt() const
Conversion to int.
IonizationMethod
ionization method
Definition: IonSource.h:80
const std::vector< ScanWindow > & getScanWindows() const
returns a const reference to the m/z scan windows
std::vector< String > precisions_
Definition: MzDataHandler.h:193
ResolutionMethod getResolutionMethod() const
returns the method used for determination of the resolution
void fillData_()
fills the current spectrum with peaks and meta data
Definition: MzDataHandler.h:722
MapType * exp_
map pointer for reading
Definition: MzDataHandler.h:172
Deisotoping.
Definition: DataProcessing.h:62
Storing a file.
Definition: XMLHandler.h:119
MSSpectrum< PeakType > SpectrumType
Spectrum type.
Definition: MzDataHandler.h:169
Selected ion monitoring scan Synonyms: 'Multiple ion monitoring scan', 'SIM scan', 'MIM scan'.
Definition: InstrumentSettings.h:59
const String & getModel() const
returns the instrument model
String & trim()
removes whitespaces (space, tab, line feed, carriage return) at the beginning and the end of the stri...
A 1-dimensional raw data point or peak.
Definition: Peak1D.h:55
SampleState
state of aggregation of the sample
Definition: Sample.h:65
Scan window description.
Definition: ScanWindow.h:47
double getRT() const
Definition: MSSpectrum.h:243
const String & getVendor() const
returns the instrument vendor
ReflectronState getReflectronState() const
returns the reflectron state (for TOF)
ScanDirection
direction of scanning
Definition: MassAnalyzer.h:103
full scan mass spectrum, is a "mass spectrum" Synonyms: 'full spectrum', 'Q1 spectrum', 'Q3 spectrum', 'Single-Stage Mass Spectrometry'
Definition: InstrumentSettings.h:57
MzDataHandler(const MapType &exp, const String &filename, const String &version, const ProgressLogger &logger)
Constructor for a read-only handler.
Definition: MzDataHandler.h:81
Peak data (also called centroided data or stick data)
Definition: SpectrumSettings.h:74
void writeCVS_(std::ostream &os, double value, const String &acc, const String &name, UInt indent=4) const
write cvParam containing strings to stream
Definition: MzDataHandler.h:222
MapType::PeakType PeakType
Peak type.
Definition: MzDataHandler.h:167
Meta information about the sample.
Definition: Sample.h:60
Information about one raw data spectrum that was combined with several other raw data spectra...
Definition: Acquisition.h:50
void getKeys(std::vector< String > &keys) const
fills the given vector with a list of all keys for which a value is set
const MapType * cexp_
map pointer for writing
Definition: MzDataHandler.h:174
const Software & getSoftware() const
returns a const reference to the software used for processing
virtual ~MzDataHandler()
Destructor.
Definition: MzDataHandler.h:95
const String & getName() const
returns the name of the software
Absorbtion scan.
Definition: InstrumentSettings.h:69
AcquisitionMode
Acquisition mode.
Definition: IonDetector.h:82
Interface for classes that can store arbitrary meta information (Type-Name-Value tuples).
Definition: MetaInfoInterface.h:56
Invalid conversion exception.
Definition: Exception.h:363
Consecutive reaction monitoring scan Synonyms: 'CRM scan'.
Definition: InstrumentSettings.h:61
MzDataHandler(MapType &exp, const String &filename, const String &version, ProgressLogger &logger)
Constructor for a write-only handler.
Definition: MzDataHandler.h:67
double end
End of the window.
Definition: ScanWindow.h:64
ScanLaw
Scan law.
Definition: MassAnalyzer.h:114
std::vector< String > endians_
Definition: MzDataHandler.h:194
UInt peak_count_
The number of peaks in the current spectrum.
Definition: MzDataHandler.h:182
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
SpectrumType spec_
The current spectrum.
Definition: MzDataHandler.h:184
std::vector< float > data_to_encode_
floating point numbers which have to be encoded and written
Definition: MzDataHandler.h:190
double getScanTime() const
returns the scan time for a single scan (in s)
const String & getMethodOfCombination() const
returns the method of combination
Precursor ion scan.
Definition: InstrumentSettings.h:64
Positive polarity.
Definition: IonSource.h:143
ResolutionMethod
resolution method
Definition: MassAnalyzer.h:80
DateTime Class.
Definition: DateTime.h:55
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:55
const String & getName() const
returns the name of the instrument
Int getFinalMSExponent() const
returns the final MS exponent
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...
void encode(std::vector< FromType > &in, ByteOrder to_byte_order, String &out, bool zlib_compression=false)
Encodes a vector of floating point numbers to a Base64 string.
Definition: Base64.h:207
Constant neutral gain scan Synonyms: 'CNG scan'.
Definition: InstrumentSettings.h:62
const InstrumentSettings & getInstrumentSettings() const
returns a const reference to the instrument settings of the current spectrum
double getScanRate() const
returns the scan rate (in s)
Type
Detector type.
Definition: IonDetector.h:52
const std::vector< Precursor > & getPrecursors() const
returns a const reference to the precursors
Options for loading files containing peak data.
Definition: PeakFileOptions.h:48
AnalyzerType
analyzer type
Definition: MassAnalyzer.h:53
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
const FloatDataArrays & getFloatDataArrays() const
Returns a const reference to the float meta data arrays.
Definition: MSSpectrum.h:298
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. ...
Unknown spectrum type.
Definition: SpectrumSettings.h:73
int Int
Signed integer type.
Definition: Types.h:96
virtual void endElement(const XMLCh *const , const XMLCh *const , const XMLCh *const qname)
Parsing method for closing tags.
Definition: MzDataHandler.h:686
Map class based on the STL map (containing several convenience functions)
Definition: Map.h:51
Description of a mass analyzer (part of a MS Instrument)
Definition: MassAnalyzer.h:48
bool split(const char splitter, std::vector< String > &substrings, bool quote_protect=false) const
Splits a string into substrings using splitter as delimiter.
Charge deconvolution.
Definition: DataProcessing.h:61
const String & getName() const
returns the sample name (default: "")
void cvParam_(const String &name, const String &value)
read attributes of MzData's cvParamType
Definition: MzDataHandler.h:1316
std::vector< std::vector< float > > decoded_list_
Definition: MzDataHandler.h:191
ResolutionType getResolutionType() const
returns the resolution type
double getConcentration() const
returns the concentration (in g/l) (default: 0.0)
SampleState getState() const
returns the state of aggregation (default: SAMPLENULL)
void writeTo(std::ostream &os)
Writes the contents to a stream.
Definition: MzDataHandler.h:816
bool hasPrefix(const String &string) const
true if String begins with string, false otherwise
double getVolume() const
returns the volume (in ml) (default: 0.0)

OpenMS / TOPP release 2.0.0 Documentation generated on Fri May 29 2015 17:20:27 using doxygen 1.8.9.1