MCPcopy Create free account
hub / github.com/BirolLab/RNA-Bloom / getMaxMedianCoverageLeft

Method getMaxMedianCoverageLeft

src/rnabloom/util/GraphUtils.java:375–436  ·  view source on GitHub ↗
(final BloomFilterDeBruijnGraph graph, final Kmer source, final int lookahead)

Source from the content-addressed store, hash-verified

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 }

Callers 2

greedyExtendLeftOnceMethod · 0.95
getPredecessorsRankedMethod · 0.95

Calls 7

getPredecessorsMethod · 0.95
getCbfNumHashMethod · 0.80
getMaxNumHashMethod · 0.80
addMethod · 0.65
getKMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected