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-2013.
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 
172  MapType * exp_;
174  const MapType * cexp_;
175 
178 
186  std::vector<std::pair<String, MetaInfoDescription> > meta_id_descs_;
188  std::vector<String> data_to_decode_;
190  std::vector<Real> data_to_encode_;
191  std::vector<std::vector<Real> > decoded_list_;
192  std::vector<std::vector<DoubleReal> > 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, DoubleReal 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;
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 auxilary 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<Real> decoded;
725  std::vector<DoubleReal> 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  DoubleReal mz = mz_precision_64 ? decoded_double_list_[0][n] : decoded_list_[0][n];
797  DoubleReal 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  if (sm.getNumber() != "" || sm.getState() || sm.getMass() || sm.getVolume() || sm.getConcentration() || !sm.isMetaEmpty())
833  {
834  os << "\t\t\t<sampleDescription>\n";
835  writeCVS_(os, sm.getNumber(), "1000001", "SampleNumber");
836  writeCVS_(os, sm.getState(), 0, "1000003", "SampleState");
837  writeCVS_(os, sm.getMass(), "1000004", "SampleMass");
838  writeCVS_(os, sm.getVolume(), "1000005", "SampleVolume");
839  writeCVS_(os, sm.getConcentration(), "1000006", "SampleConcentration");
840  writeUserParam_(os, cexp_->getSample());
841  os << "\t\t\t</sampleDescription>\n";
842  }
843 
844  if (cexp_->getSourceFiles().size() >= 1)
845  {
846  os << "\t\t\t<sourceFile>\n"
847  << "\t\t\t\t<nameOfFile>" << cexp_->getSourceFiles()[0].getNameOfFile() << "</nameOfFile>\n"
848  << "\t\t\t\t<pathToFile>" << cexp_->getSourceFiles()[0].getPathToFile() << "</pathToFile>\n";
849  if (cexp_->getSourceFiles()[0].getFileType() != "")
850  os << "\t\t\t\t<fileType>" << cexp_->getSourceFiles()[0].getFileType() << "</fileType>\n";
851  os << "\t\t\t</sourceFile>\n";
852  }
853  if (cexp_->getSourceFiles().size() > 1)
854  {
855  warning(STORE, "The MzData format can store only one source file. Only the first one is stored!");
856  }
857 
858  for (Size i = 0; i < cexp_->getContacts().size(); ++i)
859  {
860  os << "\t\t\t<contact>\n"
861  << "\t\t\t\t<name>" << cexp_->getContacts()[i].getFirstName() << " " << cexp_->getContacts()[i].getLastName() << "</name>\n"
862  << "\t\t\t\t<institution>" << cexp_->getContacts()[i].getInstitution() << "</institution>\n";
863  if (cexp_->getContacts()[i].getContactInfo() != "")
864  os << "\t\t\t\t<contactInfo>" << cexp_->getContacts()[i].getContactInfo() << "</contactInfo>\n";
865  os << "\t\t\t</contact>\n";
866  }
867  //no contacts given => add empty entry as there must be a contact entry
868  if (cexp_->getContacts().empty())
869  {
870  os << "\t\t\t<contact>\n"
871  << "\t\t\t\t<name></name>\n"
872  << "\t\t\t\t<institution></institution>\n";
873  os << "\t\t\t</contact>\n";
874  }
875 
876  os << "\t\t</admin>\n";
877  const Instrument & inst = cexp_->getInstrument();
878  os << "\t\t<instrument>\n"
879  << "\t\t\t<instrumentName>" << inst.getName() << "</instrumentName>\n"
880  << "\t\t\t<source>\n";
881  if (inst.getIonSources().size() >= 1)
882  {
883  writeCVS_(os, inst.getIonSources()[0].getInletType(), 11, "1000007", "InletType");
884  writeCVS_(os, inst.getIonSources()[0].getIonizationMethod(), 10, "1000008", "IonizationType");
885  writeCVS_(os, inst.getIonSources()[0].getPolarity(), 1, "1000009", "IonizationMode");
886  writeUserParam_(os, inst.getIonSources()[0]);
887  }
888  if (inst.getIonSources().size() > 1)
889  {
890  warning(STORE, "The MzData format can store only one ion source. Only the first one is stored!");
891  }
892  os << "\t\t\t</source>\n";
893 
894  //no analyzer given => add empty entry as there must be one entry
895  if (inst.getMassAnalyzers().empty())
896  {
897  os << "\t\t\t<analyzerList count=\"1\">\n"
898  << "\t\t\t\t<analyzer>\n"
899  << "\t\t\t\t</analyzer>\n";
900  }
901  else
902  {
903  os << "\t\t\t<analyzerList count=\"" << inst.getMassAnalyzers().size() << "\">\n";
904  for (Size i = 0; i < inst.getMassAnalyzers().size(); ++i)
905  {
906  os << "\t\t\t\t<analyzer>\n";
907  const MassAnalyzer & ana = inst.getMassAnalyzers()[i];
908  writeCVS_(os, ana.getType(), 14, "1000010", "AnalyzerType", 5);
909  writeCVS_(os, ana.getResolution(), "1000011", "MassResolution", 5);
910  writeCVS_(os, ana.getResolutionMethod(), 2, "1000012", "ResolutionMethod", 5);
911  writeCVS_(os, ana.getResolutionType(), 3, "1000013", "ResolutionType", 5);
912  writeCVS_(os, ana.getAccuracy(), "1000014", "Accuracy", 5);
913  writeCVS_(os, ana.getScanRate(), "1000015", "ScanRate", 5);
914  writeCVS_(os, ana.getScanTime(), "1000016", "ScanTime", 5);
915  writeCVS_(os, ana.getScanDirection(), 5, "1000018", "ScanDirection", 5);
916  writeCVS_(os, ana.getScanLaw(), 6, "1000019", "ScanLaw", 5);
917  writeCVS_(os, ana.getReflectronState(), 8, "1000021", "ReflectronState", 5);
918  writeCVS_(os, ana.getTOFTotalPathLength(), "1000022", "TOFTotalPathLength", 5);
919  writeCVS_(os, ana.getIsolationWidth(), "1000023", "IsolationWidth", 5);
920  writeCVS_(os, ana.getFinalMSExponent(), "1000024", "FinalMSExponent", 5);
921  writeCVS_(os, ana.getMagneticFieldStrength(), "1000025", "MagneticFieldStrength", 5);
922  writeUserParam_(os, ana, 5);
923  os << "\t\t\t\t</analyzer>\n";
924  }
925  }
926  os << "\t\t\t</analyzerList>\n";
927 
928  os << "\t\t\t<detector>\n";
929  if (inst.getIonDetectors().size() >= 1)
930  {
931  writeCVS_(os, inst.getIonDetectors()[0].getType(), 13, "1000026", "DetectorType");
932  writeCVS_(os, inst.getIonDetectors()[0].getAcquisitionMode(), 9, "1000027", "DetectorAcquisitionMode");
933  writeCVS_(os, inst.getIonDetectors()[0].getResolution(), "1000028", "DetectorResolution");
934  writeCVS_(os, inst.getIonDetectors()[0].getADCSamplingFrequency(), "1000029", "SamplingFrequency");
935  writeUserParam_(os, inst.getIonDetectors()[0]);
936  }
937  if (inst.getIonDetectors().size() > 1)
938  {
939  warning(STORE, "The MzData format can store only one ion detector. Only the first one is stored!");
940  }
941  os << "\t\t\t</detector>\n";
942  if (inst.getVendor() != "" || inst.getModel() != "" || inst.getCustomizations() != "")
943  {
944  os << "\t\t\t<additional>\n";
945  writeCVS_(os, inst.getVendor(), "1000030", "Vendor");
946  writeCVS_(os, inst.getModel(), "1000031", "Model");
947  writeCVS_(os, inst.getCustomizations(), "1000032", "Customization");
948  writeUserParam_(os, inst);
949  os << "\t\t\t</additional>\n";
950  }
951  os << "\t\t</instrument>\n";
952 
953  //the data processing information of the first spectrum is used for the whole file
954  if (cexp_->size() == 0 || (*cexp_)[0].getDataProcessing().empty())
955  {
956  os << "\t\t<dataProcessing>\n"
957  << "\t\t\t<software>\n"
958  << "\t\t\t\t<name></name>\n"
959  << "\t\t\t\t<version></version>\n"
960  << "\t\t\t</software>\n"
961  << "\t\t</dataProcessing>\n";
962  }
963  else
964  {
965  const DataProcessing & data_processing = (*cexp_)[0].getDataProcessing()[0];
966  os << "\t\t<dataProcessing>\n"
967  << "\t\t\t<software";
968  if (data_processing.getCompletionTime() != DateTime())
969  {
970  os << " completionTime=\"" << data_processing.getCompletionTime().get().substitute(' ', 'T') << "\"";
971  }
972  os << ">\n"
973  << "\t\t\t\t<name>" << data_processing.getSoftware().getName() << "</name>\n"
974  << "\t\t\t\t<version>" << data_processing.getSoftware().getVersion() << "</version>\n";
975  os << "\t\t\t</software>\n"
976  << "\t\t\t<processingMethod>\n";
977  if (data_processing.getProcessingActions().count(DataProcessing::DEISOTOPING) == 1)
978  {
979  os << "\t\t\t\t<cvParam cvLabel=\"psi\" name=\"Deisotoping\" accession=\"PSI:1000033\" />\n";
980  }
981  if (data_processing.getProcessingActions().count(DataProcessing::CHARGE_DECONVOLUTION) == 1)
982  {
983  os << "\t\t\t\t<cvParam cvLabel=\"psi\" name=\"ChargeDeconvolution\" accession=\"PSI:1000034\" />\n";
984  }
985  if (data_processing.getProcessingActions().count(DataProcessing::PEAK_PICKING) == 1)
986  {
987  os << "\t\t\t\t<cvParam cvLabel=\"psi\" name=\"Centroid Mass Spectrum\" accession=\"PSI:1000127\"/>\n";
988  }
989  writeUserParam_(os, data_processing);
990  os << "\t\t\t</processingMethod>\n"
991  << "\t\t</dataProcessing>\n";
992  }
993  os << "\t</description>\n";
994 
995  //---------------------------------------------------------------------------------------------------
996  //ACTUAL DATA
997  if (cexp_->size() != 0)
998  {
999  //check if the nativeID of all spectra are numbers or numbers prefixed with 'spectrum='
1000  //If not we need to renumber all spectra.
1001  bool all_numbers = true;
1002  bool all_empty = true;
1003  bool all_prefixed_numbers = true;
1004  for (Size s = 0; s < cexp_->size(); s++)
1005  {
1006  String native_id = (*cexp_)[s].getNativeID();
1007  if (!native_id.hasPrefix("spectrum="))
1008  {
1009  all_prefixed_numbers = false;
1010  }
1011  else
1012  {
1013  native_id = native_id.substr(9);
1014  }
1015  try
1016  {
1017  native_id.toInt();
1018  }
1019  catch (Exception::ConversionError &)
1020  {
1021  all_numbers = false;
1022  all_prefixed_numbers = false;
1023  if (native_id != "")
1024  {
1025  all_empty = false;
1026  }
1027  }
1028  }
1029  //If we need to renumber and the nativeIDs were not empty, warn the user
1030  if (!all_numbers && !all_empty)
1031  {
1032  warning(STORE, "Not all spectrum native IDs are numbers or correctly prefixed with 'spectrum='. The spectra are renumbered and the native IDs are lost!");
1033  }
1034  //Map to store the last spectrum ID for each MS level (needed to find precursor spectra)
1035  Map<Int, Size> level_id;
1036 
1037  os << "\t<spectrumList count=\"" << cexp_->size() << "\">\n";
1038  for (Size s = 0; s < cexp_->size(); ++s)
1039  {
1040  logger_.setProgress(s);
1041  const SpectrumType & spec = (*cexp_)[s];
1042 
1043  Size spectrum_id = s + 1;
1044  if (all_prefixed_numbers)
1045  {
1046  spectrum_id = spec.getNativeID().substr(9).toInt();
1047  }
1048  else if (all_numbers)
1049  {
1050  spectrum_id = spec.getNativeID().toInt();
1051  }
1052  os << "\t\t<spectrum id=\"" << spectrum_id << "\">\n"
1053  << "\t\t\t<spectrumDesc>\n"
1054  << "\t\t\t\t<spectrumSettings>\n";
1055 
1056  if (!spec.getAcquisitionInfo().empty())
1057  {
1058  os << "\t\t\t\t\t<acqSpecification spectrumType=\"";
1059  if (spec.getType() == SpectrumSettings::PEAKS)
1060  {
1061  os << "discrete";
1062  }
1063  else if (spec.getType() == SpectrumSettings::RAWDATA)
1064  {
1065  os << "continuous";
1066  }
1067  else
1068  {
1069  warning(STORE, "Spectrum type is unknown, assuming 'discrete'");
1070  os << "discrete";
1071  }
1072 
1073  os << "\" methodOfCombination=\"" << spec.getAcquisitionInfo().getMethodOfCombination() << "\""
1074  << " count=\"" << spec.getAcquisitionInfo().size() << "\">\n";
1075  for (Size i = 0; i < spec.getAcquisitionInfo().size(); ++i)
1076  {
1077  const Acquisition & ac = spec.getAcquisitionInfo()[i];
1078  Int acq_number = 0;
1079  try
1080  {
1081  if (ac.getIdentifier() != "")
1082  {
1083  acq_number = ac.getIdentifier().toInt();
1084  }
1085  }
1086  catch (...)
1087  {
1088  warning(STORE, String("Could not convert acquisition identifier '") + ac.getIdentifier() + "' to an integer. Using '0' instead!");
1089  acq_number = 0;
1090  }
1091  os << "\t\t\t\t\t\t<acquisition acqNumber=\"" << acq_number << "\">\n";
1092  writeUserParam_(os, ac, 7);
1093  os << "\t\t\t\t\t\t</acquisition>\n";
1094  }
1095  os << "\t\t\t\t\t</acqSpecification>\n";
1096  }
1097 
1098  const InstrumentSettings & iset = spec.getInstrumentSettings();
1099  os << "\t\t\t\t\t<spectrumInstrument msLevel=\"" << spec.getMSLevel() << "\"";
1100  level_id[spec.getMSLevel()] = spectrum_id;
1101 
1102  if (!iset.getScanWindows().empty())
1103  {
1104  os << " mzRangeStart=\"" << iset.getScanWindows()[0].begin << "\" mzRangeStop=\"" << iset.getScanWindows()[0].end << "\"";
1105  }
1106  if (iset.getScanWindows().size() > 1)
1107  {
1108  warning(STORE, "The MzData format can store only one scan window for each scan. Only the first one is stored!");
1109  }
1110  os << ">\n";
1111 
1112  //scan mode
1113  switch (iset.getScanMode())
1114  {
1116  //do nothing here
1117  break;
1118 
1122  if (iset.getZoomScan())
1123  {
1124  os << "\t\t\t\t\t\t<cvParam cvLabel=\"psi\" accession=\"PSI:1000036\" name=\"ScanMode\" value=\"Zoom\"/>\n";
1125  }
1126  else
1127  {
1128  os << "\t\t\t\t\t\t<cvParam cvLabel=\"psi\" accession=\"PSI:1000036\" name=\"ScanMode\" value=\"MassScan\"/>\n";
1129  }
1130  break;
1131 
1133  os << "\t\t\t\t\t\t<cvParam cvLabel=\"psi\" accession=\"PSI:1000036\" name=\"ScanMode\" value=\"SelectedIonDetection\"/>\n";
1134  break;
1135 
1137  os << "\t\t\t\t\t\t<cvParam cvLabel=\"psi\" accession=\"PSI:1000036\" name=\"ScanMode\" value=\"SelectedReactionMonitoring\"/>\n";
1138  break;
1139 
1141  os << "\t\t\t\t\t\t<cvParam cvLabel=\"psi\" accession=\"PSI:1000036\" name=\"ScanMode\" value=\"ConsecutiveReactionMonitoring\"/>\n";
1142  break;
1143 
1145  os << "\t\t\t\t\t\t<cvParam cvLabel=\"psi\" accession=\"PSI:1000036\" name=\"ScanMode\" value=\"ConstantNeutralGainScan\"/>\n";
1146  break;
1147 
1149  os << "\t\t\t\t\t\t<cvParam cvLabel=\"psi\" accession=\"PSI:1000036\" name=\"ScanMode\" value=\"ConstantNeutralLossScan\"/>\n";
1150  break;
1151 
1153  os << "\t\t\t\t\t\t<cvParam cvLabel=\"psi\" accession=\"PSI:1000036\" name=\"ScanMode\" value=\"PrecursorIonScan\"/>\n";
1154  break;
1155 
1157  os << "\t\t\t\t\t\t<cvParam cvLabel=\"psi\" accession=\"PSI:1000036\" name=\"ScanMode\" value=\"PhotodiodeArrayDetector\"/>\n";
1158  break;
1159 
1161  os << "\t\t\t\t\t\t<cvParam cvLabel=\"psi\" accession=\"PSI:1000036\" name=\"ScanMode\" value=\"EnhancedMultiplyChargedScan\"/>\n";
1162  break;
1163 
1165  os << "\t\t\t\t\t\t<cvParam cvLabel=\"psi\" accession=\"PSI:1000036\" name=\"ScanMode\" value=\"TimeDelayedFragmentationScan\"/>\n";
1166  break;
1167 
1168  default:
1169  os << "\t\t\t\t\t\t<cvParam cvLabel=\"psi\" accession=\"PSI:1000036\" name=\"ScanMode\" value=\"MassScan\"/>\n";
1170  warning(STORE, String("Scan mode '") + InstrumentSettings::NamesOfScanMode[iset.getScanMode()] + "' not supported by mzData. Using 'MassScan' scan mode!");
1171  }
1172 
1173  //scan polarity
1175  {
1176  os << String(6, '\t') << "<cvParam cvLabel=\"psi\" accession=\"PSI:1000037\" name=\"Polarity\" value=\"Positive\"/>\n";
1177  }
1179  {
1180  os << String(6, '\t') << "<cvParam cvLabel=\"psi\" accession=\"PSI:1000037\" name=\"Polarity\" value=\"Negative\"/>\n";
1181  }
1182 
1183  //Retiontion time already in TimeInSeconds
1184  writeCVS_(os, spec.getRT(), "1000039", "TimeInSeconds", 6);
1185  writeUserParam_(os, spec.getInstrumentSettings(), 6);
1186  os << "\t\t\t\t\t</spectrumInstrument>\n\t\t\t\t</spectrumSettings>\n";
1187 
1188  if (spec.getPrecursors().size() != 0)
1189  {
1190  Int precursor_ms_level = spec.getMSLevel() - 1;
1191  SignedSize precursor_id = -1;
1192  if (level_id.has(precursor_ms_level))
1193  {
1194  precursor_id = level_id[precursor_ms_level];
1195  }
1196  os << "\t\t\t\t<precursorList count=\"" << spec.getPrecursors().size() << "\">\n";
1197  for (Size i = 0; i < spec.getPrecursors().size(); ++i)
1198  {
1199  const Precursor & precursor = spec.getPrecursors()[i];
1200  os << "\t\t\t\t\t<precursor msLevel=\"" << precursor_ms_level << "\" spectrumRef=\"" << precursor_id << "\">\n";
1201  os << "\t\t\t\t\t\t<ionSelection>\n";
1202  if (precursor != Precursor())
1203  {
1204  writeCVS_(os, precursor.getMZ(), "1000040", "MassToChargeRatio", 7);
1205  writeCVS_(os, precursor.getCharge(), "1000041", "ChargeState", 7);
1206  writeCVS_(os, precursor.getIntensity(), "1000042", "Intensity", 7);
1207  os << "\t\t\t\t\t\t\t<cvParam cvLabel=\"psi\" accession=\"PSI:1000043\" name=\"IntensityUnit\" value=\"NumberOfCounts\"/>\n";
1208  writeUserParam_(os, precursor, 7);
1209  }
1210  os << "\t\t\t\t\t\t</ionSelection>\n";
1211  os << "\t\t\t\t\t\t<activation>\n";
1212  if (precursor != Precursor())
1213  {
1214  if (precursor.getActivationMethods().size() > 0)
1215  {
1216  writeCVS_(os, *(precursor.getActivationMethods().begin()), 18, "1000044", "ActivationMethod", 7);
1217  }
1218  writeCVS_(os, precursor.getActivationEnergy(), "1000045", "CollisionEnergy", 7);
1219  os << "\t\t\t\t\t\t\t<cvParam cvLabel=\"psi\" accession=\"PSI:1000046\" name=\"EnergyUnit\" value=\"eV\"/>\n";
1220  }
1221  os << "\t\t\t\t\t\t</activation>\n";
1222  os << "\t\t\t\t\t</precursor>\n";
1223  }
1224  os << "\t\t\t\t</precursorList>\n";
1225  }
1226  os << "\t\t\t</spectrumDesc>\n";
1227 
1228  // write the supplementary data?
1229  if (options_.getWriteSupplementalData())
1230  {
1231  //write meta data array descriptions
1232  for (Size i = 0; i < spec.getFloatDataArrays().size(); ++i)
1233  {
1234  const MetaInfoDescription & desc = spec.getFloatDataArrays()[i];
1235  os << "\t\t\t<supDesc supDataArrayRef=\"" << (i + 1) << "\">\n";
1236  if (!desc.isMetaEmpty())
1237  {
1238  os << "\t\t\t\t<supDataDesc>\n";
1239  writeUserParam_(os, desc, 5);
1240  os << "\t\t\t\t</supDataDesc>\n";
1241  }
1242  os << "\t\t\t</supDesc>\n";
1243  }
1244  }
1245 
1246  //write m/z and intensity arrays
1247  data_to_encode_.clear();
1248  for (Size i = 0; i < spec.size(); i++)
1249  {
1250  data_to_encode_.push_back(spec[i].getPosition()[0]);
1251  }
1252 
1253  writeBinary_(os, spec.size(), "mzArrayBinary");
1254 
1255  // intensity
1256  data_to_encode_.clear();
1257  for (Size i = 0; i < spec.size(); i++)
1258  {
1259  data_to_encode_.push_back(spec[i].getIntensity());
1260  }
1261 
1262  writeBinary_(os, spec.size(), "intenArrayBinary");
1263 
1264  // write the supplementary data?
1265  if (options_.getWriteSupplementalData())
1266  {
1267  //write supplemental data arrays
1268  for (Size i = 0; i < spec.getFloatDataArrays().size(); ++i)
1269  {
1270  const typename MapType::SpectrumType::FloatDataArray & mda = spec.getFloatDataArrays()[i];
1271  //check if spectrum and meta data array have the same length
1272  if (mda.size() != spec.size())
1273  {
1274  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() + " .");
1275  }
1276  //encode meta data array
1277  data_to_encode_.clear();
1278  for (Size j = 0; j < mda.size(); j++)
1279  {
1280  data_to_encode_.push_back(mda[j]);
1281  }
1282  //write meta data array
1283  writeBinary_(os, mda.size(), "supDataArrayBinary", mda.getName(), i + 1);
1284  }
1285  }
1286 
1287  os << "\t\t</spectrum>\n";
1288  }
1289  }
1290  else
1291  {
1292  os << "\t<spectrumList count=\"1\">\n";
1293  os << "\t\t<spectrum id=\"1\">\n";
1294  os << "\t\t\t<spectrumDesc>\n";
1295  os << "\t\t\t\t<spectrumSettings>\n";
1296  os << "\t\t\t\t\t<spectrumInstrument msLevel=\"1\"/>\n";
1297  os << "\t\t\t\t</spectrumSettings>\n";
1298  os << "\t\t\t</spectrumDesc>\n";
1299  os << "\t\t\t<mzArrayBinary>\n";
1300  os << "\t\t\t\t<data length=\"0\" endian=\"little\" precision=\"32\"></data>\n";
1301  os << "\t\t\t</mzArrayBinary>\n";
1302  os << "\t\t\t<intenArrayBinary>\n";
1303  os << "\t\t\t\t<data length=\"0\" endian=\"little\" precision=\"32\"></data>\n";
1304  os << "\t\t\t</intenArrayBinary>\n";
1305  os << "\t\t</spectrum>\n";
1306  }
1307  os << "\t</spectrumList>\n</mzData>\n";
1308 
1309  logger_.endProgress();
1310  }
1311 
1312  template <typename MapType>
1313  void MzDataHandler<MapType>::cvParam_(const String & accession, const String & value)
1314  {
1315  String error = "";
1316 
1317  //determine the parent tag
1318  String parent_tag;
1319  if (open_tags_.size() > 1)
1320  parent_tag = *(open_tags_.end() - 2);
1321 
1322  if (parent_tag == "spectrumInstrument")
1323  {
1324  if (accession == "PSI:1000036") //Scan Mode
1325  {
1326  if (value == "Zoom")
1327  {
1328  spec_.getInstrumentSettings().setZoomScan(true);
1329  spec_.getInstrumentSettings().setScanMode(InstrumentSettings::MASSSPECTRUM);
1330  }
1331  else if (value == "MassScan")
1332  {
1333  spec_.getInstrumentSettings().setScanMode(InstrumentSettings::MASSSPECTRUM);
1334  }
1335  else if (value == "SelectedIonDetection")
1336  {
1337  spec_.getInstrumentSettings().setScanMode(InstrumentSettings::SIM);
1338  }
1339  else if (value == "SelectedReactionMonitoring")
1340  {
1341  spec_.getInstrumentSettings().setScanMode(InstrumentSettings::SRM);
1342  }
1343  else if (value == "ConsecutiveReactionMonitoring")
1344  {
1345  spec_.getInstrumentSettings().setScanMode(InstrumentSettings::CRM);
1346  }
1347  else if (value == "ConstantNeutralGainScan")
1348  {
1349  spec_.getInstrumentSettings().setScanMode(InstrumentSettings::CNG);
1350  }
1351  else if (value == "ConstantNeutralLossScan")
1352  {
1353  spec_.getInstrumentSettings().setScanMode(InstrumentSettings::CNL);
1354  }
1355  else if (value == "ProductIonScan")
1356  {
1357  spec_.getInstrumentSettings().setScanMode(InstrumentSettings::MSNSPECTRUM);
1358  spec_.setMSLevel(2);
1359  }
1360  else if (value == "PrecursorIonScan")
1361  {
1362  spec_.getInstrumentSettings().setScanMode(InstrumentSettings::PRECURSOR);
1363  }
1364  else if (value == "EnhancedResolutionScan")
1365  {
1366  spec_.getInstrumentSettings().setZoomScan(true);
1367  spec_.getInstrumentSettings().setScanMode(InstrumentSettings::MASSSPECTRUM);
1368  }
1369  else
1370  {
1371  if (spec_.getMSLevel() >= 2)
1372  {
1373  exp_->getSpectra().back().getInstrumentSettings().setScanMode(InstrumentSettings::MSNSPECTRUM);
1374  }
1375  else
1376  {
1377  spec_.getInstrumentSettings().setScanMode(InstrumentSettings::MASSSPECTRUM);
1378  warning(LOAD, String("Unknown scan mode '") + value + "'. Assuming full scan");
1379  }
1380  }
1381  }
1382  else if (accession == "PSI:1000038") //Time in minutes
1383  {
1384  spec_.setRT(asDouble_(value) * 60); //Minutes to seconds
1385  if (options_.hasRTRange() && !options_.getRTRange().encloses(DPosition<1>(spec_.getRT())))
1386  {
1387  skip_spectrum_ = true;
1388  }
1389  }
1390  else if (accession == "PSI:1000039") //Time in seconds
1391  {
1392  spec_.setRT(asDouble_(value));
1393  if (options_.hasRTRange() && !options_.getRTRange().encloses(DPosition<1>(spec_.getRT())))
1394  {
1395  skip_spectrum_ = true;
1396  }
1397  }
1398  else if (accession == "PSI:1000037") //Polarity
1399  {
1400  if (value == "Positive" || value == "positive" || value == "+") //be flexible here, actually only the first one is correct
1401  {
1402  spec_.getInstrumentSettings().setPolarity(IonSource::POSITIVE);
1403  }
1404  else if (value == "Negative" || value == "negative" || value == "-") //be flexible here, actually only the first one is correct
1405  {
1406  spec_.getInstrumentSettings().setPolarity(IonSource::NEGATIVE);
1407  }
1408  else
1409  {
1410  warning(LOAD, String("Invalid scan polarity (PSI:1000037) detected: \"") + value + "\". Valid are 'Positive' or 'Negative'.");
1411  }
1412  }
1413  else
1414  {
1415  error = "SpectrumDescription.SpectrumSettings.SpectrumInstrument";
1416  }
1417  }
1418  else if (parent_tag == "ionSelection")
1419  {
1420  if (accession == "PSI:1000040") //m/z
1421  {
1422  spec_.getPrecursors().back().setMZ(asDouble_(value));
1423  }
1424  else if (accession == "PSI:1000041") //Charge
1425  {
1426  if (spec_.getPrecursors().back().getCharge() != 0)
1427  {
1428  warning(LOAD, String("Multiple precursor charges detected, expected only one! Ignoring this charge settings! accession=\"") + accession + "\", value=\"" + value + "\"");
1429  spec_.getPrecursors().back().setCharge(0);
1430  }
1431  else
1432  {
1433  spec_.getPrecursors().back().setCharge(asInt_(value));
1434  }
1435  }
1436  else if (accession == "PSI:1000042") //Intensity
1437  {
1438  spec_.getPrecursors().back().setIntensity(asDouble_(value));
1439  }
1440  else if (accession == "PSI:1000043") //Intensity unit
1441  {
1442  //ignored
1443  }
1444  else
1445  {
1446  error = "PrecursorList.Precursor.IonSelection.UserParam";
1447  }
1448  }
1449  else if (parent_tag == "activation")
1450  {
1451  if (accession == "PSI:1000044") //activationmethod
1452  {
1453  spec_.getPrecursors().back().getActivationMethods().insert((Precursor::ActivationMethod)cvStringToEnum_(18, value, "activation method"));
1454  }
1455  else if (accession == "PSI:1000045") //Energy
1456  {
1457  spec_.getPrecursors().back().setActivationEnergy(asDouble_(value));
1458  }
1459  else if (accession == "PSI:1000046") //Energy unit
1460  {
1461  //ignored - we assume electronvolt
1462  }
1463  else
1464  {
1465  error = "PrecursorList.Precursor.Activation.UserParam";
1466  }
1467  }
1468  else if (parent_tag == "supDataDesc")
1469  {
1470  //no terms defined in ontology
1471  error = "supDataDesc.UserParam";
1472  }
1473  else if (parent_tag == "acquisition")
1474  {
1475  //no terms defined in ontology
1476  error = "spectrumDesc.spectrumSettings.acquisitionSpecification.acquisition.UserParam";
1477  }
1478  else if (parent_tag == "detector")
1479  {
1480  if (accession == "PSI:1000026")
1481  {
1482  exp_->getInstrument().getIonDetectors().back().setType((IonDetector::Type)cvStringToEnum_(13, value, "detector type"));
1483  }
1484  else if (accession == "PSI:1000028")
1485  {
1486  exp_->getInstrument().getIonDetectors().back().setResolution(asDouble_(value));
1487  }
1488  else if (accession == "PSI:1000029")
1489  {
1490  exp_->getInstrument().getIonDetectors().back().setADCSamplingFrequency(asDouble_(value));
1491  }
1492  else if (accession == "PSI:1000027")
1493  {
1494  exp_->getInstrument().getIonDetectors().back().setAcquisitionMode((IonDetector::AcquisitionMode)cvStringToEnum_(9, value, "acquisition mode"));
1495  }
1496  else
1497  {
1498  error = "Description.Instrument.Detector.UserParam";
1499  }
1500  }
1501  else if (parent_tag == "source")
1502  {
1503  if (accession == "PSI:1000008")
1504  {
1505  exp_->getInstrument().getIonSources().back().setIonizationMethod((IonSource::IonizationMethod)cvStringToEnum_(10, value, "ion source"));
1506  }
1507  else if (accession == "PSI:1000007")
1508  {
1509  exp_->getInstrument().getIonSources().back().setInletType((IonSource::InletType)cvStringToEnum_(11, value, "inlet type"));
1510  }
1511  else if (accession == "PSI:1000009")
1512  {
1513  exp_->getInstrument().getIonSources().back().setPolarity((IonSource::Polarity)cvStringToEnum_(1, value, "polarity"));
1514  }
1515  else
1516  {
1517  error = "Description.Instrument.Source.UserParam";
1518  }
1519  }
1520  else if (parent_tag == "sampleDescription")
1521  {
1522  if (accession == "PSI:1000001")
1523  {
1524  exp_->getSample().setNumber(value);
1525  }
1526  else if (accession == "PSI:1000003")
1527  {
1528  exp_->getSample().setState((Sample::SampleState)cvStringToEnum_(0, value, "sample state"));
1529  }
1530  else if (accession == "PSI:1000004")
1531  {
1532  exp_->getSample().setMass(asDouble_(value));
1533  }
1534  else if (accession == "PSI:1000005")
1535  {
1536  exp_->getSample().setVolume(asDouble_(value));
1537  }
1538  else if (accession == "PSI:1000006")
1539  {
1540  exp_->getSample().setConcentration(asDouble_(value));
1541  }
1542  else
1543  {
1544  error = "Description.Admin.SampleDescription.UserParam";
1545  }
1546  }
1547  else if (parent_tag == "analyzer")
1548  {
1549  if (accession == "PSI:1000010")
1550  {
1551  exp_->getInstrument().getMassAnalyzers().back().setType((MassAnalyzer::AnalyzerType)cvStringToEnum_(14, value, "analyzer type"));
1552  }
1553  else if (accession == "PSI:1000011")
1554  {
1555  exp_->getInstrument().getMassAnalyzers().back().setResolution(asDouble_(value));
1556  }
1557  else if (accession == "PSI:1000012")
1558  {
1559  exp_->getInstrument().getMassAnalyzers().back().setResolutionMethod((MassAnalyzer::ResolutionMethod)cvStringToEnum_(2, value, "resolution method"));
1560  }
1561  else if (accession == "PSI:1000013")
1562  {
1563  exp_->getInstrument().getMassAnalyzers().back().setResolutionType((MassAnalyzer::ResolutionType)cvStringToEnum_(3, value, "resolution type"));
1564  }
1565  else if (accession == "PSI:1000014")
1566  {
1567  exp_->getInstrument().getMassAnalyzers().back().setAccuracy(asDouble_(value));
1568  }
1569  else if (accession == "PSI:1000015")
1570  {
1571  exp_->getInstrument().getMassAnalyzers().back().setScanRate(asDouble_(value));
1572  }
1573  else if (accession == "PSI:1000016")
1574  {
1575  exp_->getInstrument().getMassAnalyzers().back().setScanTime(asDouble_(value));
1576  }
1577  else if (accession == "PSI:1000018")
1578  {
1579  exp_->getInstrument().getMassAnalyzers().back().setScanDirection((MassAnalyzer::ScanDirection)cvStringToEnum_(5, value, "scan direction"));
1580  }
1581  else if (accession == "PSI:1000019")
1582  {
1583  exp_->getInstrument().getMassAnalyzers().back().setScanLaw((MassAnalyzer::ScanLaw)cvStringToEnum_(6, value, "scan law"));
1584  }
1585  else if (accession == "PSI:1000020")
1586  {
1587  // ignored
1588  }
1589  else if (accession == "PSI:1000021")
1590  {
1591  exp_->getInstrument().getMassAnalyzers().back().setReflectronState((MassAnalyzer::ReflectronState)cvStringToEnum_(8, value, "reflectron state"));
1592  }
1593  else if (accession == "PSI:1000022")
1594  {
1595  exp_->getInstrument().getMassAnalyzers().back().setTOFTotalPathLength(asDouble_(value));
1596  }
1597  else if (accession == "PSI:1000023")
1598  {
1599  exp_->getInstrument().getMassAnalyzers().back().setIsolationWidth(asDouble_(value));
1600  }
1601  else if (accession == "PSI:1000024")
1602  {
1603  exp_->getInstrument().getMassAnalyzers().back().setFinalMSExponent(asInt_(value));
1604  }
1605  else if (accession == "PSI:1000025")
1606  {
1607  exp_->getInstrument().getMassAnalyzers().back().setMagneticFieldStrength(asDouble_(value));
1608  }
1609  else if (accession == "PSI:1000017")
1610  {
1611  //ignored
1612  }
1613  else
1614  {
1615  error = "AnalyzerList.Analyzer.UserParam";
1616  }
1617  }
1618  else if (parent_tag == "additional")
1619  {
1620  if (accession == "PSI:1000030")
1621  {
1622  exp_->getInstrument().setVendor(value);
1623  }
1624  else if (accession == "PSI:1000031")
1625  {
1626  exp_->getInstrument().setModel(value);
1627  }
1628  else if (accession == "PSI:1000032")
1629  {
1630  exp_->getInstrument().setCustomizations(value);
1631  }
1632  else
1633  {
1634  error = "Description.Instrument.Additional";
1635  }
1636  }
1637  else if (parent_tag == "processingMethod")
1638  {
1639  if (accession == "PSI:1000033")
1640  {
1641  data_processing_.getProcessingActions().insert(DataProcessing::DEISOTOPING);
1642  }
1643  else if (accession == "PSI:1000034")
1644  {
1645  data_processing_.getProcessingActions().insert(DataProcessing::CHARGE_DECONVOLUTION);
1646  }
1647  else if (accession == "PSI:1000127")
1648  {
1649  data_processing_.getProcessingActions().insert(DataProcessing::PEAK_PICKING);
1650  }
1651  else if (accession == "PSI:1000035")
1652  {
1653  //ignored
1654  }
1655  else
1656  {
1657  error = "DataProcessing.DataProcessing.UserParam";
1658  }
1659  }
1660  else
1661  {
1662  warning(LOAD, String("Unexpected cvParam: accession=\"") + accession + "\" value=\"" + value + "\" in tag " + parent_tag);
1663  }
1664 
1665  if (error != "")
1666  {
1667  warning(LOAD, String("Invalid cvParam: accession=\"") + accession + "\" value=\"" + value + "\" in " + error);
1668  }
1669  //std::cout << "End of MzDataHander::cvParam_" << std::endl;
1670  }
1671 
1672  } // namespace Internal
1673 
1674 } // namespace OpenMS
1675 
1676 #endif
Deisotoping.
Definition: DataProcessing.h:62
const DataValue & getMetaValue(const String &name) const
returns the value corresponding to a string
Descripton of the applied preprocessing steps.
Definition: DataProcessing.h:51
const String & getCustomizations() const
returns a description of customizations
std::vector< std::vector< Real > > decoded_list_
Definition: MzDataHandler.h:191
Big endian type.
Definition: Base64.h:78
Description of a MS instrument.
Definition: Instrument.h:64
DoubleReal getScanTime() const
returns the scan time for a single scan (in s)
XML handler for MzDataFile.
Definition: MzDataHandler.h:60
Description of the settings a MS Instrument was run with.
Definition: InstrumentSettings.h:48
DoubleReal getVolume() const
returns the volume (in ml) (default: 0.0)
A more convenient string class.
Definition: String.h:56
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: &quot;&quot;)
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:94
void warning(const xercesc::SAXParseException &exception)
const std::vector< IonSource > & getIonSources() const
returns a const reference to the ion source list
UInt getMSLevel() const
Returns the MS level.
Definition: MSSpectrum.h:231
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
DoubleReal getAccuracy() const
returns the mass accuracy i.e. how much the theoretical mass may differ from the measured mass (in pp...
IntensityType getIntensity() const
Definition: Peak1D.h:103
ScanDirection getScanDirection() const
returns the direction of scanning
AcquisitionMode
Acquisition mode.
Definition: IonDetector.h:82
Peak data (also called centroided data or stick data)
Definition: SpectrumSettings.h:74
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
bool has(const Key &key) const
Test whether the map contains the given key.
Definition: Map.h:87
const std::set< ProcessingAction > & getProcessingActions() const
returns a const reference to the applied processing actions
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
Negative polarity.
Definition: IonSource.h:144
DataProcessing data_processing_
Definition: MzDataHandler.h:331
const std::vector< MassAnalyzer > & getMassAnalyzers() const
returns a const reference to the mass analyer list
DoubleReal getActivationEnergy() const
returns the activation energy (in electronvolt)
DoubleReal end
End of the window.
Definition: ScanWindow.h:64
Peak2D PeakType
Definition: MassTrace.h:49
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
Enhanced multiply charged scan.
Definition: InstrumentSettings.h:65
CoordinateType getMZ() const
Non-mutable access to m/z.
Definition: Peak1D.h:108
Positive polarity.
Definition: IonSource.h:143
AnalyzerType getType() const
returns the analyzer type
Int getCharge() const
Non-mutable access to the charge.
Base class for XML handlers.
Definition: XMLHandler.h:89
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:151
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
Raw data (also called profile data)
Definition: SpectrumSettings.h:75
DoubleReal getMagneticFieldStrength() const
returns the strength of the magnetic field (in T)
XMLHandler()
Not implemented.
Little endian type.
Definition: Base64.h:79
DoubleReal begin
Begin of the window.
Definition: ScanWindow.h:62
ScanDirection
direction of scanning
Definition: MassAnalyzer.h:103
MS2+ mass spectrum, is a &quot;mass spectrum&quot;.
Definition: InstrumentSettings.h:58
void init_()
Definition: MzDataHandler.h:121
PeakFileOptions options_
Options that can be set for loading/storing.
Definition: MzDataHandler.h:177
DoubleReal getTOFTotalPathLength() const
returns the path length for a TOF mass analyzer (in meter)
InletType
inlet type
Definition: IonSource.h:52
Type
Detector type.
Definition: IonDetector.h:52
Description of the meta data arrays of MSSpectrum.
Definition: MetaInfoDescription.h:49
Unknown spectrum type.
Definition: SpectrumSettings.h:73
Selected reaction monitoring scan Synonyms: &#39;Multiple reaction monitoring scan&#39;, &#39;SRM scan&#39;, &#39;MRM scan&#39;.
Definition: InstrumentSettings.h:60
ResolutionType
Resolution type.
Definition: MassAnalyzer.h:92
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
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
DoubleReal getScanRate() const
returns the scan rate (in s)
void get(UInt &month, UInt &day, UInt &year, UInt &hour, UInt &minute, UInt &second) const
Fills the arguments with the date and the time.
ResolutionMethod
resolution method
Definition: MassAnalyzer.h:80
DoubleReal getConcentration() const
returns the concentration (in g/l) (default: 0.0)
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.
DoubleReal getIsolationWidth() const
returns the isolation width i.e. in which m/z range the precursor ion is selected for MS to the n (in...
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
void writeCVS_(std::ostream &os, DoubleReal value, const String &acc, const String &name, UInt indent=4) const
write cvParam containing strings to stream
Definition: MzDataHandler.h:222
MapType * exp_
map pointer for reading
Definition: MzDataHandler.h:172
Storing a file.
Definition: XMLHandler.h:109
MSSpectrum< PeakType > SpectrumType
Spectrum type.
Definition: MzDataHandler.h:169
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...
Scan window description.
Definition: ScanWindow.h:47
const String & getVendor() const
returns the instrument vendor
ReflectronState getReflectronState() const
returns the reflectron state (for TOF)
std::vector< Real > data_to_encode_
floating point numbers which have to be encoded and written
Definition: MzDataHandler.h:190
MzDataHandler(const MapType &exp, const String &filename, const String &version, const ProgressLogger &logger)
Constructor for a read-only handler.
Definition: MzDataHandler.h:81
MapType::PeakType PeakType
Peak type.
Definition: MzDataHandler.h:167
Meta information about the sample.
Definition: Sample.h:60
ReflectronState
Reflectron state.
Definition: MassAnalyzer.h:126
full scan mass spectrum, is a &quot;mass spectrum&quot; Synonyms: &#39;full spectrum&#39;, &#39;Q1 spectrum&#39;, &#39;Q3 spectrum&#39;, &#39;Single-Stage Mass Spectrometry&#39;
Definition: InstrumentSettings.h:57
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
IonizationMethod
ionization method
Definition: IonSource.h:80
const String & getName() const
returns the name of the software
std::vector< std::vector< DoubleReal > > decoded_double_list_
Definition: MzDataHandler.h:192
Selected ion monitoring scan Synonyms: &#39;Multiple ion monitoring scan&#39;, &#39;SIM scan&#39;, &#39;MIM scan&#39;.
Definition: InstrumentSettings.h:59
Constant neutral loss scan Synonyms: &#39;CNG scan&#39;.
Definition: InstrumentSettings.h:63
Time-delayed fragmentation scan.
Definition: InstrumentSettings.h:66
Interface for classes that can store arbitrary meta information (Type-Name-Value tuples).
Definition: MetaInfoInterface.h:61
Invalid conversion exception.
Definition: Exception.h:363
DoubleReal getResolution() const
returns the resolution
MzDataHandler(MapType &exp, const String &filename, const String &version, ProgressLogger &logger)
Constructor for a write-only handler.
Definition: MzDataHandler.h:67
Consecutive reaction monitoring scan Synonyms: &#39;CRM scan&#39;.
Definition: InstrumentSettings.h:61
std::vector< String > endians_
Definition: MzDataHandler.h:194
UInt peak_count_
The number of peaks in the current spectrum.
Definition: MzDataHandler.h:182
SampleState
state of aggregation of the sample
Definition: Sample.h:65
const String & getVersion() const
returns the software version
const DateTime & getCompletionTime() const
returns the time of completition of the processing
IonSource::Polarity getPolarity() const
returns the polarity
SpectrumType spec_
The current spectrum.
Definition: MzDataHandler.h:184
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:144
const String & getMethodOfCombination() const
returns the method of combination
Unknown scan method.
Definition: InstrumentSettings.h:55
Absorbtion scan.
Definition: InstrumentSettings.h:69
DateTime Class.
Definition: DateTime.h:55
Base class for all classes that want to report their progess.
Definition: ProgressLogger.h:56
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:195
const InstrumentSettings & getInstrumentSettings() const
returns a const reference to the instrument settings of the current spectrum
Peak picking (conversion from raw to peak data)
Definition: DataProcessing.h:67
Precursor ion scan.
Definition: InstrumentSettings.h:64
DoubleReal getMass() const
returns the mass (in gram) (default: 0.0)
general spectrum type
Definition: InstrumentSettings.h:56
DoubleReal getRT() const
Definition: MSSpectrum.h:215
const std::vector< Precursor > & getPrecursors() const
returns a const reference to the precursors
Constant neutral gain scan Synonyms: &#39;CNG scan&#39;.
Definition: InstrumentSettings.h:62
ActivationMethod
Method of activation.
Definition: Precursor.h:64
Options for loading files containing peak data.
Definition: PeakFileOptions.h:47
std::vector< std::vector< String > > cv_terms_
Array of CV term lists (one sublist denotes one term and it&#39;s children)
Definition: XMLHandler.h:192
AnalyzerType
analyzer type
Definition: MassAnalyzer.h:53
const FloatDataArrays & getFloatDataArrays() const
Returns a const reference to the float meta data arrays.
Definition: MSSpectrum.h:270
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. ...
ScanLaw
Scan law.
Definition: MassAnalyzer.h:114
int Int
Signed integer type.
Definition: Types.h:100
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 serveral convenience functions)
Definition: Map.h:50
Descripton 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.
const String & getName() const
retuns the sample name (default: &quot;&quot;)
Charge deconvolution.
Definition: DataProcessing.h:61
void cvParam_(const String &name, const String &value)
read attributes of MzData&#39;s cvParamType
Definition: MzDataHandler.h:1313
ResolutionType getResolutionType() const
returns the resolution type
Polarity
Polarity of the ion source.
Definition: IonSource.h:140
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

OpenMS / TOPP release 1.11.1 Documentation generated on Thu Nov 14 2013 11:19:18 using doxygen 1.8.5