示例#1
0
    def __init__(self, parent):
        QObject.__init__(self)
        grid = OWGUI.widgetBox(parent, "", orientation = "horizontal")
        grid.setMinimumWidth(250)
        grid.setMinimumHeight(100)

        self.boxes = [ OWGUI.listBox(grid, self) for a in range(2) ]

        for box in self.boxes: 
            #box.setSelectionMode(QListWidget.SingleSelection)
            box.setSelectionMode(QListWidget.MultiSelection)

        self.connect(self.boxes[0], SIGNAL("itemSelectionChanged ()"), self.highlighted1)
        self.connect(self.boxes[1], SIGNAL("itemSelectionChanged ()"), self.highlighted2)

        self.classes = []

        def createSquarePixmap(color = Qt.black):
            return OWGUI.createAttributePixmap("", color)

        self.whiteSq = createSquarePixmap(Qt.white)
        self.marked = [ createSquarePixmap(Qt.red), createSquarePixmap(Qt.blue) ]

        self.classVals = []
示例#2
0
    def __init__(self, parent=None, signalManager = None, name='GSEA'):
        OWWidget.__init__(self, parent, signalManager, name)

        self.inputs = [("Examples", ExampleTable, self.setData)]
        self.outputs = [("Examples with selected genes only", ExampleTable), ("Results", ExampleTable), ("Distance Matrix", orange.SymMatrix) ]

        self.res = None
        self.dm = None
        
        self.name = 'GSEA'
        self.minSubsetSize = 3
        self.minSubsetSizeC = True
        self.maxSubsetSize = 1000
        self.maxSubsetSizeC = True
        self.minSubsetPart = 10
        self.minSubsetPartC = True
        self.perms = 100
        self.csgm = False
        self.gsgo = False
        self.gskegg = False
        self.buildDistances = False
        self.selectedPhenVar = 0
        self.organismIndex = 0
        self.atLeast = 3

        self.permutationTypes =  [("Phenotype", "p"),("Gene", "g") ]
        self.ptype = 0

        self.correlationTypes = [ ("Signal2Noise", "s2n") ]
        self.ctype = 0
        
        self.data = None
        self.geneSets = {}

        self.tabs = OWGUI.tabWidget(self.controlArea)

        ca = OWGUI.createTabPage(self.tabs, "Basic")

        box = OWGUI.widgetBox(ca, 'Organism')
        #FROM KEGG WIDGET - organism selection
        self.organismTaxids = []
        self.organismComboBox = cb = OWGUI.comboBox(box, self, "organismIndex", items=[], debuggingEnabled=0) #changed
        cb.setMaximumWidth(200)

        #OWGUI.checkBox(box, self, "csgm", "Case sensitive gene matching")

        box2 = OWGUI.widgetBox(ca, "Descriptors")
        self.phenCombo = OWGUI.comboBox(box2, self, "selectedPhenVar", items=[], callback=self.phenComboChange, label="Phenotype:")
        self.geneCombo = OWGUI.comboBox(box2, self, "selectedGeneVar", items=[], label = "Gene:")

        self.allowComboChangeCallback = False

        ma = self.mainArea

        self.listView = QTreeWidget(ma)
        ma.layout().addWidget(self.listView)
        self.listView.setAllColumnsShowFocus(1)
        self.listView.setColumnCount(9)
        self.listView.setHeaderLabels(["Collection", "Geneset", "NES", "ES", "P-value", "FDR", "Size", "Matched Size", "Genes"])
        
        self.listView.header().setStretchLastSection(True)
        self.listView.header().setClickable(True)
        self.listView.header().setSortIndicatorShown(True)
        self.listView.setSortingEnabled(True)
        #self.listView.header().setResizeMode(0, QHeaderView.Stretch)
        
        self.listView.setSelectionMode(QAbstractItemView.NoSelection)
        self.connect(self.listView, SIGNAL("itemSelectionChanged()"), self.newPathwaySelected)

        OWGUI.separator(ca)

        OWGUI.widgetLabel(ca, "Phenotype selection:")
        self.psel = PhenotypesSelection(ca)
        
        self.resize(600,50)
 
        OWGUI.separator(ca)

        OWGUI.checkBox(ca, self, "buildDistances", "Compute geneset distances")

        self.btnApply = OWGUI.button(ca, self, "&Compute", callback = self.compute, disabled=0)
        
        fileBox = OWGUI.widgetBox(ca, orientation='horizontal')
        OWGUI.button(fileBox, self, "Load", callback = self.loadData, disabled=0, debuggingEnabled=0)
        OWGUI.button(fileBox, self, "Save", callback = self.saveData, disabled=0, debuggingEnabled=0)
 
        #ca.layout().addStretch(1)

        ca = OWGUI.createTabPage(self.tabs, "Gene sets")
        
        box = OWGUI.widgetBox(ca)

        self.gridSel = []
        self.geneSel = []  #FIXME temporary disabled - use the same as in new "David" widget
        self.lbgs = OWGUI.listBox(box, self, "gridSel", "geneSel", selectionMode = QListWidget.MultiSelection)
        OWGUI.button(box, self, "From &File", callback = self.addCollection, disabled=0, debuggingEnabled=0)

        box = OWGUI.widgetBox(box, "Additional sources:")
        OWGUI.checkBox(box, self, "gskegg", "KEGG pathways")
        OWGUI.checkBox(box, self, "gsgo", "GO terms")
 
        #ca.layout().addStretch(1)

        ca = OWGUI.createTabPage(self.tabs, "Settings")
        box = OWGUI.widgetBox(ca, 'Properties')

        self.permTypeF = OWGUI.comboBoxWithCaption(box, self, "ptype", items=nth(self.permutationTypes, 0), \
            tooltip="Permutation type.", label="Permute")
        _ = OWGUI.spin(box, self, "perms", 50, 1000, orientation="horizontal", label="Times")
        self.corTypeF = OWGUI.comboBoxWithCaption(box, self, "ctype", items=nth(self.correlationTypes, 0), \
            tooltip="Correlation type.", label="Correlation")


        box = OWGUI.widgetBox(ca, 'Subset Filtering')

        _,_ = OWGUI.checkWithSpin(box, self, "Min. Subset Size", 1, 10000, "minSubsetSizeC", "minSubsetSize", "") #TODO check sizes
        _,_ = OWGUI.checkWithSpin(box, self, "Max. Subset Size", 1, 10000, "maxSubsetSizeC", "maxSubsetSize", "")
        _,_ = OWGUI.checkWithSpin(box, self, "Min. Subset Part (%)", 1, 100, "minSubsetPartC", "minSubsetPart", "")

        box = OWGUI.widgetBox(ca, 'Gene Filtering')

        _ = OWGUI.spin(box, self, "atLeast", 2, 10, label="Min. Values in Group")

        ca.layout().addStretch(1)

        self.addComment("Computation was not started.")

        if sys.platform == "darwin":
            self.loadFileName = os.path.expanduser("~/")
        else:
            self.loadFileName = "."

        self.gridSels = []
        self.loadSettings()

        self.setBlocking(True)
        QTimer.singleShot(0, self.UpdateOrganismComboBox)

        def cleanInvalid(maxn):
            """
            Removes invalid gene set selection
            """
            notAllOk = True

            while notAllOk:
                self.gridSels = getattr(self, "gridSels")
                notAllOk = False
                for i,a in enumerate(self.gridSels):
                    if a >= maxn:
                        self.gridSels.pop(i)
                        notAllOk = True
                        break
        
        cleanInvalid(len(self.geneSel))

        self.gridSel = self.gridSels
        self.gridSels = self.gridSel
    def __init__(self, parent=None, signalManager = None):
