From f45c9c6bf7cb9af73d19ebf8b26b4f7dd68bdc33 Mon Sep 17 00:00:00 2001 From: einarr Date: Wed, 19 Apr 2006 19:59:55 +0000 Subject: [PATCH] * fluent: General cleanup. --- fluent | 31 ++++++++++--------------------- system/project.py | 2 +- system/workflow.py | 11 ++++++++--- workflows/go_workflow.py | 24 +++++++++++++++++++++++- 4 files changed, 42 insertions(+), 26 deletions(-) diff --git a/fluent b/fluent index 63d4d60..234b5b7 100755 --- a/fluent +++ b/fluent @@ -12,6 +12,7 @@ import gtk.glade import gnome import gnome.ui import pango +import project import workflow import logger import plots @@ -21,7 +22,6 @@ import go_workflow PROGRAM_NAME = 'fluent' VERSION = '0.1.0' GLADEFILENAME = 'system/fluent.glade' -APP = 'appwindow' WF_BOX = 'workflow_vbox' DATA_BOX = 'data_vbox' @@ -32,8 +32,10 @@ class FluentApp: self.navigator = navigator.NavigatorStore() self.current_data = None + self.project = project.Project() + gtk.glade.set_custom_handler(self.custom_object_factory) - self.widget_tree = gtk.glade.XML(GLADEFILENAME, APP) + self.widget_tree = gtk.glade.XML(GLADEFILENAME, 'appwindow') self.workflow = go_workflow.EinarsWorkflow(self) def custom_object_factory(self, glade, function_name, widget_name,\ @@ -71,31 +73,15 @@ class FluentApp: self.init_gui() def init_gui(self): - self.app = self.widget_tree.get_widget(APP) - self.app.set_size_request(800, 600) + self['appwindow'].set_size_request(800, 600) # Set up workflow - wf_box = self.widget_tree.get_widget(WF_BOX) wf_menu = workflow.WorkflowView(self.workflow) wf_menu.show() - wf_box.pack_end(wf_menu) + self['workflow_vbox'].pack_end(wf_menu) - # Set up plots - pt = self.widget_tree.get_widget('small_view') - plot = plots.SinePlot() - plot.show() - plot.mark_active(True) - - plot2 = plots.ScatterPlot() - plot2.show() - - plot3 = plots.ScatterPlot() - plot3.show() - - # pt.set_child(plot, 0, 1) # Set up plot toolbar - dock = self.widget_tree.get_widget('plot_toolbar_dock') - dock.add(plot.get_toolbar(self.app)) +# self['plot_toolbar_dock'].add(plot.get_toolbar(self.app)) # Connect signals signals = {'on_quit1_activate' : (gtk.main_quit), @@ -128,6 +114,9 @@ class FluentApp: nb = self.widget_tree.get_widget('main_view') nb.goto_small() + def __getitem__(self, key): + return self.widget_tree.get_widget(key) + if __name__ == '__main__': gnome.program_init(PROGRAM_NAME, VERSION) app = FluentApp() diff --git a/system/project.py b/system/project.py index 6d840eb..36e454b 100644 --- a/system/project.py +++ b/system/project.py @@ -6,7 +6,7 @@ class Project: self.name = name self.dim_names = [] self._selection_observers = [] - self.current_data=[] + self.current_data=None self.datasets=[] self.sel_obj = dataset.Selection() diff --git a/system/workflow.py b/system/workflow.py index 6a980e0..85b7baa 100644 --- a/system/workflow.py +++ b/system/workflow.py @@ -87,9 +87,14 @@ class WorkflowView (gtk.VBox): exp.show() self.pack_start(exp, expand=False, fill=False) - def button_click_handler(self, button): - function = button.function + def run_function(self, function): logger.log('debug', 'Starting function: %s' % function.name) - function.run(self.workflow.app.current_data) + project = self.workflow.app.project + new_data = function.run(project.current_data) + if new_data != None: + project.current_data = new_data logger.log('debug', 'Function ended: %s' % function.name) + + def button_click_handler(self, button): + self.run_function(function = button.function) diff --git a/workflows/go_workflow.py b/workflows/go_workflow.py index 0808202..2bbf023 100644 --- a/workflows/go_workflow.py +++ b/workflows/go_workflow.py @@ -2,6 +2,9 @@ import gtk import logger from annotations import Annotations from workflow import * +import geneontology +import gostat +from scipy import array class EinarsWorkflow (Workflow): @@ -19,7 +22,7 @@ class EinarsWorkflow (Workflow): go = Stage('go', 'Gene Ontology Data') go.add_function(LoadAnnotationsFunction()) - go.add_function(Function('godist', 'GO Distances')) + go.add_function(GODistanceFunction()) self.add_stage(go) regression = Stage('regression', 'Regression') @@ -37,6 +40,7 @@ class LoadAnnotationsFunction(Function): def load_file(self, filename): f = open(filename) self.annotations = Annotations('genes', 'go-terms') + logger.log('notice', 'Loading annotation file: %s' % filename) for line in f.readlines(): val = line.split(' \t') @@ -61,3 +65,21 @@ class LoadAnnotationsFunction(Function): dialog.destroy() return [self.annotations] +class GODistanceFunction(Function): + + def __init__(self): + Function.__init__(self, 'go_diatance', 'GO Distances') + self.output = None + + def run(self, data): + logger.log('debug', 'datatype: %s' % type(data)) + if not type(data) == Annotations: + return None + + logger.log('debug', 'dimensions: %s' % data.dimensions) + + genes = data.get_ids('genes') + gene_distances = array((len(genes), len(genes))) + + return gene_distances +