ProteoWizard
DemuxDebugWriter.hpp
Go to the documentation of this file.
1 //
2 // $Id$
3 //
4 //
5 // Original author: Austin Keller <atkeller .@. uw.edu>
6 //
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
10 //
11 // http://www.apache.org/licenses/LICENSE-2.0
12 //
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
18 //
19 
20 #ifndef _DEMUXDEBUGWRITER_HPP
21 #define _DEMUXDEBUGWRITER_HPP
22 
23 #include "DemuxTypes.hpp"
24 #include <cstdint>
25 #include <fstream>
26 #include <vector>
27 
28 namespace pwiz {
29 namespace analysis {
30  using std::uint64_t;
31  using std::int64_t;
32 
33  /// A class for writing demux matrices to file. The primary purpose of writing demux matrices to file is for
34  /// analysis externally. Exporting matrices is useful for comparing output with Skyline, which has a similar
35  /// functionality for writing demux matrices to file. Python code exists for reading and interpreting these matrices.
36  /// This class follows the RAII of ifstream and so the file is kept open until the destructor is called.
38  {
39  public:
40 
41  /// Constructs a DemuxDebugWriter to write the debug file with the given filename
42  explicit DemuxDebugWriter(const std::string& fileName);
43 
44  /// Destructor writes header and closes the file
46 
47  /// Should be called after construction to verify that the file was opened successfully
48  bool IsOpen() const;
49 
50  /// Writes a set of matrices with the given spectrum index to file
51  void WriteDeconvBlock(uint64_t spectrumIndex,
53  DemuxTypes::MatrixPtr solution,
54  DemuxTypes::MatrixPtr signal);
55 
56  private:
57 
58  /// Writes the the header. The header is simply a pointer to the footer (fileIndex).
59  void WriteHeader();
60 
61  /// Writes the file index at the end of the file. This is the footer pointed to by the header. The footer contains information about
62  /// the locations of the beginning of each block. Each matrix has it's own header for information about its size. This means
63  /// that individual matrices must be accessed sequentially.
64  void WriteIndex();
65 
66  /// Output file stream
67  std::ofstream _writer;
68 
69  /// Set of spectrum indices and filepointers to their respective blocks
70  std::vector<std::pair<uint64_t, int64_t>> _fileIndex;
71  };
72 } //namespace analysis
73 } //namespace pwiz
74 #endif //_DEMUXDEBUGWRITER_HPP
pwiz
Definition: ChromatogramList_Filter.hpp:36
pwiz::analysis::DemuxDebugWriter::WriteIndex
void WriteIndex()
Writes the file index at the end of the file.
DemuxTypes::MatrixPtr
boost::shared_ptr< MatrixType > MatrixPtr
Definition: DemuxTypes.hpp:39
DemuxTypes.hpp
pwiz::analysis::DemuxDebugWriter::_fileIndex
std::vector< std::pair< uint64_t, int64_t > > _fileIndex
Set of spectrum indices and filepointers to their respective blocks.
Definition: DemuxDebugWriter.hpp:70
pwiz::analysis::DemuxDebugWriter::DemuxDebugWriter
DemuxDebugWriter(const std::string &fileName)
Constructs a DemuxDebugWriter to write the debug file with the given filename.
pwiz::analysis::DemuxDebugWriter::IsOpen
bool IsOpen() const
Should be called after construction to verify that the file was opened successfully.
pwiz::analysis::DemuxDebugWriter::WriteHeader
void WriteHeader()
Writes the the header. The header is simply a pointer to the footer (fileIndex).
pwiz::analysis::DemuxDebugWriter::WriteDeconvBlock
void WriteDeconvBlock(uint64_t spectrumIndex, DemuxTypes::MatrixPtr masks, DemuxTypes::MatrixPtr solution, DemuxTypes::MatrixPtr signal)
Writes a set of matrices with the given spectrum index to file.
pwiz::analysis::DemuxDebugWriter
A class for writing demux matrices to file.
Definition: DemuxDebugWriter.hpp:37
pwiz::analysis::DemuxDebugWriter::_writer
std::ofstream _writer
Output file stream.
Definition: DemuxDebugWriter.hpp:67
ralab::base::resample::int64_t
boost::int64_t int64_t
Definition: bin1d.hpp:41
pwiz::analysis::DemuxDebugWriter::~DemuxDebugWriter
~DemuxDebugWriter()
Destructor writes header and closes the file.