#        self.callbackDeposit = [] # deposit for OWGUI callback functions
        OWWidget.__init__(self, parent, signalManager, 'Expression Profiles', 1)

        #set default settings
        self.ShowAverageProfile = 1
        self.ShowSingleProfiles = 0
        self.PointWidth = 2
        self.CurveWidth = 1
        self.AverageCurveWidth = 4
        self.BoxPlotWidth = 2
        self.SelectedClasses = []
        self.Classes = []
        self.autoSendSelected = 0
        self.selectionChangedFlag = False

        self.CutLow = 0; self.CutHigh = 0; self.CutEnabled = 0
        
        self.profileLabel = None

        #load settings
        self.loadSettings()

        # GUI
        self.graph = profilesGraph(self, self.mainArea, "")
        self.mainArea.layout().addWidget(self.graph)
        self.graph.hide()
        self.connect(self.graphButton, SIGNAL("clicked()"), self.graph.saveToFile)

        # GUI definition
        self.tabs = OWGUI.tabWidget(self.space)

        # GRAPH TAB
        GraphTab = OWGUI.createTabPage(self.tabs, "Graph")

        ## display options
        self.infoLabel = OWGUI.widgetLabel(OWGUI.widgetBox(GraphTab, "Info"), "No data on input.")
        displayOptBox = OWGUI.widgetBox(GraphTab, "Display") #QVButtonGroup("Display", GraphTab)
        displayOptButtons = ['Majority Class', 'Majority Class Probability', 'Target Class Probability', 'Number of Instances']
        OWGUI.checkBox(displayOptBox, self, 'ShowSingleProfiles', 'Expression Profiles', tooltip='', callback=self.updateShowSingleProfiles)
        OWGUI.checkBox(displayOptBox, self, 'ShowAverageProfile', 'Box Plot', tooltip='', callback=self.updateShowAverageProfile)

        ## class selection (classQLB)
        self.classQVGB = OWGUI.widgetBox(GraphTab, "Classes") #QVGroupBox(GraphTab)
