Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
MSExperiment.h
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
2 // OpenMS -- Open-Source Mass Spectrometry
3 // --------------------------------------------------------------------------
4 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5 // ETH Zurich, and Freie Universitaet Berlin 2002-2015.
6 //
7 // This software is released under a three-clause BSD license:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of any author or any participating institution
14 // may be used to endorse or promote products derived from this software
15 // without specific prior written permission.
16 // For a full list of authors, refer to the file AUTHORS.
17 // --------------------------------------------------------------------------
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // --------------------------------------------------------------------------
31 // $Maintainer: Stephan Aiche$
32 // $Authors: Marc Sturm $
33 // --------------------------------------------------------------------------
34 
35 #ifndef OPENMS_KERNEL_MSEXPERIMENT_H
36 #define OPENMS_KERNEL_MSEXPERIMENT_H
37 
44 
45 #include <vector>
46 #include <algorithm>
47 #include <limits>
48 
49 namespace OpenMS
50 {
51  class Peak1D;
52 
68  template <typename PeakT = Peak1D, typename ChromatogramPeakT = ChromatogramPeak>
69  class MSExperiment :
70  public RangeManager<2>,
72  {
73 
74 public:
75 
77 
78  typedef PeakT PeakType;
81  typedef ChromatogramPeakT ChromatogramPeakType;
95  typedef std::vector<SpectrumType> Base;
97 
99 
100  typedef typename std::vector<SpectrumType>::iterator Iterator;
103  typedef typename std::vector<SpectrumType>::const_iterator ConstIterator;
109 
111  // Attention: these refer to the spectra vector only!
113  typedef typename Base::value_type value_type;
114  typedef typename Base::iterator iterator;
115  typedef typename Base::const_iterator const_iterator;
116 
117  inline Size size() const
118  {
119  return spectra_.size();
120  }
121 
122  inline void resize(Size s)
123  {
124  spectra_.resize(s);
125  }
126 
127  inline bool empty() const
128  {
129  return spectra_.empty();
130  }
131 
132  inline void reserve(Size s)
133  {
134  spectra_.reserve(s);
135  }
136 
137  inline SpectrumType& operator[] (Size n)
138  {
139  return spectra_[n];
140  }
141 
142  inline const SpectrumType& operator[] (Size n) const
143  {
144  return spectra_[n];
145  }
146 
147  inline Iterator begin()
148  {
149  return spectra_.begin();
150  }
151 
152  inline ConstIterator begin() const
153  {
154  return spectra_.begin();
155  }
156 
157  inline Iterator end()
158  {
159  return spectra_.end();
160  }
161 
162  inline ConstIterator end() const
163  {
164  return spectra_.end();
165  }
167 
168  // Aliases / chromatograms
169  inline void reserveSpaceSpectra(Size s)
170  {
171  spectra_.reserve(s);
172  }
174  {
175  chromatograms_.reserve(s);
176  }
177 
180  RangeManagerType(),
182  ms_levels_(),
183  total_size_(0)
184  {}
185 
187  MSExperiment(const MSExperiment & source) :
188  RangeManagerType(source),
189  ExperimentalSettings(source),
190  ms_levels_(source.ms_levels_),
191  total_size_(source.total_size_),
193  spectra_(source.spectra_)
194  {}
195 
198  {
199  if (&source == this) return *this;
200 
203 
204  ms_levels_ = source.ms_levels_;
205  total_size_ = source.total_size_;
207  spectra_ = source.spectra_;
208 
209  //no need to copy the alloc?!
210  //alloc_
211 
212  return *this;
213  }
214 
217  {
219  return *this;
220  }
221 
223  bool operator==(const MSExperiment & rhs) const
224  {
225  return ExperimentalSettings::operator==(rhs) &&
226  chromatograms_ == rhs.chromatograms_ &&
227  spectra_ == rhs.spectra_;
228  }
229 
231  bool operator!=(const MSExperiment & rhs) const
232  {
233  return !(operator==(rhs));
234  }
235 
237 
238 
244  template <class Container>
245  void get2DData(Container & cont) const
246  {
247  for (typename Base::const_iterator spec = spectra_.begin(); spec != spectra_.end(); ++spec)
248  {
249  if (spec->getMSLevel() != 1)
250  {
251  continue;
252  }
253  typename Container::value_type s; // explicit object here, since instantiation within push_back() fails on VS<12
254  for (typename SpectrumType::const_iterator it = spec->begin(); it != spec->end(); ++it)
255  {
256  cont.push_back(s);
257  cont.back().setRT(spec->getRT());
258  cont.back().setMZ(it->getMZ());
259  cont.back().setIntensity(it->getIntensity());
260  }
261  }
262  }
263 
275  template <class Container>
276  void set2DData(const Container& container)
277  {
278  set2DData<false, Container>(container);
279  }
280 
298  template <bool add_mass_traces, class Container>
299  void set2DData(const Container& container)
300  {
301  // clean up the container first
302  clear(true);
303 
304  SpectrumType* spectrum = 0;
305 
306  typename PeakType::CoordinateType current_rt = -std::numeric_limits<typename PeakType::CoordinateType>::max();
307 
308  for (typename Container::const_iterator iter = container.begin(); iter != container.end(); ++iter)
309  {
310  // check if the retention time has changed
311  if (current_rt != iter->getRT() || spectrum == 0)
312  {
313  // append new spectrum
314  if (current_rt > iter->getRT())
315  {
316  throw Exception::Precondition(__FILE__, __LINE__, __PRETTY_FUNCTION__, "Input container is not sorted!");
317  }
318  current_rt = iter->getRT();
319  spectra_.insert(spectra_.end(), SpectrumType());
320  spectrum = &(spectra_.back());
321  spectrum->setRT(current_rt);
322  spectrum->setMSLevel(1);
323  }
324 
325  // add either data point or mass traces (depending on template argument value)
327  }
328  }
329 
331 
332 
334 
335  AreaIterator areaBegin(CoordinateType min_rt, CoordinateType max_rt, CoordinateType min_mz, CoordinateType max_mz)
337  {
338  OPENMS_PRECONDITION(min_rt <= max_rt, "Swapped RT range boundaries!")
339  OPENMS_PRECONDITION(min_mz <= max_mz, "Swapped MZ range boundaries!")
340  OPENMS_PRECONDITION(this->isSorted(true), "Experiment is not sorted by RT and m/z! Using AreaIterator will give invalid results!")
341  //std::cout << "areaBegin: " << min_rt << " " << max_rt << " " << min_mz << " " << max_mz << std::endl;
342  return AreaIterator(spectra_.begin(), RTBegin(min_rt), RTEnd(max_rt), min_mz, max_mz);
343  }
344 
346  AreaIterator areaEnd()
347  {
348  return AreaIterator();
349  }
350 
352  ConstAreaIterator areaBeginConst(CoordinateType min_rt, CoordinateType max_rt, CoordinateType min_mz, CoordinateType max_mz) const
353  {
354  OPENMS_PRECONDITION(min_rt <= max_rt, "Swapped RT range boundaries!")
355  OPENMS_PRECONDITION(min_mz <= max_mz, "Swapped MZ range boundaries!")
356  OPENMS_PRECONDITION(this->isSorted(true), "Experiment is not sorted by RT and m/z! Using ConstAreaIterator will give invalid results!")
357  //std::cout << "areaBeginConst: " << min_rt << " " << max_rt << " " << min_mz << " " << max_mz << std::endl;
358  return ConstAreaIterator(spectra_.begin(), RTBegin(min_rt), RTEnd(max_rt), min_mz, max_mz);
359  }
360 
362  ConstAreaIterator areaEndConst() const
363  {
364  return ConstAreaIterator();
365  }
366 
374  ConstIterator RTBegin(CoordinateType rt) const
375  {
376  SpectrumType s;
377  s.setRT(rt);
378  return lower_bound(spectra_.begin(), spectra_.end(), s, typename SpectrumType::RTLess());
379  }
380 
388  ConstIterator RTEnd(CoordinateType rt) const
389  {
390  SpectrumType s;
391  s.setRT(rt);
392  return upper_bound(spectra_.begin(), spectra_.end(), s, typename SpectrumType::RTLess());
393  }
394 
400  Iterator RTBegin(CoordinateType rt)
401  {
402  SpectrumType s;
403  s.setRT(rt);
404  return lower_bound(spectra_.begin(), spectra_.end(), s, typename SpectrumType::RTLess());
405  }
406 
412  Iterator RTEnd(CoordinateType rt)
413  {
414  SpectrumType s;
415  s.setRT(rt);
416  return upper_bound(spectra_.begin(), spectra_.end(), s, typename SpectrumType::RTLess());
417  }
418 
420 
426  // Docu in base class
428  virtual void updateRanges()
429  {
430  updateRanges(-1);
431  }
432 
438  void updateRanges(Int ms_level)
439  {
440  //clear MS levels
441  ms_levels_.clear();
442 
443  //reset mz/rt/int range
444  this->clearRanges();
445  //reset point count
446  total_size_ = 0;
447 
448  //empty
449  if (spectra_.empty() && chromatograms_.empty())
450  {
451  return;
452  }
453 
454  //update
455  for (typename Base::iterator it = spectra_.begin(); it != spectra_.end(); ++it)
456  {
457  if (ms_level < Int(0) || Int(it->getMSLevel()) == ms_level)
458  {
459  //ms levels
460  if (std::find(ms_levels_.begin(), ms_levels_.end(), it->getMSLevel()) == ms_levels_.end())
461  {
462  ms_levels_.push_back(it->getMSLevel());
463  }
464 
465  // calculate size
466  total_size_ += it->size();
467 
468  //rt
469  if (it->getRT() < RangeManagerType::pos_range_.minX()) RangeManagerType::pos_range_.setMinX(it->getRT());
470  if (it->getRT() > RangeManagerType::pos_range_.maxX()) RangeManagerType::pos_range_.setMaxX(it->getRT());
471 
472  //do not update mz and int when the spectrum is empty
473  if (it->size() == 0) continue;
474 
475  it->updateRanges();
476 
477  //mz
478  if (it->getMin()[0] < RangeManagerType::pos_range_.minY()) RangeManagerType::pos_range_.setMinY(it->getMin()[0]);
479  if (it->getMax()[0] > RangeManagerType::pos_range_.maxY()) RangeManagerType::pos_range_.setMaxY(it->getMax()[0]);
480 
481  //int
482  if (it->getMinInt() < RangeManagerType::int_range_.minX()) RangeManagerType::int_range_.setMinX(it->getMinInt());
483  if (it->getMaxInt() > RangeManagerType::int_range_.maxX()) RangeManagerType::int_range_.setMaxX(it->getMaxInt());
484 
485  }
486  // for MS level = 1 we extend the range for all the MS2 precursors
487  if (ms_level == 1 && it->getMSLevel() == 2)
488  {
489  if (!it->getPrecursors().empty())
490  {
491  double pc_rt = it->getRT();
492  if (pc_rt < RangeManagerType::pos_range_.minX()) RangeManagerType::pos_range_.setMinX(pc_rt);
493  if (pc_rt > RangeManagerType::pos_range_.maxX()) RangeManagerType::pos_range_.setMaxX(pc_rt);
494  double pc_mz = it->getPrecursors()[0].getMZ();
495  if (pc_mz < RangeManagerType::pos_range_.minY()) RangeManagerType::pos_range_.setMinY(pc_mz);
496  if (pc_mz > RangeManagerType::pos_range_.maxY()) RangeManagerType::pos_range_.setMaxY(pc_mz);
497  }
498 
499  }
500 
501  }
502  std::sort(ms_levels_.begin(), ms_levels_.end());
503 
504 
505 
506 
507  if (this->chromatograms_.empty())
508  {
509  return;
510  }
511 
512  //TODO CHROM update intensity, m/z and RT according to chromatograms as well! (done????)
513 
514  for (typename std::vector<ChromatogramType>::iterator it = chromatograms_.begin(); it != chromatograms_.end(); ++it)
515  {
516 
517  // ignore TICs and ECs (as these are usually positioned at 0 and therefor lead to a large white margin in plots if included)
518  if (it->getChromatogramType() == ChromatogramSettings::TOTAL_ION_CURRENT_CHROMATOGRAM ||
519  it->getChromatogramType() == ChromatogramSettings::EMISSION_CHROMATOGRAM)
520  {
521  continue;
522  }
523 
524  // update MZ
525  if (it->getMZ() < RangeManagerType::pos_range_.minY()) RangeManagerType::pos_range_.setMinY(it->getMZ());
526  if (it->getMZ() > RangeManagerType::pos_range_.maxY()) RangeManagerType::pos_range_.setMaxY(it->getMZ());
527 
528  // do not update RT and in if the spectrum is empty
529  if (it->size() == 0) continue;
530 
531  total_size_ += it->size();
532 
533  it->updateRanges();
534 
535  // RT
536  if (it->getMin()[0] < RangeManagerType::pos_range_.minX()) RangeManagerType::pos_range_.setMinX(it->getMin()[0]);
537  if (it->getMax()[0] > RangeManagerType::pos_range_.maxX()) RangeManagerType::pos_range_.setMaxX(it->getMax()[0]);
538 
539  // int
540  if (it->getMinInt() < RangeManagerType::int_range_.minX()) RangeManagerType::int_range_.setMinX(it->getMinInt());
541  if (it->getMaxInt() > RangeManagerType::int_range_.maxX()) RangeManagerType::int_range_.setMaxX(it->getMaxInt());
542  }
543  }
544 
546  CoordinateType getMinMZ() const
547  {
548  return RangeManagerType::pos_range_.minPosition()[1];
549  }
550 
552  CoordinateType getMaxMZ() const
553  {
554  return RangeManagerType::pos_range_.maxPosition()[1];
555  }
556 
558  CoordinateType getMinRT() const
559  {
560  return RangeManagerType::pos_range_.minPosition()[0];
561  }
562 
564  CoordinateType getMaxRT() const
565  {
566  return RangeManagerType::pos_range_.maxPosition()[0];
567  }
568 
574  const AreaType & getDataRange() const
575  {
577  }
578 
580  UInt64 getSize() const
581  {
582  return total_size_;
583  }
584 
586  const std::vector<UInt> & getMSLevels() const
587  {
588  return ms_levels_;
589  }
590 
592 
595 
600  void sortSpectra(bool sort_mz = true)
601  {
602  std::sort(spectra_.begin(), spectra_.end(), typename SpectrumType::RTLess());
603 
604  if (sort_mz)
605  {
606  // sort each spectrum by m/z
607  for (Iterator iter = spectra_.begin(); iter != spectra_.end(); ++iter)
608  {
609  iter->sortByPosition();
610  }
611  }
612  }
613 
619  void sortChromatograms(bool sort_rt = true)
620  {
621  // sort the chromatograms according to their product m/z
622  std::sort(chromatograms_.begin(), chromatograms_.end(), typename ChromatogramType::MZLess());
623 
624  if (sort_rt)
625  {
626  for (typename std::vector<ChromatogramType>::iterator it = chromatograms_.begin(); it != chromatograms_.end(); ++it)
627  {
628  it->sortByPosition();
629  }
630  }
631  }
632 
638  bool isSorted(bool check_mz = true) const
639  {
640  //check RT positions
641  for (Size i = 1; i < spectra_.size(); ++i)
642  {
643  if (spectra_[i - 1].getRT() > spectra_[i].getRT()) return false;
644  }
645  //check spectra
646  if (check_mz)
647  {
648  for (Size i = 0; i < spectra_.size(); ++i)
649  {
650  if (!spectra_[i].isSorted()) return false;
651  }
652  }
653  // TODO CHROM
654  return true;
655  }
656 
658 
660  void reset()
661  {
662  spectra_.clear(); //remove data
663  RangeManagerType::clearRanges(); //reset range manager
665  }
666 
673  {
674  bool meta_present = false;
675  for (Size i = 0; i < spectra_.size(); ++i)
676  {
677  if (spectra_[i].getFloatDataArrays().size() != 0 || spectra_[i].getIntegerDataArrays().size() != 0 || spectra_[i].getStringDataArrays().size() != 0)
678  {
679  meta_present = true;
680  }
681  spectra_[i].getStringDataArrays().clear();
682  spectra_[i].getIntegerDataArrays().clear();
683  spectra_[i].getFloatDataArrays().clear();
684  }
685  return meta_present;
686  }
687 
690  {
691  return *this;
692  }
693 
696  {
697  return *this;
698  }
699 
705  ConstIterator getPrecursorSpectrum(ConstIterator iterator) const
706  {
707  if (iterator == spectra_.end() || iterator == spectra_.begin())
708  {
709  return spectra_.end();
710  }
711  UInt ms_level = iterator->getMSLevel();
712  do
713  {
714  --iterator;
715  if (iterator->getMSLevel() < ms_level)
716  {
717  return iterator;
718  }
719  }
720  while (iterator != spectra_.begin());
721 
722  return spectra_.end();
723  }
724 
726  void swap(MSExperiment & from)
727  {
728  MSExperiment tmp;
729 
730  //swap range information
731  tmp.RangeManagerType::operator=(* this);
732  this->RangeManagerType::operator=(from);
733  from.RangeManagerType::operator=(tmp);
734 
735  //swap experimental settings
736  tmp.ExperimentalSettings::operator=(* this);
738  from.ExperimentalSettings::operator=(tmp);
739 
740  // swap chromatograms
741  std::swap(chromatograms_, from.chromatograms_);
742 
743  //swap peaks
744  spectra_.swap(from.getSpectra());
745 
746  //swap remaining members
747  ms_levels_.swap(from.ms_levels_);
748  std::swap(total_size_, from.total_size_);
749  }
750 
752  void setSpectra(const std::vector<MSSpectrum<PeakT> > & spectra)
753  {
754  spectra_ = spectra;
755  }
756 
758  void addSpectrum(const MSSpectrum<PeakT> & spectrum)
759  {
760  spectra_.push_back(spectrum);
761  }
762 
764  const std::vector<MSSpectrum<PeakT> > & getSpectra() const
765  {
766  return spectra_;
767  }
768 
770  std::vector<MSSpectrum<PeakT> > & getSpectra()
771  {
772  return spectra_;
773  }
774 
776  void setChromatograms(const std::vector<MSChromatogram<ChromatogramPeakType> > & chromatograms)
777  {
778  chromatograms_ = chromatograms;
779  }
780 
783  {
784  chromatograms_.push_back(chromatogram);
785  }
786 
788  const std::vector<MSChromatogram<ChromatogramPeakType> > & getChromatograms() const
789  {
790  return chromatograms_;
791  }
792 
794 
797  {
798  return chromatograms_[id];
799  }
800 
803  {
804  return spectra_[id];
805  }
806 
808  inline Size getNrSpectra() const
809  {
810  return spectra_.size();
811  }
812 
814  inline Size getNrChromatograms() const
815  {
816  return chromatograms_.size();
817  }
819 
822  {
823  // The TIC is (re)calculated from the MS1 spectra. Even if MSExperiment does not contain a TIC chromatogram explicitly, it can be reported.
825  for (typename Base::const_iterator spec_it = spectra_.begin(); spec_it != spectra_.end(); ++spec_it)
826  {
827  if (spec_it->getMSLevel() == 1)
828  {
829  double totalIntensity = 0;
830  // sum intensities of a spectrum
831  for (typename SpectrumType::const_iterator peak_it = spec_it->begin(); peak_it != spec_it->end(); ++peak_it)
832  {
833  totalIntensity += peak_it->getIntensity();
834  }
835  // fill chromatogram
836  ChromatogramPeakType peak;
837  peak.setRT(spec_it->getRT());
838  peak.setIntensity(totalIntensity);
839  TIC.push_back(peak);
840  }
841  }
842  return TIC;
843  }
844 
850  void clear(bool clear_meta_data)
851  {
852  spectra_.clear();
853 
854  if (clear_meta_data)
855  {
856  clearRanges();
857  this->ExperimentalSettings::operator=(ExperimentalSettings()); // no "clear" method
858  chromatograms_.clear();
859  ms_levels_.clear();
860  total_size_ = 0;
861  }
862  }
863 
864 protected:
865 
866 
868  std::vector<UInt> ms_levels_;
871 
873  std::vector<MSChromatogram<ChromatogramPeakType> > chromatograms_;
874 
876  std::vector<SpectrumType> spectra_;
877 
878 private:
879 
881  template<typename ContainerIterator, bool addMassTraces>
883  {
884  static void addData_(SpectrumType* spectrum, ContainerIterator& iter);
885  };
886 
887  template<typename ContainerIterator>
888  struct ContainerAdd_<ContainerIterator, false>
889  {
891  static void addData_(SpectrumType* spectrum, ContainerIterator& iter)
892  {
893  // create temporary peak and insert it into spectrum
894  spectrum->insert(spectrum->end(), PeakType());
895  spectrum->back().setIntensity(iter->getIntensity());
896  spectrum->back().setPosition(iter->getMZ());
897  }
898  };
899 
900  template<typename ContainerIterator>
901  struct ContainerAdd_<ContainerIterator, true>
902  {
904  static void addData_(SpectrumType* spectrum, ContainerIterator& iter)
905  {
906  if (iter->metaValueExists("num_of_masstraces"))
907  {
908  Size mts = iter->getMetaValue("num_of_masstraces");
909  int charge = (iter->getCharge()==0 ? 1 : iter->getCharge()); // set to 1 if charge is 0, otherwise div/0 below
910  for (Size i = 0; i < mts; ++i)
911  {
912  String meta_name = String("masstrace_intensity_") + i;
913  if (!iter->metaValueExists(meta_name))
914  {
915  throw Exception::Precondition(__FILE__, __LINE__, __PRETTY_FUNCTION__, String("Meta value '") + meta_name + "' expected but not found in container.");
916  }
917  spectrum->insert(spectrum->end(), PeakType());
918  spectrum->back().setIntensity(iter->getMetaValue(meta_name));
919  spectrum->back().setPosition(iter->getMZ() + Constants::C13C12_MASSDIFF_U / charge * i);
920  }
921  }
923  }
924  };
925 
926  };
927 
928 
930  template <typename PeakT, typename ChromatogramPeakT>
931  std::ostream & operator<<(std::ostream & os, const MSExperiment<PeakT, ChromatogramPeakT> & exp)
932  {
933  os << "-- MSEXPERIMENT BEGIN --" << std::endl;
934 
935  //experimental settings
936  os << static_cast<const ExperimentalSettings &>(exp);
937 
938  //spectra
939  for (typename MSExperiment<PeakT>::const_iterator it = exp.begin(); it != exp.end(); ++it)
940  {
941  os << *it;
942  }
943 
944  //chromatograms
945  for (typename std::vector<MSChromatogram<ChromatogramPeakT> >::const_iterator it = exp.getChromatograms().begin(); it != exp.getChromatograms().end(); ++it)
946  {
947  os << *it;
948  }
949 
950  os << "-- MSEXPERIMENT END --" << std::endl;
951 
952  return os;
953  }
954 
955 } // namespace OpenMS
956 
957 #endif // OPENMS_KERNEL_MSEXPERIMENT_H
void setRT(CoordinateType rt)
Mutable access to RT.
Definition: ChromatogramPeak.h:117
MSSpectrum< PeakType > SpectrumType
Spectrum Type.
Definition: MSExperiment.h:91
const double C13C12_MASSDIFF_U
Internal::AreaIterator< PeakT, PeakT &, PeakT *, Iterator, typename SpectrumType::Iterator > AreaIterator
Mutable area iterator type (for traversal of a rectangular subset of the peaks)
Definition: MSExperiment.h:105
void get2DData(Container &cont) const
Reads out a 2D Spectrum.
Definition: MSExperiment.h:245
Size getNrSpectra() const
get the total number of spectra available
Definition: MSExperiment.h:808
A more convenient string class.
Definition: String.h:57
void reserveSpaceChromatograms(Size s)
Definition: MSExperiment.h:173
void set2DData(const Container &container)
Assignment of a data container with RT and MZ to an MSExperiment.
Definition: MSExperiment.h:299
bool operator==(const ExperimentalSettings &rhs) const
Equality operator.
void reset()
Resets all internal values.
Definition: MSExperiment.h:660
PositionRangeType pos_range_
Position range (D-dimensional)
Definition: RangeManager.h:151
Size size() const
Definition: MSExperiment.h:117
std::vector< SpectrumType >::iterator Iterator
Mutable iterator.
Definition: MSExperiment.h:101
bool operator==(const MSExperiment &rhs) const
Equality operator.
Definition: MSExperiment.h:223
CoordinateType maxX() const
Accessor for min_ coordinate maximum.
Definition: DIntervalBase.h:253
Base::value_type value_type
Definition: MSExperiment.h:113
std::vector< MSChromatogram< ChromatogramPeakType > > chromatograms_
chromatograms
Definition: MSExperiment.h:873
#define OPENMS_PRECONDITION(condition, message)
Precondition macro.
Definition: openms/include/OpenMS/CONCEPT/Macros.h:107
Iterator RTEnd(CoordinateType rt)
Fast search for spectrum range end (returns the past-the-end iterator)
Definition: MSExperiment.h:412
bool clearMetaDataArrays()
Clears the meta data arrays of all contained spectra (float, integer and string arrays) ...
Definition: MSExperiment.h:672
MSExperiment()
Constructor.
Definition: MSExperiment.h:179
ChromatogramPeakT ChromatogramPeakType
Chromatogram peak type.
Definition: MSExperiment.h:81
Forward iterator for an area of peaks in an experiment.
Definition: AreaIterator.h:58
Iterator begin()
Definition: MSExperiment.h:147
void sortSpectra(bool sort_mz=true)
Sorts the data points by retention time.
Definition: MSExperiment.h:600
Base::const_iterator const_iterator
Definition: MSExperiment.h:115
void resize(Size s)
Definition: MSExperiment.h:122
PeakType::IntensityType IntensityType
Intensity type of peaks.
Definition: MSExperiment.h:87
void swap(MSExperiment &from)
Swaps the content of this map with the content of from.
Definition: MSExperiment.h:726
static void addData_(SpectrumType *spectrum, ContainerIterator &iter)
CoordinateType getMaxMZ() const
returns the maximal m/z value
Definition: MSExperiment.h:552
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
ConstIterator RTEnd(CoordinateType rt) const
Fast search for spectrum range end (returns the past-the-end iterator)
Definition: MSExperiment.h:388
Precondition failed exception.
Definition: Exception.h:167
const MSChromatogram< ChromatogramPeakType > getTIC() const
returns the total ion chromatogram (TIC)
Definition: MSExperiment.h:821
void addChromatogram(const MSChromatogram< ChromatogramPeakType > &chromatogram)
adds a chromatogram to the list
Definition: MSExperiment.h:782
ConstAreaIterator areaEndConst() const
Returns an non-mutable invalid area iterator marking the end of an area.
Definition: MSExperiment.h:362
MSSpectrum< PeakT > & getSpectrum(Size id)
returns a single spectrum
Definition: MSExperiment.h:802
CoordinateType getMinMZ() const
returns the minimal m/z value
Definition: MSExperiment.h:546
CoordinateType getMinRT() const
returns the minimal retention time value
Definition: MSExperiment.h:558
SpectrumType & operator[](Size n)
Definition: MSExperiment.h:137
RangeManager< 2 > RangeManagerType
RangeManager type.
Definition: MSExperiment.h:89
Iterator end()
Definition: MSExperiment.h:157
static void addData_(SpectrumType *spectrum, ContainerIterator &iter)
specialization for adding feature mass traces
Definition: MSExperiment.h:904
ConstIterator RTBegin(CoordinateType rt) const
Fast search for spectrum range begin.
Definition: MSExperiment.h:374
Base::iterator iterator
Definition: MSExperiment.h:114
MSChromatogram< ChromatogramPeakType > ChromatogramType
Chromatogram type.
Definition: MSExperiment.h:93
void sortChromatograms(bool sort_rt=true)
Sorts the data points of the chromatograms by m/z.
Definition: MSExperiment.h:619
void updateRanges(Int ms_level)
Updates the m/z, intensity, retention time and MS level ranges of all spectra with a certain ms level...
Definition: MSExperiment.h:438
ConstAreaIterator areaBeginConst(CoordinateType min_rt, CoordinateType max_rt, CoordinateType min_mz, CoordinateType max_mz) const
Returns a non-mutable area iterator for area.
Definition: MSExperiment.h:352
void reserve(Size s)
Definition: MSExperiment.h:132
CoordinateType minX() const
Accessor for min_ coordinate minimum.
Definition: DIntervalBase.h:241
MSChromatogram< ChromatogramPeakType > & getChromatogram(Size id)
returns a single chromatogram
Definition: MSExperiment.h:796
RangeManager & operator=(const RangeManager &rhs)
Assignment operator.
Definition: RangeManager.h:77
Helper class to add either general data points in set2DData or use mass traces from meta values...
Definition: MSExperiment.h:882
const ExperimentalSettings & getExperimentalSettings() const
returns the meta information of this experiment (const access)
Definition: MSExperiment.h:689
void clearRanges()
Resets the ranges.
Definition: RangeManager.h:140
void setMSLevel(UInt ms_level)
Sets the MS level.
Definition: MSSpectrum.h:265
ConstIterator end() const
Definition: MSExperiment.h:162
bool operator!=(const MSExperiment &rhs) const
Equality operator.
Definition: MSExperiment.h:231
Definition: ChromatogramSettings.h:77
Size getNrChromatograms() const
get the total number of chromatograms available
Definition: MSExperiment.h:814
AreaIterator areaBegin(CoordinateType min_rt, CoordinateType max_rt, CoordinateType min_mz, CoordinateType max_mz)
Returns an area iterator for area.
Definition: MSExperiment.h:336
const std::vector< MSSpectrum< PeakT > > & getSpectra() const
returns the spectra list
Definition: MSExperiment.h:764
PeakType::CoordinateType CoordinateType
Coordinate type of peak positions.
Definition: MSExperiment.h:85
IntensityRangeType int_range_
Intensity range (1-dimensional)
Definition: RangeManager.h:149
PeakT PeakType
Peak type.
Definition: MSExperiment.h:79
void reserveSpaceSpectra(Size s)
Definition: MSExperiment.h:169
std::vector< SpectrumType > spectra_
spectra
Definition: MSExperiment.h:876
DRange< 2 > AreaType
Area type.
Definition: MSExperiment.h:83
Internal::AreaIterator< const PeakT, const PeakT &, const PeakT *, ConstIterator, typename SpectrumType::ConstIterator > ConstAreaIterator
Immutable area iterator type (for traversal of a rectangular subset of the peaks) ...
Definition: MSExperiment.h:107
void addSpectrum(const MSSpectrum< PeakT > &spectrum)
adds a spectra to the list
Definition: MSExperiment.h:758
ExperimentalSettings & getExperimentalSettings()
returns the meta information of this experiment (mutable access)
Definition: MSExperiment.h:695
void setRT(double rt)
Sets the absolute retention time (is seconds)
Definition: MSSpectrum.h:249
const std::vector< UInt > & getMSLevels() const
returns an array of MS levels
Definition: MSExperiment.h:586
MSExperiment(const MSExperiment &source)
Copy constructor.
Definition: MSExperiment.h:187
In-Memory representation of a mass spectrometry experiment.
Definition: MSExperiment.h:69
bool isSorted(bool check_mz=true) const
Checks if all spectra are sorted with respect to ascending RT.
Definition: MSExperiment.h:638
ExperimentalSettings & operator=(const ExperimentalSettings &source)
Assignment operator.
void setChromatograms(const std::vector< MSChromatogram< ChromatogramPeakType > > &chromatograms)
sets the chromatogram list
Definition: MSExperiment.h:776
const AreaType & getDataRange() const
Returns RT and m/z range the data lies in.
Definition: MSExperiment.h:574
MSExperiment & operator=(const ExperimentalSettings &source)
Assignment operator.
Definition: MSExperiment.h:216
std::vector< MSSpectrum< PeakT > > & getSpectra()
returns the spectra list
Definition: MSExperiment.h:770
std::vector< SpectrumType >::const_iterator ConstIterator
Non-mutable iterator.
Definition: MSExperiment.h:103
void setIntensity(IntensityType intensity)
Mutable access to the data point intensity (height)
Definition: ChromatogramPeak.h:108
AreaIterator areaEnd()
Returns an invalid area iterator marking the end of an area.
Definition: MSExperiment.h:346
CoordinateType getMaxRT() const
returns the maximal retention time value
Definition: MSExperiment.h:564
static void addData_(SpectrumType *spectrum, ContainerIterator &iter)
general method for adding data points (no mass traces desired or found)
Definition: MSExperiment.h:891
UInt64 getSize() const
returns the total number of peaks
Definition: MSExperiment.h:580
void clear(bool clear_meta_data)
Clears all data and meta data.
Definition: MSExperiment.h:850
MSExperiment & operator=(const MSExperiment &source)
Assignment operator.
Definition: MSExperiment.h:197
bool empty() const
Definition: MSExperiment.h:127
Iterator RTBegin(CoordinateType rt)
Fast search for spectrum range begin.
Definition: MSExperiment.h:400
std::vector< SpectrumType > Base
STL base class type.
Definition: MSExperiment.h:95
void setSpectra(const std::vector< MSSpectrum< PeakT > > &spectra)
sets the spectra list
Definition: MSExperiment.h:752
Handles the management of a position and intensity range.
Definition: RangeManager.h:48
void set2DData(const Container &container)
Assignment of a data container with RT and MZ to an MSExperiment.
Definition: MSExperiment.h:276
virtual void updateRanges()
Updates minimum and maximum position/intensity.
Definition: MSExperiment.h:428
UInt64 total_size_
Number of all data points.
Definition: MSExperiment.h:870
int Int
Signed integer type.
Definition: Types.h:96
ConstIterator getPrecursorSpectrum(ConstIterator iterator) const
Returns the precursor spectrum of the scan pointed to by iterator.
Definition: MSExperiment.h:705
Description of the experimental settings.
Definition: ExperimentalSettings.h:59
const std::vector< MSChromatogram< ChromatogramPeakType > > & getChromatograms() const
returns the chromatogram list
Definition: MSExperiment.h:788
ConstIterator begin() const
Definition: MSExperiment.h:152
std::vector< UInt > ms_levels_
MS levels of the data.
Definition: MSExperiment.h:868
ExperimentalSettings()
Constructor.

OpenMS / TOPP release 2.0.0 Documentation generated on Tue Nov 1 2016 16:34:46 using doxygen 1.8.11