Small updates.

This commit is contained in:
2007-01-12 10:50:55 +00:00
parent ae3aa7e4aa
commit 58886726d8
2 changed files with 35 additions and 4 deletions

View File

@@ -61,7 +61,29 @@ class GeneOntology(networkx.XDiGraph):
"""Returns the root node of the molecular_function tree"""
return self.by_id['GO:0003674']
def _subsumer(self, t1, t2, heap):
while heap != []:
t = heap[0]
heap = heap[1:]
p1 = networkx.shortest_path(self, t, t1)
p2 = networkx.shortest_path(self, t, t2)
if p1 and p2:
return t
heap += self.in_neighbors(t)
return None
def subsumer(self, t1, t2):
if t1 == t2:
return t1
if networkx.shortest_path(self, t1, t2):
return t1
elif networkx.shortest_path(self, t2, t1):
return t2
return self._subsumer(t1, t2, self.in_neighbors(t1))
def old_subsumer(self, t1, t2):
if t1 == t2:
return t1
@@ -83,6 +105,8 @@ class GeneOntology(networkx.XDiGraph):
return t
print "GeneOntology.subsumer: should not reach this point"
print "path is now: %s" % path
print "ids are: %s " % [x['id'] for x in path]
def _split_obo_line(line):
"""Splits a line from an obo file in its three constituent parts.