##        self.classQVGB.setTitle("Classes")
        self.classQLB = OWGUI.listBox(self.classQVGB, self, "SelectedClasses", "Classes", selectionMode=QListWidget.MultiSelection, callback=self.classSelectionChange) #QListBox(self.classQVGB)
##        self.classQLB.setSelectionMode(QListBox.Multi)
        self.unselectAllClassedQLB = OWGUI.button(self.classQVGB, self, "Unselect all", callback=self.SUAclassQLB) #QPushButton("(Un)Select All", self.classQVGB)
##        self.connect(self.unselectAllClassedQLB, SIGNAL("clicked()"), self.SUAclassQLB)
##        self.connect(self.classQLB, SIGNAL("selectionChanged()"), self.classSelectionChange)

        ## show single/average profile
##        self.showAverageQLB = QPushButton("Box Plot", self.classQVGB)
##        self.showAverageQLB.setToggleButton(1)
##        self.showAverageQLB.setOn(self.ShowAverageProfile)
##        self.showSingleQLB = QPushButton("Single Profiles", self.classQVGB)
##        self.showSingleQLB.setToggleButton(1)
##        self.showSingleQLB.setOn(self.ShowSingleProfiles)
##        self.connect(self.showAverageQLB, SIGNAL("toggled(bool)"), self.updateShowAverageProfile)
##        self.connect(self.showSingleQLB, SIGNAL("toggled(bool)"), self.updateShowSingleProfiles)

##        self.tabs.insertTab(GraphTab, "Graph")

        # SETTINGS TAB
        SettingsTab = OWGUI.createTabPage(self.tabs, "Settings") #QVGroupBox(self)

        self.profileLabelComboBox = OWGUI.comboBox(SettingsTab, self, 'profileLabel', 'Profile Labels', sendSelectedValue=True, valueType=str)
        OWGUI.hSlider(SettingsTab, self, 'PointWidth', box='Point Width', minValue=0, maxValue=9, step=1, callback=self.updatePointWidth, ticks=1)
        OWGUI.hSlider(SettingsTab, self, 'CurveWidth', box='Profile Width', minValue=1, maxValue=9, step=1, callback=self.updateCurveWidth, ticks=1)
        OWGUI.hSlider(SettingsTab, self, 'AverageCurveWidth', box='Average Profile Width', minValue=1, maxValue=9, step=1, callback=self.updateAverageCurveWidth, ticks=1)
        OWGUI.hSlider(SettingsTab, self, 'BoxPlotWidth', box='Box Plot Width', minValue=0, maxValue=9, step=1, callback=self.updateBoxPlotWidth, ticks=1)
        OWGUI.checkBox(SettingsTab, self, 'graph.renderAntialiased', "Render antialiased", callback=self.graph.setCurveRenderHints)


    ## graph y scale
        box = OWGUI.widgetBox(SettingsTab, "Threshold/ Values") #QVButtonGroup("Threshol/ Values", SettingsTab)
        OWGUI.checkBox(box, self, 'CutEnabled', "Enabled", callback=self.setCutEnabled)
        self.sliderCutLow = OWGUI.qwtHSlider(box, self, 'CutLow', label='Low:', labelWidth=33, minValue=-20, maxValue=0, step=0.1, precision=1, ticks=0, maxWidth=80, callback=self.updateYaxis)
        self.sliderCutHigh = OWGUI.qwtHSlider(box, self, 'CutHigh', label='High:', labelWidth=33, minValue=0, maxValue=20, step=0.1, precision=1, ticks=0, maxWidth=80, callback=self.updateYaxis)
        if not self.CutEnabled:
            self.sliderCutLow.box.setDisabled(1)
            self.sliderCutHigh.box.setDisabled(1)

