/usr/include/pbseq/hdf/HDFRegionTableWriter.hpp is in libpbihdf-dev 0~20161219-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | #ifndef _BLASR_HDF_REGION_TABLE_WRITER_HPP_
#define _BLASR_HDF_REGION_TABLE_WRITER_HPP_
#include <string>
// pbdata/
#include "../pbdata/Enumerations.h"
#include "../pbdata/reads/RegionTable.hpp"
#include "HDFFile.hpp"
#include "HDFArray.hpp"
#include "HDF2DArray.hpp"
#include "HDFAtom.hpp"
using namespace H5;
using namespace std;
class HDFRegionTableWriter {
public:
HDFFile regionTableFile;
HDF2DArray<int> regions;
HDFAtom<vector<string> > regionTypes;
HDFAtom<vector<string> > regionDescriptions;
HDFAtom<vector<string> > regionSources;
HDFAtom<vector<string> > columnNames;
int curRow;
int nRows;
HDFGroup *parentGroupPtr, pulseDataGroup;
void CreateGroupStructure() {
regionTableFile.rootGroup.AddGroup("PulseData");
if (pulseDataGroup.Initialize(regionTableFile.rootGroup, "PulseData") == 0) {
cout << "Could not create group PulseData. This is a bug." << endl;
exit(1);
}
parentGroupPtr = &pulseDataGroup;
regions.Initialize(pulseDataGroup, "Regions", RegionAnnotation::NCOLS);
}
int Create(string fileName) {
H5File newFile(fileName.c_str(), H5F_ACC_TRUNC, FileCreatPropList::DEFAULT, FileAccPropList::DEFAULT);
regionTableFile.hdfFile.openFile(fileName.c_str(), H5F_ACC_RDWR, H5P_DEFAULT);
regionTableFile.rootGroup.Initialize(regionTableFile.hdfFile, "/");
CreateGroupStructure();
}
HDFRegionTableWriter() {
curRow = 0;
nRows = 0;
parentGroupPtr = NULL;
}
int Initialize(HDFGroup &parentGroupP) {
/*
* Initialize in an existing file.
*/
parentGroupPtr = &parentGroupP;
return Initialize();
}
int Initialize(string ®ionTableFileName,
const H5::FileAccPropList & fileAccPropList = H5::FileAccPropList::DEFAULT) {
/*
* Initialize access to the HDF file.
*/
try {
regionTableFile.Open(regionTableFileName, H5F_ACC_TRUNC, fileAccPropList);
}
catch (Exception &e) {
cout << e.getDetailMsg() << endl;
return 0;
}
CreateGroupStructure();
return 1;
}
int Initialize() {
if (regions.Initialize(*parentGroupPtr, "Regions", RegionAnnotation::NCOLS) == 0) {
return 0;
}
nRows = regions.GetNRows();
curRow = 0;
return 1;
}
void Finalize(vector<string> &columnNamesVect,
vector<string> ®ionTypesVect,
vector<string> ®ionDescriptionsVect,
vector<string> ®ionSourcesVect) {
//
// Make sure data has been written to the dataset. If not, the
// dataset will not exist and creating the attributes will fail.
//
if (curRow > 0) {
regionTypes.Create(regions.dataset, "RegionTypes", regionTypesVect);
columnNames.Create(regions.dataset, "ColumnNames", columnNamesVect);
regionDescriptions.Create(regions.dataset, "RegionDescriptions", regionDescriptionsVect);
regionSources.Create(regions.dataset, "RegionSources", regionSourcesVect);
}
}
void WriteRows(vector<RegionAnnotation> &annotations) {
int i;
for (i = 0; i < annotations.size(); i++) {
Write(annotations[i]);
}
}
int Write(RegionAnnotation &annotation, int at=-1) {
if (at == -1) {
regions.WriteRow(annotation.row, annotation.NCOLS);
++curRow;
}
else {
}
return 1;
}
void Close() {
regions.Close();
//
// Check to see if this is external
//
if (parentGroupPtr == &pulseDataGroup) {
pulseDataGroup.Close();
}
regionTableFile.rootGroup.Close();
}
};
#endif
|