Process an a branch group extension. */
| 157 | |
| 158 | /** Process an a branch group extension. */ |
| 159 | static inline bool |
| 160 | processBranchGroupExtension(BranchGroup& group, |
| 161 | size_t branchIndex, |
| 162 | const graph_traits<SequenceCollectionHash>::vertex_descriptor& seq, |
| 163 | SequenceCollectionHash::SymbolSetPair ext, |
| 164 | int multiplicity, |
| 165 | unsigned maxLength) |
| 166 | { |
| 167 | typedef SequenceCollectionHash Graph; |
| 168 | typedef graph_traits<Graph>::vertex_descriptor V; |
| 169 | typedef vertex_bundle_type<Graph>::type VP; |
| 170 | |
| 171 | BranchRecord& branch = group[branchIndex]; |
| 172 | branch.setData(std::make_pair(seq, VP(multiplicity, ext))); |
| 173 | |
| 174 | extDirection dir = group.getDirection(); |
| 175 | if (ext.dir[!dir].isAmbiguous()) { |
| 176 | // Check that this fork is due to branches of our bubble |
| 177 | // merging back together. If not, stop this bubble. |
| 178 | if (branch.size() < 2) { |
| 179 | group.setNoExtension(); |
| 180 | return false; |
| 181 | } |
| 182 | |
| 183 | std::vector<V> extKmer; |
| 184 | generateSequencesFromExtension(seq, !dir, |
| 185 | ext.dir[!dir], extKmer); |
| 186 | assert(extKmer.size() > 1); |
| 187 | for (std::vector<V>::iterator it = extKmer.begin(); |
| 188 | it != extKmer.end(); ++it) { |
| 189 | assert(branch.size() > 1); |
| 190 | if (!group.exists(branch.size() - 2, *it)) { |
| 191 | group.setNoExtension(); |
| 192 | return false; |
| 193 | } |
| 194 | } |
| 195 | // Ignore the ambiguity. |
| 196 | ext.dir[!dir].clear(); |
| 197 | } |
| 198 | |
| 199 | if (ext.dir[dir].isAmbiguous()) { |
| 200 | // Create a new branch to follow the fork. |
| 201 | std::vector<V> extKmer; |
| 202 | generateSequencesFromExtension(seq, dir, |
| 203 | ext.dir[dir], extKmer); |
| 204 | assert(extKmer.size() > 1); |
| 205 | BranchRecord original = branch; |
| 206 | std::vector<V>::iterator it = extKmer.begin(); |
| 207 | branch.push_back(std::make_pair(*it++, VP())); |
| 208 | for (; it != extKmer.end(); ++it) |
| 209 | group.addBranch(original, *it); |
| 210 | return group.isExtendable(); |
| 211 | } |
| 212 | |
| 213 | V nextKmer = seq; |
| 214 | if (processLinearExtensionForBranch(branch, |
| 215 | nextKmer, ext, multiplicity, |
| 216 | maxLength, false)) |
no test coverage detected