Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
CachedMzML.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-2017.
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 
38 
40 #include <OpenMS/CONCEPT/Types.h>
42 #include <OpenMS/CONCEPT/Macros.h>
43 
46 
47 #include <fstream>
48 
49 #define CACHED_MZML_FILE_IDENTIFIER 8094
50 
51 namespace OpenMS
52 {
53 
63  class OPENMS_DLLAPI CachedmzML :
64  public ProgressLogger
65  {
67  double dbl_field_;
68 
69 public:
70 
71  typedef PeakMap MapType;
74 
75  // using double precision to store all data (has to agree with type of BinaryDataArrayPtr)
76  typedef double DatumSingleton;
77 
78  typedef std::vector<DatumSingleton> Datavector;
79 
83  CachedmzML();
85 
87  ~CachedmzML();
88 
90  CachedmzML& operator=(const CachedmzML& rhs);
92 
96 
98  void writeMemdump(MapType& exp, String out);
99 
101  void writeMetadata(MapType exp, String out_meta, bool addCacheMetaValue=false);
102 
104  void readMemdump(MapType& exp_reading, String filename) const;
106 
110  void createMemdumpIndex(String filename);
112 
114  const std::vector<std::streampos>& getSpectraIndex() const;
115 
117  const std::vector<std::streampos>& getChromatogramIndex() const;
119 
123 
131  std::ifstream& ifs,
132  int& ms_level,
133  double& rt)
134  {
135  std::vector<OpenSwath::BinaryDataArrayPtr> data = readSpectrumFast(ifs, ms_level, rt);
136  data1 = data[0];
137  data2 = data[1];
138  }
139 
140  static std::vector<OpenSwath::BinaryDataArrayPtr> readSpectrumFast(std::ifstream& ifs, int& ms_level, double& rt);
141 
148  OpenSwath::BinaryDataArrayPtr& data2, std::ifstream& ifs)
149  {
150  std::vector<OpenSwath::BinaryDataArrayPtr> data = readChromatogramFast(ifs);
151  data1 = data[0];
152  data2 = data[1];
153  }
154 
155  static std::vector<OpenSwath::BinaryDataArrayPtr> readChromatogramFast(std::ifstream& ifs);
157 
158 protected:
159 
161  void readSpectrum_(SpectrumType& spectrum, std::ifstream& ifs) const;
162 
164  void readChromatogram_(ChromatogramType& chromatogram, std::ifstream& ifs) const;
165 
167  void writeSpectrum_(const SpectrumType& spectrum, std::ofstream& ofs);
168 
170  void writeChromatogram_(const ChromatogramType& chromatogram, std::ofstream& ofs);
171 
173  static inline void readDataFast_(std::ifstream& ifs, std::vector<OpenSwath::BinaryDataArrayPtr>& data, const Size& data_size,
174  const Size& nr_float_arrays);
175 
177  std::vector<std::streampos> spectra_index_;
178  std::vector<std::streampos> chrom_index_;
179 
180  };
181 }
182 
A more convenient string class.
Definition: String.h:57
The representation of a chromatogram.
Definition: MSChromatogram.h:54
double DatumSingleton
Definition: CachedMzML.h:76
std::vector< std::streampos > chrom_index_
Definition: CachedMzML.h:178
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
boost::shared_ptr< BinaryDataArray > BinaryDataArrayPtr
Definition: openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/DataStructures.h:79
The representation of a 1D spectrum.
Definition: MSSpectrum.h:66
MSChromatogram ChromatogramType
Definition: CachedMzML.h:73
static void readSpectrumFast(OpenSwath::BinaryDataArrayPtr &data1, OpenSwath::BinaryDataArrayPtr &data2, std::ifstream &ifs, int &ms_level, double &rt)
fast access to a spectrum (a direct copy of the data into the provided arrays)
Definition: CachedMzML.h:129
std::vector< DatumSingleton > Datavector
Definition: CachedMzML.h:78
In-Memory representation of a mass spectrometry experiment.
Definition: MSExperiment.h:77
MSSpectrum SpectrumType
Definition: CachedMzML.h:72
PeakMap MapType
Definition: CachedMzML.h:71
An class that uses on-disk caching to read and write spectra and chromatograms.
Definition: CachedMzML.h:63
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:54
double dbl_field_
Definition: CachedMzML.h:67
int int_field_
Definition: CachedMzML.h:66
std::vector< std::streampos > spectra_index_
Members.
Definition: CachedMzML.h:177
static void readChromatogramFast(OpenSwath::BinaryDataArrayPtr &data1, OpenSwath::BinaryDataArrayPtr &data2, std::ifstream &ifs)
fast access to a chromatogram (a direct copy of the data into the provided arrays) ...
Definition: CachedMzML.h:147

OpenMS / TOPP release 2.3.0 Documentation generated on Wed Apr 18 2018 19:29:04 using doxygen 1.8.14