1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
|
#ifndef _BLASR_HDF_SCAN_DATA_READER_HPP_
#define _BLASR_HDF_SCAN_DATA_READER_HPP_
#include <map>
#include <string>
#include <pbdata/Enumerations.h>
#include <hdf/HDFAtom.hpp>
#include <hdf/HDFFile.hpp>
#include <hdf/HDFGroup.hpp>
#include <pbdata/reads/ScanData.hpp>
//
// The SanDataReader cannot live outside
class HDFScanDataReader
{
public:
bool fileHasScanData, useRunCode;
HDFGroup scanDataGroup;
HDFGroup dyeSetGroup;
HDFGroup acqParamsGroup;
HDFGroup runInfoGroup;
bool initializedAcqParamsGroup, initializedRunInfoGroup;
bool useWhenStarted;
HDFAtom<std::string> whenStartedAtom;
HDFAtom<unsigned int> platformIdAtom;
HDFAtom<float> frameRateAtom;
HDFAtom<unsigned int> numFramesAtom;
HDFAtom<std::string> movieNameAtom;
HDFAtom<std::string> runCodeAtom;
HDFAtom<std::string> baseMapAtom;
HDFAtom<std::string> bindingKitAtom;
HDFAtom<std::string> sequencingKitAtom;
//
// It is useful to cache the movie name in the reader since this is
// loaded once upon initialization, and may be fetched when loading
// reads one at a time.
//
bool useMovieName;
std::string movieName, runCode;
PlatformId platformId;
HDFScanDataReader();
void Reset();
int InitializeAcqParamsAtoms();
//
// This is created on top of a file that is already opened, so
// instead of initializing by opening a file, it is initialized by
// passing the root group that should contain the ScanData group.
// When shutting down, no file handle needs to be closed.
//
int Initialize(HDFGroup *pulseDataGroup);
std::string GetMovieName();
// Given a PacBio (pls/plx/bas/bax/ccs/rgn).h5 file, which contains its movie
// name in group /ScanData/RunInfo attribute MovieName, open the file, return
// its movie name and finally close the file. Return "" if the movie name
// does not exist. This is a short path to get movie name.
std::string GetMovieName_and_Close(std::string &fileName);
std::string GetRunCode();
int Read(ScanData &scanData);
void ReadWhenStarted(std::string &whenStarted);
PlatformId GetPlatformId();
int ReadPlatformId(PlatformId &pid);
/// Reads value of Attribute /ScanData/RunInfo/BindingKit
int ReadBindingKit(std::string &bindingKit);
/// Reads value of Attribute /ScanData/RunInfo/SequencingKit
int ReadSequencingKit(std::string &sequencingKit);
int LoadMovieName(std::string &movieName);
int LoadBaseMap(std::map<char, size_t> &baseMap);
std::map<char, size_t> BaseMap(void) const { return baseMap_; }
void Close();
private:
std::map<char, size_t> baseMap_;
/// Reads value of a string attribute within a HDFGroup.
/// \returns 1 if succesfully read value of the string attribute, 0 otherwise.
/// \param[out] attributeValue, value of a string attribute.
/// \param[in] attributeName, name of the string attribute.
/// \param[in] group, HDFGroup of the string attribute .
/// \param[in] atom, initialized HDFAtom obj for reading attribute .
int ReadStringAttribute(std::string &attributeValue, const std::string &attributeName,
HDFGroup &group, HDFAtom<std::string> &atom);
};
#endif
|