go-distance seems to be able to calculate resnik now. Not asserted with
calculations by hand.
This commit is contained in:
parent
28f0f53e8a
commit
fefaffb2e3
|
@ -13,6 +13,7 @@ struct node* get_bp();
|
||||||
struct node* get_term(char *);
|
struct node* get_term(char *);
|
||||||
void calc_ic(struct node *, unsigned int);
|
void calc_ic(struct node *, unsigned int);
|
||||||
struct node *common_subsumer(struct node *, struct node *);
|
struct node *common_subsumer(struct node *, struct node *);
|
||||||
|
float resnik(struct node *, struct node *);
|
||||||
|
|
||||||
|
|
||||||
/* initialisation */
|
/* initialisation */
|
||||||
|
@ -91,6 +92,11 @@ int godist_init() {
|
||||||
/* calc_ic(get_bp(), 0xffff);*/
|
/* calc_ic(get_bp(), 0xffff);*/
|
||||||
/* find_multi_parented();*/
|
/* find_multi_parented();*/
|
||||||
common_subsumer(get_term("GO:0000003"), get_term("GO:0000004"));
|
common_subsumer(get_term("GO:0000003"), get_term("GO:0000004"));
|
||||||
|
/** should return go:0016032 */
|
||||||
|
common_subsumer(get_term("GO:0019081"), get_term("GO:0050434"));
|
||||||
|
|
||||||
|
printf("Resnik: %f\n", resnik(get_term("GO:0000003"), get_term("GO:0000004")));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void godist_exit() {
|
void godist_exit() {
|
||||||
|
@ -271,10 +277,21 @@ struct node *common_subsumer(struct node *n1, struct node *n2) {
|
||||||
struct node *anc1[MAX_NODES];
|
struct node *anc1[MAX_NODES];
|
||||||
struct node *anc2[MAX_NODES];
|
struct node *anc2[MAX_NODES];
|
||||||
int ancc1=0, ancc2=0;
|
int ancc1=0, ancc2=0;
|
||||||
|
int i, j;
|
||||||
|
struct node *retval=NULL;
|
||||||
|
|
||||||
add_ancestors(&ancc1, anc1, n1);
|
add_ancestors(&ancc1, anc1, n1);
|
||||||
add_ancestors(&ancc2, anc2, n2);
|
add_ancestors(&ancc2, anc2, n2);
|
||||||
printf("Ancestors: %d %d\n", ancc1, ancc2);
|
for (i=0; i<ancc1; i++)
|
||||||
|
for (j=0; j<ancc2; j++)
|
||||||
|
if (anc1[i] == anc2[j])
|
||||||
|
if ((!retval) || (anc1[i]->ic > retval->ic))
|
||||||
|
retval = anc1[i];
|
||||||
|
if (retval)
|
||||||
|
printf("Retval: %s\n", retval->term);
|
||||||
|
else
|
||||||
|
printf("No value to return");
|
||||||
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_ancestors(int *ancc, struct node *anc[], struct node *n) {
|
void add_ancestors(int *ancc, struct node *anc[], struct node *n) {
|
||||||
|
@ -285,5 +302,10 @@ void add_ancestors(int *ancc, struct node *anc[], struct node *n) {
|
||||||
}
|
}
|
||||||
|
|
||||||
float resnik(struct node *n1, struct node *n2) {
|
float resnik(struct node *n1, struct node *n2) {
|
||||||
|
struct node *subsumer = common_subsumer(n1, n2);
|
||||||
|
if (!subsumer)
|
||||||
|
return 20;
|
||||||
|
else
|
||||||
|
return n1->ic + n2->ic - 2.0 * subsumer->ic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in New Issue