void SGEdgeStatsVisitor::postvisit(StringGraph* /*pGraph*/) { printf("FoundOverlaps\n"); printCounts(foundCounts); printf("\nPotentially Missing Overlaps\n\n"); printCounts(missingCounts); }
int main(int argSize, char ** argArray) { unsigned firstArg = 1, files, i, totalLines = 0, totalWords = 0, totalCharacters = 0; char operator = 'a'; FILE * filePointer; Result * results, totalResults; //Determine the operator, if any if (argSize > 1 && argArray[1][0] == '-') { switch (argArray[1][1]) { case 'l': case 'w': case 'c': operator = argArray[1][1]; default: firstArg = 2; } } //Calculate the results from either input or files if (firstArg == argSize) { files = 1; results = (Result *)malloc(files * sizeof(Result)); results[0] = calculateCounts(stdin, ""); } else { files = argSize - firstArg; results = (Result *)malloc(files * sizeof(Result)); for (i = 0; i < files; i++) { filePointer = fopen(argArray[firstArg + i], "r"); results[i] = calculateCounts(filePointer, argArray[firstArg + i]); } } //Output the results for (i = 0; i < files; i++) { printCounts(results[i], operator); totalLines += results[i].lines; totalWords += results[i].words; totalCharacters += results[i].characters; } //Print the total results if there are more than 1 files if (files > 1) { totalResults.lines = totalLines; totalResults.words = totalWords; totalResults.characters = totalCharacters; totalResults.fileName = "Total"; printCounts(totalResults, operator); } free(results); return 0; }
void print( const PlayerT & player ) { if ( player.state_ ) { std::cout << "<Player side=\"" << player.side_ << "\""; std::cout << " unum=\"" << player.unum_ << "\""; std::cout << " type=\"" << player.type_ << "\""; if ( player.state_ != 1 ) std::cout << " mode=\"" << player.state_ << "\""; std::cout << ">\n"; printPos( player.x_, player.y_ ); printVel( player.vx_, player.vy_ ); printAngles( player.body_, player.neck_ ); printView( player.view_width_, player.view_quality_ == 'h' ); printStamina( player.stamina_, player.effort_, player.recovery_ ); printCounts( player.kick_count_, player.dash_count_, player.turn_count_, player.say_count_, player.turn_neck_count_, player.catch_count_, player.move_count_, player.change_view_count_ ); std::cout << "</Player>\n"; } }
int hubTrackSettings(char *hubUrl, struct hash *totals) /* Read hub trackDb files, noting settings used. If hubUrl is NULL, do this for * all public hubs */ { if (hubUrl != NULL) return oneHubTrackSettings(hubUrl, totals); // Get all urls from hubPublic table struct sqlConnection *conn = hConnectCentral(); char query[1024]; // NOTE: don't bother with site-local names for these tables /* sqlSafef(query, sizeof(query), "select hubUrl from %s where hubUrl not in (select hubUrl from %s)\n", defaultHubPublicTableName, defaultHubStatusTableName); */ sqlSafef(query, sizeof(query), "select hubUrl from %s where shortLabel not like '%%Test%%'", defaultHubPublicTableName); struct slName *hub, *hubs = sqlQuickList(conn, query); int errs = 0; for (hub = hubs; hub != NULL; hub = hub->next) { errs += oneHubTrackSettings(hub->name, totals); } if (totals) printCounts(totals); return errs; }
void getCountMagic(char* word) { int i; int k; int sizeword = strlen(word); for (i = 0; i < sizeword; i++) { k = word[i] - 97; counts_magic[k]++; } counts_magic[14] = (counts_magic[14] * 0.5); printCounts(counts_magic, 30); return; }
int main(int argc, char ** argv) { //WRITE ME (plus add appropriate error checking!) if (argc == 1){ fprintf(stderr, "Please input a valid File!\n"); exit (EXIT_FAILURE); } FILE * file1 = fopen(argv[1], "r"); if (file1 == NULL){ fprintf(stderr, "File does not exist!\n"); exit (EXIT_FAILURE); } if (fclose(file1) != 0){ fprintf(stderr, "Failed to close file!\n"); exit (EXIT_FAILURE); } //read the key/value pairs from the file named by argv[1] (call the result kv) kvarray_t * kvs = readKVs(argv[1]); //count from 2 to argc (call the number you count i) for (int i = 2; i < argc; i++) { //count the values that appear in the file named by argv[i], using kv as the key/value pair // (call this result c) FILE * file2 = fopen(argv[i], "r"); if (file2 == NULL){ fprintf(stderr, "File does not exist!\n"); exit (EXIT_FAILURE); } if (fclose(file2) != 0){ fprintf(stderr, "Failed to close file!\n"); } counts_t * c = countFile(argv[i], kvs); //compute the output file name from argv[i] (call this outName) char * outName = computeOutputFileName(argv[i]); //open the file named by outName (call that f) FILE * f = fopen(outName,"w"); //print the counts from c into the FILE f printCounts(c,f); //close f fclose(f); //free the memory for outName and c free(outName); freeCounts(c); } //free the memory for kv freeKVs(kvs); return EXIT_SUCCESS; }
void getCount(char* word) { int i; int sizeword = strlen(word); for (i = 0; i < sizeword; i++) { char letter = word[i]; switch(letter) { case 'f': counts[0]++; break; case 'a': counts[1]++; break; case 'c': counts[2]++; break; case 'e': counts[3]++; break; case 'b': counts[4]++; break; case 'o': counts[5] = (counts[5] + 0.5); break; case 'k': counts[6]++; break; default: break; } } printCounts(counts, 7); return; }
int oneHubTrackSettings(char *hubUrl, struct hash *totals) /* Read hub trackDb files, noting settings used */ { struct trackHub *hub = NULL; struct errCatch *errCatch = errCatchNew(); if (errCatchStart(errCatch)) hub = trackHubOpen(hubUrl, "hub_0"); errCatchEnd(errCatch); errCatchFree(&errCatch); if (hub == NULL) return 1; printf("%s (%s)\n", hubUrl, hub->shortLabel); struct trackHubGenome *genome; struct hash *counts; if (totals) counts = totals; else counts = newHash(0); struct hashEl *el; for (genome = hub->genomeList; genome != NULL; genome = genome->next) { struct trackDb *tdb, *tdbs = trackHubTracksForGenome(hub, genome); for (tdb = tdbs; tdb != NULL; tdb = tdb->next) { struct hashCookie cookie = hashFirst(trackDbHashSettings(tdb)); verbose(2, " track: %s\n", tdb->shortLabel); while ((el = hashNext(&cookie)) != NULL) { int count = hashIntValDefault(counts, el->name, 0); count++; hashReplace(counts, el->name, intToPt(count)); } } } if (!totals) printCounts(counts); trackHubClose(&hub); return 0; }
// If there is a simple undefeated Condorcet winner, that is enough. Return the winner. static int VRR_plainCondorcet( VRR* it, int winnersLength, NameVote** winnersP, int** defeatCountP ) { int* defeatCount; int i; defeatCount = (int*)malloc( sizeof(int)*it->numc ); assert( defeatCount != NULL ); if ( debug ) { printCounts( stdout, it ); } countDefeats( it, defeatCount ); for ( i = 0; i < it->numc; i++ ) { if ( defeatCount[i] == 0 ) { // winner VRR_makeWinners( it, defeatCount ); free( defeatCount ); return VRR_returnWinners( it, winnersLength, winnersP ); } } *defeatCountP = defeatCount; return -1; }
VOID Fini(INT32 code, VOID *v) { UINT32 status = 0; if (icount[0] != icount[1]) { out << "***Mismatch in total instructions : Before " << dec << icount[0] << " After " << dec << icount[1] << endl; status = 1; } UINT32 expectedCounts[5]; for (UINT32 i=0; i<5; i++) expectedCounts[i] = 0; for (UINT32 j=0; j<=icount[0]; j++) { for (UINT32 i=0; i<5; i++) { if (j & (1<<i)) { expectedCounts[i]++; } } } for (UINT32 i=0; i<5; i++) { if (icountBits[i] != expectedCounts[i]) { out << "*** Bit counts failed : " << dec << i << " expected " << expectedCounts[i] << " see " <<icountBits[i] << endl; } } printCounts(); out.close(); _exit(status); }
int main(int argc, char ** argv) { int i; if(argc<=2) { fprintf(stderr,"The no. of inputs are less"); return EXIT_FAILURE; } kvarray_t *kv=readKVs(argv[1]); if(kv->length==-1) { printf("Couldn't open file!"); return EXIT_FAILURE; } if(kv->length==-2) { printf("Couldn't close file"); return EXIT_FAILURE; } //WRITE ME (plus add appropriate error checking!) //read the key/value pairs from the file named by argv[1] (call the result kv) for(i=2;i<argc;i++) { counts_t *c=countFile(argv[i],kv); //count the values that appear in the file named by argv[i], using kv as the key/value pair // (call this result c) char *outName = computeOutputFileName(argv[i]);//compute the output file name from argv[i] (call this outName) FILE *f = fopen(outName,"w");//open the file named by outName (call that f) printCounts(c,f);//print the counts from c into the FILE f if(fclose(f)!=0) { fprintf(stderr,"Couldn't close file!"); return EXIT_FAILURE; }//close f free(outName); freeCounts(c); //free the memory for outName and c } freeKVs(kv); //free the memory for kv return EXIT_SUCCESS; }
int main(int argSize, char ** argArray) { unsigned firstArg = 1, files, i, totalLines = 0, totalWords = 0, totalCharacters = 0; int process, descriptors[2]; char operator = 'a'; FILE * filePointer; Result result, totalResults; //Set up the pipe pipe(descriptors); //Determine the operator, if any if (argSize > 1 && argArray[1][0] == '-') { switch (argArray[1][1]) { case 'l': case 'w': case 'c': operator = argArray[1][1]; default: firstArg = 2; } } //Calculate the results from either input or files if (firstArg == argSize) { files = 1; process = fork(); if (process == 0) { result = calculateCounts(stdin, ""); write(descriptors[1], &result, sizeof(result)); exit(0); } } else { files = argSize - firstArg; for (i = 0; i < files; i++) { process = fork(); if (process == 0) { filePointer = fopen(argArray[firstArg + i], "r"); result = calculateCounts(filePointer, argArray[firstArg + i]); write(descriptors[1], &result, sizeof(result)); exit(0); } } } wait(0); //Output the results for (i = 0; i < files; i++) { read(descriptors[0], &result, sizeof(result)); printCounts(result, operator); totalLines += result.lines; totalWords += result.words; totalCharacters += result.characters; } //Print the total results if there are more than 1 files if (files > 1) { totalResults.lines = totalLines; totalResults.words = totalWords; totalResults.characters = totalCharacters; totalResults.fileName = "Total"; printCounts(totalResults, operator); } return 0; }
void abcCounts::print(funkyPars *pars){ if(pars->numSites==0) return; if(dumpCounts) printCounts(header->target_name[pars->refId],pars->posi,pars->counts,pars->numSites,pars->nInd,bpos,bbin,dumpCounts,pars->keepSites); if(bbin.l>0) aio::bgzf_write(oFileCountsBin,bbin.s,bbin.l);bbin.l=0; if(bpos.l>0) aio::bgzf_write(oFileCountsPos,bpos.s,bpos.l);bpos.l=0; if(doQsDist) countQs(pars->chk,qsDist,pars->keepSites,minQ); if(doDepth!=0){ assert(pars->counts!=NULL); for(int s=0;s<pars->numSites;s++) { if(pars->keepSites[s]==0) continue; for(int i=0;i<pars->nInd;i++){ int sum=0; for(int a=0;a<4;a++) sum+=pars->counts[s][i*4+a]; if(sum>maxDepth){ sum=maxDepth; } depthCount[i][sum]++; } } //thorfinn below for(int s=0;s<pars->numSites;s++) { if(pars->keepSites[s]==0) continue; int sum=0; for(int i=0;i<4*pars->nInd;i++){ sum+=pars->counts[s][i]; if(sum>maxDepth){ sum=maxDepth; } } globCount[sum]++; } } if(iCounts==1){ for(int s=0;s<pars->numSites;s++) { if(pars->keepSites[s]==0) continue; int cnt[4]; for(int i=0;i<4;i++) cnt[i] = pars->counts[s][i]; int p = pars->posi[s]+1; aio::bgzf_write(oFileIcounts,&p,sizeof(int)); // new aio::bgzf_write(oFileIcounts,cnt,sizeof(int)*4); // new } } if(iCounts==2){ for(int s=0;s<pars->chk->nSites;s++){ // fprintf(stderr,"TT: %d %d\n",pars->chk->nd[s][0].l2,pars->chk->nd[s][0].deletion); if(pars->keepSites[s]==0||pars->chk->nd==NULL||pars->chk->nd[s][0]->l2||pars->chk->nd[s][0]->deletion) continue; int count[4]={0,0,0,0}; //loop over persample reads for(int l=0;pars->chk->nd[s][0]&&l<pars->chk->nd[s][0]->l;l++){ int allele = refToInt[pars->chk->nd[s][0]->seq[l]]; int tmp=lookup[pars->chk->nd[s][0]->seq[l]]; #if 0 fprintf(stderr,"l:%d b:%c qs:%d\n",l,pars->chk->nd[s][0].seq[l],pars->chk->nd[s][0].qs[l]); #endif if(allele==4)//skip of 'n'/'N' continue; if(qfileFname&&pars->chk->nd[s][0]->qs[l]<=qCutoff[tmp]) //skip if we are using qscores and we are below continue; // if q score bin to sample from: count if sampled if(pars->chk->nd[s][0]->qs[l]==qCutoff[tmp]+1){ double x =drand48(); //fprintf(stderr,"skipping\n"); if(x>=fCutoff[tmp]) count[tmp%5]++; }else // if in q score bigger: always count count[tmp%5]++; } if(1||count[0]+ count[1]+count[2]+count[3]){ int p = pars->posi[s]+1; aio::bgzf_write(oFileIcounts,&p,sizeof(int)); // new aio::bgzf_write(oFileIcounts,count,sizeof(int)*4); // new } } } }