| 196 | */ |
| 197 | template <class KmerType> |
| 198 | static void readContigs(const string& path, |
| 199 | Graph& g, vector<KmerType>& prefixes, |
| 200 | unordered_map<KmerType, vector<ContigNode> >& suffixMap) |
| 201 | { |
| 202 | if (opt::verbose > 0) |
| 203 | cerr << "Reading `" << path << "'...\n"; |
| 204 | |
| 205 | unsigned count = 0; |
| 206 | FastaReader in(path.c_str(), FastaReader::FOLD_CASE); |
| 207 | for (FastaRecord rec; in >> rec;) { |
| 208 | Sequence& seq = rec.seq; |
| 209 | if (count++ == 0) { |
| 210 | // Detect colour-space contigs. |
| 211 | opt::colourSpace = isdigit(seq[0]); |
| 212 | } else { |
| 213 | if (opt::colourSpace) |
| 214 | assert(isdigit(seq[0])); |
| 215 | else |
| 216 | assert(isalpha(seq[0])); |
| 217 | } |
| 218 | |
| 219 | flattenAmbiguityCodes(seq); |
| 220 | |
| 221 | // Add the prefix to the collection. |
| 222 | unsigned overlap = opt::k - 1; |
| 223 | assert(seq.length() > overlap); |
| 224 | KmerType prefix(seq.substr(0, overlap)); |
| 225 | KmerType suffix(seq.substr(seq.length() - overlap)); |
| 226 | prefixes.push_back(prefix); |
| 227 | prefixes.push_back(reverseComplement(suffix)); |
| 228 | |
| 229 | // Add the suffix to the index. |
| 230 | ContigProperties vp(seq.length(), getCoverage(rec.comment)); |
| 231 | ContigNode u = add_vertex(vp, g); |
| 232 | put(vertex_name, g, u, rec.id); |
| 233 | suffixMap[suffix].push_back(u); |
| 234 | suffixMap[reverseComplement(prefix)].push_back( |
| 235 | get(vertex_complement, g, u)); |
| 236 | } |
| 237 | assert(in.eof()); |
| 238 | } |
| 239 | |
| 240 | /** Build contig overlap graph. */ |
| 241 | template <class KmerType> |
no test coverage detected