Updated GO workflow. Options class test added. Reading the ontology takes too
long.
This commit is contained in:
parent
438dbd358b
commit
fb77ddb549
|
@ -5,6 +5,23 @@ import geneontology
|
||||||
from scipy import array, randn, log, ones
|
from scipy import array, randn, log, ones
|
||||||
import networkx
|
import networkx
|
||||||
|
|
||||||
|
EVIDENCE_CODES=[('IMP', 'Inferred from mutant phenotype'),
|
||||||
|
('IGI', 'Inferred from genetic interaction'),
|
||||||
|
('IPI', 'Inferred from physical interaction'),
|
||||||
|
('ISS', 'Inferred from sequence or structure similarity'),
|
||||||
|
('IDA', 'Inferred from direct assay'),
|
||||||
|
('IEP', 'Inferred on expression pattern'),
|
||||||
|
('IEA', 'Inferred from electronic annotation'),
|
||||||
|
('TAS', 'Traceable author statement'),
|
||||||
|
('NAS', 'Non-traceable author statement'),
|
||||||
|
('ND', 'No biological data available'),
|
||||||
|
('RCA', 'Inferred from reviewed computational analysis'),
|
||||||
|
('IC', 'Inferred by curator')]
|
||||||
|
|
||||||
|
DISTANCE_METRICS = [('resnik', 'Resnik'),
|
||||||
|
('jiang', 'Jiang & Conrath'),
|
||||||
|
('fussimeg', 'FuSSiMeG')]
|
||||||
|
|
||||||
class GoTermView (gtk.Frame):
|
class GoTermView (gtk.Frame):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
@ -13,8 +30,22 @@ class GoTermView (gtk.Frame):
|
||||||
self._table = tab
|
self._table = tab
|
||||||
|
|
||||||
self._name = gtk.Label('')
|
self._name = gtk.Label('')
|
||||||
tab.attach(gtk.Label('Name:'), 0, 1, 0, 1)
|
self._name.set_line_wrap(True)
|
||||||
tab.attach(self._name, 1, 2, 0, 1)
|
self._name.set_alignment(0, 0)
|
||||||
|
name_label = gtk.Label('Name:')
|
||||||
|
name_label.set_alignment(0, 0)
|
||||||
|
tab.attach(name_label, 0, 1, 0, 1, gtk.FILL, gtk.FILL, 5, 5)
|
||||||
|
tab.attach(self._name, 1, 2, 0, 1, gtk.FILL|gtk.EXPAND, gtk.FILL, 5, 5)
|
||||||
|
|
||||||
|
self._def = gtk.TextBuffer()
|
||||||
|
textview = gtk.TextView(self._def)
|
||||||
|
textview.set_wrap_mode(gtk.WRAP_WORD)
|
||||||
|
scrolled_window = gtk.ScrolledWindow()
|
||||||
|
scrolled_window.add(textview)
|
||||||
|
def_label = gtk.Label('Def:')
|
||||||
|
def_label.set_alignment(0.0, 0.0)
|
||||||
|
tab.attach(def_label, 0, 1, 1, 2, gtk.FILL, gtk.FILL, 5, 5)
|
||||||
|
tab.attach(scrolled_window, 1, 2, 1, 2, gtk.FILL|gtk.EXPAND, gtk.FILL|gtk.EXPAND, 5, 5)
|
||||||
|
|
||||||
self.add(tab)
|
self.add(tab)
|
||||||
self.set_go_term(None)
|
self.set_go_term(None)
|
||||||
|
@ -23,9 +54,11 @@ class GoTermView (gtk.Frame):
|
||||||
if term:
|
if term:
|
||||||
self.set_label(term['id'])
|
self.set_label(term['id'])
|
||||||
self._name.set_text(term['name'])
|
self._name.set_text(term['name'])
|
||||||
|
self._def.set_text(term['def'])
|
||||||
else:
|
else:
|
||||||
self.set_label('GO Term')
|
self.set_label('GO Term')
|
||||||
self._name.set_text('')
|
self._name.set_text('')
|
||||||
|
self._def.set_text('')
|
||||||
|
|
||||||
|
|
||||||
class GeneOntologyTree (gtk.HPaned):
|
class GeneOntologyTree (gtk.HPaned):
|
||||||
|
@ -77,6 +110,10 @@ class GoWorkflow (workflow.Workflow):
|
||||||
load.add_function(LoadAnnotationsFunction())
|
load.add_function(LoadAnnotationsFunction())
|
||||||
self.add_stage(load)
|
self.add_stage(load)
|
||||||
|
|
||||||
|
go = workflow.Stage('go', 'Gene Ontology')
|
||||||
|
go.add_function(GoDistanceFunction())
|
||||||
|
self.add_stage(go)
|
||||||
|
|
||||||
|
|
||||||
class LoadGOFunction(workflow.Function):
|
class LoadGOFunction(workflow.Function):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
@ -90,6 +127,7 @@ class LoadGOFunction(workflow.Function):
|
||||||
label.set_use_underline(True)
|
label.set_use_underline(True)
|
||||||
fluents.app['bottom_notebook'].append_page(browser, label)
|
fluents.app['bottom_notebook'].append_page(browser, label)
|
||||||
|
|
||||||
|
|
||||||
class LoadAnnotationsFunction(workflow.Function):
|
class LoadAnnotationsFunction(workflow.Function):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
@ -124,3 +162,118 @@ class LoadAnnotationsFunction(workflow.Function):
|
||||||
dialog.destroy()
|
dialog.destroy()
|
||||||
return [self.annotations]
|
return [self.annotations]
|
||||||
|
|
||||||
|
|
||||||
|
class EvidenceCodeFrame(gtk.Frame):
|
||||||
|
def __init__(self):
|
||||||
|
gtk.Frame.__init__(self, 'Evidence Codes')
|
||||||
|
|
||||||
|
self._ec_buttons = {}
|
||||||
|
|
||||||
|
vbox = gtk.VBox(len(EVIDENCE_CODES))
|
||||||
|
for code, desc in EVIDENCE_CODES:
|
||||||
|
btn = gtk.CheckButton('%s (%s)' % (code, desc))
|
||||||
|
self._ec_buttons[code] = btn
|
||||||
|
vbox.add(btn)
|
||||||
|
self.add(vbox)
|
||||||
|
|
||||||
|
def set_options(self, options):
|
||||||
|
for code, desc in EVIDENCE_CODES:
|
||||||
|
self._ec_buttons[code].set_active(options[code])
|
||||||
|
|
||||||
|
def update_options(self, options):
|
||||||
|
for code, desc in EVIDENCE_CODES:
|
||||||
|
options[code] = self._ec_buttons[code].get_active()
|
||||||
|
return options
|
||||||
|
|
||||||
|
|
||||||
|
class DistanceMetricFrame(gtk.Frame):
|
||||||
|
def __init__(self):
|
||||||
|
gtk.Frame.__init__(self, 'Distance Metrics')
|
||||||
|
|
||||||
|
self._metric_buttons = {}
|
||||||
|
|
||||||
|
vbox = gtk.VBox(len(DISTANCE_METRICS))
|
||||||
|
prev = None
|
||||||
|
for code, text in DISTANCE_METRICS:
|
||||||
|
btn = gtk.RadioButton(prev, '%s' % text)
|
||||||
|
self._metric_buttons[code] = btn
|
||||||
|
vbox.add(btn)
|
||||||
|
prev = btn
|
||||||
|
self.add(vbox)
|
||||||
|
|
||||||
|
def set_options(self, options):
|
||||||
|
self._metric_buttons[options['metric']].set_active(True)
|
||||||
|
|
||||||
|
def update_options(self, options):
|
||||||
|
for code, text in DISTANCE_METRICS:
|
||||||
|
if self._metric_buttons[code].get_active():
|
||||||
|
options['metric'] = code
|
||||||
|
return options
|
||||||
|
return options
|
||||||
|
|
||||||
|
|
||||||
|
class GoDistanceDialog(gtk.Dialog):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
gtk.Dialog.__init__(self, 'GO term distance matrix',
|
||||||
|
None,
|
||||||
|
gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
|
||||||
|
(gtk.STOCK_OK, gtk.RESPONSE_OK,
|
||||||
|
gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
|
||||||
|
|
||||||
|
self._ec_frame = EvidenceCodeFrame()
|
||||||
|
self._metric_frame = DistanceMetricFrame()
|
||||||
|
self.vbox.add(self._ec_frame)
|
||||||
|
self.vbox.add(self._metric_frame)
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
self.vbox.show_all()
|
||||||
|
return gtk.Dialog.run(self)
|
||||||
|
|
||||||
|
def set_options(self, options):
|
||||||
|
self._ec_frame.set_options(options)
|
||||||
|
self._metric_frame.set_options(options)
|
||||||
|
|
||||||
|
def update_options(self, options):
|
||||||
|
self._ec_frame.update_options(options)
|
||||||
|
self._metric_frame.update_options(options)
|
||||||
|
return options
|
||||||
|
|
||||||
|
def set_editable(self, editable):
|
||||||
|
self._ec_frame.set_sensitive(editable)
|
||||||
|
self._metric_frame.set_sensitive(editable)
|
||||||
|
|
||||||
|
|
||||||
|
class GoDistanceFunction(workflow.Function):
|
||||||
|
def __init__(self):
|
||||||
|
workflow.Function.__init__(self, 'go-dist', 'GO term distance matrix')
|
||||||
|
self.options = GoDistanceOptions()
|
||||||
|
|
||||||
|
def run(self, data):
|
||||||
|
self.options = self.show_gui(self.options)
|
||||||
|
|
||||||
|
def show_gui(self, options, edit=True):
|
||||||
|
dialog = GoDistanceDialog()
|
||||||
|
dialog.set_options(self.options)
|
||||||
|
dialog.show_all()
|
||||||
|
dialog.set_editable(edit)
|
||||||
|
response = dialog.run()
|
||||||
|
dialog.hide()
|
||||||
|
if response == gtk.RESPONSE_OK:
|
||||||
|
return dialog.update_options(self.options)
|
||||||
|
else:
|
||||||
|
return options
|
||||||
|
|
||||||
|
|
||||||
|
class Options(dict):
|
||||||
|
def __init__(self):
|
||||||
|
dict.__init__(self)
|
||||||
|
|
||||||
|
|
||||||
|
class GoDistanceOptions(Options):
|
||||||
|
def __init__(self):
|
||||||
|
Options.__init__(self)
|
||||||
|
for code, desc in EVIDENCE_CODES:
|
||||||
|
self[code] = True
|
||||||
|
self['metric'] = 'fussimeg'
|
||||||
|
|
||||||
|
|
Reference in New Issue