void xmlBranchSave::FillLODs( const dataBranch &_data , TiXmlElement* root ) { //формирование записей LOD'ов //создать запись для вершин TiXmlElement *pLods = NULL; pLods = new TiXmlElement( m_BranchNames.m_sLODs.c_str() ); //количество LOD's pLods->SetAttribute( m_BranchNames.m_sNum.c_str() , _data.m_vLOD.size() ); for( int i = 0 ; i < _data.m_vLOD.size() ; ++i ) { //создать запись для вершин TiXmlElement *pLod = NULL; pLod = new TiXmlElement( m_BranchNames.m_sLOD.c_str() ); //номер LOD's pLod->SetAttribute( m_BranchNames.m_sNum.c_str() , i ); //номер LOD's pLod->SetDoubleAttribute( m_BranchNames.m_sAlfaTest.c_str() , _data .m_vLOD[ i ].m_fAlphaTestValue ); //заполнить данными о координатах FillVertex( _data .m_vLOD[ i ] , pLod ); //заполнить индексами FillIndexes( _data .m_vLOD[ i ] , pLod ); pLods->LinkEndChild( pLod ); } root->LinkEndChild( pLods ); }
TiXmlElement* xmlFrondsSave::GetXmlData() { //получить xml тег с сформированными данными //получить ссылку на данные веток dataFronds &_data = xmlRoot::Instance().GetDataFronds(); //формируем корневой узел данных TiXmlElement *pFronds = NULL; pFronds = new TiXmlElement( m_FrondsNames.m_sFronds.c_str() ); //значение альфа теста pFronds->SetDoubleAttribute( m_FrondsNames.m_sAlfaTest.c_str() , _data.m_fAlphaTestValue ); //заполнить данными о текстурах FillTextures( _data , pFronds ); //заполнить данными о координатах FillVertex( _data , pFronds ); //заполнить индексами FillIndexes( _data , pFronds ); return pFronds; }
bool RecalibrationModel::InitializeModel(string model_file_name, int model_threshold) { is_enabled_ = false; if (model_file_name.empty() or model_file_name == "off") { printf("RecalibrationModel: disabled\n\n"); return false; } ifstream model_file; model_file.open(model_file_name.c_str()); if (model_file.fail()) { printf("RecalibrationModel: disabled (cannot open %s)\n\n", model_file_name.c_str()); model_file.close(); return false; } if (model_threshold < 0 or model_threshold > MAX_HPXLEN) { cout << "RecalibrationModel: disabled (invalid model threshold of "<< model_threshold <<")" << endl; return false; } else recalModelHPThres = model_threshold; string comment_line; getline(model_file, comment_line); //skip the comment time int flowStart, flowEnd, flowSpan, xMin, xMax, xSpan, yMin, yMax, ySpan, max_hp_calibrated; model_file >> flowStart >> flowEnd >> flowSpan >> xMin >> xMax >> xSpan >> yMin >> yMax >> ySpan >> max_hp_calibrated; stratification.SetupChipRegions(xMin, xMax, xSpan, yMin, yMax, ySpan); stratification.SetupFlowRegions(flowStart,flowEnd, flowSpan); //calculate number of partitions and initialize the stratifiedAs and stratifiedBs SetupStratification(flowStart,flowEnd, flowSpan,xMin,xMax,xSpan,yMin,yMax,ySpan,max_hp_calibrated); //TODO: parse model_file into stratifiedAs and stratifiedBs while (model_file.good()) { float paramA, paramB; int refHP; char flowBase; model_file >> flowBase >> flowStart >> flowEnd >> xMin >> xMax >> yMin >> yMax >> refHP >> paramA >> paramB; //populate it to stratifiedAs and startifiedBs int offsetRegion = stratification.OffsetRegion(xMin,yMin); FillIndexes(offsetRegion, NuctoInt(flowBase), refHP, flowStart, flowEnd, paramA, paramB); } model_file.close(); cout << "Recalibration Model: enabled (using calibration file " << model_file_name << ")" << endl; cout << " - using calibration model for HPs " << recalModelHPThres << " and up in a " << stratification.xCuts << 'x' << stratification.yCuts << 'x' << stratification.flowCuts << " grid." << endl << endl; is_enabled_ = true; return is_enabled_; }
void RecalibrationModel::Initialize(OptArgs& opts) { is_enabled_ = false; string model_file_name = opts.GetFirstString ('-', "model-file", ""); if (model_file_name.empty() or model_file_name == "off") { printf("RecalibrationModel: disabled\n\n"); return; } ifstream model_file; model_file.open(model_file_name.c_str()); if (model_file.fail()) { printf("RecalibrationModel: disabled (cannot open %s)\n\n", model_file_name.c_str()); model_file.close(); return; } recalModelHPThres = opts.GetFirstInt('-', "recal-model-hp-thres", 4); string comment_line; getline(model_file, comment_line); //skip the comment time int flowStart, flowEnd, flowSpan, xMin, xMax, xSpan, yMin, yMax, ySpan, max_hp_calibrated; model_file >> flowStart >> flowEnd >> flowSpan >> xMin >> xMax >> xSpan >> yMin >> yMax >> ySpan >> max_hp_calibrated; stratification.SetupRegion(xMin, xMax, xSpan, yMin, yMax, ySpan); //calculate number of partitions and initialize the stratifiedAs and stratifiedBs SetupStratification(flowStart,flowEnd, flowSpan,xMin,xMax,xSpan,yMin,yMax,ySpan,max_hp_calibrated); //TODO: parse model_file into stratifiedAs and stratifiedBs while (model_file.good()) { float paramA, paramB; int refHP; char flowBase; model_file >> flowBase >> flowStart >> flowEnd >> xMin >> xMax >> yMin >> yMax >> refHP >> paramA >> paramB; //populate it to stratifiedAs and startifiedBs int nucInd = NuctoInt(flowBase); //boundary check int offsetRegion = stratification.OffsetRegion(xMin,yMin); FillIndexes(offsetRegion,nucInd, refHP, flowStart, flowEnd, paramA, paramB); } model_file.close(); printf("Recalibration: enabled (using calibration file %s)\n\n", model_file_name.c_str()); is_enabled_ = true; if (recalModelHPThres > MAX_HPXLEN) is_enabled_ = false; }
void RecalibrationModel::InitializeFromJSON(Json::Value &recal_params, string &my_block_key, bool spam_enabled) { // this needs to signal when it fails in some way int flowStart, flowEnd, flowSpan, xMin, xMax, xSpan, yMin, yMax, ySpan, max_hp_calibrated; flowStart = rGetParamsInt(recal_params[my_block_key],"flowStart",0); //cout << flowStart << endl; flowEnd = rGetParamsInt(recal_params[my_block_key],"flowEnd",0); //cout << flowEnd << endl; flowSpan = rGetParamsInt(recal_params[my_block_key],"flowSpan",0); //cout << flowSpan << endl; xMin = rGetParamsInt(recal_params[my_block_key],"xMin",0); //cout << xMin << endl; xMax =rGetParamsInt(recal_params[my_block_key],"xMax",0); //cout << xMax << endl; xSpan =rGetParamsInt(recal_params[my_block_key],"xSpan",0); //cout << xSpan << endl; yMin = rGetParamsInt(recal_params[my_block_key],"yMin",0); //cout << yMin << endl; yMax =rGetParamsInt(recal_params[my_block_key],"yMax",0); //cout << yMax << endl; ySpan = rGetParamsInt(recal_params[my_block_key],"ySpan",0); //cout << ySpan << endl; max_hp_calibrated = rGetParamsInt(recal_params[my_block_key],"max_hp_calibrated",0); stratification.SetupRegion(xMin, xMax, xSpan, yMin, yMax, ySpan); //calculate number of partitions and initialize the stratifiedAs and stratifiedBs SetupStratification(flowStart,flowEnd, flowSpan,xMin,xMax,xSpan,yMin,yMax,ySpan,max_hp_calibrated); // stratification setup done // now iterate and obtain each line from the JSON int iter_size = recal_params[my_block_key]["modelParameters"].size(); for (int i_item=0; i_item<iter_size; i_item++) { // extract my single line //model_file >> flowBase >> flowStart >> flowEnd >> xMin >> xMax >> yMin >> yMax >> refHP >> paramA >> paramB; //flowBase is a special extraction flowStart = rGetParamsInt(recal_params[my_block_key]["modelParameters"][i_item],"flowStart",0); flowEnd = rGetParamsInt(recal_params[my_block_key]["modelParameters"][i_item],"flowEnd",0); xMin = rGetParamsInt(recal_params[my_block_key]["modelParameters"][i_item],"xMin",0); xMax =rGetParamsInt(recal_params[my_block_key]["modelParameters"][i_item],"xMax",0); yMin = rGetParamsInt(recal_params[my_block_key]["modelParameters"][i_item],"yMin",0); yMax =rGetParamsInt(recal_params[my_block_key]["modelParameters"][i_item],"yMax",0); int refHP; refHP = rGetParamsInt(recal_params[my_block_key]["modelParameters"][i_item],"refHP",0); float paramA, paramB; paramA = rGetParamsDbl(recal_params[my_block_key]["modelParameters"][i_item],"paramA",1.0); paramB = rGetParamsDbl(recal_params[my_block_key]["modelParameters"][i_item],"paramB",0.0); //string flowBase = recal_params[my_block_key]["modelParameters"][i_item]["flowBase"].asCString(); char flowBase = (char) rGetParamsInt(recal_params[my_block_key]["modelParameters"][i_item],"flowBase",0); int nucInd = NuctoInt(flowBase); // all set with the values int offsetRegion = stratification.OffsetRegion(xMin,yMin); FillIndexes(offsetRegion,nucInd, refHP, flowStart, flowEnd, paramA, paramB); } // now we're done! if (spam_enabled) printf("Recalibration: enabled (using recalibration comment %s)\n\n", my_block_key.c_str()); // if something bad happened above, how do we find out? is_enabled_ = true; }
void RecalibrationModel::InitializeFromJSON(Json::Value &recal_params, string &my_block_key, bool spam_enabled, int over_flow_protect) { // this needs to signal when it fails in some way verbose_ = spam_enabled; int flowStart, flowEnd, flowSpan, xMin, xMax, xSpan, yMin, yMax, ySpan, max_hp_calibrated; flowStart = rGetParamsInt(recal_params[my_block_key],"flowStart",0); //cout << flowStart << endl; flowEnd = rGetParamsInt(recal_params[my_block_key],"flowEnd",0); if (over_flow_protect>flowEnd) flowEnd = over_flow_protect; // allocate for combined bam files that need to access flows "past the end" without crashing //cout << flowEnd << endl; flowSpan = rGetParamsInt(recal_params[my_block_key],"flowSpan",0); //cout << flowSpan << endl; xMin = rGetParamsInt(recal_params[my_block_key],"xMin",0); //cout << xMin << endl; xMax =rGetParamsInt(recal_params[my_block_key],"xMax",0); //cout << xMax << endl; xSpan =rGetParamsInt(recal_params[my_block_key],"xSpan",0); //cout << xSpan << endl; yMin = rGetParamsInt(recal_params[my_block_key],"yMin",0); //cout << yMin << endl; yMax =rGetParamsInt(recal_params[my_block_key],"yMax",0); //cout << yMax << endl; ySpan = rGetParamsInt(recal_params[my_block_key],"ySpan",0); //cout << ySpan << endl; max_hp_calibrated = rGetParamsInt(recal_params[my_block_key],"max_hp_calibrated",0); stratification.SetupChipRegions(xMin, xMax, xSpan, yMin, yMax, ySpan); stratification.SetupFlowRegions(flowStart,flowEnd, flowSpan); //calculate number of partitions and initialize the stratifiedAs and stratifiedBs SetupStratification(flowStart,flowEnd, flowSpan,xMin,xMax,xSpan,yMin,yMax,ySpan,max_hp_calibrated); // stratification setup done // now iterate and obtain each line from the JSON int iter_size = recal_params[my_block_key]["modelParameters"].size(); for (int i_item=0; i_item<iter_size; i_item++) { // extract my single line //model_file >> flowBase >> flowStart >> flowEnd >> xMin >> xMax >> yMin >> yMax >> refHP >> paramA >> paramB; //flowBase is a special extraction flowStart = rGetParamsInt(recal_params[my_block_key]["modelParameters"][i_item],"flowStart",0); flowEnd = rGetParamsInt(recal_params[my_block_key]["modelParameters"][i_item],"flowEnd",0); xMin = rGetParamsInt(recal_params[my_block_key]["modelParameters"][i_item],"xMin",0); xMax =rGetParamsInt(recal_params[my_block_key]["modelParameters"][i_item],"xMax",0); yMin = rGetParamsInt(recal_params[my_block_key]["modelParameters"][i_item],"yMin",0); yMax =rGetParamsInt(recal_params[my_block_key]["modelParameters"][i_item],"yMax",0); int refHP; refHP = rGetParamsInt(recal_params[my_block_key]["modelParameters"][i_item],"refHP",0); float paramA, paramB; paramA = rGetParamsDbl(recal_params[my_block_key]["modelParameters"][i_item],"paramA",1.0); paramB = rGetParamsDbl(recal_params[my_block_key]["modelParameters"][i_item],"paramB",0.0); //string flowBase = recal_params[my_block_key]["modelParameters"][i_item]["flowBase"].asCString(); char flowBase = (char) rGetParamsInt(recal_params[my_block_key]["modelParameters"][i_item],"flowBase",0); int nucInd = NuctoInt(flowBase); // all set with the values int offsetRegion = stratification.OffsetRegion(xMin,yMin); // note we only fill >in< flows fit by the recalibration model FillIndexes(offsetRegion,nucInd, refHP, flowStart, flowEnd, paramA, paramB); } // if something bad happened above, how do we find out? - We do some basic sanity checks CheckArraySize(); // now we're done! if (verbose_) cout << "Recalibration: enabled (using recalibration comment " << my_block_key << ") in a " << stratification.xCuts << 'x' << stratification.yCuts << 'x' << stratification.flowCuts << " grid." <<endl << endl; is_enabled_ = true; }