| 36 | |
| 37 | template <typename Graph> |
| 38 | bool loadSequence(Graph* seqCollection, Sequence& seq) |
| 39 | { |
| 40 | typedef typename graph_traits<Graph>::vertex_descriptor V; |
| 41 | |
| 42 | size_t len = seq.length(); |
| 43 | |
| 44 | if (isalnum(seq[0])) { |
| 45 | if (opt::colourSpace) |
| 46 | assert(isdigit(seq[0])); |
| 47 | else |
| 48 | assert(isalpha(seq[0])); |
| 49 | } |
| 50 | |
| 51 | bool good = seq.find_first_not_of("ACGT0123") == std::string::npos; |
| 52 | bool discarded = true; |
| 53 | |
| 54 | for (unsigned i = 0; i < len - V::length() + 1; ++i) { |
| 55 | Sequence kmer(seq, i, V::length()); |
| 56 | if (good || kmer.find_first_not_of("acgtACGT0123") |
| 57 | == std::string::npos) { |
| 58 | if (good || kmer.find_first_of("acgt") == std::string::npos) |
| 59 | seqCollection->add(V(kmer)); |
| 60 | else { |
| 61 | transform(kmer.begin(), kmer.end(), kmer.begin(), |
| 62 | ::toupper); |
| 63 | seqCollection->add(V(kmer), 0); |
| 64 | } |
| 65 | discarded = false; |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | return discarded; |
| 70 | } |
| 71 | |
| 72 | /** Load sequence data into the collection. */ |
| 73 | template <typename Graph> |