(final BloomFilterDeBruijnGraph graph, final Kmer source, final int lookahead)
| 247 | } |
| 248 | |
| 249 | public static float getMaxMedianCoverageRight(final BloomFilterDeBruijnGraph graph, final Kmer source, final int lookahead) { |
| 250 | int k = graph.getK(); |
| 251 | int numHash = graph.getCbfNumHash(); |
| 252 | |
| 253 | ArrayDeque<Kmer> neighbors = source.getSuccessors(k, numHash, graph); |
| 254 | |
| 255 | if (neighbors.isEmpty()) { |
| 256 | if (lookahead > 0) { |
| 257 | return 0; |
| 258 | } |
| 259 | else { |
| 260 | return source.count; |
| 261 | } |
| 262 | } |
| 263 | else { |
| 264 | ArrayDeque<Kmer> path = new ArrayDeque<>(lookahead); |
| 265 | path.add(source); |
| 266 | |
| 267 | Kmer cursor = neighbors.removeFirst(); |
| 268 | path.add(cursor); |
| 269 | |
| 270 | ArrayDeque<ArrayDeque<Kmer>> frontier = new ArrayDeque<>(lookahead); |
| 271 | frontier.add(neighbors); |
| 272 | |
| 273 | float bestCov = 0; |
| 274 | |
| 275 | while (!frontier.isEmpty()) { |
| 276 | if (path.size() < lookahead) { |
| 277 | neighbors = cursor.getSuccessors(k, numHash, graph); |
| 278 | if (!neighbors.isEmpty()) { |
| 279 | cursor = neighbors.removeFirst(); |
| 280 | path.add(cursor); |
| 281 | frontier.add(neighbors); |
| 282 | continue; |
| 283 | } |
| 284 | } |
| 285 | |
| 286 | if (path.size() == lookahead) { |
| 287 | // we only calculate coverage if path is long enough |
| 288 | float pathCov = getMinimumKmerCoverage(path); |
| 289 | if (bestCov < pathCov) { |
| 290 | bestCov = pathCov; |
| 291 | } |
| 292 | } |
| 293 | |
| 294 | while (!frontier.isEmpty()) { |
| 295 | neighbors = frontier.getLast(); |
| 296 | path.removeLast(); |
| 297 | if (neighbors.isEmpty()) { |
| 298 | frontier.removeLast(); |
| 299 | } |
| 300 | else { |
| 301 | cursor = neighbors.removeFirst(); |
| 302 | path.add(cursor); |
| 303 | break; |
| 304 | } |
| 305 | } |
| 306 | } |
no test coverage detected