Small updates.
This commit is contained in:
parent
ae3aa7e4aa
commit
58886726d8
|
@ -61,7 +61,29 @@ class GeneOntology(networkx.XDiGraph):
|
||||||
"""Returns the root node of the molecular_function tree"""
|
"""Returns the root node of the molecular_function tree"""
|
||||||
return self.by_id['GO:0003674']
|
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):
|
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:
|
if t1 == t2:
|
||||||
return t1
|
return t1
|
||||||
|
|
||||||
|
@ -83,6 +105,8 @@ class GeneOntology(networkx.XDiGraph):
|
||||||
return t
|
return t
|
||||||
|
|
||||||
print "GeneOntology.subsumer: should not reach this point"
|
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):
|
def _split_obo_line(line):
|
||||||
"""Splits a line from an obo file in its three constituent parts.
|
"""Splits a line from an obo file in its three constituent parts.
|
||||||
|
|
|
@ -277,8 +277,11 @@ class SelectGoTermsFunction(workflow.Function):
|
||||||
workflow.Function.__init__(self, 'go-select', 'Select GO Terms')
|
workflow.Function.__init__(self, 'go-select', 'Select GO Terms')
|
||||||
self.wf = wf
|
self.wf = wf
|
||||||
|
|
||||||
def run(self):
|
def run(self, ds):
|
||||||
self.wf.project.set_selection('go-terms', set(['GO:0007582', 'GO:0008150', 'GO:0051704', 'GO:0044419']))
|
terms = [x['id'] for x in networkx.paths.bfs(go, go.get_bp())]
|
||||||
|
|
||||||
|
self.wf.project.set_selection('go-terms', set(terms[:100]))
|
||||||
|
# self.wf.project.set_selection('go-terms', set(['GO:0007582', 'GO:0008150', 'GO:0051704', 'GO:0044419']))
|
||||||
|
|
||||||
|
|
||||||
class GoDistanceFunction(workflow.Function):
|
class GoDistanceFunction(workflow.Function):
|
||||||
|
@ -296,7 +299,11 @@ class GoDistanceFunction(workflow.Function):
|
||||||
term1 = go.by_id[t1]
|
term1 = go.by_id[t1]
|
||||||
term2 = go.by_id[t2]
|
term2 = go.by_id[t2]
|
||||||
subsumer = go.subsumer(term1, term2)
|
subsumer = go.subsumer(term1, term2)
|
||||||
print "%s - %s - %s" % (t1, subsumer['id'], t2)
|
|
||||||
|
if subsumer == None:
|
||||||
|
m[i, j] = 1000
|
||||||
|
else:
|
||||||
|
# print "%s - %s - %s" % (t1, subsumer['id'], t2)
|
||||||
m[i, j] = ic[t1] + ic[t2] - 2.0 * ic[subsumer['id']]
|
m[i, j] = ic[t1] + ic[t2] - 2.0 * ic[subsumer['id']]
|
||||||
ds = dataset.Dataset(m, (('go-terms', ids), ('_go-terms', ids)), 'Resnik')
|
ds = dataset.Dataset(m, (('go-terms', ids), ('_go-terms', ids)), 'Resnik')
|
||||||
return ds
|
return ds
|
||||||
|
|
Reference in New Issue