[Bio] / PyGUI / EnzymeWindow.py Repository:
ViewVC logotype

View of /PyGUI/EnzymeWindow.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.13 - (download) (as text) (annotate)
Wed Jul 14 20:22:13 2004 UTC (15 years, 3 months ago) by efrank
Branch: MAIN
CVS Tags: V00-00-03, MigrateToNewPackage, mass-spec-01, forRick-14Jul04-0, mass-spec-03, mass-spec-02, forRick-14Jul04-1, HEAD
Changes since 1.12: +0 -1 lines
getting it to work.  in a rush for rick demo.

from wxPython.wx import *
from wxPython.grid import *
from KahOM.RecoElem import RecoElem
from PyGUI.RecoElempanel import RecoElempanel
from PyGUI.MainLayout import MainLayout
from PyGUI.DoubleTextEntryDialog import DoubleTextEntryDialog

class EnzymeWindow:
#    def __init__(self, parent):
#    def initEvents(self ):


    #------------------------------------------------------------------------
    def __init__(self, parent):
    #------------------------------------------------------------------------
        self.parent = parent
        self.initEvents()

        self.__searchGrid   = self.parent.enzymesSearchResultsGrid
        self.__selectedGrid = self.parent.enzymesSelectedResultsGrid

        self.parent.addEnzymesBtn.Enable(false)
        self.parent.enzymesListFunctionBtn.Enable(false)
       
        return
    
    #------------------------------------------------------------------------
    def enzymeSearchText(self):
    #------------------------------------------------------------------------
        return self.parent.enzymesSearchText.GetValue()

    #------------------------------------------------------------------------
    def queryType(self):
    #
    #   What to search on.  Can be EC, Name, Substrate, Product
    #------------------------------------------------------------------------
        return self.parent.choicesEnzymesComboBox.GetValue()
    
    #------------------------------------------------------------------------
    def matchType(self):
    #
    #   Type of match: Can be Equals, Contains, Like, 
    #------------------------------------------------------------------------
        return self.parent.optionsEnzymesComboBox.GetValue()


    #------------------------------------------------------------------------
    def initEvents(self ):
    #------------------------------------------------------------------------
        
        comboValue = self.parent.foundryComboBox
        EVT_COMBOBOX(comboValue, comboValue.GetId(), self.onFoundryComboBox)
        

        searchEnzymesBtn = self.parent.searchEnzymesBtn
        EVT_BUTTON(self.parent, searchEnzymesBtn.GetId(), self.onSearchEnzymes)

        addEnzymesBtn = self.parent.addEnzymesBtn
        EVT_BUTTON(self.parent, addEnzymesBtn.GetId(),
                   self.onAddEnzymes)

        enzymesSearchSelectBtn = self.parent.enzymesSearchSelectBtn
        EVT_BUTTON(self.parent, enzymesSearchSelectBtn.GetId(),
                   self.onSelectSearchResults)

        enzymesListFunctionBtn = self.parent.enzymesListFunctionBtn
        EVT_BUTTON(self.parent, enzymesListFunctionBtn.GetId(),
                   self.onEnzymesListFunctions)

        enzymesSearchClearBtn = self.parent.enzymesSearchClearBtn
        EVT_BUTTON(self.parent, enzymesSearchClearBtn.GetId(),
                   self.onClearSearchResults)

        clearSelectedEnzymesBtn =  self.parent.clearSelectedEnzymesBtn
        EVT_BUTTON(self.parent, clearSelectedEnzymesBtn.GetId(),
                   self.onClearSelectedEnzymes)

        
        return
        
   #------------------------------------------------------------------------
    def onSearchEnzymes(self, evt):
   #------------------------------------------------------------------------
        wxBeginBusyCursor()

        factory     = self.parent.getCurrentDataFactory()
        if (factory.getFoundryType() == "Wit"):
            self.parent.error( "Search Enzymes not supported in Wit" )
            return
        foundryName = factory.getFoundryName()

        target      = self.enzymeSearchText()
        likeOpt     = self.matchType()
        queryType   = self.queryType()

        if   (queryType == "EC"):
            results = factory.enzymeECSearch( target, likeOpt )
        elif (queryType == "Name"):
            results = factory.enzymeNameSearch( target, likeOpt )
        elif (queryType == "Substrate"):
            results = factory.enzymeBySubstrateSearch( target, likeOpt )
        elif (queryType == "Product"):
            results = factory.enzymeByProductSearch( target, likeOpt )
        else:
            self.parent.error( "searchSeedEnzymes: code logic error")
            wxEndBusyCursor()
            return
        self.updateSearchResultsGrid(foundryName, results)
        wxEndBusyCursor()
        return

    #------------------------------------------------------------------------
    def onAddEnzymes(self, evt):
    #------------------------------------------------------------------------
        self.parent.error( "Adding enzymes is not supported yet")
        return
        

    #------------------------------------------------------------------------
    def updateSearchResultsGrid(self, factoryName, results):
    #------------------------------------------------------------------------
        theGrid = self.__searchGrid
        n       = theGrid.GetNumberRows()
        for r in results:
            if (None == r[1]): r[1]=""
            theGrid.AppendRows(numRows=1)
            theGrid.SetCellValue(n, 0 , factoryName)
            theGrid.SetCellValue(n, 1, r[0] )
            theGrid.SetCellValue(n, 2, r[1] )
            theGrid.SetReadOnly(n, 0)
            theGrid.SetReadOnly(n, 1)
            theGrid.SetReadOnly(n, 2)
            n += 1
        theGrid.AutoSizeColumn(1)
        theGrid.AutoSizeColumn(2)
        theGrid.FitInside()
        
        return
    
    #------------------------------------------------------------------------
    def onClearSearchResults(self, event):
    #------------------------------------------------------------------------

        if (self.__searchGrid.GetNumberRows() == 0 ):
            return
        
        self.__searchGrid.DeleteRows(0, self.__searchGrid.GetNumberRows())
        self.__searchGrid.ClearGrid()
        return

    #------------------------------------------------------------------------
    def onClearSelectedEnzymes(self, event):
    #------------------------------------------------------------------------

        nRows = self.__selectedGrid.GetNumberRows()
        if (0 != nRows):
            self.__selectedGrid.DeleteRows(0, nRows)
            self.__selectedGrid.ClearGrid()

        return
        
    #------------------------------------------------------------------------
    def onEnzymesListFunctions(self, event):
    #
    #   Lists the enzymatic functions for the selected EC/enzyme
    #------------------------------------------------------------------------
        self.parent.error( "onEnzymesListFunctions")
        return
    
    #------------------------------------------------------------------------
    def onSelectSearchResults(self, event):
    #------------------------------------------------------------------------

        onSelectRows = self.__searchGrid.GetSelectedRows()

        bottomGrid       = self.__selectedGrid
        bottomGridNumber = self.__selectedGrid.GetNumberRows()
        
        for s in onSelectRows:
            bottomFoundryValue = self.__searchGrid.GetCellValue(s, 0)
            bottomECValue      = self.__searchGrid.GetCellValue(s, 1)
            bottomNameValue    = self.__searchGrid.GetCellValue(s, 2)

            bottomGrid.AppendRows(numRows=1)
            bottomGrid.SetCellValue(bottomGridNumber, 0, bottomFoundryValue)
            bottomGrid.SetCellValue(bottomGridNumber, 1, bottomECValue)
            bottomGrid.AutoSizeColumn(1)
            bottomGrid.SetCellValue(bottomGridNumber, 2, bottomNameValue)
            bottomGrid.AutoSizeColumn(2)
            bottomGridNumber += 1
        
        bottomGrid.FitInside()
        
        return
        
    #------------------------------------------------------------------------
    def onFoundryComboBox(self, evt):
    #------------------------------------------------------------------------
        
        cb = evt.GetEventObject()
        choice = evt.GetString()
        
        return

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3