static void printFuncCall(FILE* file, struct func_call_t* funcCall) { fprintf(file, "<"); if (funcCall->funcPtr) printUStr(file, funcCall->ident); if (funcCall->fieldOfView) printChain(file, funcCall->fieldOfView); if (funcCall->subCall) { fprintf(file, "["); printChain(file, funcCall->subCall); fprintf(file, "]"); } fprintf(file, ">"); }
int main(){ int i, j; assert(signal(SIGINT, caught_signal) != SIG_ERR); mpz_init(total); for(i=0; i<X;i++){ for(j=0; j<X; j++){ prepcode[i][j]=Unknown; tcode[i][j]=0; } tate[i]=0; yoko[i]=0; } chaincont=0; chain_main(); dputs("Long overdue. This program will follow below steps."); printChain(); dputs("\nThe structure is this."); /*TODO: Can't use pfCode because the argument type is different.*/ /*Note that the argument type of pfCode was originaly enum trident.*/ for(i=0; i<X; i++){ for(j=0; j<X; j++){ if(!prepcode[j][i]) will_and_die("There still be Unknown in prepcode.", \ EXIT_FAILURE); printf("%c", prepcode[j][i]==1?'f':'a'); } putchar('\n'); } printf("Chaincount:%d\n", chaincont); for(i=0; i<Ceilings; i++) dned[i]=False; for(i=0; i<X; i++) sum_tate[i]=sum_yoko[i]=0; for(i=0; i<2; i++) sum_name[i]=0; follow(0); fputs("Total: ", stdout); mpz_out_str(stdout, BASE, total); putchar('\n'); mpz_clear(total); return 0; }
/* Recursively prints out the optimal chain in order. Counts hits and bps. */ unsigned int printChain(const Querymatch* matches, const int bestmatch, Info* info) { if(bestmatch == -1) { return 0; } else { info->hits = printChain(matches, matches[bestmatch].prec, info); info->hits++; Querymatch m = matches[bestmatch]; /* Count covered bps in ref and query */ info->query_bps_optimal = info->query_bps_optimal + m.querylen; /* print details */ printf("%lu\t%lu\t%lu\t%lu\n", m.queryseqnum, m.querystart_fwdstrand, m.queryend, m.score); return info->hits; } }
static void printChain(FILE* file, struct lterm_t* chain) { if (chain->tag != L_TERM_CHAIN_TAG) PRINT_AND_EXIT(DEBUG_PRINT_BAD_CHAIN); struct lterm_t* currTerm = chain->next; while (currTerm != chain) { switch (currTerm->tag) { case L_TERM_FRAGMENT_TAG : { printFragmentTogether(file, currTerm->fragment); break; } case L_TERM_CHAIN_KEEPER_TAG: { fprintf(file, "("); printChain(file, currTerm->chain); fprintf(file, ")"); break; } case L_TERM_FUNC_CALL: { printFuncCall(file, currTerm->funcCall); break; } default: PRINT_AND_EXIT(BAD_TAG_AT_ASSEMBLY); } currTerm = currTerm->next; } }
void printFieldOfView(FILE* file, struct lterm_t* fov) { printChain(file, fov); fprintf(file, "\n"); }
int main(int argc, char* argv[]) { unsigned int queryseqlen; Info* info; FILE* fp; char* filename; Querymatch* matches; unsigned int* match_num; if(argc != 3) { fprintf(stderr, "False number of arguments.\nUsage: " \ "[queryseqlength] [matches]\n"); return EXIT_FAILURE; } if (sscanf(argv[1], "%u", &queryseqlen) != 1) { fprintf(stderr, "error - sequence length argument is not an integer!"); return EXIT_FAILURE; } /* Get matches file */ filename = argv[2]; fp = fopen(filename, "r"); if(fp == NULL) { fprintf(stderr, "Could not load file (it's your fault): %s\n", filename); return EXIT_FAILURE; } info = malloc(sizeof(struct Info)); /* Initialize some important variables (use default struct setup?) */ info->query_bps_optimal = 0; info->query_bps_total = queryseqlen; /* space for match data in RAM -- extended by realloc later */ matches = malloc(sizeof(struct Querymatches_s)); match_num = malloc(sizeof(unsigned int)); matches = readQuerymatches(fp, matches, match_num); fclose(fp); /* sort matches by x-coordinate of end-point */ qsort(matches, *match_num, sizeof(Querymatch), compare); /* DEBUG PRINT */ int debug = 0; if(debug) { int i; for(i = 0; i < *match_num; i++) { Querymatch m = matches[i]; printf("%lu\t%lu\t%lu\t%lu\n", m.queryseqnum, m.querystart_fwdstrand, m.queryend, m.score); } return EXIT_SUCCESS; } unsigned int bestmatch = findOptimalScore(matches, match_num, info); info->hits = printChain(matches, bestmatch, info); printInfo(info); /* don't forget to free the enslaved RAM */ free(matches); free(match_num); free(info); return EXIT_SUCCESS; }