From 97f56f66ace5787ab44d8e77c72ab7c4d2f5fcd7 Mon Sep 17 00:00:00 2001 From: tangstad Date: Fri, 5 May 2006 14:30:23 +0000 Subject: [PATCH] Added text-input for contrast-matrix creator for affymetrics workflow. --- system/dialogs.py | 27 +++++++++++++++++++++++++++ workflows/affy_workflow.py | 18 ++++++++++++++++-- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/system/dialogs.py b/system/dialogs.py index 807584c..32277a3 100644 --- a/system/dialogs.py +++ b/system/dialogs.py @@ -79,3 +79,30 @@ class CreateProjectDruid(gtk.Window): wf = self.workflows.get_value(it, 1) self.wf_info.set_text(wf.description) + +def get_text(title, text): + """Allow user to type in a string for text.""" + dlg = gtk.Dialog(title) + dlg.show() + + text = gtk.Label(text) + text.show() + + entry = gtk.Entry() + entry.show() + entry.set_activates_default(True) + dlg.vbox.pack_start(text) + dlg.vbox.pack_start(entry) + + dlg.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL) + dlg.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK) + dlg.set_default_response(gtk.RESPONSE_OK) + response = dlg.run() + + retval = None + + if response == gtk.RESPONSE_OK: + retval = entry.get_text() + dlg.destroy() + return retval + diff --git a/workflows/affy_workflow.py b/workflows/affy_workflow.py index 43fc40a..602e109 100644 --- a/workflows/affy_workflow.py +++ b/workflows/affy_workflow.py @@ -1,5 +1,5 @@ import gtk -from system import dataset, logger, plots, workflow +from system import dataset, logger, plots, workflow, dialogs from scipy import randn, array, transpose, zeros import cPickle @@ -17,6 +17,7 @@ class AffyWorkflow (workflow.Workflow): load.add_function(PhenotypeImportFunction()) load.add_function(TestDataFunction()) load.add_function(DatasetLoadFunction()) + load.add_function(ContrastMatrixGenerateFunction()) self.add_stage(load) explore = workflow.Stage('explore', 'Explorative analysis') @@ -103,7 +104,20 @@ class DatasetSaveFunction(workflow.Function): logger.log("notice", "Saved data to %r." % chooser.get_filename()) finally: chooser.destroy() - + + +class ContrastMatrixGenerateFunction(workflow.Function): + def __init__(self): + workflow.Function.__init__(self, 'contrast_create', 'Create contrast matrix') + + def run(self, data): + response = dialogs.get_text('Enter contrasts...', """\ +Enter comma-separated list of contrasts. +Available categories: %s + +Example: Y-N, M-F""" % ", ".join(data.get_categories())) + logger.log("notice", "contrasts selected: %s" % response) + class CelFileImportFunction(workflow.Function): """Loads Affymetrics .CEL-files into matrix."""