string SimulateRead(const SequencingParameters& p, const std::string& tpl, RandomNumberGenerator& rng) { std::string read; read.reserve(tpl.length() * 2); int pos = 0; while (pos < (int)tpl.length()) { char base = tpl[pos]; char prevBase = pos > 0 ? tpl[pos-1] : 'N'; int channel = Channel(base); // // Tabulate the different possible move probabilities, then choose one // bool canMerge = base == prevBase; vector<double> errorProbs = ErrorProbs(p, channel, canMerge); int choice = rng.RandomChoice(errorProbs); if (choice == (int) errorProbs.size() - 1) { // Match read.push_back(base); pos++; } else if (choice < 4) { // Insert vector<double> insertProbs = vector<double>(errorProbs.begin(), errorProbs.begin() + 4); int eChannel = rng.RandomChoice(insertProbs); char eBase = "TGAC"[eChannel]; read.push_back(eBase); } else if (choice == 4) { // Dark pos++; } else if (choice == 5) { // Miscall read.push_back(rng.RandomBase()); pos++; } else { // Merge assert (canMerge); pos++; } } return read; }