// If there has been significant progress, display it. void printStatus(unsigned current_value) { if (current_value >= m_next_threshold) { m_next_threshold += m_percent_interval; printPercent(current_value / static_cast<double>(m_max_value) * 100.); } if (current_value + 1 == m_max_value) std::cout << " 100%" << std::endl; }
void dupeFoo(char *pslName, char *faName, char *regionFile) /* dupeFoo - Do some duplication analysis. */ { struct lineFile *lf; struct frag *fragList = NULL, *frag; struct hash *fragHash = newHash(16); struct psl *psl; int fragCount=0,missCount=0,dupeCount=0,kSub=0, k1=0, k10=0,k100=0,k1000=0,k10000=0,diffChrom=0,distance; /* Read in fragment list and put it in hash. */ fragList = readFragList(faName); for (frag = fragList; frag != NULL; frag = frag->next) hashAdd(fragHash, frag->name, frag); /* Read psl's and store under the fragment the belong to. */ lf = pslFileOpen(pslName); while ((psl = pslNext(lf)) != NULL) { if ((frag = hashFindVal(fragHash, psl->qName)) == NULL) errAbort("Couldn't find %s in %s line %d of %s", psl->qName, faName, lf->lineIx, lf->fileName); slAddHead(&frag->pslList, psl); } lineFileClose(&lf); /* Look through fragments and report missing and dupes. */ for (frag = fragList; frag != NULL; frag = frag->next) { ++fragCount; if ((psl = frag->pslList) == NULL) { ++missCount; printf("missing %s\n", frag->name); } else { for (psl = frag->pslList; psl != NULL; psl = psl->next) { if (sameString(psl->tName, frag->chrom)) { distance = frag->start - psl->tStart; if (distance != 0) { if (distance < 0) distance = -distance; if (distance >= 10000000) ++k10000; else if (distance >= 1000000) ++k1000; else if (distance >= 100000) ++k100; else if (distance >= 10000) ++k10; else if (distance >= 1000) ++k1; else ++kSub; } } else { ++diffChrom; } } } } printPercent("Total", fragCount, fragCount); printPercent("Unaligned", missCount, fragCount); printPercent("Other Chrom", diffChrom, fragCount); printPercent("Same Chrom >10M", k10000, fragCount); printPercent("Same Chrom >1M", k1000, fragCount); printPercent("Same Chrom >10Ok", k100, fragCount); printPercent("Same Chrom >1Ok", k10, fragCount); printPercent("Same Chrom >1k", k1, fragCount); printPercent("Self-overlap", kSub, fragCount); writeRegions(fragList, regionFile); }