##        self.tabs.insertTab(SettingsTab, "Settings")

        self.toolbarSelection = ZoomSelectToolbar(self, self.controlArea, self.graph, self.autoSendSelected, buttons=(ZoomSelectToolbar.IconZoom, ZoomSelectToolbar.IconPan, ZoomSelectToolbar.IconSelect, ZoomSelectToolbar.IconSpace,
                                                                       ZoomSelectToolbar.IconRemoveLast, ZoomSelectToolbar.IconRemoveAll, ZoomSelectToolbar.IconSendSelection))
        cb = OWGUI.checkBox(self.controlArea, self, "autoSendSelected", "Auto send on selection change")
        OWGUI.setStopper(self, self.toolbarSelection.buttonSendSelections, cb, "selectionChangedFlag", self.commit)
        
        # inputs
        # data and graph temp variables
        
        self.inputs = [("Examples", ExampleTable, self.data, Default + Multiple)]
        self.outputs = [("Examples", ExampleTable, Default)]

        # temp variables
        self.MAdata = []
        self.classColor = None
        self.classBrighterColor = None
        self.numberOfClasses  = 0
        self.classValues = []
        self.ctrlPressed = False
        self.attrIcons = self.createAttributeIconDict()

        self.graph.canvas().setMouseTracking(1)

#        self.zoomStack = []
##        self.connect(self.graph,
##                     SIGNAL('plotMousePressed(const QMouseEvent&)'),
##                     self.onMousePressed)
##        self.connect(self.graph,
##                     SIGNAL('plotMouseReleased(const QMouseEvent&)'),
##                     self.onMouseReleased)
        self.resize(800,600)
