Output a new contig. */
| 296 | |
| 297 | /** Output a new contig. */ |
| 298 | static ContigNode outputNewContig(const Graph& g, |
| 299 | const vector<Path>& solutions, |
| 300 | size_t longestPrefix, size_t longestSuffix, |
| 301 | const Sequence& seq, const unsigned coverage, |
| 302 | ofstream& out) |
| 303 | { |
| 304 | assert(!solutions.empty()); |
| 305 | assert(longestPrefix > 0); |
| 306 | assert(longestSuffix > 0); |
| 307 | |
| 308 | size_t numContigs = num_vertices(g) / 2; |
| 309 | ContigNode u(numContigs + g_newVertices.size(), false); |
| 310 | string name = createContigName(); |
| 311 | put(vertex_name, g, u, name); |
| 312 | out << '>' << name |
| 313 | << ' ' << seq.length() << ' ' << coverage << ' '; |
| 314 | |
| 315 | int dtu = INT_MAX, duv = INT_MAX; |
| 316 | for (vector<Path>::const_iterator it = solutions.begin(); |
| 317 | it != solutions.end(); it++) { |
| 318 | if (it != solutions.begin()) |
| 319 | out << ';'; |
| 320 | const ContigPath& path = *it; |
| 321 | ContigPath::const_iterator |
| 322 | first = path.begin() + longestPrefix, |
| 323 | last = path.end() - longestSuffix; |
| 324 | assert(first <= last); |
| 325 | if (first < last) { |
| 326 | ContigPath::const_iterator it = first; |
| 327 | out << get(vertex_name, g, *it); |
| 328 | for (++it; it != last; ++it) |
| 329 | out << ',' << get(vertex_name, g, *it); |
| 330 | dtu = min(dtu, getDistance(g, first[-1], first[0])); |
| 331 | duv = min(duv, getDistance(g, last[-1], last[0])); |
| 332 | } else |
| 333 | out << '*'; |
| 334 | } |
| 335 | out << '\n' << seq << '\n'; |
| 336 | assert(dtu < INT_MAX); |
| 337 | assert(duv < INT_MAX); |
| 338 | |
| 339 | // Record the newly-created contig to be added to the graph later. |
| 340 | g_newVertices.push_back(NewVertex( |
| 341 | *(solutions[0].begin() + longestPrefix - 1), |
| 342 | u, |
| 343 | *(solutions[0].rbegin() + longestSuffix - 1), |
| 344 | ContigProperties(seq.length(), coverage), |
| 345 | dtu, duv)); |
| 346 | return u; |
| 347 | } |
| 348 | |
| 349 | /** Return a consensus sequence of a and b. |
| 350 | * @return an empty string if a consensus could not be found |
no test coverage detected