float PhaseEstimator::EvaluateParameters(vector<BasecallerRead *>& useful_reads, DPTreephaser& treephaser, const float *parameters, const bool usePIDNorm) { float try_cf = parameters[0]; float try_ie = parameters[1]; float try_dr = parameters[2]; if (try_cf < 0 or try_ie < 0 or try_dr < 0 or try_cf > 0.04 or try_ie > 0.04 or try_dr > 0.01) return 1e10; treephaser.SetModelParameters(try_cf, try_ie, try_dr); float metric = 0; for (vector<BasecallerRead *>::iterator read = useful_reads.begin(); read != useful_reads.end(); ++read) { treephaser.Simulate(**read, 120); float normalizer = (usePIDNorm ? treephaser.PIDNormalize(**read, 8, 100) : treephaser.Normalize(**read, 20, 100)); for (unsigned int flow = 20; flow < 100 and flow < (*read)->raw_measurements.size(); flow++) { if ((*read)->raw_measurements[flow] > 1.2) continue; float delta = (*read)->raw_measurements[flow] - (*read)->prediction[flow] * normalizer; metric += delta * delta; } } return isnan(metric) ? 1e10 : metric; }
float PhaseEstimator::EvaluateParameters(vector<BasecallerRead *>& useful_reads, DPTreephaser& treephaser, const float *parameters) { float try_cf = parameters[0]; float try_ie = parameters[1]; float try_dr = parameters[2]; if (try_cf < 0 or try_ie < 0 or try_dr < 0 or try_cf > 0.04 or try_ie > 0.04 or try_dr > 0.01) return 1e10; treephaser.SetModelParameters(try_cf, try_ie, try_dr); float metric = 0; for (vector<BasecallerRead *>::iterator read = useful_reads.begin(); read != useful_reads.end(); ++read) { // Simulate phasing parameter treephaser.Simulate(**read, phasing_end_flow_+20); // Optionally determine optimal normalization for this parameter set? if (norm_during_param_eval_) NormalizeBasecallerRead(treephaser, **read, phasing_start_flow_, phasing_end_flow_); // Determine squared distance penalty for this parameter set for (int flow = phasing_start_flow_; flow < phasing_end_flow_ and flow < (int)(*read)->raw_measurements.size(); ++flow) { if ((*read)->raw_measurements[flow] > inclusion_threshold_) continue; // Keep key normalized raw measurements as a constant and normalize predictions towards key normalized values float delta = ((*read)->normalized_measurements[flow] - (*read)->prediction[flow]) * (*read)->multiplicative_correction[flow]; metric += delta * delta; } } return isnan(metric) ? 1e10 : metric; }
int HypothesisEvaluator::EvaluateOneHypothesis(DPTreephaser &working_treephaser, BasecallerRead ¤t_hypothesis, int applyNormalization) { int last_incorporating_flow = LastIncorporatingFlow(current_hypothesis); // Simulate sequence working_treephaser.Simulate(current_hypothesis, nFlows); // Adaptively normalize each hypothesis if (applyNormalization>0) { int window_size= 50; int steps = last_incorporating_flow / window_size; working_treephaser.WindowedNormalize(current_hypothesis, steps, window_size); } // Solver simulates beginning of the read and then fills in the remaining clipped bases working_treephaser.Solve(current_hypothesis, nFlows, last_incorporating_flow); /*cout << "Solved sequence of length: " << hypothesesReadsVector[r].sequence.size() << " ;nFlows = " << nFlows << endl; cout << "Total read: "; for (int i=0; i<hypothesesReadsVector[r].sequence.size(); i++) cout << hypothesesReadsVector[r].sequence[i]; cout << endl;*/ return(last_incorporating_flow); }