示例#4
0
    def __init__(self, parent=None, signalManager=None):
        #        self.callbackDeposit = [] # deposit for OWGUI callback functions
        OWWidget.__init__(self, parent, signalManager, 'Expression Profiles',
                          1)

        #set default settings
        self.ShowAverageProfile = 1
        self.ShowSingleProfiles = 0
        self.PointWidth = 2
        self.CurveWidth = 1
        self.AverageCurveWidth = 4
        self.BoxPlotWidth = 2
        self.SelectedClasses = []
        self.Classes = []
        self.autoSendSelected = 0
        self.selectionChangedFlag = False

        self.CutLow = 0
        self.CutHigh = 0
        self.CutEnabled = 0

        self.profileLabel = None

        #load settings
        self.loadSettings()

        # GUI
        self.graph = profilesGraph(self, self.mainArea, "")
        self.mainArea.layout().addWidget(self.graph)
        self.graph.hide()
        self.connect(self.graphButton, SIGNAL("clicked()"),
                     self.graph.saveToFile)

        # GUI definition
        self.tabs = OWGUI.tabWidget(self.space)

        # GRAPH TAB
        GraphTab = OWGUI.createTabPage(self.tabs, "Graph")

        ## display options
        self.infoLabel = OWGUI.widgetLabel(OWGUI.widgetBox(GraphTab, "Info"),
                                           "No data on input.")
        displayOptBox = OWGUI.widgetBox(
            GraphTab, "Display")  #QVButtonGroup("Display", GraphTab)
        displayOptButtons = [
            'Majority Class', 'Majority Class Probability',
            'Target Class Probability', 'Number of Instances'
        ]
        OWGUI.checkBox(displayOptBox,
                       self,
                       'ShowSingleProfiles',
                       'Expression Profiles',
                       tooltip='',
                       callback=self.updateShowSingleProfiles)
        OWGUI.checkBox(displayOptBox,
                       self,
                       'ShowAverageProfile',
                       'Box Plot',
                       tooltip='',
                       callback=self.updateShowAverageProfile)

        ## class selection (classQLB)
        self.classQVGB = OWGUI.widgetBox(GraphTab,
                                         "Classes")  #QVGroupBox(GraphTab)
        ##        self.classQVGB.setTitle("Classes")
        self.classQLB = OWGUI.listBox(
            self.classQVGB,
            self,
            "SelectedClasses",
            "Classes",
            selectionMode=QListWidget.MultiSelection,
            callback=self.classSelectionChange)  #QListBox(self.classQVGB)
        ##        self.classQLB.setSelectionMode(QListBox.Multi)
        self.unselectAllClassedQLB = OWGUI.button(
            self.classQVGB, self, "Unselect all", callback=self.SUAclassQLB
        )  #QPushButton("(Un)Select All", self.classQVGB)
        ##        self.connect(self.unselectAllClassedQLB, SIGNAL("clicked()"), self.SUAclassQLB)
        ##        self.connect(self.classQLB, SIGNAL("selectionChanged()"), self.classSelectionChange)

        ## show single/average profile
        ##        self.showAverageQLB = QPushButton("Box Plot", self.classQVGB)
        ##        self.showAverageQLB.setToggleButton(1)
        ##        self.showAverageQLB.setOn(self.ShowAverageProfile)
        ##        self.showSingleQLB = QPushButton("Single Profiles", self.classQVGB)
        ##        self.showSingleQLB.setToggleButton(1)
        ##        self.showSingleQLB.setOn(self.ShowSingleProfiles)
        ##        self.connect(self.showAverageQLB, SIGNAL("toggled(bool)"), self.updateShowAverageProfile)
        ##        self.connect(self.showSingleQLB, SIGNAL("toggled(bool)"), self.updateShowSingleProfiles)

        ##        self.tabs.insertTab(GraphTab, "Graph")

        # SETTINGS TAB
        SettingsTab = OWGUI.createTabPage(self.tabs,
                                          "Settings")  #QVGroupBox(self)

        self.profileLabelComboBox = OWGUI.comboBox(SettingsTab,
                                                   self,
                                                   'profileLabel',
                                                   'Profile Labels',
                                                   sendSelectedValue=True,
                                                   valueType=str)
        OWGUI.hSlider(SettingsTab,
                      self,
                      'PointWidth',
                      box='Point Width',
                      minValue=0,
                      maxValue=9,
                      step=1,
                      callback=self.updatePointWidth,
                      ticks=1)
        OWGUI.hSlider(SettingsTab,
                      self,
                      'CurveWidth',
                      box='Profile Width',
                      minValue=1,
                      maxValue=9,
                      step=1,
                      callback=self.updateCurveWidth,
                      ticks=1)
        OWGUI.hSlider(SettingsTab,
                      self,
                      'AverageCurveWidth',
                      box='Average Profile Width',
                      minValue=1,
                      maxValue=9,
                      step=1,
                      callback=self.updateAverageCurveWidth,
                      ticks=1)
        OWGUI.hSlider(SettingsTab,
                      self,
                      'BoxPlotWidth',
                      box='Box Plot Width',
                      minValue=0,
                      maxValue=9,
                      step=1,
                      callback=self.updateBoxPlotWidth,
                      ticks=1)
        OWGUI.checkBox(SettingsTab,
                       self,
                       'graph.renderAntialiased',
                       "Render antialiased",
                       callback=self.graph.setCurveRenderHints)

        ## graph y scale
        box = OWGUI.widgetBox(
            SettingsTab, "Threshold/ Values"
        )  #QVButtonGroup("Threshol/ Values", SettingsTab)
        OWGUI.checkBox(box,
                       self,
                       'CutEnabled',
                       "Enabled",
                       callback=self.setCutEnabled)
        self.sliderCutLow = OWGUI.qwtHSlider(box,
                                             self,
                                             'CutLow',
                                             label='Low:',
                                             labelWidth=33,
                                             minValue=-20,
                                             maxValue=0,
                                             step=0.1,
                                             precision=1,
                                             ticks=0,
                                             maxWidth=80,
                                             callback=self.updateYaxis)
        self.sliderCutHigh = OWGUI.qwtHSlider(box,
                                              self,
                                              'CutHigh',
                                              label='High:',
                                              labelWidth=33,
                                              minValue=0,
                                              maxValue=20,
                                              step=0.1,
                                              precision=1,
                                              ticks=0,
                                              maxWidth=80,
                                              callback=self.updateYaxis)
        if not self.CutEnabled:
            self.sliderCutLow.box.setDisabled(1)
            self.sliderCutHigh.box.setDisabled(1)

