ProteoWizard
IO.hpp
Go to the documentation of this file.
1 //
2 // $Id: IO.hpp 3013 2011-09-27 06:57:13Z pcbrefugee $
3 //
4 //
5 // Original author: Darren Kessner <darren@proteowizard.org>
6 //
7 // Copyright 2007 Spielberg Family Center for Applied Proteomics
8 // Cedars-Sinai Medical Center, Los Angeles, California 90048
9 //
10 // Licensed under the Apache License, Version 2.0 (the "License");
11 // you may not use this file except in compliance with the License.
12 // You may obtain a copy of the License at
13 //
14 // http://www.apache.org/licenses/LICENSE-2.0
15 //
16 // Unless required by applicable law or agreed to in writing, software
17 // distributed under the License is distributed on an "AS IS" BASIS,
18 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 // See the License for the specific language governing permissions and
20 // limitations under the License.
21 //
22 
23 
24 #ifndef _IO_HPP_
25 #define _IO_HPP_
26 
27 
29 #include "MSData.hpp"
30 #include "BinaryDataEncoder.hpp"
33 #include "boost/iostreams/positioning.hpp"
34 
35 
36 namespace pwiz {
37 namespace msdata {
38 
39 
40 
41 /// Identifying information for a spectrum
42 /// subclassed to add private information for faster file IO in mzML and mzXML
44 {
45  /// for efficient read of peak lists after previous read of
46  /// scan header in mzML and mzXML - avoids reparsing the header
47  mutable boost::iostreams::stream_offset sourceFilePositionForBinarySpectrumData;
48  SpectrumIdentityFromXML() : SpectrumIdentity(), sourceFilePositionForBinarySpectrumData((boost::iostreams::stream_offset)-1) {}
49 };
50 
51 /// Identifying information for a spectrum as read from mzML or mzXML
52 /// subclassed to add private information for faster file IO in mzXML
54 {
55  /// for efficient read of peak lists after previous read of
56  /// scan header in mzXML - avoids reparsing the header
57  mutable unsigned int peaksCount;
59 };
60 
61 
62 namespace IO {
63 
64 
65 PWIZ_API_DECL void write(minimxml::XMLWriter& writer, const CV& cv);
66 PWIZ_API_DECL void read(std::istream& is, CV& cv);
67 
68 
69 PWIZ_API_DECL void write(minimxml::XMLWriter& writer, const UserParam& userParam);
70 PWIZ_API_DECL void read(std::istream& is, UserParam& userParam);
71 
72 
73 PWIZ_API_DECL void write(minimxml::XMLWriter& writer, const CVParam& cv);
74 PWIZ_API_DECL void read(std::istream& is, CVParam& cv);
75 
76 
77 PWIZ_API_DECL void write(minimxml::XMLWriter& writer, const ParamGroup& paramGroup);
78 PWIZ_API_DECL void read(std::istream& is, ParamGroup& paramGroup);
79 
80 
81 PWIZ_API_DECL void write(minimxml::XMLWriter& writer, const FileContent& fc);
82 PWIZ_API_DECL void read(std::istream& is, FileContent& fc);
83 
84 
85 PWIZ_API_DECL void write(minimxml::XMLWriter& writer, const SourceFile& sf);
86 PWIZ_API_DECL void read(std::istream& is, SourceFile& sf);
87 
88 
89 PWIZ_API_DECL void write(minimxml::XMLWriter& writer, const Contact& c);
90 PWIZ_API_DECL void read(std::istream& is, Contact& c);
91 
92 
93 PWIZ_API_DECL void write(minimxml::XMLWriter& writer, const FileDescription& fd);
94 PWIZ_API_DECL void read(std::istream& is, FileDescription& fd);
95 
96 
97 PWIZ_API_DECL void write(minimxml::XMLWriter& writer, const Sample& sf);
98 PWIZ_API_DECL void read(std::istream& is, Sample& sf);
99 
100 
101 PWIZ_API_DECL void write(minimxml::XMLWriter& writer, const Component& component);
102 PWIZ_API_DECL void read(std::istream& is, Component& component);
103 
104 
105 PWIZ_API_DECL void write(minimxml::XMLWriter& writer, const ComponentList& componentList);
106 PWIZ_API_DECL void read(std::istream& is, ComponentList& componentList);
107 
108 
109 PWIZ_API_DECL void write(minimxml::XMLWriter& writer, const Software& software);
110 PWIZ_API_DECL void read(std::istream& is, Software& software);
111 
112 
113 PWIZ_API_DECL void write(minimxml::XMLWriter& writer, const InstrumentConfiguration& instrumentConfiguration);
114 PWIZ_API_DECL void read(std::istream& is, InstrumentConfiguration& instrumentConfiguration);
115 
116 
117 PWIZ_API_DECL void write(minimxml::XMLWriter& writer, const ProcessingMethod& processingMethod);
118 PWIZ_API_DECL void read(std::istream& is, ProcessingMethod& processingMethod);
119 
120 
121 PWIZ_API_DECL void write(minimxml::XMLWriter& writer, const DataProcessing& dataProcessing);
122 PWIZ_API_DECL void read(std::istream& is, DataProcessing& dataProcessing);
123 
124 
125 PWIZ_API_DECL void write(minimxml::XMLWriter& writer, const Target& t);
126 PWIZ_API_DECL void read(std::istream& is, Target& t);
127 
128 
129 PWIZ_API_DECL void write(minimxml::XMLWriter& writer, const ScanSettings& scanSettings);
130 PWIZ_API_DECL void read(std::istream& is, ScanSettings& scanSettings);
131 
132 
133 PWIZ_API_DECL void write(minimxml::XMLWriter& writer, const IsolationWindow& isolationWindow);
134 PWIZ_API_DECL void read(std::istream& is, IsolationWindow& isolationWindow);
135 
136 
137 PWIZ_API_DECL void write(minimxml::XMLWriter& writer, const SelectedIon& selectedIon);
138 PWIZ_API_DECL void read(std::istream& is, SelectedIon& selectedIon);
139 
140 
141 PWIZ_API_DECL void write(minimxml::XMLWriter& writer, const Activation& activation);
142 PWIZ_API_DECL void read(std::istream& is, Activation& activation);
143 
144 
145 PWIZ_API_DECL void write(minimxml::XMLWriter& writer, const Precursor& precursor);
146 PWIZ_API_DECL void read(std::istream& is, Precursor& precursor, const std::map<std::string,std::string>* legacyIdRefToNativeId = 0);
147 
148 
149 PWIZ_API_DECL void write(minimxml::XMLWriter& writer, const Product& product);
150 PWIZ_API_DECL void read(std::istream& is, Product& product);
151 
152 
153 PWIZ_API_DECL void write(minimxml::XMLWriter& writer, const ScanWindow& selectionWindow);
154 PWIZ_API_DECL void read(std::istream& is, ScanWindow& selectionWindow);
155 
156 
157 PWIZ_API_DECL void write(minimxml::XMLWriter& writer, const Scan& scan, const MSData& msd);
158 PWIZ_API_DECL void read(std::istream& is, Scan& scan);
159 
160 
161 PWIZ_API_DECL void write(minimxml::XMLWriter& writer, const ScanList& scanList, const MSData& msd);
162 PWIZ_API_DECL void read(std::istream& is, ScanList& scanList);
163 
164 
166 void write(minimxml::XMLWriter& writer, const BinaryDataArray& binaryDataArray,
168 PWIZ_API_DECL void read(std::istream& is, BinaryDataArray& binaryDataArray, const MSData* msd = 0);
169 
170 //
171 // enum for preference in binary data read - ignore, read, read only binary if possible
172 //
173 enum PWIZ_API_DECL BinaryDataFlag {IgnoreBinaryData, ReadBinaryData, ReadBinaryDataOnly };
174 
175 
177 void write(minimxml::XMLWriter& writer, const Spectrum& spectrum, const MSData& msd,
178  const BinaryDataEncoder::Config& config = BinaryDataEncoder::Config());
180 void read(std::istream& is, Spectrum& spectrum,
181  BinaryDataFlag binaryDataFlag = IgnoreBinaryData,
182  int version = 0,
183  const std::map<std::string,std::string>* legacyIdRefToNativeId = 0,
184  const MSData* msd = 0,
185  const SpectrumIdentityFromXML *id = 0);
186 
187 
189 void write(minimxml::XMLWriter& writer, const Chromatogram& chromatogram,
190  const BinaryDataEncoder::Config& config = BinaryDataEncoder::Config());
192 void read(std::istream& is, Chromatogram& chromatogram,
193  BinaryDataFlag binaryDataFlag = IgnoreBinaryData);
194 
195 
197 void write(minimxml::XMLWriter& writer, const SpectrumList& spectrumList, const MSData& msd,
198  const BinaryDataEncoder::Config& config = BinaryDataEncoder::Config(),
199  std::vector<boost::iostreams::stream_offset>* spectrumPositions = 0,
200  const pwiz::util::IterationListenerRegistry* iterationListenerRegistry = 0);
201 PWIZ_API_DECL void read(std::istream& is, SpectrumListSimple& spectrumListSimple);
202 
203 
205 void write(minimxml::XMLWriter& writer, const ChromatogramList& chromatogramList,
206  const BinaryDataEncoder::Config& config = BinaryDataEncoder::Config(),
207  std::vector<boost::iostreams::stream_offset>* chromatogramPositions = 0,
208  const pwiz::util::IterationListenerRegistry* iterationListenerRegistry = 0);
209 PWIZ_API_DECL void read(std::istream& is, ChromatogramListSimple& chromatogramListSimple);
210 
211 
212 enum PWIZ_API_DECL SpectrumListFlag {IgnoreSpectrumList, ReadSpectrumList};
213 
214 
216 void write(minimxml::XMLWriter& writer, const Run& run, const MSData& msd,
217  const BinaryDataEncoder::Config& config = BinaryDataEncoder::Config(),
218  std::vector<boost::iostreams::stream_offset>* spectrumPositions = 0,
219  std::vector<boost::iostreams::stream_offset>* chromatogramPositions = 0,
220  const pwiz::util::IterationListenerRegistry* iterationListenerRegistry = 0);
222 void read(std::istream& is, Run& run,
223  SpectrumListFlag spectrumListFlag = IgnoreSpectrumList);
224 
225 
227 void write(minimxml::XMLWriter& writer, const MSData& msd,
228  const BinaryDataEncoder::Config& config = BinaryDataEncoder::Config(),
229  std::vector<boost::iostreams::stream_offset>* spectrumPositions = 0,
230  std::vector<boost::iostreams::stream_offset>* chromatogramPositions = 0,
231  const pwiz::util::IterationListenerRegistry* iterationListenerRegistry = 0);
233 void read(std::istream& is, MSData& msd,
234  SpectrumListFlag spectrumListFlag = IgnoreSpectrumList);
235 
236 
237 } // namespace IO
238 
239 
240 } // namespace msdata
241 } // namespace pwiz
242 
243 
244 #endif // _IO_HPP_
245 
246