Changeset 430:240c57f3dbcc in orange-bioinformatics


Ignore:
Timestamp:
07/22/08 16:10:24 (6 years ago)
Author:
ales_erjavec <ales.erjavec@…>
Branch:
default
Convert:
f631f95048b5d7253f778d729f6ccc4d8d19d177
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • prototypes/OWDicty.py

    r429 r430  
    3333         
    3434class OWDicty(OWWidget): 
    35     settingsList = ["serverToken", "platform", "tables", "selectedTables"] 
     35    settingsList = ["serverToken", "platform", "platformList", "experiments", "selectedExperiments"] 
    3636    def __init__(self, parent=None, signalManager=None, name="Dicty database"): 
    3737        OWWidget.__init__(self, parent, signalManager, name) 
    3838        self.outputs = [("Example tables", ExampleTable, Multiple)] 
    3939        self.serverToken = "" 
    40 ##        self.type = None 
    41 ##        self.typesList = ["norms", "chips"] #[n for n, long in obiDicty.DatabaseConnection.obidPairs] 
    4240 
    4341        self.platform = None 
    4442        self.platformList = [] 
    4543         
    46         self.sampleList = [] 
    47         self.sampleSelected = [] 
    48  
    49         self.treatmentList = [] 
    50         self.treatmentSelected = [] 
    51  
    52         self.growthCondList = [] 
    53         self.growthCondSelected = [] 
    54          
    55         self.joinList = [n for n, long in obiDicty.DatabaseConnection.aoidPairs] 
    56         self.joinSelected = [] 
    57          
    58         self.separateList = [n for n, long in obiDicty.DatabaseConnection.aoidPairs] 
    59         self.separateSelected = [] 
     44        self.experiments = [] 
     45        self.selectedExperiments = [] 
    6046         
    6147        self.loadSettings() 
    6248         
    6349        OWGUI.lineEdit(self.controlArea, self, "serverToken", box="Server Token", callback=self.Connect) 
    64 ##        self.typeCombo = OWGUI.comboBox(self.controlArea, self, "type", box="Type", items=self.typesList, sendSelectedValue=True, callback=self.UpdateControls) 
    65         self.platformCombo = OWGUI.comboBox(self.controlArea, self, "platform", box="Platform", items=self.platformList, sendSelectedValue=True, callback=partial(self.UpdateControls, ["sample", "treatment", "growthCond"])) 
    66         self.sampleListBox = OWGUI.listBox(self.controlArea, self, "sampleSelected", "sampleList", box="Samples", selectionMode=QListWidget.ExtendedSelection, callback=partial(self.UpdateControls, ["treatment", "growthCond"])) 
    67         self.treatmentListBox = OWGUI.listBox(self.controlArea, self, "treatmentSelected", "treatmentList", box="Treatment", selectionMode=QListWidget.ExtendedSelection, callback=partial(self.UpdateControls, ["growthCond"])) 
    68         self.growthCondListBox = OWGUI.listBox(self.controlArea, self, "growthCondSelected", "growthCondList", box="Growth Condition", selectionMode=QListWidget.ExtendedSelection, callback=partial(self.UpdateControls, [])) 
    69         self.joinListBox = OWGUI.listBox(self.mainArea, self, "joinSelected", "joinList", box="Join", selectionMode=QListWidget.ExtendedSelection) 
    70         self.separateListBox = OWGUI.listBox(self.mainArea, self, "separateSelected", "separateList", box="Separate", selectionMode=QListWidget.ExtendedSelection) 
    71          
     50##        OWGUI.lineEdit(self.mainArea, self, "search",  
     51        self.experimentsWidget = QTreeWidget() 
     52        self.experimentsWidget.setHeaderLabels(["Strain", "Treatment", "Growth condition"]) 
     53        self.experimentsWidget.setSelectionMode(QTreeWidget.ExtendedSelection) 
     54        self.experimentsWidget.setRootIsDecorated(False) 
     55##        self.experimentsWidget.setAlternatingRowColors(True) 
     56        self.mainArea.layout().addWidget(self.experimentsWidget) 
    7257##        OWGUI.button(self.controlArea, self, "&Preview", callback=self.ShowPreview) 
     58        OWGUI.button(self.controlArea, self, "&Update", callback=self.UpdateExperiments) 
    7359        OWGUI.button(self.controlArea, self, "&Commit", callback=self.Commit) 
    7460        OWGUI.rubber(self.controlArea) 
    7561 
    76         self.dbc = None 
    77         self.locks = defaultdict(Lock) 
    78         self.InitControls() 
     62        self.dbc = None         
     63 
     64        self.FillExperimentsWidget() 
     65 
     66        self.resize(600, 400) 
    7967 
    8068    def __updateSelectionList(self, oldList, oldSelection, newList): 
    8169        oldList = [oldList[i] for i in oldSelection] 
    8270        return [ i for i, new in enumerate(newList) if new in oldList] 
    83  
    84     def GetOptions(self): 
    85         print self.platform, [self.sampleList[i] for i in self.sampleSelected], [self.joinList[i] for i in self.joinSelected], [self.separateList[i] for i in self.separateSelected] 
    86         return self.platform, [self.sampleList[i] for i in self.sampleSelected], [self.joinList[i] for i in self.joinSelected], [self.separateList[i] for i in self.separateSelected] 
    87  
    88     def GetQuery(self): 
    89         query = {} 
    90         if self.platform: 
    91             query["platform"] = self.platform 
    92         if self.sampleSelected: 
    93             query["sample"] = [self.sampleList[i] for i in self.sampleSelected] 
    94         if self.treatmentSelected: 
    95             query["treatment"] = [self.treatmentList[i] for i in self.treatmentSelected] 
    96         if self.growthCondSelected: 
    97             query["growthCond"] = [self.growthCondList[i] for i in self.growthCondSelected] 
    98         return {} #query 
    9971     
    10072    def Connect(self): 
     
    11183        self.error(0) 
    11284 
    113     def InitControls(self): 
     85    def UpdateExperiments(self): 
    11486        if not self.dbc: 
    11587            self.Connect() 
    116         self.platformThread = MyQThread(self, partial(self.dbc.annotationOptions, self.dbc.aoidt("platform"))) 
    117         self.platformCombo.setDisabled(True) 
    118         def _set(): 
    119             self.platformCombo.clear() 
    120             self.platformCombo.addItems(self.platformThread.returnValue["platform"]) 
    121             self.platformCombo.setDisabled(False) 
    122         self.connect(self.platformThread, SIGNAL("finished()"), partial(_set)) 
    123         self.platformThread.start() 
    124              
    125     def UpdateControls(self, controls=()): 
    126         if not self.dbc: 
    127             self.Connect() 
    128         query = self.GetQuery() 
    129         for control in controls: 
    130             thread = MyQThread(self, partial(self.dbc.annotationOptions, self.dbc.aoidt(control), **query)) 
    131             setattr(self, control+"Thread", thread) 
    132             listBox = getattr(self, control+"ListBox") 
    133             listBox.setDisabled(True) 
    134             def _set(control): 
    135                 setattr(self, control+"List", getattr(self, control+"Thread").returnValue[control]) 
    136                 getattr(self, control+"ListBox").setDisabled(False) 
    137             self.connect(thread, SIGNAL("finished()"), partial(_set, control)) 
    138             thread.start() 
     88        self.experiments = [] 
     89        self.experimentsWidget.clear() 
     90        self.progressBarInit() 
     91        strains = self.dbc.annotationOptions(self.dbc.aoidt("sample"))["sample"] 
     92        for i, strain in enumerate(strains): 
     93            opt = self.dbc.annotationOptions(sample=strain) 
     94            treatments = opt["treatment"] 
     95            growthConds = opt["growthCond"] 
     96            for treatment in treatments: 
     97                for cond in growthConds: 
     98                    self.experiments.append([strain, treatment, cond]) 
     99                    QTreeWidgetItem(self.experimentsWidget, self.experiments[-1]) 
     100            self.progressBarSet((100.0 * i) / len(strains)) 
     101        self.progressBarFinished() 
     102 
     103    def FillExperimentsWidget(self): 
     104        self.experimentsWidget.clear() 
     105        for strings in self.experiments: 
     106            QTreeWidgetItem(self.experimentsWidget, strings) 
    139107 
    140108    def ShowPreview(self): 
     
    142110 
    143111    def Commit(self): 
    144         platform, sample, join, separate = self.GetOptions() 
    145         tables = self.dbc.getData(platform=platform, sample=sample, join=join, separate=separate) 
     112        if not self.dbc: 
     113            self.Connect() 
     114        allTables = [] 
     115##        print self.experimentsWidget.selectedIndexes() 
     116        for item in self.experimentsWidget.selectedItems(): 
     117##            item = self.experimentsWidget.itemFromIndex(index) 
     118            print str(item.text(0)), str(item.text(1)), str(item.text(2)) 
     119            tables = self.dbc.getData(sample=str(item.text(0)), treatment=str(item.text(1)), growthCond=str(item.text(2))) 
     120##            print len(tables) 
     121            allTables.extend(tables) 
    146122        self.send("Example tables", None) 
    147         for i, table in enumerate(tables): 
     123        for i, table in enumerate(allTables): 
    148124            self.send("Example tables", table, i) 
    149125 
Note: See TracChangeset for help on using the changeset viewer.