35 #ifndef OPENMS_KERNEL_MSEXPERIMENT_H 36 #define OPENMS_KERNEL_MSEXPERIMENT_H 110 typedef std::vector<SpectrumType>
Base;
115 typedef std::vector<SpectrumType>::iterator
Iterator;
177 inline ConstIterator
end()
const 203 RangeManagerType(source),
214 if (&source ==
this)
return *
this;
259 template <
class Container>
262 for (
typename Base::const_iterator spec =
spectra_.begin(); spec !=
spectra_.end(); ++spec)
264 if (spec->getMSLevel() != 1)
268 typename Container::value_type s;
269 for (
typename SpectrumType::const_iterator it = spec->begin(); it != spec->end(); ++it)
272 cont.back().setRT(spec->getRT());
273 cont.back().setMZ(it->getMZ());
274 cont.back().setIntensity(it->getIntensity());
290 template <
class Container>
293 set2DData<false, Container>(container);
310 template <
class Container>
315 SpectrumType* spectrum = 0;
317 for (
typename Container::const_iterator iter = container.begin(); iter != container.end(); ++iter)
320 if (current_rt != iter->getRT() || spectrum == 0)
323 if (current_rt > iter->getRT())
327 current_rt = iter->getRT();
328 spectrum =
createSpec_(current_rt, store_metadata_names);
353 template <
bool add_mass_traces,
class Container>
358 SpectrumType* spectrum = 0;
360 for (
typename Container::const_iterator iter = container.begin(); iter != container.end(); ++iter)
363 if (current_rt != iter->getRT() || spectrum == 0)
366 if (current_rt > iter->getRT())
370 current_rt = iter->getRT();
384 AreaIterator
areaBegin(CoordinateType min_rt, CoordinateType max_rt, CoordinateType min_mz, CoordinateType max_mz)
401 ConstAreaIterator
areaBeginConst(CoordinateType min_rt, CoordinateType max_rt, CoordinateType min_mz, CoordinateType max_mz)
const 405 OPENMS_PRECONDITION(this->
isSorted(
true),
"Experiment is not sorted by RT and m/z! Using ConstAreaIterator will give invalid results!")
423 ConstIterator
RTBegin(CoordinateType rt)
const 437 ConstIterator
RTEnd(CoordinateType rt)
const 506 if (ms_level <
Int(0) ||
Int(it->getMSLevel()) == ms_level)
522 if (it->size() == 0)
continue;
536 if (ms_level == 1 && it->getMSLevel() == 2)
538 if (!it->getPrecursors().empty())
540 double pc_rt = it->getRT();
543 double pc_mz = it->getPrecursors()[0].getMZ();
578 if (it->size() == 0)
continue;
658 iter->sortByPosition();
677 it->sortByPosition();
723 bool meta_present =
false;
726 if (
spectra_[i].getFloatDataArrays().size() != 0 ||
spectra_[i].getIntegerDataArrays().size() != 0 ||
spectra_[i].getStringDataArrays().size() != 0)
730 spectra_[i].getStringDataArrays().clear();
731 spectra_[i].getIntegerDataArrays().clear();
732 spectra_[i].getFloatDataArrays().clear();
753 for (std::vector<SourceFile>::const_iterator it = sfs.begin(); it != sfs.end(); ++it)
756 String path = it->getPathToFile();
757 String filename = it->getNameOfFile();
759 if (path.empty() || filename.empty())
761 LOG_WARN <<
"Path or file name of primary MS run is empty. " 762 <<
"This might be the result of incomplete conversion. " 763 <<
"Not that tracing back e.g. identification results to the original file might more difficult." << std::endl;
767 String ms_run_location = path +
"/" + filename;
768 toFill.push_back(ms_run_location);
784 UInt ms_level = iterator->getMSLevel();
788 if (iterator->getMSLevel() < ms_level)
793 while (iterator !=
spectra_.begin());
804 tmp.RangeManagerType::operator=(* this);
806 from.RangeManagerType::operator=(tmp);
809 tmp.ExperimentalSettings::operator=(* this);
811 from.ExperimentalSettings::operator=(tmp);
904 for (Base::const_iterator spec_it =
spectra_.begin(); spec_it !=
spectra_.end(); ++spec_it)
906 if (spec_it->getMSLevel() == 1)
908 double totalIntensity = 0;
910 for (SpectrumType::const_iterator peak_it = spec_it->begin(); peak_it != spec_it->end(); ++peak_it)
912 totalIntensity +=
static_cast<double>(peak_it->getIntensity());
915 ChromatogramPeakType peak;
916 peak.
setRT(spec_it->getRT());
960 template<
typename ContainerValueType,
bool addMassTraces>
963 static void addData_(SpectrumType* spectrum,
const ContainerValueType* item);
964 static void addData_(SpectrumType* spectrum,
const ContainerValueType* item,
const StringList& store_metadata_names);
967 template<
typename ContainerValueType>
971 static void addData_(SpectrumType* spectrum,
const ContainerValueType* item)
974 spectrum->insert(spectrum->end(),
PeakType());
975 spectrum->back().setIntensity(item->getIntensity());
976 spectrum->back().setPosition(item->getMZ());
979 static void addData_(SpectrumType* spectrum,
const ContainerValueType* item,
const StringList& store_metadata_names)
982 for (StringList::const_iterator itm = store_metadata_names.begin(); itm != store_metadata_names.end(); ++itm)
984 float val = std::numeric_limits<float>::quiet_NaN();
985 if (item->metaValueExists(*itm)) val = item->getMetaValue(*itm);
991 template<
typename ContainerValueType>
995 static void addData_(SpectrumType* spectrum,
const ContainerValueType* item)
997 if (item->metaValueExists(
"num_of_masstraces"))
999 Size mts = item->getMetaValue(
"num_of_masstraces");
1000 int charge = (item->getCharge()==0 ? 1 : item->getCharge());
1001 for (
Size i = 0; i < mts; ++i)
1004 if (!item->metaValueExists(meta_name))
1006 throw Exception::Precondition(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION,
String(
"Meta value '") + meta_name +
"' expected but not found in container.");
1008 ContainerValueType p;
1009 p.setIntensity(item->getMetaValue(meta_name));
1026 SpectrumType* spectrum = 0;
1028 spectrum = &(spectra_.back());
1029 spectrum->
setRT(rt);
1046 StringList::const_iterator itm = metadata_names.begin();
1047 for (; itm != metadata_names.end(); ++itm)
1060 os <<
"-- MSEXPERIMENT BEGIN --" << std::endl;
1063 os << static_cast<const ExperimentalSettings &>(exp);
1066 for (std::vector<MSSpectrum>::const_iterator it = exp.
getSpectra().begin(); it != exp.
getSpectra().end(); ++it)
1077 os <<
"-- MSEXPERIMENT END --" << std::endl;
1086 #endif // OPENMS_KERNEL_MSEXPERIMENT_H void setRT(CoordinateType rt)
Mutable access to RT.
Definition: ChromatogramPeak.h:117
ConstIterator RTBegin(CoordinateType rt) const
Fast search for spectrum range begin.
Definition: MSExperiment.h:423
CoordinateType getMaxRT() const
returns the maximal retention time value
Definition: MSExperiment.h:613
bool operator==(const ExperimentalSettings &rhs) const
Equality operator.
const double C13C12_MASSDIFF_U
const std::vector< MSChromatogram > & getChromatograms() const
returns the chromatogram list
Definition: MSExperiment.h:861
A more convenient string class.
Definition: String.h:57
void reserveSpaceChromatograms(Size s)
Definition: MSExperiment.h:188
void set2DData(const Container &container)
Assignment of a data container with RT and MZ to an MSExperiment.
Definition: MSExperiment.h:354
static void addData_(SpectrumType *spectrum, const ContainerValueType *item)
general method for adding data points
Definition: MSExperiment.h:971
void reset()
Resets all internal values.
Definition: MSExperiment.h:709
PositionRangeType pos_range_
Position range (D-dimensional)
Definition: RangeManager.h:151
std::vector< SpectrumType >::iterator Iterator
Mutable iterator.
Definition: MSExperiment.h:116
Peak1D PeakT
Definition: MSExperiment.h:88
void addSpectrum(const MSSpectrum &spectrum)
adds a spectrum to the list
Definition: MSExperiment.h:831
The representation of a chromatogram.
Definition: MSChromatogram.h:55
CoordinateType maxX() const
Accessor for min_ coordinate maximum.
Definition: DIntervalBase.h:253
Definition: ChromatogramSettings.h:70
Base::value_type value_type
Definition: MSExperiment.h:128
#define OPENMS_PRECONDITION(condition, message)
Precondition macro.
Definition: openms/include/OpenMS/CONCEPT/Macros.h:107
Comparator for the retention time.
Definition: MSSpectrum.h:75
Iterator RTEnd(CoordinateType rt)
Fast search for spectrum range end (returns the past-the-end iterator)
Definition: MSExperiment.h:461
unsigned int UInt
Unsigned integer type.
Definition: Types.h:95
ConstAreaIterator areaEndConst() const
Returns an non-mutable invalid area iterator marking the end of an area.
Definition: MSExperiment.h:411
bool clearMetaDataArrays()
Clears the meta data arrays of all contained spectra (float, integer and string arrays) ...
Definition: MSExperiment.h:721
MSExperiment()
Constructor.
Definition: MSExperiment.h:194
ChromatogramPeakT ChromatogramPeakType
Chromatogram peak type.
Definition: MSExperiment.h:96
Forward iterator for an area of peaks in an experiment.
Definition: AreaIterator.h:58
ConstIterator end() const
Definition: MSExperiment.h:177
std::vector< MSChromatogram > chromatograms_
chromatograms
Definition: MSExperiment.h:952
SpectrumType * createSpec_(PeakType::CoordinateType rt)
Definition: MSExperiment.h:1024
Iterator begin()
Definition: MSExperiment.h:162
SpectrumType * createSpec_(PeakType::CoordinateType rt, const StringList &metadata_names)
Definition: MSExperiment.h:1041
void sortSpectra(bool sort_mz=true)
Sorts the data points by retention time.
Definition: MSExperiment.h:649
Base::const_iterator const_iterator
Definition: MSExperiment.h:130
const std::vector< UInt > & getMSLevels() const
returns an array of MS levels
Definition: MSExperiment.h:635
void setChromatograms(const std::vector< MSChromatogram > &chromatograms)
sets the chromatogram list
Definition: MSExperiment.h:849
void resize(Size s)
Definition: MSExperiment.h:137
std::vector< MSSpectrum > & getSpectra()
returns the spectrum list (mutable)
Definition: MSExperiment.h:843
PeakType::IntensityType IntensityType
Intensity type of peaks.
Definition: MSExperiment.h:102
void swap(MSExperiment &from)
Swaps the content of this map with the content of from.
Definition: MSExperiment.h:799
void addChromatogram(const MSChromatogram &chromatogram)
adds a chromatogram to the list
Definition: MSExperiment.h:855
Size size() const
Definition: MSExperiment.h:132
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
Precondition failed exception.
Definition: Exception.h:167
MSSpectrum & getSpectrum(Size id)
returns a single spectrum
Definition: MSExperiment.h:881
bool isSorted(bool check_mz=true) const
Checks if all spectra are sorted with respect to ascending RT.
Definition: MSExperiment.h:687
const FloatDataArrays & getFloatDataArrays() const
Returns a const reference to the float meta data arrays.
MSSpectrum SpectrumType
Spectrum Type.
Definition: MSExperiment.h:106
Float data array class.
Definition: DataArrays.h:46
SpectrumType & operator[](Size n)
Definition: MSExperiment.h:152
RangeManager< 2 > RangeManagerType
RangeManager type.
Definition: MSExperiment.h:104
std::vector< MSChromatogram > & getChromatograms()
returns the chromatogram list (mutable)
Definition: MSExperiment.h:867
#define LOG_WARN
Macro if a warning, a piece of information which should be read by the user, should be logged...
Definition: LogStream.h:451
Iterator end()
Definition: MSExperiment.h:172
static void addData_(SpectrumType *spectrum, const ContainerValueType *item)
Base::iterator iterator
Definition: MSExperiment.h:129
The representation of a 1D spectrum.
Definition: MSSpectrum.h:67
void sortChromatograms(bool sort_rt=true)
Sorts the data points of the chromatograms by m/z.
Definition: MSExperiment.h:668
Internal::AreaIterator< PeakT, PeakT &, PeakT *, Iterator, SpectrumType::Iterator > AreaIterator
Mutable area iterator type (for traversal of a rectangular subset of the peaks)
Definition: MSExperiment.h:120
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:487
bool operator!=(const MSExperiment &rhs) const
Equality operator.
Definition: MSExperiment.h:246
const std::vector< SourceFile > & getSourceFiles() const
returns a const reference to the source data file
Comparator for the retention time.
Definition: MSChromatogram.h:64
void reserve(Size s)
Definition: MSExperiment.h:147
void set2DData(const Container &container, const StringList &store_metadata_names)
Assignment of a data container with RT and MZ to an MSExperiment.
Definition: MSExperiment.h:311
Size getNrChromatograms() const
get the total number of chromatograms available
Definition: MSExperiment.h:893
RangeManager & operator=(const RangeManager &rhs)
Assignment operator.
Definition: RangeManager.h:77
void getPrimaryMSRunPath(StringList &toFill) const
get the file path to the first MS run
Definition: MSExperiment.h:750
Helper class to add either general data points in set2DData or use mass traces from meta values...
Definition: MSExperiment.h:961
Size getNrSpectra() const
get the total number of spectra available
Definition: MSExperiment.h:887
A 1-dimensional raw data point or peak.
Definition: Peak1D.h:55
std::ostream & operator<<(std::ostream &os, const AccurateMassSearchResult &amsr)
void clearRanges()
Resets the ranges.
Definition: RangeManager.h:140
void setMSLevel(UInt ms_level)
Sets the MS level.
ChromatogramPeak ChromatogramPeakT
Definition: MSExperiment.h:89
Definition: ChromatogramSettings.h:77
AreaIterator areaBegin(CoordinateType min_rt, CoordinateType max_rt, CoordinateType min_mz, CoordinateType max_mz)
Returns an area iterator for area.
Definition: MSExperiment.h:385
PeakType::CoordinateType CoordinateType
Coordinate type of peak positions.
Definition: MSExperiment.h:100
bool empty() const
Definition: MSExperiment.h:142
IntensityRangeType int_range_
Intensity range (1-dimensional)
Definition: RangeManager.h:149
PeakT PeakType
Peak type.
Definition: MSExperiment.h:94
void reserveSpaceSpectra(Size s)
Definition: MSExperiment.h:184
OPENMS_UINT64_TYPE UInt64
Unsigned integer type (64bit)
Definition: Types.h:78
std::vector< SpectrumType > spectra_
spectra
Definition: MSExperiment.h:955
DRange< 2 > AreaType
Area type.
Definition: MSExperiment.h:98
ExperimentalSettings & getExperimentalSettings()
returns the meta information of this experiment (mutable access)
Definition: MSExperiment.h:744
void setRT(double rt)
Sets the absolute retention time (in seconds)
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:401
std::vector< String > StringList
Vector of String.
Definition: ListUtils.h:74
MSExperiment(const MSExperiment &source)
Copy constructor.
Definition: MSExperiment.h:202
In-Memory representation of a mass spectrometry experiment.
Definition: MSExperiment.h:82
const MSChromatogram getTIC() const
returns the total ion chromatogram (TIC)
Definition: MSExperiment.h:900
ExperimentalSettings & operator=(const ExperimentalSettings &source)
Assignment operator.
UInt64 getSize() const
returns the total number of peaks
Definition: MSExperiment.h:629
MSChromatogram ChromatogramType
Chromatogram type.
Definition: MSExperiment.h:108
MSExperiment & operator=(const ExperimentalSettings &source)
Assignment operator.
Definition: MSExperiment.h:231
ConstIterator getPrecursorSpectrum(ConstIterator iterator) const
Returns the precursor spectrum of the scan pointed to by iterator.
Definition: MSExperiment.h:778
ConstIterator RTEnd(CoordinateType rt) const
Fast search for spectrum range end (returns the past-the-end iterator)
Definition: MSExperiment.h:437
std::vector< SpectrumType >::const_iterator ConstIterator
Non-mutable iterator.
Definition: MSExperiment.h:118
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:395
static void addData_(SpectrumType *spectrum, const ContainerValueType *item)
specialization for adding feature mass traces (does not support metadata_names currently) ...
Definition: MSExperiment.h:995
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:128
CoordinateType minX() const
Accessor for min_ coordinate minimum.
Definition: DIntervalBase.h:241
CoordinateType getMaxMZ() const
returns the maximal m/z value
Definition: MSExperiment.h:601
void clear(bool clear_meta_data)
Clears all data and meta data.
Definition: MSExperiment.h:929
const ExperimentalSettings & getExperimentalSettings() const
returns the meta information of this experiment (const access)
Definition: MSExperiment.h:738
MSExperiment & operator=(const MSExperiment &source)
Assignment operator.
Definition: MSExperiment.h:212
Iterator RTBegin(CoordinateType rt)
Fast search for spectrum range begin.
Definition: MSExperiment.h:449
void get2DData(Container &cont) const
Reads out a 2D Spectrum.
Definition: MSExperiment.h:260
std::vector< SpectrumType > Base
STL base class type.
Definition: MSExperiment.h:110
A 1-dimensional raw data point or peak for chromatograms.
Definition: ChromatogramPeak.h:55
const std::vector< MSSpectrum > & getSpectra() const
returns the spectrum list
Definition: MSExperiment.h:837
Handles the management of a position and intensity range.
Definition: RangeManager.h:48
MSChromatogram & getChromatogram(Size id)
returns a single chromatogram
Definition: MSExperiment.h:875
CoordinateType getMinMZ() const
returns the minimal m/z value
Definition: MSExperiment.h:595
void set2DData(const Container &container)
Assignment of a data container with RT and MZ to an MSExperiment.
Definition: MSExperiment.h:291
virtual void updateRanges()
Updates minimum and maximum position/intensity.
Definition: MSExperiment.h:477
ConstIterator begin() const
Definition: MSExperiment.h:167
UInt64 total_size_
Number of all data points.
Definition: MSExperiment.h:949
static void addData_(SpectrumType *spectrum, const ContainerValueType *item, const StringList &store_metadata_names)
general method for adding data points, including metadata arrays (populated from metainfointerface) ...
Definition: MSExperiment.h:979
int Int
Signed integer type.
Definition: Types.h:103
void setSpectra(const std::vector< MSSpectrum > &spectra)
sets the spectrum list
Definition: MSExperiment.h:825
Internal::AreaIterator< const PeakT, const PeakT &, const PeakT *, ConstIterator, SpectrumType::ConstIterator > ConstAreaIterator
Immutable area iterator type (for traversal of a rectangular subset of the peaks) ...
Definition: MSExperiment.h:122
Description of the experimental settings.
Definition: ExperimentalSettings.h:59
CoordinateType getMinRT() const
returns the minimal retention time value
Definition: MSExperiment.h:607
const AreaType & getDataRange() const
Returns RT and m/z range the data lies in.
Definition: MSExperiment.h:623
std::vector< UInt > ms_levels_
MS levels of the data.
Definition: MSExperiment.h:947
bool operator==(const MSExperiment &rhs) const
Equality operator.
Definition: MSExperiment.h:238
ExperimentalSettings()
Constructor.