From c4f9f5c3996dc3278825573acd42dcf937b69071 Mon Sep 17 00:00:00 2001 From: tangstad Date: Fri, 21 Apr 2006 13:04:31 +0000 Subject: [PATCH] Created new workflow for showing information about a dataset as a view. --- workflows/go_workflow.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/workflows/go_workflow.py b/workflows/go_workflow.py index fc93224..3c9987a 100644 --- a/workflows/go_workflow.py +++ b/workflows/go_workflow.py @@ -17,6 +17,7 @@ class EinarsWorkflow (Workflow): load = Stage('load', 'Load Data') load.add_function(Function('load', 'Load Microarrays')) load.add_function(TestDataFunction()) + load.add_function(DatasetInfoFunction()) self.add_stage(load) preproc = Stage('preprocess', 'Preprocessing') @@ -99,3 +100,37 @@ class TestDataFunction(Function): X = dataset.Dataset(x,[axis_0,axis_1]) return [X] + +class DatasetInfoFunction(Function): + def __init__(self): + Function.__init__(self, 'data_info', 'Show information') + + def run(self, data): + if data: + logger.log('notice', 'Generating view for %s.' % data.get_name()) + return [DatasetInfoView(data)] + else: + logger.log('notice', 'Not generating view... no data.') + return [] + + +class DatasetInfoView(plots.Plot): + def __init__(self, data): + plots.Plot.__init__(self, None) + + buf = gtk.TextBuffer() + buf_iter = buf.get_start_iter() + buf.insert(buf_iter, "Data: %s\n\n" % data.get_name()) + buf.insert(buf_iter, "Dimensions: ") + + dims = [] + for name in data.get_dim_names(): + dims.append((name, data.dims[data._dim_num[name]])) + + buf.insert(buf_iter, ", ".join(["%s (%d)" % dim for dim in dims])) + + area = gtk.TextView(buf) + area.connect('button_press_event', self.on_button_press) + area.set_editable(False) + self.add(area) + area.show()