ProteoWizard
MSDataFile.hpp
Go to the documentation of this file.
1 //
2 // $Id: MSDataFile.hpp 4009 2012-10-17 18:40:44Z kaipot $
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 _MSDATAFILE_HPP_
25 #define _MSDATAFILE_HPP_
26 
27 
29 #include "MSData.hpp"
30 #include "Reader.hpp"
31 #include "BinaryDataEncoder.hpp"
33 
34 
35 namespace pwiz {
36 namespace msdata {
37 
38 
39 /// MSData object plus file I/O
41 {
42  /// constructs MSData object backed by file;
43  /// reader==0 -> use DefaultReaderList
44  MSDataFile(const std::string& filename,
45  const Reader* reader = 0,
46  bool calculateSourceFileChecksum = false);
47 
48  /// data format for write()
50 
51  /// configuration for write()
53  {
54  Format format;
56  bool indexed;
57  bool gzipped; // if true, file is written as .gz
58 
59  WriteConfig(Format _format = Format_mzML,bool _gzipped = false)
60  : format(_format), indexed(true), gzipped(_gzipped)
61  {}
62  };
63 
64  /// static write function for any MSData object;
65  /// iterationListenerRegistry may be used for progress updates
66  static void write(const MSData& msd,
67  const std::string& filename,
68  const WriteConfig& config = WriteConfig(),
69  const pwiz::util::IterationListenerRegistry* iterationListenerRegistry = 0);
70 
71  /// member write function
72  void write(const std::string& filename,
73  const WriteConfig& config = WriteConfig(),
74  const pwiz::util::IterationListenerRegistry* iterationListenerRegistry = 0);
75 
76  /// static write function for any MSData object;
77  /// iterationListenerRegistry may be used for progress updates
78  static void write(const MSData& msd,
79  std::ostream& os,
80  const WriteConfig& config = WriteConfig(),
81  const pwiz::util::IterationListenerRegistry* iterationListenerRegistry = 0);
82 
83  /// member write function
84  void write(std::ostream& os,
85  const WriteConfig& config = WriteConfig(),
86  const pwiz::util::IterationListenerRegistry* iterationListenerRegistry = 0);
87 };
88 
89 
90 /// calculates and adds a CV term for the SHA1 checksum of a source file element
91 PWIZ_API_DECL void calculateSourceFileSHA1(SourceFile& sourceFile);
92 
93 /// Iterate and calculate SHA-1 for all source files
94 PWIZ_API_DECL void calculateSHA1Checksums(const MSData& msd);
95 
96 PWIZ_API_DECL std::ostream& operator<<(std::ostream& os, MSDataFile::Format format);
97 PWIZ_API_DECL std::ostream& operator<<(std::ostream& os, const MSDataFile::WriteConfig& config);
98 
99 
100 } // namespace msdata
101 } // namespace pwiz
102 
103 
104 #endif // _MSDATAFILE_HPP_
105