예제 #1
0
파일: view.py 프로젝트: smdabdoub/find
 def deleteSelection(self):
     """
     Delete the data object referenced by the current tree selection.
     """
     item = self.getSanitizedItemSelectionData()
     
     if item is None:
         return
     
     if item[0] is DATA_SET_ITEM:
         ids = (item[1], None) if len(item) < 3 else (item[1], item[2])
         self.Parent.TopLevelParent.facsPlotPanel.deleteAssociatedSubplots(ids)
         self.applyToSelection(DataStore.remove, FacsData.removeClustering)
         # if all data deleted, clear axes selectors
         if len(DataStore.getData()) == 0:
             self.Parent.TopLevelParent.updateAxesList([])
             
     if item[0] is FIGURE_SET_ITEM:
         id = item[1]
         
         #TODO: figure out if this is a good shortcut for clearing the figure of subplots
         if id == FigureStore.getSelectedIndex():
             wx.MessageBox('The currently selected Figure cannot be deleted.', 'Invalid Action', wx.OK | wx.ICON_WARNING)
         else:
             FigureStore.remove(id)
     
     self.updateTree()
예제 #2
0
파일: view.py 프로젝트: smdabdoub/find
 def buildFigureTree(self, root, figures):
     for id, fig in figures.iteritems():
         child = self.tree.AppendItem(root, fig.name)
         if (FigureStore.getSelectedIndex() == id):
             self.tree.SetItemBold(child, True)
         self.tree.SetPyData(child, (FIGURE_SET_ITEM, id))
         self.tree.SetItemImage(child, self.figureicn, wx.TreeItemIcon_Normal)
예제 #3
0
파일: view.py 프로젝트: smdabdoub/find
 def selectItemTreeSelection(self, rightClick=False):
     """
     Using the selected tree item, set the corresponding object 
     in the data store as the current selection.
     """
     item = self.getSanitizedItemSelectionData()
     
     if item is not None:
         if item[0] is DATA_SET_ITEM:
             self.applyToSelection(DataStore.selectDataSet, FacsData.selectClustering)
         
         if item[0] is FIGURE_SET_ITEM and not rightClick:
             if item[1] != FigureStore.getSelectedIndex():
                 currFig = FigureStore.getSelectedFigure()
                 newFig = FigureStore.get(item[1])
                 switchFigures(self.Parent.TopLevelParent.facsPlotPanel, currFig, newFig, True)
                 self.Parent.TopLevelParent.selectAxes(newFig.axes)
                 FigureStore.setSelectedFigure(item[1])
예제 #4
0
파일: io.py 프로젝트: smdabdoub/find
def saveState(dir, filename):
    """
    Save a representation of the system state: All the loaded data sets, 
    their clusterings, any transformations or analyses (future), 
    and all plots.
    
    The state is saved in JSON format based on a dict of the following form:
    
    data: list of IDs
    binfile: the filename of the binary file used to store all the actual data
    data-dID: dict of settings belonging to a FacsData instance
    clust-dID-cID: a dict of attributes belonging to a clustering
    figures: list of figureID strings
    fig-ID: A dict for each figure keyed on the ID. The subplot attribute here 
          is replaced with a list of fig-ID-p-ID strings for locating subplot dicts
    fig-ID-p-ID: A dict for each subplot in each figure keyed on fig ID and plot ID.
    current-data: data ID
    current-figure: figure ID
    """ 
    store = shelve.open(os.path.join(dir, filename))
    #store = dbopen(os.path.join(dir, filename), 'c', format='csv')
    # The actual numeric data will be stored in a separate binary file using
    # the numpy savez() method allowing for efficient storage/retrieval of data
    binfile = '%s.npz' % filename
    bindata = {}
    
    store['data'] = DataStore.getData().keys()
    store['binfile'] = binfile
    for dID in DataStore.getData():
        fdata = DataStore.get(dID)
        dStr = 'data-%i' % dID
        dfname = fdata.filename if (fdata.filename is not '') else binfile
        bindata[dStr] = fdata.data
        store[dStr] = {'filename':     dfname,
                       'displayname':  fdata.displayname, 
                       'labels':       fdata.labels, 
                       'annotations':  fdata.annotations, 
                       'analysis':     fdata.analysis, 
                       'ID':           fdata.ID,
                       'parent':       fdata.parent,
                       'children':     fdata.children,
                       'selDims':      fdata.selDims,
                       'clustering':   fdata.clustering.keys(),
                       'nodeExpanded': fdata.nodeExpanded,
                       'selectedClustering': fdata.selectedClustering}
        # clusterings
        for cID in fdata.clustering:
            cStr = 'clust-%i-%i' % (dID, cID)
            csett = {'method':            fdata.methodIDs[cID],
                     'opts':              fdata.clusteringOpts[cID],
                     'clusteringSelDims': fdata.clusteringSelDims[cID],
                     'infoExpanded':      fdata.infoExpanded[cID]}
            store[cStr] = csett
            bindata[cStr] = fdata.clustering[cID]
    
    
    # figures
    sfigs = []
    for figID in FigureStore.getFigures():
        fig = FigureStore.get(figID)
        fStr = 'fig-%i' % figID
        d = dict(fig.__dict__)
        splots = packSubplots(store, figID, fig.subplots)
        d['subplots'] = splots
        store[fStr] = d
        sfigs.append(fStr)        
        
    store['figures'] = list(sfigs)

    # other
    store['current-data'] = DataStore.getCurrentIndex()
    store['current-figure'] = FigureStore.getSelectedIndex()
    
    # write out settings data
    store.close()
    # write out numeric data to binary file
    np.savez(os.path.join(dir, binfile), **bindata)