Projects/laydi
Projects
/
laydi
Archived
7
0
Fork 0

* fluent: General cleanup.

This commit is contained in:
Einar Ryeng 2006-04-19 19:59:55 +00:00
parent 4541716f90
commit f45c9c6bf7
4 changed files with 42 additions and 26 deletions

31
fluent
View File

@ -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()

View File

@ -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()

View File

@ -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)

View File

@ -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