##        self.tabs.insertTab(SettingsTab, "Settings")

        self.toolbarSelection = ZoomSelectToolbar(
            self,
            self.controlArea,
            self.graph,
            self.autoSendSelected,
            buttons=(ZoomSelectToolbar.IconZoom, ZoomSelectToolbar.IconPan,
                     ZoomSelectToolbar.IconSelect, ZoomSelectToolbar.IconSpace,
                     ZoomSelectToolbar.IconRemoveLast,
                     ZoomSelectToolbar.IconRemoveAll,
                     ZoomSelectToolbar.IconSendSelection))
        cb = OWGUI.checkBox(self.controlArea, self, "autoSendSelected",
                            "Auto send on selection change")
        OWGUI.setStopper(self, self.toolbarSelection.buttonSendSelections, cb,
                         "selectionChangedFlag", self.commit)

        # inputs
        # data and graph temp variables

        self.inputs = [("Examples", ExampleTable, self.data,
                        Default + Multiple)]
        self.outputs = [("Examples", ExampleTable, Default)]

        # temp variables
        self.MAdata = []
        self.classColor = None
        self.classBrighterColor = None
        self.numberOfClasses = 0
        self.classValues = []
        self.ctrlPressed = False
        self.attrIcons = self.createAttributeIconDict()

        self.graph.canvas().setMouseTracking(1)

        #        self.zoomStack = []
        ##        self.connect(self.graph,
        ##                     SIGNAL('plotMousePressed(const QMouseEvent&)'),
        ##                     self.onMousePressed)
        ##        self.connect(self.graph,
        ##                     SIGNAL('plotMouseReleased(const QMouseEvent&)'),
        ##                     self.onMouseReleased)
        self.resize(800, 600)
示例#5
0
    def __init__(self, parallelWidget, parent=None, signalManager=None):
        OWWidget.__init__(self, parent, signalManager,
                          "Parallel Optimization Dialog", False)
        self.setCaption("Parallel Optimization Dialog")
        self.parallelWidget = parallelWidget

        self.optimizationMeasure = 0
        self.attributeCount = 5
        self.numberOfAttributes = 6
        self.fileName = ""
        self.lastSaveDirName = os.getcwd() + "/"
        self.fileBuffer = []
        self.projections = []
        self.allResults = []
        self.canOptimize = 0
        self.orderAllAttributes = 1  # do we wish to order all attributes or find just an interesting subset
        self.worstVal = -1  # used in heuristics to stop the search in uninteresting parts of the graph

        self.loadSettings()

        self.measureBox = OWGUI.radioButtonsInBox(
            self.controlArea,
            self,
            "optimizationMeasure", ["Correlation", "VizRank"],
            box="Select optimization measure",
            callback=self.updateGUI)
        self.vizrankSettingsBox = OWGUI.widgetBox(self.controlArea,
                                                  "VizRank settings")
        self.optimizeBox = OWGUI.widgetBox(self.controlArea, "Optimize")
        self.manageBox = OWGUI.widgetBox(self.controlArea, "Manage results")
        self.resultsBox = OWGUI.widgetBox(self.mainArea, "Results")

        self.resultList = OWGUI.listBox(self.resultsBox, self)
        self.resultList.setMinimumSize(200, 200)
        self.connect(self.resultList, SIGNAL("itemSelectionChanged()"),
                     self.showSelectedAttributes)

        # remove non-existing files
        names = []
        for i in range(len(self.fileBuffer) - 1, -1, -1):
            (short, longName) = self.fileBuffer[i]
            if not os.path.exists(longName):
                self.fileBuffer.remove((short, longName))
            else:
                names.append(short)
        names.append("(None)")
        self.fileName = "(None)"

        self.hbox1 = OWGUI.widgetBox(self.vizrankSettingsBox,
                                     "VizRank projections file",
                                     orientation="horizontal")
        self.vizrankFileCombo = OWGUI.comboBox(
            self.hbox1,
            self,
            "fileName",
            items=names,
            tooltip=
            "File that contains information about interestingness of scatterplots\n"
            "generated by VizRank method in scatterplot widget",
            callback=self.changeProjectionFile,
            sendSelectedValue=1,
            valueType=str)
        self.browseButton = OWGUI.button(self.hbox1,
                                         self,
                                         "...",
                                         callback=self.loadProjections)
        self.browseButton.setMaximumWidth(20)

        self.resultsInfoBox = OWGUI.widgetBox(self.vizrankSettingsBox,
                                              "VizRank parameters")
        self.kNeighborsLabel = OWGUI.widgetLabel(self.resultsInfoBox,
                                                 "Number of neighbors (k):")
        self.percentDataUsedLabel = OWGUI.widgetLabel(self.resultsInfoBox,
                                                      "Percent of data used:")
        self.testingMethodLabel = OWGUI.widgetLabel(self.resultsInfoBox,
                                                    "Testing method used:")
        self.qualityMeasureLabel = OWGUI.widgetLabel(self.resultsInfoBox,
                                                     "Quality measure used:")

        self.allAttributesRadio = QRadioButton("Order all attributes",
                                               self.optimizeBox)
        self.optimizeBox.layout().addWidget(self.allAttributesRadio)
        self.connect(self.allAttributesRadio, SIGNAL("clicked()"),
                     self.setAllAttributeRadio)
        box = OWGUI.widgetBox(self.optimizeBox, orientation="horizontal")
        self.subsetAttributeRadio = QRadioButton("Find subsets of", box)
        box.layout().addWidget(self.subsetAttributeRadio)
        self.connect(self.subsetAttributeRadio, SIGNAL("clicked()"),
                     self.setSubsetAttributeRadio)
        self.subsetAttributeEdit = OWGUI.lineEdit(box,
                                                  self,
                                                  "numberOfAttributes",
                                                  valueType=int)
        self.subsetAttributeEdit.setMaximumWidth(30)
        OWGUI.widgetLabel(box, "attributes")

        self.startOptimizationButton = OWGUI.button(
            self.optimizeBox,
            self,
            "Start Optimization",
            callback=self.startOptimization)
        f = self.startOptimizationButton.font()
        f.setBold(1)
        self.startOptimizationButton.setFont(f)
        self.stopOptimizationButton = OWGUI.button(
            self.optimizeBox,
            self,
            "Stop Evaluation",
            callback=self.stopOptimizationClick)
        self.stopOptimizationButton.setFont(f)
        self.stopOptimizationButton.hide()
        self.connect(self.stopOptimizationButton, SIGNAL("clicked()"),
                     self.stopOptimizationClick)

        self.clearButton = OWGUI.button(self.manageBox, self, "Clear Results",
                                        self.clearResults)
        self.loadButton = OWGUI.button(self.manageBox, self, "Load",
                                       self.loadResults)
        self.saveButton = OWGUI.button(self.manageBox, self, "Save",
                                       self.saveResults)
        self.closeButton = OWGUI.button(self.manageBox, self, "Close Dialog",
                                        self.hide)

        self.changeProjectionFile()
        self.updateGUI()
        if self.orderAllAttributes:
            self.setAllAttributeRadio()
        else:
            self.setSubsetAttributeRadio()
    def __init__(self, parallelWidget, parent=None, signalManager=None):
        OWWidget.__init__(self, parent, signalManager, "Parallel Optimization Dialog", False)
        self.setCaption("Parallel Optimization Dialog")
        self.parallelWidget = parallelWidget

        self.optimizationMeasure = 0
        self.attributeCount = 5
        self.numberOfAttributes = 6
        self.fileName = ""
        self.lastSaveDirName = os.getcwd() + "/"
        self.fileBuffer = []
        self.projections = []
        self.allResults = []
        self.canOptimize = 0
        self.orderAllAttributes = 1  # do we wish to order all attributes or find just an interesting subset
        self.worstVal = -1  # used in heuristics to stop the search in uninteresting parts of the graph

        self.loadSettings()

        self.measureBox = OWGUI.radioButtonsInBox(self.controlArea, self, "optimizationMeasure",
                                                  ["Correlation", "VizRank"], box="Select optimization measure",
                                                  callback=self.updateGUI)
        self.vizrankSettingsBox = OWGUI.widgetBox(self.controlArea, "VizRank settings")
        self.optimizeBox = OWGUI.widgetBox(self.controlArea, "Optimize")
        self.manageBox = OWGUI.widgetBox(self.controlArea, "Manage results")
        self.resultsBox = OWGUI.widgetBox(self.mainArea, "Results")

        self.resultList = OWGUI.listBox(self.resultsBox, self)
        self.resultList.setMinimumSize(200, 200)
        self.connect(self.resultList, SIGNAL("itemSelectionChanged()"), self.showSelectedAttributes)

        # remove non-existing files
        names = []
        for i in range(len(self.fileBuffer) - 1, -1, -1):
            (short, longName) = self.fileBuffer[i]
            if not os.path.exists(longName):
                self.fileBuffer.remove((short, longName))
            else:
                names.append(short)
        names.append("(None)")
        self.fileName = "(None)"

        self.hbox1 = OWGUI.widgetBox(self.vizrankSettingsBox, "VizRank projections file", orientation="horizontal")
        self.vizrankFileCombo = OWGUI.comboBox(self.hbox1, self, "fileName", items=names,
                                               tooltip="File that contains information about interestingness of scatterplots\n"
                                                       "generated by VizRank method in scatterplot widget",
                                               callback=self.changeProjectionFile, sendSelectedValue=1, valueType=str)
        self.browseButton = OWGUI.button(self.hbox1, self, "...", callback=self.loadProjections)
        self.browseButton.setMaximumWidth(20)

        self.resultsInfoBox = OWGUI.widgetBox(self.vizrankSettingsBox, "VizRank parameters")
        self.kNeighborsLabel = OWGUI.widgetLabel(self.resultsInfoBox, "Number of neighbors (k):")
        self.percentDataUsedLabel = OWGUI.widgetLabel(self.resultsInfoBox, "Percent of data used:")
        self.testingMethodLabel = OWGUI.widgetLabel(self.resultsInfoBox, "Testing method used:")
        self.qualityMeasureLabel = OWGUI.widgetLabel(self.resultsInfoBox, "Quality measure used:")

        self.allAttributesRadio = QRadioButton("Order all attributes", self.optimizeBox)
        self.optimizeBox.layout().addWidget(self.allAttributesRadio)
        self.connect(self.allAttributesRadio, SIGNAL("clicked()"), self.setAllAttributeRadio)
        box = OWGUI.widgetBox(self.optimizeBox, orientation="horizontal")
        self.subsetAttributeRadio = QRadioButton("Find subsets of", box)
        box.layout().addWidget(self.subsetAttributeRadio)
        self.connect(self.subsetAttributeRadio, SIGNAL("clicked()"), self.setSubsetAttributeRadio)
        self.subsetAttributeEdit = OWGUI.lineEdit(box, self, "numberOfAttributes", valueType=int)
        self.subsetAttributeEdit.setMaximumWidth(30)
        OWGUI.widgetLabel(box, "attributes")

        self.startOptimizationButton = OWGUI.button(self.optimizeBox, self, "Start Optimization",
                                                    callback=self.startOptimization)
        f = self.startOptimizationButton.font()
        f.setBold(1)
        self.startOptimizationButton.setFont(f)
        self.stopOptimizationButton = OWGUI.button(self.optimizeBox, self, "Stop Evaluation",
                                                   callback=self.stopOptimizationClick)
        self.stopOptimizationButton.setFont(f)
        self.stopOptimizationButton.hide()
        self.connect(self.stopOptimizationButton, SIGNAL("clicked()"), self.stopOptimizationClick)

        self.clearButton = OWGUI.button(self.manageBox, self, "Clear Results", self.clearResults)
        self.loadButton = OWGUI.button(self.manageBox, self, "Load", self.loadResults)
        self.saveButton = OWGUI.button(self.manageBox, self, "Save", self.saveResults)
        self.closeButton = OWGUI.button(self.manageBox, self, "Close Dialog", self.hide)

        self.changeProjectionFile()
        self.updateGUI()
        if self.orderAllAttributes:
            self.setAllAttributeRadio()
        else:
            self.setSubsetAttributeRadio()