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

Method correctErrorHelper

src/rnabloom/util/GraphUtils.java:3711–3912  ·  view source on GitHub ↗
(ArrayList<Kmer> kmers,
                                                    BloomFilterDeBruijnGraph graph, 
                                                    int lookahead,
                                                    int maxIndelSize,
                                                    float covThreshold,
                                                    float percentIdentity,
                                                    float minKmerCov)

Source from the content-addressed store, hash-verified

3709 }
3710
3711 public static ArrayList<Kmer> correctErrorHelper(ArrayList<Kmer> kmers,
3712 BloomFilterDeBruijnGraph graph,
3713 int lookahead,
3714 int maxIndelSize,
3715 float covThreshold,
3716 float percentIdentity,
3717 float minKmerCov) {
3718
3719
3720 boolean corrected = false;
3721 int numKmers = kmers.size();
3722
3723 int k = graph.getK();
3724 int numHash = graph.getMaxNumHash();
3725 int expectedGapSize = k;
3726
3727 ArrayList<Kmer> kmers2 = new ArrayList<>(numKmers + maxIndelSize);
3728 int numBadKmersSince = 0;
3729 Kmer kmer;
3730 for (int i=0; i<numKmers; ++i) {
3731 kmer = kmers.get(i);
3732
3733 if (kmer.count >= covThreshold) {
3734
3735 if (numBadKmersSince > 0) {
3736 if (kmers2.isEmpty()) {
3737 // check left edge
3738 ArrayDeque<Kmer> leftVars = kmers.get(i-1).getLeftVariants(k, numHash, graph, minKmerCov);
3739 if (leftVars.isEmpty()) {
3740 // no branches found
3741 for (int j=0; j<i; ++j) {
3742 kmers2.add(kmers.get(j));
3743 }
3744 }
3745 else if (numBadKmersSince >= lookahead) {
3746 // calculate median cov of edge kmers
3747 float[] tipCovs = new float[numBadKmersSince];
3748 for (int j=0; j<i; ++j) {
3749 tipCovs[j] = kmers.get(j).count;
3750 }
3751 float tipMedCov = getMedian(tipCovs);
3752
3753 ArrayDeque<Kmer> greedyTipKmers = greedyExtendLeft(graph, kmer, lookahead, numBadKmersSince);
3754 if (greedyTipKmers.size() == numBadKmersSince && getMedianKmerCoverage(greedyTipKmers) > tipMedCov) {
3755 if (getPercentIdentity(graph.assemble(greedyTipKmers), graph.assemble(kmers, 0, i)) >= percentIdentity){
3756 corrected = true;
3757 kmers2.addAll(greedyTipKmers);
3758 }
3759 else if (!kmers.get(0).hasPredecessors(k, numHash, graph) && numBadKmersSince < k) {
3760 // this is blunt end in graph
3761 // do not add its kmers
3762 corrected = true;
3763 }
3764 else {
3765 // use original sequence
3766 for (int j=0; j<i; ++j) {
3767 kmers2.add(kmers.get(j));
3768 }

Callers 2

correctErrorsSEMethod · 0.95
correctErrorsPEMethod · 0.95

Calls 15

greedyExtendLeftMethod · 0.95
getMedianKmerCoverageMethod · 0.95
toStringMethod · 0.95
getMaxCoveragePathMethod · 0.95
greedyExtendRightMethod · 0.95
correctMismatchesMethod · 0.95
getMaxNumHashMethod · 0.80
getMedianMethod · 0.80
getPercentIdentityMethod · 0.80
assembleMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected