From c55a39f7f91bb03e0cf45af72f1b41a1c738b690 Mon Sep 17 00:00:00 2001 From: einarr Date: Mon, 17 Apr 2006 20:29:29 +0000 Subject: [PATCH] * workflows/go_workflow.py: A workflow that makes distance matrices based on gene ontology information. Currently only reads gene annotations. --- workflows/go_workflow.py | 63 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 workflows/go_workflow.py diff --git a/workflows/go_workflow.py b/workflows/go_workflow.py new file mode 100644 index 0000000..0808202 --- /dev/null +++ b/workflows/go_workflow.py @@ -0,0 +1,63 @@ +import gtk +import logger +from annotations import Annotations +from workflow import * + +class EinarsWorkflow (Workflow): + + def __init__(self, app): + Workflow.__init__(self, app) + self.name = 'Einar\'s Workflow' + + load = Stage('load', 'Load Data') + load.add_function(Function('load', 'Load Microarrays')) + self.add_stage(load) + + preproc = Stage('preprocess', 'Preprocessing') + preproc.add_function(Function('rma', 'RMA')) + self.add_stage(preproc) + + go = Stage('go', 'Gene Ontology Data') + go.add_function(LoadAnnotationsFunction()) + go.add_function(Function('godist', 'GO Distances')) + self.add_stage(go) + + regression = Stage('regression', 'Regression') + regression.add_function(Function('pls', 'PLS')) + self.add_stage(regression) + + logger.log('debug', '\tEinar\'s workflow is now active') + +class LoadAnnotationsFunction(Function): + + def __init__(self): + Function.__init__(self, 'load-go-ann', 'Load Annotations') + self.annotations = None + + def load_file(self, filename): + f = open(filename) + self.annotations = Annotations('genes', 'go-terms') + + for line in f.readlines(): + val = line.split(' \t') + + if len(val) > 1: + val = [v.strip() for v in val] + retval.add_annotations('genes', val[0], + 'go-terms', set(val[1:])) + + def on_response(self, dialog, response): + if response == gtk.RESPONSE_OK: + logger.log('notice', 'Reading file: %s' % dialog.get_filename()) + self.load_file(dialog.get_filename()) + + def run(self, data): + btns = ('Open', gtk.RESPONSE_OK, \ + 'Cancel', gtk.RESPONSE_CANCEL) + dialog = gtk.FileChooserDialog('Open GO Annotation File', + buttons=btns) + dialog.connect('response', self.on_response) + dialog.run() + dialog.destroy() + return [self.annotations] +