Validation on number of inputs added
This commit is contained in:
parent
a613f0a3fa
commit
56a6028547
|
@ -21,9 +21,10 @@ class NavigatorView (gtk.TreeView):
|
|||
# Selection Mode
|
||||
self.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
|
||||
self.get_selection().set_select_function(self.is_selectable)
|
||||
self.get_selection().connect('changed',self.selection_changed_handler)
|
||||
|
||||
# Setting up TextRenderers etc
|
||||
self.connect('cursor_changed', self.cursor_changed_handler)
|
||||
# self.connect('cursor_changed', self.cursor_changed_handler)
|
||||
self.connect('row_activated', self.row_activated_handler)
|
||||
|
||||
textrenderer = gtk.CellRendererText()
|
||||
|
@ -68,11 +69,8 @@ class NavigatorView (gtk.TreeView):
|
|||
return True
|
||||
|
||||
# selection changed, setting current_data ojbects
|
||||
def cursor_changed_handler(self, widget):
|
||||
|
||||
|
||||
|
||||
selection = widget.get_selection()
|
||||
def selection_changed_handler(self, selection):
|
||||
|
||||
model, paths = selection.get_selected_rows()
|
||||
|
||||
objs = [self.data_tree.get_value(self.data_tree.get_iter(path),2) for path in paths]
|
||||
|
@ -80,22 +78,11 @@ class NavigatorView (gtk.TreeView):
|
|||
if objs and isinstance(objs[0], dataset.Dataset):
|
||||
logger.log('debug', 'Selecting dataset')
|
||||
self.project.set_current_data(objs)
|
||||
else:
|
||||
logger.log('debug', 'Deselecting dataset')
|
||||
self.project.set_current_data([])
|
||||
|
||||
|
||||
# current object hasn't been added to selection yet, so we're adding it in
|
||||
cur_path, column = widget.get_cursor()
|
||||
|
||||
obj = model.get_value(model.get_iter(cur_path),2)
|
||||
objs = [model.get_value(model.get_iter(path), 2) for path in paths]
|
||||
|
||||
if (not obj in objs) and isinstance(obj, dataset.Dataset):
|
||||
objs += obj
|
||||
|
||||
if objs:
|
||||
if isinstance(objs[0], dataset.Dataset):
|
||||
logger.log('debug', 'Selecting dataset')
|
||||
self.project.set_current_data(objs)
|
||||
|
||||
# TreeView changed. Set correct focus and colours
|
||||
def row_changed_handler(self, treestore, pos, iter):
|
||||
obj = treestore.get_value(iter,2)
|
||||
|
|
|
@ -13,7 +13,7 @@ class Project:
|
|||
self.name = name
|
||||
self.dim_names = []
|
||||
self._selection_observers = []
|
||||
self.current_data = None
|
||||
self.current_data = []
|
||||
self.datasets = []
|
||||
self.sel_obj = dataset.Selection()
|
||||
|
||||
|
|
|
@ -114,12 +114,19 @@ class Function:
|
|||
self.id = id
|
||||
self.name = name
|
||||
|
||||
def valid_input(input):
|
||||
return True
|
||||
# ,ust return a Validation object
|
||||
def validate_input(input):
|
||||
return Validation(True,"Validation Not Implemented")
|
||||
|
||||
def run(self, data):
|
||||
def run(self):
|
||||
pass
|
||||
|
||||
class Validation:
|
||||
def __init__(self,result, reason):
|
||||
self.succeeded = result
|
||||
self.reason = reason
|
||||
|
||||
|
||||
class WorkflowView (gtk.VBox):
|
||||
|
||||
def __init__(self, wf):
|
||||
|
@ -162,10 +169,25 @@ class WorkflowView (gtk.VBox):
|
|||
project = self.workflow.app.project
|
||||
parent_data = project.current_data
|
||||
|
||||
new_data = function.run(project.current_data)
|
||||
validation = function.validate_input()
|
||||
|
||||
if not validation.succeeded:
|
||||
logger.log('warning','Invalid Inputdata: ' + str(reason))
|
||||
return
|
||||
|
||||
argcount =function.run.func_code.co_argcount - 1
|
||||
|
||||
if argcount != len(parent_data):
|
||||
logger.log('warning','Method requires ' + str(argcount) + ' Data. ' + str(len(parent_data)) + ' selected')
|
||||
return
|
||||
if not project.current_data:
|
||||
new_data = function.run()
|
||||
else:
|
||||
new_data = function.run(*project.current_data)
|
||||
|
||||
if new_data != None:
|
||||
project.add_data(parent_data, new_data, function.name)
|
||||
|
||||
|
||||
logger.log('debug', 'Function ended: %s' % function.name)
|
||||
|
||||
def button_click_handler(self, button):
|
||||
|
|
|
@ -31,7 +31,7 @@ class TestDataFunction(workflow.Function):
|
|||
def __init__(self):
|
||||
workflow.Function.__init__(self, 'test_data', 'Generate Test Data')
|
||||
|
||||
def run(self, data):
|
||||
def run(self):
|
||||
logger.log('notice', 'Injecting foo test data')
|
||||
x = randn(20,30)
|
||||
X = dataset.Dataset(x)
|
||||
|
@ -43,7 +43,7 @@ class DatasetLoadFunction(workflow.Function):
|
|||
def __init__(self):
|
||||
workflow.Function.__init__(self, 'load_data', 'Load Pickled Dataset')
|
||||
|
||||
def run(self, data):
|
||||
def run(self):
|
||||
chooser = gtk.FileChooserDialog(title="Select cel files...", parent=None,
|
||||
action=gtk.FILE_CHOOSER_ACTION_OPEN,
|
||||
buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
|
||||
|
@ -69,7 +69,7 @@ class DatasetSaveFunction(workflow.Function):
|
|||
def __init__(self):
|
||||
workflow.Function.__init__(self, 'save_data', 'Save Pickled Dataset')
|
||||
|
||||
def run(self, data):
|
||||
def run(self):
|
||||
if not data:
|
||||
logger.log("notice", "No data to save.")
|
||||
return
|
||||
|
@ -103,7 +103,7 @@ class CelFileImportFunction(workflow.Function):
|
|||
def __init__(self):
|
||||
workflow.Function.__init__(self, 'cel_import', 'Import Affy')
|
||||
|
||||
def run(self, (data,)):
|
||||
def run(self,data):
|
||||
import rpy
|
||||
chooser = gtk.FileChooserDialog(title="Select cel files...", parent=None,
|
||||
action=gtk.FILE_CHOOSER_ACTION_OPEN,
|
||||
|
@ -152,7 +152,7 @@ class PCAFunction(workflow.Function):
|
|||
workflow.Function.__init__(self, 'pca', 'PCA')
|
||||
self._workflow = wf
|
||||
|
||||
def run(self, (data,)):
|
||||
def run(self,data):
|
||||
import rpy
|
||||
|
||||
dim_2, dim_1 = data.get_dim_names()
|
||||
|
|
|
@ -65,7 +65,7 @@ class LoadAnnotationsFunction(workflow.Function):
|
|||
logger.log('notice', 'Reading file: %s' % dialog.get_filename())
|
||||
self.load_file(dialog.get_filename())
|
||||
|
||||
def run(self, data):
|
||||
def run(self):
|
||||
btns = ('Open', gtk.RESPONSE_OK, \
|
||||
'Cancel', gtk.RESPONSE_CANCEL)
|
||||
dialog = gtk.FileChooserDialog('Open GO Annotation File',
|
||||
|
@ -81,7 +81,7 @@ class GODistanceFunction(workflow.Function):
|
|||
workflow.Function.__init__(self, 'go_diatance', 'GO Distances')
|
||||
self.output = None
|
||||
|
||||
def run(self, (data,)):
|
||||
def run(self, data):
|
||||
logger.log('debug', 'datatype: %s' % type(data))
|
||||
if not type(data) == Annotations:
|
||||
return None
|
||||
|
@ -98,7 +98,7 @@ class TestDataFunction(workflow.Function):
|
|||
def __init__(self):
|
||||
workflow.Function.__init__(self, 'test_data', 'Generate Test Data')
|
||||
|
||||
def run(self, data):
|
||||
def run(self):
|
||||
logger.log('notice', 'Injecting foo test data')
|
||||
x = randn(20,30)
|
||||
X = dataset.Dataset(x)
|
||||
|
@ -108,7 +108,7 @@ class DatasetLog(workflow.Function):
|
|||
def __init__(self):
|
||||
workflow.Function.__init__(self, 'log', 'Log')
|
||||
|
||||
def run(self, (data,)):
|
||||
def run(self, data):
|
||||
logger.log('notice', 'Taking the log of dataset %s' % data.get_name())
|
||||
d = data.asarray()
|
||||
d = log(d)
|
||||
|
@ -121,7 +121,7 @@ class DatasetLoadFunction(workflow.Function):
|
|||
def __init__(self):
|
||||
workflow.Function.__init__(self, 'load_data', 'Load Pickled Dataset')
|
||||
|
||||
def run(self, data):
|
||||
def run(self):
|
||||
chooser = gtk.FileChooserDialog(title="Select cel files...", parent=None,
|
||||
action=gtk.FILE_CHOOSER_ACTION_OPEN,
|
||||
buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
|
||||
|
@ -147,7 +147,7 @@ class DatasetSaveFunction(workflow.Function):
|
|||
def __init__(self):
|
||||
workflow.Function.__init__(self, 'save_data', 'Save Pickled Dataset')
|
||||
|
||||
def run(self, data):
|
||||
def run(self):
|
||||
if not data:
|
||||
logger.log("notice", "No data to save.")
|
||||
return
|
||||
|
@ -180,7 +180,7 @@ class CelFileImportFunction(workflow.Function):
|
|||
def __init__(self):
|
||||
workflow.Function.__init__(self, 'cel_import', 'Import Affy')
|
||||
|
||||
def run(self, (data,)):
|
||||
def run(self, data):
|
||||
import rpy
|
||||
chooser = gtk.FileChooserDialog(title="Select cel files...", parent=None,
|
||||
action=gtk.FILE_CHOOSER_ACTION_OPEN,
|
||||
|
@ -229,7 +229,7 @@ class PCAFunction(workflow.Function):
|
|||
workflow.Function.__init__(self, 'pca', 'PCA')
|
||||
self._workflow = wf
|
||||
|
||||
def run(self, (data,)):
|
||||
def run(self, data):
|
||||
import rpy
|
||||
|
||||
dim_2, dim_1 = data.get_dim_names()
|
||||
|
|
|
@ -49,7 +49,7 @@ class LoadAnnotationsFunction(Function):
|
|||
logger.log('notice', 'Reading file: %s' % dialog.get_filename())
|
||||
self.load_affy_file(dialog.get_filename())
|
||||
|
||||
def run(self, (data,)):
|
||||
def run(self,data):
|
||||
btns = ('Open', gtk.RESPONSE_OK, \
|
||||
'Cancel', gtk.RESPONSE_CANCEL)
|
||||
dialog = gtk.FileChooserDialog('Open Affy Annotation File',
|
||||
|
@ -81,7 +81,7 @@ class PCAFunction(Function):
|
|||
self.output = None
|
||||
self.workflow = workflow
|
||||
|
||||
def run(self, (data,)):
|
||||
def run(self,data):
|
||||
logger.log('debug', 'datatype: %s' % type(data))
|
||||
if not isinstance(data,dataset.Dataset):
|
||||
return None
|
||||
|
@ -226,7 +226,7 @@ class LoadMoothaData(Function):
|
|||
def __init__(self):
|
||||
Function.__init__(self, 'load', 'Load diabetes data')
|
||||
|
||||
def run(self,(data,)):
|
||||
def run(self,data):
|
||||
data_file = open('full_data.pickle','r')
|
||||
data = pickle.load(data_file)
|
||||
data_file.close()
|
||||
|
@ -250,7 +250,7 @@ class Log2Function(Function):
|
|||
def __init__(self):
|
||||
Function.__init__(self, 'log', 'Log2')
|
||||
|
||||
def run(self,(data,)):
|
||||
def run(self,data):
|
||||
x = log2(data._array)
|
||||
#pull out identifiers
|
||||
ids = []
|
||||
|
|
Reference in New Issue