Create Resnik distances and save them as ftsv.
This commit is contained in:
@@ -32,6 +32,7 @@ class GeneOntology(networkx.XDiGraph):
|
||||
def __init__(self):
|
||||
networkx.XDiGraph.__init__(self)
|
||||
self.by_id = {}
|
||||
self.undirected = None
|
||||
|
||||
def add_term(self, term):
|
||||
self.add_node(term)
|
||||
@@ -62,12 +63,12 @@ class GeneOntology(networkx.XDiGraph):
|
||||
|
||||
def subsumer(self, t1, t2):
|
||||
if t1 == t2:
|
||||
# print "t1 == t2"
|
||||
return t1
|
||||
|
||||
go_undir = self.to_undirected()
|
||||
# print go_undir.nodes()
|
||||
path = networkx.shortest_path(go_undir, t1, t2)
|
||||
if self.undirected == None:
|
||||
self.undirected = self.to_undirected()
|
||||
|
||||
path = networkx.shortest_path(self.undirected, t1, t2)
|
||||
if not path:
|
||||
print "Woah, path not found."
|
||||
return None
|
||||
@@ -76,12 +77,9 @@ class GeneOntology(networkx.XDiGraph):
|
||||
print "This shouldn't happen"
|
||||
return t1
|
||||
|
||||
# print t1['id'], t2['id'], path
|
||||
# print "path:", path
|
||||
for t in path:
|
||||
if networkx.shortest_path(self, t, t1) and \
|
||||
networkx.shortest_path(self, t, t2):
|
||||
# print " ", t1, t2, t
|
||||
return t
|
||||
|
||||
print "GeneOntology.subsumer: should not reach this point"
|
||||
|
Reference in New Issue
Block a user