OpenMS  2.4.0
MSSpectrum.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: Timo Sachsenberg$
32 // $Authors: Marc Sturm $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
37 #include <OpenMS/KERNEL/Peak1D.h>
44 
45 namespace OpenMS
46 {
47  class Peak1D;
66  class OPENMS_DLLAPI MSSpectrum :
67  private std::vector<Peak1D>,
68  public RangeManager<1>,
69  public SpectrumSettings
70  {
71 public:
72 
74  struct OPENMS_DLLAPI RTLess : public std::binary_function<MSSpectrum, MSSpectrum, bool>
75  {
76  bool operator()(const MSSpectrum& a, const MSSpectrum& b) const;
77  };
78 
80 
81  typedef OpenMS::Peak1D PeakType;
86  typedef std::vector<PeakType> ContainerType;
89  typedef std::vector<FloatDataArray> FloatDataArrays;
92  typedef std::vector<StringDataArray> StringDataArrays;
95  typedef std::vector<IntegerDataArray> IntegerDataArrays;
97 
99 
100  typedef typename ContainerType::iterator Iterator;
103  typedef typename ContainerType::const_iterator ConstIterator;
105  typedef typename ContainerType::reverse_iterator ReverseIterator;
107  typedef typename ContainerType::const_reverse_iterator ConstReverseIterator;
109 
111 
112  using ContainerType::operator[];
113  using ContainerType::begin;
114  using ContainerType::rbegin;
115  using ContainerType::end;
116  using ContainerType::rend;
117  using ContainerType::resize;
118  using ContainerType::size;
119  using ContainerType::push_back;
120  using ContainerType::emplace_back;
121  using ContainerType::pop_back;
122  using ContainerType::empty;
123  using ContainerType::front;
124  using ContainerType::back;
125  using ContainerType::reserve;
126  using ContainerType::insert;
127  using ContainerType::erase;
128  using ContainerType::swap;
129 
130  using typename ContainerType::iterator;
131  using typename ContainerType::const_iterator;
132  using typename ContainerType::size_type;
133  using typename ContainerType::value_type;
134  using typename ContainerType::reference;
135  using typename ContainerType::const_reference;
136  using typename ContainerType::pointer;
137  using typename ContainerType::difference_type;
139 
140 
142  MSSpectrum();
143 
145  MSSpectrum(const MSSpectrum& source);
146 
148  ~MSSpectrum() override
149  {}
150 
152  MSSpectrum& operator=(const MSSpectrum& source);
153 
155  MSSpectrum& operator=(const SpectrumSettings & source);
156 
158  bool operator==(const MSSpectrum& rhs) const;
159 
161  bool operator!=(const MSSpectrum& rhs) const
162  {
163  return !(operator==(rhs));
164  }
165 
166  // Docu in base class (RangeManager)
167  void updateRanges() override;
168 
172  double getRT() const;
173 
175  void setRT(double rt);
176 
185  double getDriftTime() const;
186 
190  void setDriftTime(double dt);
191 
197  UInt getMSLevel() const;
198 
200  void setMSLevel(UInt ms_level);
201 
203  const String& getName() const;
204 
206  void setName(const String& name);
207 
209 
223  const FloatDataArrays& getFloatDataArrays() const;
225 
228  {
229  return float_data_arrays_;
230  }
231 
233  void setFloatDataArrays(const FloatDataArrays& fda);
234 
236  const StringDataArrays& getStringDataArrays() const;
237 
239  StringDataArrays& getStringDataArrays();
240 
242  void setStringDataArrays(const StringDataArrays& sda);
243 
245  const IntegerDataArrays& getIntegerDataArrays() const;
246 
248  IntegerDataArrays& getIntegerDataArrays();
249 
251  void setIntegerDataArrays(const IntegerDataArrays& ida);
253 
255 
256 
261  void sortByIntensity(bool reverse = false);
262 
268  void sortByPosition();
269 
271  bool isSorted() const;
272 
274 
277 
287  Size findNearest(CoordinateType mz) const;
288 
300  Int findNearest(CoordinateType mz, CoordinateType tolerance) const;
301 
315  Int findNearest(CoordinateType mz, CoordinateType tolerance_left, CoordinateType tolerance_right) const;
316 
322  Iterator MZBegin(CoordinateType mz);
323 
329  Iterator MZBegin(Iterator begin, CoordinateType mz, Iterator end);
330 
336  Iterator MZEnd(CoordinateType mz);
337 
343  Iterator MZEnd(Iterator begin, CoordinateType mz, Iterator end);
344 
350  ConstIterator MZBegin(CoordinateType mz) const;
351 
357  ConstIterator MZBegin(ConstIterator begin, CoordinateType mz, ConstIterator end) const;
358 
364  ConstIterator MZEnd(CoordinateType mz) const;
365 
371  ConstIterator MZEnd(ConstIterator begin, CoordinateType mz, ConstIterator end) const;
372 
380  Iterator PosBegin(CoordinateType mz);
381 
389  Iterator PosBegin(Iterator begin, CoordinateType mz, Iterator end);
390 
398  ConstIterator PosBegin(CoordinateType mz) const;
399 
407  ConstIterator PosBegin(ConstIterator begin, CoordinateType mz, ConstIterator end) const;
408 
416  Iterator PosEnd(CoordinateType mz);
417 
425  Iterator PosEnd(Iterator begin, CoordinateType mz, Iterator end);
426 
434  ConstIterator PosEnd(CoordinateType mz) const;
435 
443  ConstIterator PosEnd(ConstIterator begin, CoordinateType mz, ConstIterator end) const;
444 
446 
447 
453  void clear(bool clear_meta_data);
454 
455  /*
456  @brief Select a (subset of) spectrum and its data_arrays, only retaining the indices given in @p indices
457 
458  @param indices Vector of indices to keep
459  @return Reference to this MSSpectrum
460 
461  */
462  MSSpectrum& select(const std::vector<Size>& indices);
463 
464 protected:
465 
468 
470  double drift_time_;
471 
474 
477 
480 
483 
486  };
487 
488  inline std::ostream& operator<<(std::ostream& os, const MSSpectrum& spec)
489  {
490  os << "-- MSSPECTRUM BEGIN --" << std::endl;
491 
492  // spectrum settings
493  os << static_cast<const SpectrumSettings&>(spec);
494 
495  // peaklist
496  for (MSSpectrum::ConstIterator it = spec.begin(); it != spec.end(); ++it)
497  {
498  os << *it << std::endl;
499  }
500 
501  os << "-- MSSPECTRUM END --" << std::endl;
502  return os;
503  }
504 
505 } // namespace OpenMS
OpenMS::PeakType
Peak2D PeakType
Definition: MassTrace.h:47
OpenMS::DataArrays::IntegerDataArray
Integer data array class.
Definition: DataArrays.h:51
ConsensusXMLFile.h
OpenMS::MSSpectrum::CoordinateType
PeakType::CoordinateType CoordinateType
Coordinate (m/z) type.
Definition: MSSpectrum.h:84
OpenMS::MSSpectrum::~MSSpectrum
~MSSpectrum() override
Destructor.
Definition: MSSpectrum.h:148
OpenMS::TOPPBase
Base class for TOPP applications.
Definition: TOPPBase.h:150
DataArrays.h
FileHandler.h
SimTypes.h
MSSim.h
OpenMS::ConsensusXMLFile::store
void store(const String &filename, const ConsensusMap &consensus_map)
Stores a consensus map to file.
OpenMS::StopWatch::stop
bool stop()
OpenMS::MSSpectrum::RTLess
Comparator for the retention time.
Definition: MSSpectrum.h:74
OpenMS::MSSim::simulate
void simulate(SimTypes::MutableSimRandomNumberGeneratorPtr rnd_gen, SimTypes::SampleChannels &peptides)
General purpose function to simulate a mass spectrometry run.
StopWatch.h
OpenMS::FASTAFile
This class serves for reading in and writing FASTA files.
Definition: FASTAFile.h:64
OpenMS::MzMLFile::store
void store(const String &filename, const PeakMap &map) const
Stores a map in an MzML file.
OpenMS::MSSim
Central class for simulation of mass spectrometry experiments.
Definition: MSSim.h:68
OpenMS::Param::setValue
void setValue(const String &key, const DataValue &value, const String &description="", const StringList &tags=StringList())
Sets a value.
OpenMS::MzMLFile
File adapter for MzML files.
Definition: MzMLFile.h:55
OpenMS::String
A more convenient string class.
Definition: String.h:57
OpenMS::MSSim::getContaminants
const SimTypes::FeatureMapSim & getContaminants() const
Access the contaminants feature map of simulated features.
Peak1D.h
MzMLFile.h
OpenMS::Param::setValidStrings
void setValidStrings(const String &key, const std::vector< String > &strings)
Sets the valid strings for the parameter key.
LOG_ERROR
#define LOG_ERROR
Macro to be used if non-fatal error are reported (processing continues)
Definition: LogStream.h:446
OpenMS::Size
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
IdXMLFile.h
FeatureXMLFile.h
OpenMS::ListUtils::contains
static bool contains(const std::vector< T > &container, const E &elem)
Checks whether the element elem is contained in the given container.
Definition: ListUtils.h:149
DTA2DFile.h
OpenMS::SimTypes::SampleProteins
std::vector< SimProtein > SampleProteins
Container for FASTAEntry & abundance information.
Definition: SimTypes.h:90
OpenMS::MSSim::getLabelingConsensus
ConsensusMap & getLabelingConsensus()
Access the labeling consensus map of simulated features.
OpenMS::MSSpectrum::IntegerDataArray
OpenMS::DataArrays::IntegerDataArray IntegerDataArray
Integer data array vector type.
Definition: MSSpectrum.h:94
OpenMS::SimTypes::MutableSimRandomNumberGeneratorPtr
boost::shared_ptr< SimRandomNumberGenerator > MutableSimRandomNumberGeneratorPtr
Definition: SimTypes.h:174
OpenMS::MSSpectrum::StringDataArrays
std::vector< StringDataArray > StringDataArrays
Definition: MSSpectrum.h:92
OpenMS::SimTypes::SimRandomNumberGenerator
Wrapper class for random number generators used by the simulation classes.
Definition: SimTypes.h:118
SpectrumSettings.h
OpenMS::MSSpectrum::operator!=
bool operator!=(const MSSpectrum &rhs) const
Equality operator.
Definition: MSSpectrum.h:161
OpenMS::SimTypes::SampleChannels
std::vector< SampleProteins > SampleChannels
Container for multiple channels of SampleProteins.
Definition: SimTypes.h:93
OpenMS::MSSpectrum::name_
String name_
Name.
Definition: MSSpectrum.h:476
OpenMS::Exception::InvalidParameter
Exception indicating that an invalid parameter was handed over to an algorithm.
Definition: Exception.h:347
OpenMS::Int
int Int
Signed integer type.
Definition: Types.h:102
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
OpenMS::RangeManager
Handles the management of a position and intensity range.
Definition: RangeManager.h:47
OpenMS::MetaInfoInterface::setMetaValue
void setMetaValue(const String &name, const DataValue &value)
Sets the DataValue corresponding to a name.
OpenMS::MSSpectrum::integer_data_arrays_
IntegerDataArrays integer_data_arrays_
Integer data arrays.
Definition: MSSpectrum.h:485
double
FASTAFile.h
OpenMS::MSSpectrum::string_data_arrays_
StringDataArrays string_data_arrays_
String data arrays.
Definition: MSSpectrum.h:482
OpenMS::StopWatch::getClockTime
double getClockTime() const
OpenMS::MetaInfoInterface
Interface for classes that can store arbitrary meta information (Type-Name-Value tuples).
Definition: MetaInfoInterface.h:55
MzXMLFile.h
OpenMS::MSSim::getPeakMap
const SimTypes::MSSimExperiment & getPeakMap() const
Access the picked (centroided) experiment.
OpenMS::MSSpectrum::IntegerDataArrays
std::vector< IntegerDataArray > IntegerDataArrays
Definition: MSSpectrum.h:95
OpenMS::DefaultParamHandler::setParameters
void setParameters(const Param &param)
Sets the parameters.
OpenMS::MSSim::getChargeConsensus
ConsensusMap & getChargeConsensus()
Access the charge consensus map of simulated features.
seqan::find
bool find(TFinder &finder, const Pattern< TNeedle, FuzzyAC > &me, PatternAuxData< TNeedle > &dh)
Definition: AhoCorasickAmbiguous.h:884
OpenMS::DataArrays::StringDataArray
String data array class.
Definition: DataArrays.h:57
RangeManager.h
OpenMS::Peak1D
A 1-dimensional raw data point or peak.
Definition: Peak1D.h:54
OpenMS::operator<<
std::ostream & operator<<(std::ostream &os, const AccurateMassSearchResult &amsr)
OpenMS::ConsensusMap
A container for consensus elements.
Definition: ConsensusMap.h:75
OpenMS::StringList
std::vector< String > StringList
Vector of String.
Definition: ListUtils.h:73
OpenMS::FeatureXMLFile::store
void store(const String &filename, const FeatureMap &feature_map)
stores the map feature_map in file with name filename.
OpenMS::UInt
unsigned int UInt
Unsigned integer type.
Definition: Types.h:94
OpenMS::StopWatch
StopWatch Class.
Definition: StopWatch.h:59
OpenMS::MSSpectrum::FloatDataArrays
std::vector< FloatDataArray > FloatDataArrays
Definition: MSSpectrum.h:89
OpenMS::MSSpectrum::getFloatDataArrays
FloatDataArrays & getFloatDataArrays()
Returns a mutable reference to the float meta data arrays.
Definition: MSSpectrum.h:227
main
int main(int argc, const char **argv)
Definition: INIFileEditor.cpp:73
OpenMS::SimTypes::SimProtein
Plain data object holding sequence and abundance information on a single protein.
Definition: SimTypes.h:73
OpenMS::StopWatch::start
bool start()
OpenMS::ConsensusMap::getColumnHeaders
const ColumnHeaders & getColumnHeaders() const
Non-mutable access to the file descriptions.
OpenMS::IdXMLFile::store
void store(String filename, const std::vector< ProteinIdentification > &protein_ids, const std::vector< PeptideIdentification > &peptide_ids, const String &document_id="")
Stores the data in an idXML file.
OpenMS::MSSpectrum::retention_time_
double retention_time_
Retention time.
Definition: MSSpectrum.h:467
OpenMS::MSSpectrum::drift_time_
double drift_time_
Drift time.
Definition: MSSpectrum.h:470
KDTree::operator==
bool operator==(_Iterator< _Val, _Ref, _Ptr > const &, _Iterator< _Val, _Ref, _Ptr > const &)
Definition: KDTree.h:806
OpenMS::Param::setSectionDescription
void setSectionDescription(const String &key, const String &description)
Sets a description for an existing section.
ComparatorUtils.h
OpenMS::FASTAFile::load
static void load(const String &filename, std::vector< FASTAEntry > &data)
loads a FASTA file given by 'filename' and stores the information in 'data'
OpenMS::FeatureXMLFile
This class provides Input/Output functionality for feature maps.
Definition: FeatureXMLFile.h:68
OpenMS::MSSim::getSimulatedFeatures
const SimTypes::FeatureMapSim & getSimulatedFeatures() const
Access the simulated features.
OpenMS::MSSpectrum::ms_level_
UInt ms_level_
MS level.
Definition: MSSpectrum.h:473
OpenMS::MSSpectrum::float_data_arrays_
FloatDataArrays float_data_arrays_
Float data arrays.
Definition: MSSpectrum.h:479
StandardDeclarations.h
OpenMS::SpectrumSettings
Representation of 1D spectrum settings.
Definition: SpectrumSettings.h:63
OpenMS::Param
Management and storage of parameters / INI files.
Definition: Param.h:74
OpenMS::MSSpectrum::ContainerType
std::vector< PeakType > ContainerType
Spectrum base type.
Definition: MSSpectrum.h:86
OpenMS::MSSpectrum::Iterator
ContainerType::iterator Iterator
Mutable iterator.
Definition: MSSpectrum.h:101
OpenMS::MSSpectrum::StringDataArray
OpenMS::DataArrays::StringDataArray StringDataArray
String data array vector type.
Definition: MSSpectrum.h:91
OpenMS::MSSpectrum::ConstIterator
ContainerType::const_iterator ConstIterator
Non-mutable iterator.
Definition: MSSpectrum.h:103
OpenMS::MSSpectrum::ReverseIterator
ContainerType::reverse_iterator ReverseIterator
Mutable reverse iterator.
Definition: MSSpectrum.h:105
OpenMS::MSSpectrum::FloatDataArray
OpenMS::DataArrays::FloatDataArray FloatDataArray
Float data array vector type.
Definition: MSSpectrum.h:88
OpenMS::MSSpectrum
The representation of a 1D spectrum.
Definition: MSSpectrum.h:66
OpenMS::MSSpectrum::ConstReverseIterator
ContainerType::const_reverse_iterator ConstReverseIterator
Non-mutable reverse iterator.
Definition: MSSpectrum.h:107
OpenMS::DataArrays::FloatDataArray
Float data array class.
Definition: DataArrays.h:45
OpenMS::Param::insert
void insert(const String &prefix, const Param &param)
OpenMS::UniqueIdInterface::getUniqueId
UInt64 getUniqueId() const
Non-mutable access to unique id - returns the unique id.
Definition: UniqueIdInterface.h:109
OpenMS::ProgressLogger::setLogType
void setLogType(LogType type) const
Sets the progress log that should be used. The default type is NONE!
TOPPBase.h
OpenMS::MSSim::getIdentifications
void getIdentifications(std::vector< ProteinIdentification > &proteins, std::vector< PeptideIdentification > &peptides) const
Access the simulated identifications (proteins and peptides)
OpenMS::ConsensusXMLFile
This class provides Input functionality for ConsensusMaps and Output functionality for alignments and...
Definition: ConsensusXMLFile.h:61
OpenMS::IdXMLFile
Used to load and store idXML files.
Definition: IdXMLFile.h:63
OpenMS::MSSim::getExperiment
const SimTypes::MSSimExperiment & getExperiment() const
Access the simulated experiment.
MetaInfoDescription.h