ProteoWizard
Public Member Functions | Private Member Functions | Private Attributes | List of all members
pwiz::analysis::DemuxDebugReader Class Reference

A class for reading demux matrices from file. More...

#include <DemuxDebugReader.hpp>

Public Member Functions

 DemuxDebugReader (const std::string &fileName)
 Constructs a DemuxDebugReader to read the debug file with the given filename.
 
 ~DemuxDebugReader ()
 Destructor closes the file.
 
size_t NumBlocks () const
 Number of blocks (sets of matrices) that are contained in the file.
 
void ReadDeconvBlock (uint64_t &spectrumIndex, DemuxTypes::MatrixPtr masks, DemuxTypes::MatrixPtr solution, DemuxTypes::MatrixPtr signal)
 Can be used to read through the blocks sequntially.
 
void ReadDeconvBlock (size_t blockIndex, uint64_t &spectrumIndex, DemuxTypes::MatrixPtr masks, DemuxTypes::MatrixPtr solution, DemuxTypes::MatrixPtr signal)
 Used for random-access reading of the blocks.
 
bool IsOpen () const
 Should be called after construction to verify that the file was opened successfully.
 

Private Member Functions

void ReadHeader ()
 Reads the header/footer which contains information about the number of blocks and their locations in the file for random access.
 

Private Attributes

std::ifstream _reader
 Input file stream of the debug file.
 
std::vector< std::pair< uint64_t, int64_t > > _fileIndex
 Set of pointers to blocks in the file extracted from the header/footer information.
 
size_t _currentBlockIndex
 Current block index used for tracking progress through file when sequential iteration of ReadDeconvBlock() is used.
 

Detailed Description

A class for reading demux matrices from file.

The primary purpose of writing demux matrices to file is for analysis externally, so the intent of this class is to provide a method to test the output of the DemuxDebugWriter class. This class follows the RAII of ifstream and so the file is kept open until the destructor is called.

Definition at line 37 of file DemuxDebugReader.hpp.

Constructor & Destructor Documentation

◆ DemuxDebugReader()

pwiz::analysis::DemuxDebugReader::DemuxDebugReader ( const std::string &  fileName)
explicit

Constructs a DemuxDebugReader to read the debug file with the given filename.

During construction the file header is read to inform the NumBlocks() function of the filesize and to build a map of pointers to the matrix blocks for random access.

Parameters
fileNameFilename of debug matrices file

◆ ~DemuxDebugReader()

pwiz::analysis::DemuxDebugReader::~DemuxDebugReader ( )

Destructor closes the file.

Member Function Documentation

◆ NumBlocks()

size_t pwiz::analysis::DemuxDebugReader::NumBlocks ( ) const

Number of blocks (sets of matrices) that are contained in the file.

This is the number of times that ReadDeconvBlock can be called sequentially. Throws error if IsOpen() returns false.

Returns
Number of blocks in the file

Referenced by DemuxDebugRWTest::ReadWriteTest().

◆ ReadDeconvBlock() [1/2]

void pwiz::analysis::DemuxDebugReader::ReadDeconvBlock ( uint64_t &  spectrumIndex,
DemuxTypes::MatrixPtr  masks,
DemuxTypes::MatrixPtr  solution,
DemuxTypes::MatrixPtr  signal 
)

Can be used to read through the blocks sequntially.

Each time this is called the next set of blocks is returned. This can be called NumBlocks() times before an out_of_range error will be thrown. Throws error if IsOpen() returns false.

Parameters
[out]spectrumIndexThe index of the spectrum corresponding to this block
[out]masksThe masks matrix
[out]solutionThe solution matrix
[out]signalThe signal matrix

Referenced by DemuxDebugRWTest::ReadWriteTest().

◆ ReadDeconvBlock() [2/2]

void pwiz::analysis::DemuxDebugReader::ReadDeconvBlock ( size_t  blockIndex,
uint64_t &  spectrumIndex,
DemuxTypes::MatrixPtr  masks,
DemuxTypes::MatrixPtr  solution,
DemuxTypes::MatrixPtr  signal 
)

Used for random-access reading of the blocks.

The block indices range from 0 to NumBlocks() - 1. Throws error if IsOpen() returns false.

Parameters
[in]blockIndexindex of the block to read
[out]spectrumIndexThe index of the spectrum corresponding to this block
[out]masksThe masks matrix
[out]solutionThe solution matrix
[out]signalThe signal matrix

◆ IsOpen()

bool pwiz::analysis::DemuxDebugReader::IsOpen ( ) const

Should be called after construction to verify that the file was opened successfully.

Returns
true if file was successfully opened and its header read and verified, false otherwise

Referenced by DemuxDebugRWTest::ReadWriteTest().

◆ ReadHeader()

void pwiz::analysis::DemuxDebugReader::ReadHeader ( )
private

Reads the header/footer which contains information about the number of blocks and their locations in the file for random access.

Member Data Documentation

◆ _reader

std::ifstream pwiz::analysis::DemuxDebugReader::_reader
private

Input file stream of the debug file.

Definition at line 88 of file DemuxDebugReader.hpp.

◆ _fileIndex

std::vector<std::pair<uint64_t, int64_t> > pwiz::analysis::DemuxDebugReader::_fileIndex
private

Set of pointers to blocks in the file extracted from the header/footer information.

Definition at line 91 of file DemuxDebugReader.hpp.

◆ _currentBlockIndex

size_t pwiz::analysis::DemuxDebugReader::_currentBlockIndex
private

Current block index used for tracking progress through file when sequential iteration of ReadDeconvBlock() is used.

Definition at line 94 of file DemuxDebugReader.hpp.


The documentation for this class was generated from the following file: