unsigned int HypothesisEvaluator::SolveBeginningOfRead(DPTreephaser &working_treephaser, BasecallerRead &master_read, const vector<string>& Hypotheses, int startFlow) { //cout << "Hypothesis sequence: " << Hypotheses[0] << endl; // Solve beginning of maybe clipped read if (startFlow>0) { int until_flow = min((startFlow+20), nFlows); working_treephaser.Solve(master_read, until_flow, 0); } /*cout << "Solved prefix of size " << read.sequence.size() << ": "; for (int i=0; i<read.sequence.size(); i++) cout << read.sequence[i]; cout << endl;*/ // StartFlow clipped? Get solved HP length at startFlow unsigned int base = 0; int flow = 0; int HPlength = 0; while (base<master_read.sequence.size()) { while (flow < treePhaserFlowOrder.num_flows() and treePhaserFlowOrder.nuc_at(flow) != master_read.sequence[base]) flow++; if (flow > startFlow or flow == treePhaserFlowOrder.num_flows()) break; if (flow == startFlow) HPlength++; base++; } // Get HP size at the start of the reference, i.e., Hypotheses[0] int count = 1; while (Hypotheses[0][count] == Hypotheses[0][0]) count++; // Adjust the length of the base prefix and erase extra solved bases if (HPlength>count) base -= count; else base -= HPlength; master_read.sequence.erase(master_read.sequence.begin()+base, master_read.sequence.end()); unsigned int prefix_size = master_read.sequence.size(); /*cout << "Shortened prefix to size " << prefix_size << " until startFlow" << startFlow << ": "; for (int i=0; i<read.sequence.size(); i++) cout << read.sequence[i]; cout << endl;*/ return(prefix_size); }
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); }