OpenMS  2.4.0
SwathFileConsumer.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-2018.
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: Hannes Roest $
32 // $Authors: Hannes Roest $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
37 #include <boost/cast.hpp>
38 
39 // Datastructures
42 
43 // Consumers
47 
48 // Helpers
51 
55 
56 #ifdef _OPENMP
57 #include <omp.h>
58 #endif
59 
60 namespace OpenMS
61 {
62 
100  class OPENMS_DLLAPI FullSwathFileConsumer :
102  {
103 
104 public:
105  typedef PeakMap MapType;
108 
110  ms1_map_(), // initialize to null
111  consuming_possible_(true),
112  use_external_boundaries_(false),
113  correct_window_counter_(0)
114  {
115  use_external_boundaries_ = !swath_map_boundaries_.empty();
116  }
117 
125  FullSwathFileConsumer(std::vector<OpenSwath::SwathMap> swath_boundaries) :
126  swath_map_boundaries_(swath_boundaries),
127  ms1_map_(), // initialize to null
128  consuming_possible_(true),
129  use_external_boundaries_(false),
130  correct_window_counter_(0)
131  {
132  use_external_boundaries_ = !swath_map_boundaries_.empty();
133  }
134 
136 
137  void setExpectedSize(Size, Size) override {}
138  void setExperimentalSettings(const ExperimentalSettings& exp) override {settings_ = exp; }
139 
151  void retrieveSwathMaps(std::vector<OpenSwath::SwathMap>& maps)
152  {
153  consuming_possible_ = false; // make consumption of further spectra / chromatograms impossible
154  ensureMapsAreFilled_();
155  if (ms1_map_)
156  {
159  map.lower = -1;
160  map.upper = -1;
161  map.center = -1;
162  map.ms1 = true;
163  maps.push_back(map);
164  }
165 
166  // Print warning if the lower/upper window could not be determined and we
167  // required manual determination of the boundaries.
168  if (!use_external_boundaries_ && correct_window_counter_ != swath_maps_.size())
169  {
170  std::cout << "WARNING: Could not correctly read the upper/lower limits of the SWATH windows from your input file. Read " <<
171  correct_window_counter_ << " correct (non-zero) window limits (expected " << swath_maps_.size() << " windows)." << std::endl;
172  }
173 
174  size_t nonempty_maps = 0;
175  for (Size i = 0; i < swath_maps_.size(); i++)
176  {
179  map.lower = swath_map_boundaries_[i].lower;
180  map.upper = swath_map_boundaries_[i].upper;
181  map.center = swath_map_boundaries_[i].center;
182  map.ms1 = false;
183  maps.push_back(map);
184  if (map.sptr->getNrSpectra() > 0) {nonempty_maps++;}
185  }
186 
187  if (nonempty_maps != swath_map_boundaries_.size())
188  {
189  std::cout << "WARNING: The number nonempty maps found in the input file (" << nonempty_maps << ") is not equal to the number of provided swath window boundaries (" <<
190  swath_map_boundaries_.size() << "). Please check your input." << std::endl;
191  }
192 
193  }
194 
197  {
198  std::cerr << "Read chromatogram while reading SWATH files, did not expect that!" << std::endl;
199  }
200 
207  {
208  if (!consuming_possible_)
209  {
210  throw Exception::IllegalArgument(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION,
211  "FullSwathFileConsumer cannot consume any more spectra after retrieveSwathMaps has been called already");
212  }
213 
214  if (s.getMSLevel() == 1)
215  {
216  consumeMS1Spectrum_(s);
217  }
218  else
219  {
220  if (s.getPrecursors().empty())
221  {
222  throw Exception::InvalidParameter(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION,
223  "Swath scan does not provide a precursor.");
224  }
225 
226  const std::vector<Precursor> prec = s.getPrecursors();
227  double center = prec[0].getMZ();
228  double lower = prec[0].getMZ() - prec[0].getIsolationWindowLowerOffset();
229  double upper = prec[0].getMZ() + prec[0].getIsolationWindowUpperOffset();
230  bool found = false;
231 
232  // Check if enough information is present to infer the swath
233  if (center <= 0.0)
234  {
235  throw Exception::InvalidParameter(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION,
236  "Swath scan does not provide any precursor isolation information.");
237  }
238 
239  // try to match the current scan to one of the already known windows
240  for (Size i = 0; i < swath_map_boundaries_.size(); i++)
241  {
242  // We group by the precursor mz (center of the window) since this
243  // should be present in all SWATH scans.
244  if (std::fabs(center - swath_map_boundaries_[i].center) < 1e-6)
245  {
246  found = true;
247  consumeSwathSpectrum_(s, i);
248  }
249  }
250  if (!found)
251  {
252  if (use_external_boundaries_)
253  {
254  throw Exception::InvalidParameter(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION,
255  String("Encountered SWATH scan with boundary ") + center + " m/z which was not present in the provided windows.");
256  }
257  else
258  {
259  consumeSwathSpectrum_(s, swath_map_boundaries_.size());
260 
261  // we found a new SWATH window
262  if (lower > 0.0 && upper > 0.0)
263  {correct_window_counter_++;}
264 
265  OpenSwath::SwathMap boundary;
266  boundary.lower = lower;
267  boundary.upper = upper;
268  boundary.center = center;
269  swath_map_boundaries_.push_back(boundary);
270 
271  LOG_DEBUG << "Adding Swath centered at " << center
272  << " m/z with an isolation window of " << lower << " to " << upper
273  << " m/z." << std::endl;
274  }
275  }
276  }
277  }
278 
279 protected:
280 
288  virtual void consumeSwathSpectrum_(MapType::SpectrumType& s, size_t swath_nr) = 0;
289 
296  virtual void consumeMS1Spectrum_(MapType::SpectrumType& s) = 0;
297 
303  virtual void ensureMapsAreFilled_() = 0;
304 
306  std::vector<OpenSwath::SwathMap> swath_map_boundaries_;
307 
309  std::vector<boost::shared_ptr<PeakMap > > swath_maps_;
310  boost::shared_ptr<PeakMap > ms1_map_;
311 
313  // (MSExperiment has no constructor using ExperimentalSettings)
315 
318 
321 
324 
325  };
326 
333  class OPENMS_DLLAPI RegularSwathFileConsumer :
334  public FullSwathFileConsumer
335  {
336 
337 public:
338  typedef PeakMap MapType;
341 
343 
344  RegularSwathFileConsumer(std::vector<OpenSwath::SwathMap> known_window_boundaries) :
345  FullSwathFileConsumer(known_window_boundaries) {}
346 
347 protected:
349  {
350  boost::shared_ptr<PeakMap > exp(new PeakMap(settings_));
351  swath_maps_.push_back(exp);
352  }
353 
354  void consumeSwathSpectrum_(MapType::SpectrumType& s, size_t swath_nr) override
355  {
356  while (swath_maps_.size() <= swath_nr)
357  {
358  addNewSwathMap_();
359  }
360 
361  swath_maps_[swath_nr]->addSpectrum(s);
362  }
363 
364  void addMS1Map_()
365  {
366  boost::shared_ptr<PeakMap > exp(new PeakMap(settings_));
367  ms1_map_ = exp;
368  }
369 
371  {
372  if (!ms1_map_)
373  {
374  addMS1Map_();
375  }
376  ms1_map_->addSpectrum(s);
377  }
378 
379  void ensureMapsAreFilled_() override {}
380  };
381 
391  class OPENMS_DLLAPI CachedSwathFileConsumer :
392  public FullSwathFileConsumer
393  {
394 
395 public:
396  typedef PeakMap MapType;
399 
400  CachedSwathFileConsumer(String cachedir, String basename, Size nr_ms1_spectra, std::vector<int> nr_ms2_spectra) :
401  ms1_consumer_(nullptr),
402  swath_consumers_(),
403  cachedir_(cachedir),
404  basename_(basename),
405  nr_ms1_spectra_(nr_ms1_spectra),
406  nr_ms2_spectra_(nr_ms2_spectra)
407  {}
408 
409  CachedSwathFileConsumer(std::vector<OpenSwath::SwathMap> known_window_boundaries,
410  String cachedir, String basename, Size nr_ms1_spectra, std::vector<int> nr_ms2_spectra) :
411  FullSwathFileConsumer(known_window_boundaries),
412  ms1_consumer_(nullptr),
413  swath_consumers_(),
414  cachedir_(cachedir),
415  basename_(basename),
416  nr_ms1_spectra_(nr_ms1_spectra),
417  nr_ms2_spectra_(nr_ms2_spectra)
418  {}
419 
421  {
422  // Properly delete the MSDataCachedConsumer -> free memory and _close_ file stream
423  while (!swath_consumers_.empty())
424  {
425  delete swath_consumers_.back();
426  swath_consumers_.pop_back();
427  }
428  if (ms1_consumer_ != nullptr)
429  {
430  delete ms1_consumer_;
431  ms1_consumer_ = nullptr;
432  }
433  }
434 
435 protected:
437  {
438  String meta_file = cachedir_ + basename_ + "_" + String(swath_consumers_.size()) + ".mzML";
439  String cached_file = meta_file + ".cached";
440  MSDataCachedConsumer* consumer = new MSDataCachedConsumer(cached_file, true);
441  consumer->setExpectedSize(nr_ms2_spectra_[swath_consumers_.size()], 0);
442  swath_consumers_.push_back(consumer);
443 
444  // maps for meta data
445  boost::shared_ptr<PeakMap > exp(new PeakMap(settings_));
446  swath_maps_.push_back(exp);
447  }
448 
449  void consumeSwathSpectrum_(MapType::SpectrumType& s, size_t swath_nr) override
450  {
451  while (swath_maps_.size() <= swath_nr)
452  {
453  addNewSwathMap_();
454  }
455  swath_consumers_[swath_nr]->consumeSpectrum(s);
456  swath_maps_[swath_nr]->addSpectrum(s); // append for the metadata (actual data is deleted)
457  }
458 
459  void addMS1Map_()
460  {
461  String meta_file = cachedir_ + basename_ + "_ms1.mzML";
462  String cached_file = meta_file + ".cached";
463  ms1_consumer_ = new MSDataCachedConsumer(cached_file, true);
464  ms1_consumer_->setExpectedSize(nr_ms1_spectra_, 0);
465  boost::shared_ptr<PeakMap > exp(new PeakMap(settings_));
466  ms1_map_ = exp;
467  }
468 
470  {
471  if (ms1_consumer_ == nullptr)
472  {
473  addMS1Map_();
474  }
475  ms1_consumer_->consumeSpectrum(s);
476  ms1_map_->addSpectrum(s); // append for the metadata (actual data is deleted)
477  }
478 
479  void ensureMapsAreFilled_() override
480  {
481  size_t swath_consumers_size = swath_consumers_.size();
482  bool have_ms1 = (ms1_consumer_ != nullptr);
483 
484  // Properly delete the MSDataCachedConsumer -> free memory and _close_ file stream
485  // The file streams to the cached data on disc can and should be closed
486  // here safely. Since ensureMapsAreFilled_ is called after consuming all
487  // the spectra, there will be no more spectra to append but the client
488  // might already want to read after this call, so all data needs to be
489  // present on disc and the file streams closed.
490  //
491  // TODO merge with destructor code into own function!
492  while (!swath_consumers_.empty())
493  {
494  delete swath_consumers_.back();
495  swath_consumers_.pop_back();
496  }
497  if (ms1_consumer_ != nullptr)
498  {
499  delete ms1_consumer_;
500  ms1_consumer_ = nullptr;
501  }
502 
503  if (have_ms1)
504  {
505  boost::shared_ptr<PeakMap > exp(new PeakMap);
506  String meta_file = cachedir_ + basename_ + "_ms1.mzML";
507  // write metadata to disk and store the correct data processing tag
508  Internal::CachedMzMLHandler().writeMetadata(*ms1_map_, meta_file, true);
509  MzMLFile().load(meta_file, *exp.get());
510  ms1_map_ = exp;
511  }
512 
513 #ifdef _OPENMP
514 #pragma omp parallel for
515 #endif
516  for (SignedSize i = 0; i < boost::numeric_cast<SignedSize>(swath_consumers_size); i++)
517  {
518  boost::shared_ptr<PeakMap > exp(new PeakMap);
519  String meta_file = cachedir_ + basename_ + "_" + String(i) + ".mzML";
520  // write metadata to disk and store the correct data processing tag
521  Internal::CachedMzMLHandler().writeMetadata(*swath_maps_[i], meta_file, true);
522  MzMLFile().load(meta_file, *exp.get());
523  swath_maps_[i] = exp;
524  }
525  }
526 
528  std::vector<MSDataCachedConsumer*> swath_consumers_;
529 
533  std::vector<int> nr_ms2_spectra_;
534  };
535 
545  class OPENMS_DLLAPI MzMLSwathFileConsumer :
546  public FullSwathFileConsumer
547  {
548 
549 public:
550  typedef PeakMap MapType;
553 
554  MzMLSwathFileConsumer(String cachedir, String basename, Size nr_ms1_spectra, std::vector<int> nr_ms2_spectra) :
555  ms1_consumer_(nullptr),
556  swath_consumers_(),
557  cachedir_(cachedir),
558  basename_(basename),
559  nr_ms1_spectra_(nr_ms1_spectra),
560  nr_ms2_spectra_(nr_ms2_spectra)
561  {}
562 
563  MzMLSwathFileConsumer(std::vector<OpenSwath::SwathMap> known_window_boundaries,
564  String cachedir, String basename, Size nr_ms1_spectra, std::vector<int> nr_ms2_spectra) :
565  FullSwathFileConsumer(known_window_boundaries),
566  ms1_consumer_(nullptr),
567  swath_consumers_(),
568  cachedir_(cachedir),
569  basename_(basename),
570  nr_ms1_spectra_(nr_ms1_spectra),
571  nr_ms2_spectra_(nr_ms2_spectra)
572  {}
573 
575  {
576  deleteSetNull_();
577  }
578 
579 protected:
580 
582  {
583  // Properly delete the MSDataCachedConsumer -> free memory and _close_ file stream
584  while (!swath_consumers_.empty())
585  {
586  delete swath_consumers_.back();
587  swath_consumers_.pop_back();
588  }
589  if (ms1_consumer_ != nullptr)
590  {
591  delete ms1_consumer_;
592  ms1_consumer_ = nullptr;
593  }
594  }
595 
597  {
598  String mzml_file = cachedir_ + basename_ + "_" + String(swath_consumers_.size()) + ".mzML";
599  PlainMSDataWritingConsumer* consumer = new PlainMSDataWritingConsumer(mzml_file);
600  consumer->getOptions().setCompression(true);
601  consumer->setExpectedSize(nr_ms2_spectra_[swath_consumers_.size()], 0);
602  swath_consumers_.push_back(consumer);
603  }
604 
605  void consumeSwathSpectrum_(MapType::SpectrumType& s, size_t swath_nr) override
606  {
607  // only use swath_maps_ to count how many we have already added
608  while (swath_consumers_.size() <= swath_nr)
609  {
610  addNewSwathMap_();
611  }
612  swath_consumers_[swath_nr]->consumeSpectrum(s);
613  s.clear(false);
614  }
615 
616  void addMS1Map_()
617  {
618  String mzml_file = cachedir_ + basename_ + "_ms1.mzML";
619  ms1_consumer_ = new PlainMSDataWritingConsumer(mzml_file);
620  ms1_consumer_->setExpectedSize(nr_ms1_spectra_, 0);
621  ms1_consumer_->getOptions().setCompression(true);
622  boost::shared_ptr<PeakMap > exp(new PeakMap(settings_));
623  // ms1_map_ = exp;
624  }
625 
627  {
628  if (ms1_consumer_ == nullptr)
629  {
630  addMS1Map_();
631  }
632  ms1_consumer_->consumeSpectrum(s);
633  s.clear(false);
634  }
635 
636  void ensureMapsAreFilled_() override
637  {
638  deleteSetNull_();
639  }
640 
642  std::vector<PlainMSDataWritingConsumer*> swath_consumers_;
643 
647  std::vector<int> nr_ms2_spectra_;
648  };
649 
650 }
651 
MSDataTransformingConsumer.h
OpenMS::CachedSwathFileConsumer::addMS1Map_
void addMS1Map_()
Definition: SwathFileConsumer.h:459
OpenMS::FullSwathFileConsumer::FullSwathFileConsumer
FullSwathFileConsumer()
Definition: SwathFileConsumer.h:109
OpenMS::CachedSwathFileConsumer::CachedSwathFileConsumer
CachedSwathFileConsumer(std::vector< OpenSwath::SwathMap > known_window_boundaries, String cachedir, String basename, Size nr_ms1_spectra, std::vector< int > nr_ms2_spectra)
Definition: SwathFileConsumer.h:409
OpenMS::CachedSwathFileConsumer::ms1_consumer_
MSDataCachedConsumer * ms1_consumer_
Definition: SwathFileConsumer.h:527
OpenMS::CachedSwathFileConsumer::ensureMapsAreFilled_
void ensureMapsAreFilled_() override
Callback function after the reading is complete.
Definition: SwathFileConsumer.h:479
OpenMS::MSDataCachedConsumer::setExpectedSize
void setExpectedSize(Size, Size) override
Set expected size of spectra and chromatograms to be consumed.
Definition: MSDataCachedConsumer.h:100
OpenMS::Exception::IllegalArgument
A method or algorithm argument contains illegal values.
Definition: Exception.h:648
OpenMS::CachedSwathFileConsumer::SpectrumType
MapType::SpectrumType SpectrumType
Definition: SwathFileConsumer.h:397
OpenMS::CachedSwathFileConsumer::addNewSwathMap_
void addNewSwathMap_()
Definition: SwathFileConsumer.h:436
SwathMap.h
OpenMS::Interfaces::IMSDataConsumer
The interface of a consumer of spectra and chromatograms.
Definition: IMSDataConsumer.h:67
OpenMS::CachedSwathFileConsumer::ChromatogramType
MapType::ChromatogramType ChromatogramType
Definition: SwathFileConsumer.h:398
OpenMS::CachedSwathFileConsumer::CachedSwathFileConsumer
CachedSwathFileConsumer(String cachedir, String basename, Size nr_ms1_spectra, std::vector< int > nr_ms2_spectra)
Definition: SwathFileConsumer.h:400
OpenMS::FullSwathFileConsumer::consuming_possible_
bool consuming_possible_
Whether further spectra can still be consumed.
Definition: SwathFileConsumer.h:317
OpenMS::FullSwathFileConsumer::swath_maps_
std::vector< boost::shared_ptr< PeakMap > > swath_maps_
A list of SWATH maps and the MS1 map.
Definition: SwathFileConsumer.h:309
OpenMS::RegularSwathFileConsumer::consumeMS1Spectrum_
void consumeMS1Spectrum_(MapType::SpectrumType &s) override
Consume an MS1 spectrum.
Definition: SwathFileConsumer.h:370
OpenMS::MzMLSwathFileConsumer::consumeSwathSpectrum_
void consumeSwathSpectrum_(MapType::SpectrumType &s, size_t swath_nr) override
Consume an MS2 spectrum belonging to SWATH "swath_nr".
Definition: SwathFileConsumer.h:605
OpenMS::MzMLSwathFileConsumer::consumeMS1Spectrum_
void consumeMS1Spectrum_(MapType::SpectrumType &s) override
Consume an MS1 spectrum.
Definition: SwathFileConsumer.h:626
OpenMS::ExperimentalSettings
Description of the experimental settings.
Definition: ExperimentalSettings.h:58
OpenMS::MzMLFile
File adapter for MzML files.
Definition: MzMLFile.h:55
OpenMS::String
A more convenient string class.
Definition: String.h:57
OpenMS::MzMLSwathFileConsumer::addMS1Map_
void addMS1Map_()
Definition: SwathFileConsumer.h:616
OpenMS::CachedSwathFileConsumer::swath_consumers_
std::vector< MSDataCachedConsumer * > swath_consumers_
Definition: SwathFileConsumer.h:528
OpenMS::RegularSwathFileConsumer
In-memory implementation of FullSwathFileConsumer.
Definition: SwathFileConsumer.h:333
OpenMS::MSExperiment
In-Memory representation of a mass spectrometry experiment.
Definition: MSExperiment.h:77
OpenMS::SpectrumSettings::getPrecursors
const std::vector< Precursor > & getPrecursors() const
returns a const reference to the precursors
SimpleOpenMSSpectraAccessFactory.h
OpenMS::Size
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
OpenMS::FullSwathFileConsumer::consumeChromatogram
void consumeChromatogram(MapType::ChromatogramType &) override
Consume a chromatogram -> should not happen when dealing with SWATH maps.
Definition: SwathFileConsumer.h:196
OpenMS::CachedSwathFileConsumer::nr_ms1_spectra_
int nr_ms1_spectra_
Definition: SwathFileConsumer.h:532
OpenMS::CachedSwathFileConsumer::basename_
String basename_
Definition: SwathFileConsumer.h:531
OpenMS::FullSwathFileConsumer::~FullSwathFileConsumer
~FullSwathFileConsumer() override
Definition: SwathFileConsumer.h:135
DataStructures.h
OpenMS::CachedSwathFileConsumer::cachedir_
String cachedir_
Definition: SwathFileConsumer.h:530
IMSDataConsumer.h
OpenMS::CachedSwathFileConsumer::nr_ms2_spectra_
std::vector< int > nr_ms2_spectra_
Definition: SwathFileConsumer.h:533
MSDataCachedConsumer.h
OpenMS::CachedSwathFileConsumer::consumeMS1Spectrum_
void consumeMS1Spectrum_(MapType::SpectrumType &s) override
Consume an MS1 spectrum.
Definition: SwathFileConsumer.h:469
OpenMS::Internal::MzMLHandler::getOptions
PeakFileOptions & getOptions()
Get the peak file options.
OpenSwath::SwathMap::lower
double lower
Definition: SwathMap.h:48
OpenSwath::SwathMap::ms1
bool ms1
Definition: SwathMap.h:51
OpenMS::RegularSwathFileConsumer::addMS1Map_
void addMS1Map_()
Definition: SwathFileConsumer.h:364
OpenMS::Internal::CachedMzMLHandler::writeMetadata
void writeMetadata(MapType exp, String out_meta, bool addCacheMetaValue=false)
Write only the meta data of an MSExperiment.
OpenMS::RegularSwathFileConsumer::ensureMapsAreFilled_
void ensureMapsAreFilled_() override
Callback function after the reading is complete.
Definition: SwathFileConsumer.h:379
OpenMS::MzMLSwathFileConsumer::nr_ms1_spectra_
int nr_ms1_spectra_
Definition: SwathFileConsumer.h:646
OpenMS::RegularSwathFileConsumer::RegularSwathFileConsumer
RegularSwathFileConsumer()
Definition: SwathFileConsumer.h:342
OpenMS::FullSwathFileConsumer::setExperimentalSettings
void setExperimentalSettings(const ExperimentalSettings &exp) override
Set experimental settings (meta-data) of the data to be consumed.
Definition: SwathFileConsumer.h:138
OpenMS::Exception::InvalidParameter
Exception indicating that an invalid parameter was handed over to an algorithm.
Definition: Exception.h:347
OpenSwathHelper.h
OpenMS::MzMLSwathFileConsumer::cachedir_
String cachedir_
Definition: SwathFileConsumer.h:644
OpenMS::MzMLSwathFileConsumer::ensureMapsAreFilled_
void ensureMapsAreFilled_() override
Callback function after the reading is complete.
Definition: SwathFileConsumer.h:636
OpenMS::CachedSwathFileConsumer
On-disk cached implementation of FullSwathFileConsumer.
Definition: SwathFileConsumer.h:391
OpenMS::MSSpectrum::getMSLevel
UInt getMSLevel() const
Returns the MS level.
OpenMS::RegularSwathFileConsumer::addNewSwathMap_
void addNewSwathMap_()
Definition: SwathFileConsumer.h:348
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
OpenMS::MzMLSwathFileConsumer::ms1_consumer_
PlainMSDataWritingConsumer * ms1_consumer_
Definition: SwathFileConsumer.h:641
LOG_DEBUG
#define LOG_DEBUG
Macro for general debugging information.
Definition: LogStream.h:458
OpenMS::FullSwathFileConsumer::setExpectedSize
void setExpectedSize(Size, Size) override
Set expected size of spectra and chromatograms to be consumed.
Definition: SwathFileConsumer.h:137
OpenMS::FullSwathFileConsumer::SpectrumType
MapType::SpectrumType SpectrumType
Definition: SwathFileConsumer.h:106
OpenMS::MSDataCachedConsumer
Transforming and cached writing consumer of MS data.
Definition: MSDataCachedConsumer.h:54
OpenMS::MzMLSwathFileConsumer::nr_ms2_spectra_
std::vector< int > nr_ms2_spectra_
Definition: SwathFileConsumer.h:647
OpenMS::FullSwathFileConsumer::FullSwathFileConsumer
FullSwathFileConsumer(std::vector< OpenSwath::SwathMap > swath_boundaries)
Constructor.
Definition: SwathFileConsumer.h:125
OpenMS::MzMLFile::load
void load(const String &filename, PeakMap &map)
Loads a map from a MzML file. Spectra and chromatograms are sorted by default (this can be disabled u...
OpenMS::MzMLSwathFileConsumer::~MzMLSwathFileConsumer
~MzMLSwathFileConsumer() override
Definition: SwathFileConsumer.h:574
CachedMzMLHandler.h
OpenMS::MzMLSwathFileConsumer::ChromatogramType
MapType::ChromatogramType ChromatogramType
Definition: SwathFileConsumer.h:552
OpenMS::FullSwathFileConsumer
Abstract base class which can consume spectra coming from SWATH experiment stored in a single file.
Definition: SwathFileConsumer.h:100
OpenSwath::SwathMap::center
double center
Definition: SwathMap.h:50
OpenMS::FullSwathFileConsumer::MapType
PeakMap MapType
Definition: SwathFileConsumer.h:105
OpenMS::FullSwathFileConsumer::ChromatogramType
MapType::ChromatogramType ChromatogramType
Definition: SwathFileConsumer.h:107
OpenMS::CachedSwathFileConsumer::~CachedSwathFileConsumer
~CachedSwathFileConsumer() override
Definition: SwathFileConsumer.h:420
OpenSwath::SwathMap::upper
double upper
Definition: SwathMap.h:49
OpenMS::MSSpectrum::clear
void clear(bool clear_meta_data)
Clears all data and meta data.
OpenMS::RegularSwathFileConsumer::consumeSwathSpectrum_
void consumeSwathSpectrum_(MapType::SpectrumType &s, size_t swath_nr) override
Consume an MS2 spectrum belonging to SWATH "swath_nr".
Definition: SwathFileConsumer.h:354
OpenMS::MzMLSwathFileConsumer::MzMLSwathFileConsumer
MzMLSwathFileConsumer(std::vector< OpenSwath::SwathMap > known_window_boundaries, String cachedir, String basename, Size nr_ms1_spectra, std::vector< int > nr_ms2_spectra)
Definition: SwathFileConsumer.h:563
OpenMS::SimpleOpenMSSpectraFactory::getSpectrumAccessOpenMSPtr
static OpenSwath::SpectrumAccessPtr getSpectrumAccessOpenMSPtr(boost::shared_ptr< OpenMS::PeakMap > exp)
Simple Factory method to get a SpectrumAccess Ptr from an MSExperiment.
OpenMS::PeakMap
MSExperiment PeakMap
Two-dimensional map of raw data points or peaks.
Definition: StandardTypes.h:61
OpenMS::RegularSwathFileConsumer::RegularSwathFileConsumer
RegularSwathFileConsumer(std::vector< OpenSwath::SwathMap > known_window_boundaries)
Definition: SwathFileConsumer.h:344
OpenMS::MzMLSwathFileConsumer::addNewSwathMap_
void addNewSwathMap_()
Definition: SwathFileConsumer.h:596
OpenMS::MzMLSwathFileConsumer::MzMLSwathFileConsumer
MzMLSwathFileConsumer(String cachedir, String basename, Size nr_ms1_spectra, std::vector< int > nr_ms2_spectra)
Definition: SwathFileConsumer.h:554
OpenMS::RegularSwathFileConsumer::SpectrumType
MapType::SpectrumType SpectrumType
Definition: SwathFileConsumer.h:339
OpenMS::MzMLSwathFileConsumer
On-disk mzML implementation of FullSwathFileConsumer.
Definition: SwathFileConsumer.h:545
OpenMS::FullSwathFileConsumer::correct_window_counter_
size_t correct_window_counter_
How many windows were correctly annotated (non-zero window limits)
Definition: SwathFileConsumer.h:323
OpenMS::SignedSize
ptrdiff_t SignedSize
Signed Size type e.g. used as pointer difference.
Definition: Types.h:134
OpenMS::MSDataWritingConsumer::setExpectedSize
void setExpectedSize(Size expectedSpectra, Size expectedChromatograms) override
Set expected size of spectra and chromatograms to be written.
OpenMS::MzMLSwathFileConsumer::basename_
String basename_
Definition: SwathFileConsumer.h:645
OpenMS::FullSwathFileConsumer::consumeSpectrum
void consumeSpectrum(MapType::SpectrumType &s) override
* Consume a spectrum which may belong either to an MS1 scan or one of n MS2 (SWATH) scans
Definition: SwathFileConsumer.h:206
OpenMS::PlainMSDataWritingConsumer
Consumer class that writes MS data to disk using the mzML format.
Definition: MSDataWritingConsumer.h:240
OpenMS::FullSwathFileConsumer::retrieveSwathMaps
void retrieveSwathMaps(std::vector< OpenSwath::SwathMap > &maps)
Populate the vector of swath maps after consuming all spectra.
Definition: SwathFileConsumer.h:151
OpenSwath::SwathMap
Data structure to hold one SWATH map with information about upper / lower isolation window and whethe...
Definition: SwathMap.h:45
OpenMS::RegularSwathFileConsumer::MapType
PeakMap MapType
Definition: SwathFileConsumer.h:338
OpenMS::PeakFileOptions::setCompression
void setCompression(bool compress)
OpenMS::MSChromatogram
The representation of a chromatogram.
Definition: MSChromatogram.h:54
OpenMS::FullSwathFileConsumer::ms1_map_
boost::shared_ptr< PeakMap > ms1_map_
Definition: SwathFileConsumer.h:310
OpenMS::FullSwathFileConsumer::settings_
PeakMap settings_
The Experimental settings.
Definition: SwathFileConsumer.h:314
OpenMS::RegularSwathFileConsumer::ChromatogramType
MapType::ChromatogramType ChromatogramType
Definition: SwathFileConsumer.h:340
OpenMS::MzMLSwathFileConsumer::MapType
PeakMap MapType
Definition: SwathFileConsumer.h:550
OpenMS::FullSwathFileConsumer::swath_map_boundaries_
std::vector< OpenSwath::SwathMap > swath_map_boundaries_
A list of Swath map identifiers (lower/upper boundary and center)
Definition: SwathFileConsumer.h:306
OpenMS::MzMLSwathFileConsumer::deleteSetNull_
void deleteSetNull_()
Definition: SwathFileConsumer.h:581
OpenSwath::SwathMap::sptr
OpenSwath::SpectrumAccessPtr sptr
Definition: SwathMap.h:47
OpenMS::CachedSwathFileConsumer::MapType
PeakMap MapType
Definition: SwathFileConsumer.h:396
MSDataWritingConsumer.h
OpenMS::MSSpectrum
The representation of a 1D spectrum.
Definition: MSSpectrum.h:66
OpenMS::MzMLSwathFileConsumer::swath_consumers_
std::vector< PlainMSDataWritingConsumer * > swath_consumers_
Definition: SwathFileConsumer.h:642
StandardTypes.h
OpenMS::Internal::CachedMzMLHandler
An class that uses on-disk caching to read and write spectra and chromatograms.
Definition: CachedMzMLHandler.h:66
OpenMS::FullSwathFileConsumer::use_external_boundaries_
bool use_external_boundaries_
Whether to use external input for SWATH boundaries.
Definition: SwathFileConsumer.h:320
OpenMS::CachedSwathFileConsumer::consumeSwathSpectrum_
void consumeSwathSpectrum_(MapType::SpectrumType &s, size_t swath_nr) override
Consume an MS2 spectrum belonging to SWATH "swath_nr".
Definition: SwathFileConsumer.h:449
OpenMS::MzMLSwathFileConsumer::SpectrumType
MapType::SpectrumType SpectrumType
Definition: SwathFileConsumer.h:551