(final BloomFilterDeBruijnGraph graph, final Kmer source, final int lookahead)
| 373 | } |
| 374 | |
| 375 | public static float getMaxMedianCoverageLeft(final BloomFilterDeBruijnGraph graph, final Kmer source, final int lookahead) { |
| 376 | int k = graph.getK(); |
| 377 | int numHash = graph.getCbfNumHash(); |
| 378 | |
| 379 | ArrayDeque<Kmer> neighbors = source.getPredecessors(k, numHash, graph); |
| 380 | |
| 381 | if (neighbors.isEmpty()) { |
| 382 | if (lookahead > 0) { |
| 383 | return 0; |
| 384 | } |
| 385 | else { |
| 386 | return source.count; |
| 387 | } |
| 388 | } |
| 389 | else { |
| 390 | ArrayDeque<Kmer> path = new ArrayDeque<>(lookahead); |
| 391 | path.add(source); |
| 392 | |
| 393 | Kmer cursor = neighbors.removeFirst(); |
| 394 | path.add(cursor); |
| 395 | |
| 396 | ArrayDeque<ArrayDeque<Kmer>> frontier = new ArrayDeque<>(lookahead); |
| 397 | frontier.add(neighbors); |
| 398 | |
| 399 | float bestCov = 0; |
| 400 | |
| 401 | while (!frontier.isEmpty()) { |
| 402 | if (path.size() < lookahead) { |
| 403 | neighbors = cursor.getPredecessors(k, numHash, graph); |
| 404 | if (!neighbors.isEmpty()) { |
| 405 | cursor = neighbors.removeFirst(); |
| 406 | path.add(cursor); |
| 407 | frontier.add(neighbors); |
| 408 | continue; |
| 409 | } |
| 410 | } |
| 411 | |
| 412 | if (path.size() == lookahead) { |
| 413 | // we only calculate coverage if path is long enough |
| 414 | float pathCov = getMinimumKmerCoverage(path); |
| 415 | if (bestCov < pathCov) { |
| 416 | bestCov = pathCov; |
| 417 | } |
| 418 | } |
| 419 | |
| 420 | while (!frontier.isEmpty()) { |
| 421 | neighbors = frontier.getLast(); |
| 422 | path.removeLast(); |
| 423 | if (neighbors.isEmpty()) { |
| 424 | frontier.removeLast(); |
| 425 | } |
| 426 | else { |
| 427 | cursor = neighbors.removeFirst(); |
| 428 | path.add(cursor); |
| 429 | break; |
| 430 | } |
| 431 | } |
| 432 | } |
no test coverage detected