Projects/laydi
Projects
/
laydi
Archived
7
0
Fork 0

ontology distance script now accumulates annotations correctly.

This commit is contained in:
Einar Ryeng 2007-03-26 23:15:14 +00:00
parent 11eb3306b9
commit 728c334e8a
2 changed files with 52 additions and 17 deletions

View File

@ -9,6 +9,7 @@
void print_terms(); void print_terms();
void add_link(char*, char*); void add_link(char*, char*);
struct node* get_bp(); struct node* get_bp();
struct node* get_term(char *);
/* initialisation */ /* initialisation */
int godist_init() { int godist_init() {
@ -48,8 +49,26 @@ int godist_init() {
fclose(tree_fd); fclose(tree_fd);
printf(" %d edges\n", link_count); printf(" %d edges\n", link_count);
accumulate_evidence(get_bp()); for (i=0; i<term_array_size; i++) {
clear_flags(get_bp());
accumulate_evidence(term_array[i]);
printf(".");
}
print_term(get_bp()); print_term(get_bp());
print_term(get_term("GO:0040007"));
print_term(get_term("GO:0007275"));
print_term(get_term("GO:0007582"));
print_term(get_term("GO:0043473"));
print_term(get_term("GO:0000004"));
print_term(get_term("GO:0051704"));
print_term(get_term("GO:0000003"));
print_term(get_term("GO:0016032"));
print_term(get_term("GO:0009987"));
print_term(get_term("GO:0050896"));
print_term(get_term("GO:0050789"));
/* find_multi_parented();*/
} }
void godist_exit() { void godist_exit() {
@ -95,11 +114,7 @@ int godist_read_term(FILE *fd) {
e.key = n->term; e.key = n->term;
e.data = (void*)n; e.data = (void*)n;
res = hsearch(e, ENTER); res = hsearch(e, ENTER);
/* if (res);
printf("hash-insert: %s", ((struct node*)res->data)->term);
else
printf("hash-insert: error");
*/
term_array[term_array_size++] = n; term_array[term_array_size++] = n;
} }
@ -111,11 +126,6 @@ float go_distance(char *term1, char *term2) {
return 0.0; return 0.0;
} }
void add_node(char *term, int parentc, struct node **parents) {
}
void clear_flags(struct node *n) { void clear_flags(struct node *n) {
int i; int i;
for (i=0; i<n->childrenc; i++) for (i=0; i<n->childrenc; i++)
@ -152,20 +162,20 @@ void add_link(char *parent_id, char *child_id) {
} }
parent->children[parent->childrenc] = child; parent->children[parent->childrenc] = child;
parent->childrenc++; parent->childrenc++;
/* printf("adding %x as child of %x\n", child, parent);*/
child->parents[child->parentc] = parent; child->parents[child->parentc] = parent;
child->parentc++; child->parentc++;
} }
struct node *get_bp() { struct node *get_bp() {
return get_term("GO:0008150");
}
struct node *get_term(char *term) {
ENTRY e, *ep; ENTRY e, *ep;
e.key = "GO:0008150"; e.key = term;
ep = hsearch(e, FIND); ep = hsearch(e, FIND);
if (ep) { if (ep) {
/* printf("BP is %x and %s\n", (int) ep->data, ep->key);
printf("%d\n", ((struct node*)ep->data)->childrenc );
printf("%s\n", ((struct node*)ep->data)->term);*/
return ep->data; return ep->data;
} }
return NULL; return NULL;
@ -175,6 +185,7 @@ void accumulate_evidence(struct node *n) {
int i, j; int i, j;
if (n->visited) if (n->visited)
return; return;
n->visited = 1;
for (i=0; i<12; i++) for (i=0; i<12; i++)
n->acc_evidence[i] = n->evidence[i]; n->acc_evidence[i] = n->evidence[i];
@ -186,7 +197,6 @@ void accumulate_evidence(struct node *n) {
n->acc_evidence[j] += n->children[i]->acc_evidence[j]; n->acc_evidence[j] += n->children[i]->acc_evidence[j];
} }
} }
/* printf(".");*/
} }
void print_terms() { void print_terms() {
@ -211,3 +221,15 @@ void print_term(struct node *n) {
printf("\n"); printf("\n");
} }
void find_multi_parented() {
int i;
for (i=0; i<term_array_size; i++) {
if (term_array[i]->parentc > 1)
printf("%s -- %d\n", term_array[i]->term, term_array[i]->parentc);
}
}
float calc_ic(unsigned int evidence) {
}

View File

@ -7,6 +7,19 @@
#define MAX_PARENTS 100 #define MAX_PARENTS 100
#define MAX_CHILDREN 100 #define MAX_CHILDREN 100
enum EVIDENCE { MP = 1,
IGI = 1 << 1,
IPI = 1 << 2,
ISS = 1 << 3,
IDA = 1 << 4,
IEP = 1 << 5,
IEA = 1 << 6,
TAS = 1 << 7,
NAS = 1 << 8,
ND = 1 << 9,
RCA = 1 << 10,
IC = 1 << 11 };
struct node; struct node;
struct node { struct node {
/* GO term id. E.g: "GO:0005180" */ /* GO term id. E.g: "GO:0005180" */