Find all overlaps with the given focal read and call a consensus sequence
| 169 | |
| 170 | // Find all overlaps with the given focal read and call a consensus sequence |
| 171 | static string find_complex_overlap(const RotatedRead& f, |
| 172 | const Rotations& r, |
| 173 | vector<RotatedRead>& rl) |
| 174 | { |
| 175 | // A vector for tracking all the overlaps, seeded with the initial read |
| 176 | vector<Overlap> o; |
| 177 | o.push_back(Overlap(f.seq, 0)); |
| 178 | |
| 179 | // The pre-pended string to use to seed the search |
| 180 | const string& seq1 = '$' + f.seq; |
| 181 | |
| 182 | //Find it in the sorted list - NOTE: if the flank read doesn't correspond |
| 183 | // to a real read, this iterator will not be used |
| 184 | Rotations::const_iterator rt = lower_bound(r.begin(), r.end(), seq1); |
| 185 | |
| 186 | /* |
| 187 | Continue down the sorted list, checking for other matches |
| 188 | - for real reads (seq1 == rt->seq), continue from the position |
| 189 | of seq1 in the list |
| 190 | - otherwise, just start at the beginning |
| 191 | */ |
| 192 | for(Rotations::const_iterator st = (seq1 == rt->seq) ? rt+1 : r.begin(); |
| 193 | st != r.end(); ++st) |
| 194 | { |
| 195 | // Check for an overlap between the two sequences, |
| 196 | // allowing for mismatches |
| 197 | const string& seq2 = st->seq; |
| 198 | unsigned new_overlap = tier_overlap(seq1, seq2, true); |
| 199 | |
| 200 | // Continue if there's no match |
| 201 | if (new_overlap == 0 |
| 202 | || new_overlap > opt::max_overlap) |
| 203 | continue; |
| 204 | |
| 205 | // Add a new overlap object for each appropriate overlap found |
| 206 | o.push_back(Overlap( |
| 207 | original_read_from_rotated_read(seq2), new_overlap)); |
| 208 | } |
| 209 | |
| 210 | // Counters for calculating coverage |
| 211 | // Vector size should be something like "read_length + maximum tier" |
| 212 | // THIS WILL BREAK WITH LONGER READS |
| 213 | vector<BaseCount> counts(300); |
| 214 | |
| 215 | // Pretty-print the alignment for verbose only |
| 216 | if(opt::verbose){ |
| 217 | cerr << endl; |
| 218 | sort(o.begin(), o.end(), offset_sort); |
| 219 | } |
| 220 | |
| 221 | // Go through each overlap to count bases offset by the appropriate amount |
| 222 | for(vector<Overlap>::const_iterator ot = o.begin(); |
| 223 | ot != o.end(); ++ot){ |
| 224 | |
| 225 | // Pretty-print each found read aligned with the focal read |
| 226 | if (opt::verbose) |
| 227 | cerr << string(ot->offset, ' ') << ot->seq << " t:" << ot->offset; |
| 228 |
no test coverage detected