diff --git a/scripts/geneontology/go-distance/godist.c b/scripts/geneontology/go-distance/godist.c index 90770bd..3369667 100644 --- a/scripts/geneontology/go-distance/godist.c +++ b/scripts/geneontology/go-distance/godist.c @@ -71,6 +71,9 @@ int godist_init() { total_ann += n->acc_evidence[i]; printf("Using %d annotations.\n", total_ann); + print_term(get_term("GO:0006006")); + print_term(get_term("GO:0019318")); + print_term(get_term("GO:0005996")); print_term(get_bp()); /* print_term(get_term("GO:0040007")); @@ -155,10 +158,12 @@ float go_distance(char *term1, char *term2) { } void clear_flags(struct node *n) { - int i; - for (i=0; ichildrenc; i++) - clear_flags(n->children[i]); - n->visited = 0; + int i, j; + for (i=0; ivisited = 0; + for (j=0; j<12; j++) + term_array[i]->temp_acc[j] = 0; + } } void add_link(char *parent_id, char *child_id) { @@ -210,19 +215,27 @@ struct node *get_term(char *term) { } void accumulate_evidence(struct node *n) { + int i; + acc_ev(n); + for (i=0; i<12; i++) { + n->acc_evidence[i] = n->temp_acc[i]; + } +} + +void acc_ev(struct node *n) { int i, j; if (n->visited) return; n->visited = 1; for (i=0; i<12; i++) - n->acc_evidence[i] = n->evidence[i]; + n->temp_acc[i] = n->evidence[i]; for (i=0; i<(n->childrenc); i++) { if (!n->children[i]->visited) { - accumulate_evidence(n->children[i]); + acc_ev(n->children[i]); for (j=0; j<12; j++) - n->acc_evidence[j] += n->children[i]->acc_evidence[j]; + n->temp_acc[j] += n->children[i]->temp_acc[j]; } } } @@ -270,7 +283,7 @@ void calc_ic(struct node *n, unsigned int evidence) { if (evidence & 1<acc_evidence[i]; n->ic = -log(ann/total_ann); - printf("%f\n", n->ic); + /* printf("%f\n", n->ic);*/ } struct node *common_subsumer(struct node *n1, struct node *n2) { @@ -288,7 +301,7 @@ struct node *common_subsumer(struct node *n1, struct node *n2) { if ((!retval) || (anc1[i]->ic > retval->ic)) retval = anc1[i]; if (retval) - printf("Retval: %s\n", retval->term); + ;// printf("Retval: %s\n", retval->term); else printf("No value to return"); return retval; @@ -313,9 +326,13 @@ float resnik(struct node *n1, struct node *n2) { int read_terms(FILE *fd, struct node *terms[], int *termc) { char term[11]; int retval; + printf("read_terms\n"); retval = fscanf(fd, " %10s ", term); - if (retval != EOF) { - terms[*termc++] = get_term(term); + while (retval != EOF) { + printf("."); + fflush(stdout); + terms[(*termc)++] = get_term(term); + retval = fscanf(fd, " %10s ", term); } return retval; } @@ -326,11 +343,15 @@ void build_dataset() { int i, j; FILE *fd = fopen("dimension", "r"); + read_terms(fd, terms, &termc); - for (int i=0; i