void BkgParamH5::Init ( const char *results_folder, const SpatialContext &loc_context, const ImageSpecClass &my_image_spec, int numFlows, int write_params_flag, int _max_frames, int _flow_block_size, int num_flow_blocks ) { cout << "BkgParamH5::Init... _max_frames = " << _max_frames << ", MAX_COMPRESSED_FRAMES = " << MAX_COMPRESSED_FRAMES << endl; //max_frames = MAX_COMPRESSED_FRAMES; max_frames = _max_frames; if ( write_params_flag>0 ) { local_results_directory=results_folder; flow_block_size = _flow_block_size; datacube_numflows = numFlows; nFlowBlks = num_flow_blocks; bead_col = loc_context.cols; bead_row = loc_context.rows; region_total = loc_context.numRegions; ConstructOneFile ( h5BeadDbg, hgBeadDbgFile,local_results_directory, "bead_param.h5" ); TryInitBeads ( h5BeadDbg, write_params_flag ); //write_params_flag: 1-only important params, small file; 2-all params (very large file, use for debugging only) ConstructOneFile ( h5RegionDbg, hgRegionDbgFile,local_results_directory, "region_param.h5" ); TryInitRegionParams ( h5RegionDbg,my_image_spec ); ///------------------------------------------------------------------------------------------------------------ /// savePointers to be passed to BkgModel::WriteBeadParameterstoDataCubes ///------------------------------------------------------------------------------------------------------------ /// WARNING: these pointers determine >individual< behavior of data cubes /// just because one cube exists doesn't mean any others exists - see different logging levels /// if a cube exists, the >exporting< function in GlobalWriter needs to handle it correctly. savePointers(); } else { hgBeadDbgFile = ""; hgRegionDbgFile=""; } }
std::string BkgParamH5::Init(SystemContext &sys_context, SpatialContext &loc_context, int numFlows, ImageSpecClass &my_image_spec) { //wells_output_directory is a better choice than basecaller_output_directory //hgBgDbgFile = ToStr(sys_context.dat_source_directory) + "/bg_param.h5"; //cout << "dat_source_directory:" << sys_context.dat_source_directory << endl; //cout << "basecaller_output_directory:" << sys_context.basecaller_output_directory << endl; //cout << "wells_output_directory:" << sys_context.wells_output_directory << endl; if (ToStr(sys_context.wells_output_directory)=="") hgBgDbgFile = sys_context.experimentName; else hgBgDbgFile = ToStr(sys_context.wells_output_directory); if (hgBgDbgFile[hgBgDbgFile.length()-1] != '/') hgBgDbgFile += '/'; hgBgDbgFile += "bg_param.h5"; cout << "hgBgDbgFile:" << hgBgDbgFile << endl; h5BgDbg.Init(); h5BgDbg.SetFile(hgBgDbgFile); h5BgDbg.Open(true); int blocksOfFlow = NUMFB; int nFlowBlks = ceil(float(numFlows)/NUMFB); //int numParam = sizeof(reg_params)/sizeof(float); // +1 not necessary int numParam = sizeof(reg_params_H5)/sizeof(float); // +1 not necessary hsize_t rp_dims[2], rp_chunks[2]; char s[128]; string str; ///------------------------------------------------------------------------------------------------------------ /// bead parameters ///------------------------------------------------------------------------------------------------------------ try { beadDC.Init(loc_context.cols, loc_context.rows, numFlows); beadDC.SetRange(0,loc_context.cols, 0, loc_context.rows, 0, blocksOfFlow); beadDC.AllocateBuffer(); beadDCDS = h5BgDbg.CreateDataSet("/bead/fg_bead_DC", beadDC, 3); h5BgDbg.CreateAttribute(beadDCDS->getDataSetId(),"description","bead_DC per flow"); h5BgDbg.makeParamNames("fg_beadDC_",numFlows,str); h5BgDbg.CreateAttribute(beadDCDS->getDataSetId(),"paramNames",str.c_str()); amplMultiplier.Init(loc_context.cols, loc_context.rows, numFlows); amplMultiplier.SetRange(0,loc_context.cols, 0, loc_context.rows, 0, blocksOfFlow); amplMultiplier.AllocateBuffer(); amplDS = h5BgDbg.CreateDataSet("/bead/ampl_multiplier", amplMultiplier, 3); h5BgDbg.CreateAttribute(amplDS->getDataSetId(),"description","Amplitude-multiplier per flow"); h5BgDbg.makeParamNames("ampl_",numFlows,str); h5BgDbg.CreateAttribute(amplDS->getDataSetId(),"paramNames",str.c_str()); kRateMultiplier.Init(loc_context.cols, loc_context.rows, numFlows); kRateMultiplier.SetRange(0,loc_context.cols, 0, loc_context.rows, 0, blocksOfFlow); kRateMultiplier.AllocateBuffer(); kRateDS = h5BgDbg.CreateDataSet("/bead/k_rate_multiplier", kRateMultiplier, 3); h5BgDbg.CreateAttribute(kRateDS->getDataSetId(),"description","K-rate-multiplier per flow"); h5BgDbg.makeParamNames("kRate_",numFlows,str); h5BgDbg.CreateAttribute(kRateDS->getDataSetId(),"paramNames",str.c_str()); bgResidualError.Init(loc_context.cols, loc_context.rows, numFlows); bgResidualError.SetRange(0,loc_context.cols, 0, loc_context.rows, 0, blocksOfFlow); bgResidualError.AllocateBuffer(); resErrorDS = h5BgDbg.CreateDataSet("/bead/res_error", bgResidualError, 3); h5BgDbg.CreateAttribute(resErrorDS->getDataSetId(),"description","Residual-error per flow"); h5BgDbg.makeParamNames("resErr_",numFlows,str); h5BgDbg.CreateAttribute(resErrorDS->getDataSetId(),"paramNames",str.c_str()); beadInitParam.Init(loc_context.cols, loc_context.rows, 4); beadInitParam.SetRange(0,loc_context.cols, 0, loc_context.rows, 0, beadInitParam.GetNumZ()); beadInitParam.AllocateBuffer(); beadInitParamDS = h5BgDbg.CreateDataSet("/bead/bead_init_param", beadInitParam, 3); h5BgDbg.CreateAttribute(beadInitParamDS->getDataSetId(),"description","Bead-init-param, same for all flows, 4 data points: Copies, R, dmult, gain"); h5BgDbg.CreateAttribute(beadInitParamDS->getDataSetId(),"paramNames","Copies, R, dmult, gain"); beadFblk_avgErr.set_size(loc_context.cols, loc_context.rows); beadFblk_clonal.set_size(loc_context.cols, loc_context.rows); beadFblk_corrupt.set_size(loc_context.cols, loc_context.rows); rp_dims[0] = rp_chunks[0] = loc_context.cols; rp_dims[1] = rp_chunks[1] = loc_context.rows; for (int i=0; i<nFlowBlks; i++) { int f = (i+1)*NUMFB; if (i==nFlowBlks-1) f = numFlows; sprintf(s,"/bead/flowBlkParams/avgErr/flow_%04d",f); H5DataSet *ptr = h5BgDbg.CreateDataSet(s, 2, rp_dims, rp_chunks, 3, h5BgDbg.GetH5Type(beadFblk_avgErr.at(0,0))); h5BgDbg.CreateAttribute(ptr->getDataSetId(),"description","avg-err per flow-block"); h5BgDbg.CreateAttribute(ptr->getDataSetId(),"paramNames","avgErr"); beadFblk_avgErrDS.push_back(ptr); sprintf(s,"/bead/flowBlkParams/clonal/flow_%04d",f); ptr = h5BgDbg.CreateDataSet(s, 2, rp_dims, rp_chunks, 3, h5BgDbg.GetH5Type(beadFblk_clonal.at(0,0))); h5BgDbg.CreateAttribute(ptr->getDataSetId(),"description","clonal flag per flow-block"); h5BgDbg.CreateAttribute(ptr->getDataSetId(),"paramNames","clonal"); beadFblk_clonalDS.push_back(ptr); sprintf(s,"/bead/flowBlkParams/corrupt/flow_%04d",f); ptr = h5BgDbg.CreateDataSet(s, 2, rp_dims, rp_chunks, 3, h5BgDbg.GetH5Type(beadFblk_corrupt.at(0,0))); h5BgDbg.CreateAttribute(ptr->getDataSetId(),"description","corrupt flag per flow-block"); h5BgDbg.CreateAttribute(ptr->getDataSetId(),"paramNames","corrupt"); beadFblk_corruptDS.push_back(ptr); } } catch( char * str ) { cout << "Exception raised while creating bead datasets in BkgParamH5::Init(): " << str << '\n'; } ///------------------------------------------------------------------------------------------------------------ /// region parameters ///------------------------------------------------------------------------------------------------------------ try { //cout << "Init...regionalParams.n_rows,n_cols=" << regionalParams.n_rows << "," << regionalParams.n_cols << endl; //rp_dims[0] = loc_context.numRegions * nFlowBlks; char s[128]; rp_dims[0] = rp_chunks[0] = loc_context.numRegions; rp_dims[1] = rp_chunks[1] = numFlows; beadDC_bg.set_size(rp_dims[0], rp_dims[1]); beadDC_bgDS = h5BgDbg.CreateDataSet("/region/bg_bead_DC", 2, rp_dims, rp_chunks, 3, h5BgDbg.GetH5Type(beadDC_bg.at(0,0))); h5BgDbg.CreateAttribute(beadDC_bgDS->getDataSetId(),"description","bg_bead_DC"); h5BgDbg.makeParamNames("bg_beadDC_",numFlows,str); h5BgDbg.CreateAttribute(beadDC_bgDS->getDataSetId(),"paramNames",str.c_str()); rp_dims[0] = rp_chunks[0] = loc_context.numRegions; rp_dims[1] = rp_chunks[1] = 2; regionOffset.set_size(rp_dims[0], rp_dims[1]); regionOffsetDS = h5BgDbg.CreateDataSet("/region/region_offset_RowCol", 2, rp_dims, rp_chunks, 3, h5BgDbg.GetH5Type(regionOffset.at(0,0))); h5BgDbg.CreateAttribute(regionOffsetDS->getDataSetId(),"description","region-offset-xy"); h5BgDbg.CreateAttribute(regionOffsetDS->getDataSetId(),"paramNames","row,col"); regionalParams.set_size(loc_context.numRegions, numParam); regionalParamsExtra.set_size(loc_context.numRegions, 9); emptyOnceParam.Init(loc_context.numRegions, my_image_spec.uncompFrames, numFlows); emptyOnceParam.SetRange(0,loc_context.numRegions, 0, my_image_spec.uncompFrames, 0, blocksOfFlow); emptyOnceParam.AllocateBuffer(); emptyOnceParamDS = h5BgDbg.CreateDataSet("/region/emptyTrace", emptyOnceParam, 3); h5BgDbg.CreateAttribute(emptyOnceParamDS->getDataSetId(),"description","Empty-trace per region, per imgFrame , per flow"); h5BgDbg.makeParamNames("empty_",numFlows,str); h5BgDbg.CreateAttribute(emptyOnceParamDS->getDataSetId(),"paramNames",str.c_str()); darkOnceParam.Init(loc_context.numRegions, NUMNUC, MAX_COMPRESSED_FRAMES); darkOnceParam.SetRange(0,loc_context.numRegions, 0, NUMNUC, 0, darkOnceParam.GetNumZ()); darkOnceParam.AllocateBuffer(); darkOnceParamDS = h5BgDbg.CreateDataSet("/region/darkMatter/missingMass", darkOnceParam, 3); sprintf(s,"Missing-mass per region, per nucleotide, %d data points",MAX_COMPRESSED_FRAMES); h5BgDbg.CreateAttribute(darkOnceParamDS->getDataSetId(),"description",s); h5BgDbg.makeParamNames("missingMass_",MAX_COMPRESSED_FRAMES,str); h5BgDbg.CreateAttribute(darkOnceParamDS->getDataSetId(),"paramNames",str.c_str()); rp_dims[0] = rp_chunks[0] = loc_context.numRegions; rp_dims[1] = rp_chunks[1] = NUMFB; darknessParam.set_size(loc_context.numRegions, NUMFB); darknessParamDS = h5BgDbg.CreateDataSet("/region/darkMatter/darkness", 2, rp_dims, rp_chunks, 3, h5BgDbg.GetH5Type(darknessParam.at(0,0))); h5BgDbg.CreateAttribute(darknessParamDS->getDataSetId(),"description","Darkness per region, per flowBuffer"); h5BgDbg.makeParamNames("darkness_",NUMFB,str); h5BgDbg.CreateAttribute(darknessParamDS->getDataSetId(),"paramNames",str.c_str()); rp_dims[1] = rp_chunks[1] = 2; regionInitParam.set_size(loc_context.numRegions, 2); regionInitParamDS = h5BgDbg.CreateDataSet("/region/region_init_param", 2, rp_dims, rp_chunks, 3, h5BgDbg.GetH5Type(regionInitParam.at(0,0))); h5BgDbg.CreateAttribute(regionInitParamDS->getDataSetId(),"description","Region-init-param per region, 2 data points: t_mid_nuc_start & sigma_start"); h5BgDbg.CreateAttribute(regionInitParamDS->getDataSetId(),"paramNames","t_mid_nuc_start,sigma_start"); emphasisParam.Init(loc_context.numRegions, MAX_HPLEN+1, MAX_COMPRESSED_FRAMES); emphasisParam.SetRange(0,loc_context.numRegions, 0, MAX_HPLEN+1, 0, emphasisParam.GetNumZ()); emphasisParam.AllocateBuffer(); for (int i=0; i<nFlowBlks; i++) { int f = (i+1)*NUMFB; if (i==nFlowBlks-1) f = numFlows; sprintf(s,"/region/emphasis/flow_%04d",f); H5DataSet *ptr = h5BgDbg.CreateDataSet(s, emphasisParam, 3); sprintf(s,"Emphasis param per region, per HP length, %d data points per flow-block",MAX_COMPRESSED_FRAMES); h5BgDbg.CreateAttribute(ptr->getDataSetId(),"description",s); h5BgDbg.makeParamNames("emphasis_",NUMFB,str); h5BgDbg.CreateAttribute(ptr->getDataSetId(),"paramNames",str.c_str()); emphasisParamDS.push_back(ptr); rp_dims[0] = rp_chunks[0] = loc_context.numRegions; rp_dims[1] = rp_chunks[1] = numParam; sprintf(s,"/region/region_param/flow_%04d",f); ptr = h5BgDbg.CreateDataSet(s, 2, rp_dims, rp_chunks, 3, h5BgDbg.GetH5Type(regionalParams.at(0,0))); sprintf(s,"Region_param per region, %d data points per flow-block",numParam); h5BgDbg.CreateAttribute(ptr->getDataSetId(),"description",s); h5BgDbg.makeParamNames("regionParam_",numParam,str); h5BgDbg.CreateAttribute(ptr->getDataSetId(),"paramNames",str.c_str()); regionParamDS.push_back(ptr); rp_dims[1] = rp_chunks[1] = regionalParamsExtra.n_cols; sprintf(s,"/region/region_param_extra/flow_%04d",f); ptr = h5BgDbg.CreateDataSet(s, 2, rp_dims, rp_chunks, 3, h5BgDbg.GetH5Type(regionalParamsExtra.at(0,0))); sprintf(s,"Region_param_extra per region, %d data points per flow-block",regionalParamsExtra.n_cols); h5BgDbg.CreateAttribute(ptr->getDataSetId(),"description",s); h5BgDbg.CreateAttribute(ptr->getDataSetId(),"paramNames","midNucTime_0,midNucTime_1,midNucTime_2,midNucTime_3,sigma_0,sigma_1,sigma_2,sigma_3,sigma"); regionParamDSExtra.push_back(ptr); } } catch( char * str ) { cout << "Exception raised while creating region datasets in BkgParamH5::Init(): " << str << '\n'; } ///------------------------------------------------------------------------------------------------------------ /// savePointers to be passed to BkgModel::WriteBeadParameterstoDataCubes ///------------------------------------------------------------------------------------------------------------ savePointers(); return hgBgDbgFile; }