Fixed bug in ftsv save and open dialogs. The save dialog now looks as intended.
Added the possibility to load several datasets at once. Error handling should still be improved.
This commit is contained in:
parent
ea4c0af6de
commit
f612dda72f
|
@ -205,38 +205,42 @@ class NavigatorMenu(gtk.Menu):
|
||||||
|
|
||||||
def on_load_dataset(self, item, navigator):
|
def on_load_dataset(self, item, navigator):
|
||||||
dialog = gtk.FileChooserDialog('Load dataset')
|
dialog = gtk.FileChooserDialog('Load dataset')
|
||||||
|
dialog.set_action(gtk.FILE_CHOOSER_ACTION_OPEN)
|
||||||
dialog.add_buttons(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN, gtk.RESPONSE_OK)
|
dialog.add_buttons(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN, gtk.RESPONSE_OK)
|
||||||
|
dialog.set_select_multiple(True)
|
||||||
retval = dialog.run()
|
retval = dialog.run()
|
||||||
if retval in [gtk.RESPONSE_CANCEL, gtk.RESPONSE_DELETE_EVENT]:
|
if retval in [gtk.RESPONSE_CANCEL, gtk.RESPONSE_DELETE_EVENT]:
|
||||||
pass
|
pass
|
||||||
elif retval == gtk.RESPONSE_OK:
|
elif retval == gtk.RESPONSE_OK:
|
||||||
fd = open(dialog.get_filename())
|
for filename in dialog.get_filenames():
|
||||||
ds = dataset.read_ftsv(fd)
|
fd = open(filename)
|
||||||
fd.close()
|
ds = dataset.read_ftsv(fd)
|
||||||
|
fd.close()
|
||||||
|
|
||||||
if isinstance(ds, dataset.GraphDataset):
|
if isinstance(ds, dataset.GraphDataset):
|
||||||
icon = fluents.icon_factory.get("graph_dataset")
|
icon = fluents.icon_factory.get("graph_dataset")
|
||||||
elif isinstance(ds, dataset.CategoryDataset):
|
elif isinstance(ds, dataset.CategoryDataset):
|
||||||
icon = fluents.icon_factory.get("category_dataset")
|
icon = fluents.icon_factory.get("category_dataset")
|
||||||
else:
|
else:
|
||||||
icon = fluents.icon_factory.get("dataset")
|
icon = fluents.icon_factory.get("dataset")
|
||||||
|
|
||||||
project = navigator.project
|
project = navigator.project
|
||||||
project.add_dataset(ds)
|
project.add_dataset(ds)
|
||||||
project.data_tree_insert(None, ds.get_name(), ds, None, "black", icon)
|
project.data_tree_insert(None, ds.get_name(), ds, None, "black", icon)
|
||||||
else:
|
else:
|
||||||
print "unknown; ", retval
|
print "unknown; ", retval
|
||||||
dialog.destroy()
|
dialog.destroy()
|
||||||
|
|
||||||
def on_save_dataset(self, item, navigator):
|
def on_save_dataset(self, item, navigator):
|
||||||
dialog = gtk.FileChooserDialog('Save dataset')
|
dialog = gtk.FileChooserDialog('Save dataset')
|
||||||
|
dialog.set_action(gtk.FILE_CHOOSER_ACTION_SAVE)
|
||||||
dialog.add_buttons(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_SAVE, gtk.RESPONSE_OK)
|
dialog.add_buttons(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_SAVE, gtk.RESPONSE_OK)
|
||||||
|
dialog.set_current_name("%s.ftsv" % self.dataset.get_name())
|
||||||
retval = dialog.run()
|
retval = dialog.run()
|
||||||
if retval in [gtk.RESPONSE_CANCEL, gtk.RESPONSE_DELETE_EVENT]:
|
if retval in [gtk.RESPONSE_CANCEL, gtk.RESPONSE_DELETE_EVENT]:
|
||||||
print "Cancelled"
|
logger.log("debug", "Cancelled save dataset")
|
||||||
elif retval == gtk.RESPONSE_OK:
|
elif retval == gtk.RESPONSE_OK:
|
||||||
print "OK"
|
logger.log("debug", "Saving dataset as: %s" % dialog.get_filename())
|
||||||
print dialog.get_filename()
|
|
||||||
fd = open(dialog.get_filename(), 'w')
|
fd = open(dialog.get_filename(), 'w')
|
||||||
dataset.write_ftsv(fd, self.dataset)
|
dataset.write_ftsv(fd, self.dataset)
|
||||||
fd.close()
|
fd.close()
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import gtk
|
import gtk
|
||||||
from fluents import dataset, logger, plots, workflow, fluents
|
from fluents import dataset, logger, plots, workflow, fluents
|
||||||
|
from fluents.lib import blmfuncs
|
||||||
import geneontology
|
import geneontology
|
||||||
#import gostat
|
#import gostat
|
||||||
from scipy import array, randn, log, ones, zeros
|
from scipy import array, randn, log, ones, zeros
|
||||||
|
@ -123,6 +124,10 @@ class GoWorkflow (workflow.Workflow):
|
||||||
go.add_function(SaveDistancesFunction())
|
go.add_function(SaveDistancesFunction())
|
||||||
self.add_stage(go)
|
self.add_stage(go)
|
||||||
|
|
||||||
|
blm = workflow.Stage('blm', 'Bilinear Analysis')
|
||||||
|
blm.add_function(blmfuncs.PCA())
|
||||||
|
self.add_stage(blm)
|
||||||
|
|
||||||
|
|
||||||
class LoadGOFunction(workflow.Function):
|
class LoadGOFunction(workflow.Function):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
Reference in New Issue