void mem_pestat(const mem_opt_t *opt, int64_t l_pac, int n, const mem_alnreg_v *regs, mem_pestat_t pes[4]) { int i, d, max; uint64_v isize[4]; memset(pes, 0, 4 * sizeof(mem_pestat_t)); memset(isize, 0, sizeof(kvec_t(int)) * 4); /* infer based on the first reg from the two reads */ for (i = 0; i < n>>1; ++i) { int dir; int64_t is; mem_alnreg_v *r[2]; r[0] = (mem_alnreg_v*)®s[i<<1|0]; r[1] = (mem_alnreg_v*)®s[i<<1|1]; if (r[0]->n == 0 || r[1]->n == 0) continue; if (cal_sub(opt, r[0]) > MIN_RATIO * r[0]->a[0].score) continue; if (cal_sub(opt, r[1]) > MIN_RATIO * r[1]->a[0].score) continue; if (r[0]->a[0].rid != r[1]->a[0].rid) continue; // not on the same chr if (r[0]->a[0].bss != r[1]->a[0].bss) continue; /* not on the same bisulfite strand */ dir = mem_infer_dir(l_pac, r[0]->a[0].rb, r[1]->a[0].rb, &is); if (is && is <= opt->max_ins) kv_push(uint64_t, isize[dir], is); } if (bwa_verbose >= 3) fprintf(stderr, "[M::%s] # candidate unique pairs for (FF, FR, RF, RR): (%ld, %ld, %ld, %ld)\n", __func__, isize[0].n, isize[1].n, isize[2].n, isize[3].n); for (d = 0; d < 4; ++d) { // TODO: this block is nearly identical to the one in bwtsw2_pair.c. It would be better to merge these two. mem_pestat_t *r = &pes[d]; uint64_v *q = &isize[d]; int p25, p50, p75, x; if (q->n < MIN_DIR_CNT) { fprintf(stderr, "[M::%s] skip orientation %c%c as there are not enough pairs\n", __func__, "FR"[d>>1&1], "FR"[d&1]); r->failed = 1; free(q->a); continue; } else fprintf(stderr, "[M::%s] analyzing insert size distribution for orientation %c%c...\n", __func__, "FR"[d>>1&1], "FR"[d&1]);
int main(int argc, char **argv) { double time_spent; /* To add time */ int time_spent_m, time_spent_s; /* To add time */ time_t begin, end; /* To add time */ int i, r, n1, n2; int rounds, maxnum; /* rounds is how many iterations of the game there will be maxnum is the biggest values used in the sums */ int score = 0; /* initial settings for rounds & turns */ rounds = (argv[1] && isdigit(argv[1][0])) ? atoi(argv[1]) : ROUNDS; maxnum = (argv[2] && isdigit(argv[2][0])) ? atoi(argv[2]) : MAXNUM; /* start the timer */ begin = time(NULL); /* return HOWTO instead of play */ if(argv[1] && (argv[1][0] == 'h')){ help(); return 0; } /* the main dispach switch */ srand ( (unsigned)time ( NULL ) ); for(i = 0; i < rounds; i++){ r = rand() % 4; n1 = rand() % maxnum; n2 = rand() % maxnum; switch(r){ case 0: /* addition */ score += cal_add(n1, n2); break; case 1: /* subtraction - call function with biggest number first, so we don't need to have negatives in the answer */ score += (n1 >= n2) ? cal_sub(n1, n2) : cal_sub(n2, n1); break; case 2: /* multiplication */ score += cal_mul(n1, n2); break; case 3: /* division - we avoid 0 in the division, just to simplify things like subtraction, we also use the bigger val divided by the smaller */ while(n1 == 0 || n2 == 0){ n1 = rand() % MAXNUM; n2 = rand() % MAXNUM; } score += (n1 >= n2) ? cal_div(n1, n2) : cal_sub(n2, n1); break; default: /* catch imposible */ printf("Something isn't working rights\n"); return 0; } } /* end timer */ end = time(NULL); time_spent = difftime(end, begin); time_spent_m = (int)(time_spent)/60; time_spent_s = (int)(time_spent)%60; /* Report */ printf("\n"); printf("You got %d out of %d in %d ", score, rounds, time_spent_m); printf("%s", (time_spent_m == 1)?"minute":"minutes"); printf(", %d ", time_spent_s); printf("%s", (time_spent_s == 1)?"second":"seconds"); if((rounds - score) < 4){ printf("!"); } else{ printf("."); } printf("\n\n"); return 0; }