Changeset 434:e2e8e7aabc4a in orange-bioinformatics


Ignore:
Timestamp:
07/24/08 14:55:42 (6 years ago)
Author:
ales_erjavec <ales.erjavec@…>
Branch:
default
Convert:
0309f7b8790abdb6e6d9f970412d8b891ae20ff1
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • widgets/OWDicty.py

    r432 r434  
    33<description>Widget interface to dicty experaments</description> 
    44""" 
    5 from __future__ import with_statement 
    65 
    76from OWWidget import * 
     
    98import OWGUI 
    109 
    11 from functools import partial 
    12 from collections import defaultdict 
    13 from threading import Lock, Thread 
    14 from traceback import print_exception 
    1510import sys 
    1611         
    1712class OWDicty(OWWidget): 
    18     settingsList = ["serverToken", "platform", "platformList", "experiments", "selectedExperiments"] 
     13    settingsList = ["serverToken", "platform", "platformList", "experiments", "selectedExperiments", "joinSelected", "separateSelected"] 
    1914    def __init__(self, parent=None, signalManager=None, name="Dicty database"): 
    2015        OWWidget.__init__(self, parent, signalManager, name) 
     
    2419        self.platform = None 
    2520        self.platformList = [] 
     21 
     22        self.joinList = [n for n, long in obiDicty.DatabaseConnection.aoidPairs] 
     23        self.joinSelected = [0] 
     24         
     25        self.separateList = [n for n, long in obiDicty.DatabaseConnection.aoidPairs] 
     26        self.separateSelected = [4, 5]         
    2627         
    2728        self.experiments = [] 
     
    3031        self.searchString = "" 
    3132         
    32         self.loadSettings() 
     33        OWGUI.lineEdit(self.controlArea, self, "serverToken", box="Server Token", callback=self.Connect) 
    3334         
    34         OWGUI.lineEdit(self.controlArea, self, "serverToken", box="Server Token", callback=self.Connect) 
     35        self.joinListBox = OWGUI.listBox(self.controlArea, self, "joinSelected", "joinList", box="Join By", selectionMode=QListWidget.ExtendedSelection) 
     36        self.separateListBox = OWGUI.listBox(self.controlArea, self, "separateSelected", "separateList", box="Separate By", selectionMode=QListWidget.ExtendedSelection) 
     37        OWGUI.button(self.controlArea, self, "&Update list", callback=self.UpdateExperiments) 
     38        OWGUI.button(self.controlArea, self, "&Commit", callback=self.Commit) 
     39        OWGUI.rubber(self.controlArea) 
     40 
    3541        OWGUI.lineEdit(self.mainArea, self, "searchString", "Search", callbackOnType=True, callback=self.SearchUpdate) 
    3642        self.experimentsWidget = QTreeWidget() 
    37         self.experimentsWidget.setHeaderLabels(["Strain", "Treatment", "Growth condition"]) 
     43        self.experimentsWidget.setHeaderLabels(["Strain", "Treatment", "Growth condition", "Platform"]) #, "Num. of replications", "Num. of tech replications"]) 
    3844        self.experimentsWidget.setSelectionMode(QTreeWidget.ExtendedSelection) 
    3945        self.experimentsWidget.setRootIsDecorated(False) 
     
    4248        self.mainArea.layout().addWidget(self.experimentsWidget) 
    4349##        OWGUI.button(self.controlArea, self, "&Preview", callback=self.ShowPreview) 
    44         OWGUI.button(self.controlArea, self, "&Update list", callback=self.UpdateExperiments) 
    45         OWGUI.button(self.controlArea, self, "&Commit", callback=self.Commit) 
    46         OWGUI.rubber(self.controlArea) 
    4750 
     51        self.loadSettings() 
    4852        self.dbc = None         
    4953 
     
    8185            treatments = opt["treatment"] 
    8286            growthConds = opt["growthCond"] 
     87            platforms = opt["platform"] 
     88            print opt 
    8389            for treatment in treatments: 
    8490                for cond in growthConds: 
    85                     self.experiments.append([strain, treatment, cond]) 
    86                     self.items.append(QTreeWidgetItem(self.experimentsWidget, self.experiments[-1])) 
     91                    for platform in platforms: 
     92                        self.experiments.append([strain, treatment, cond, platform]) #, str(len(opt["replicate"])), str(len(opt["techReplicate"]))]) 
     93                        self.items.append(QTreeWidgetItem(self.experimentsWidget, self.experiments[-1])) 
    8794            self.progressBarSet((100.0 * i) / len(strains)) 
    8895        self.progressBarFinished() 
     
    102109 
    103110    def SearchUpdate(self, string=""): 
    104         print "s:",self.searchString 
    105111        for item in self.items: 
    106             item.setHidden(not all(s in (item.text(0) + item.text(1) + item.text(2)) for s in self.searchString.split())) 
     112            item.setHidden(not all(s in (item.text(0) + item.text(1) + item.text(2) + item.text(3)) for s in self.searchString.split())) 
    107113             
    108          
    109  
     114     
    110115    def Commit(self): 
    111116        if not self.dbc: 
    112117            self.Connect() 
    113118        allTables = [] 
    114 ##        print self.experimentsWidget.selectedIndexes() 
     119        join = [self.joinList[i] for i in self.joinSelected] 
     120        separate = [self.separateList[i] for i in self.separateSelected] 
     121        import time 
     122        start = time.time() 
     123        print "Start:", start 
    115124        for item in self.experimentsWidget.selectedItems(): 
    116 ##            item = self.experimentsWidget.itemFromIndex(index) 
    117             print str(item.text(0)), str(item.text(1)), str(item.text(2)) 
    118             tables = self.dbc.getData(sample=str(item.text(0)), treatment=str(item.text(1)), growthCond=str(item.text(2))) 
    119 ##            print len(tables) 
     125##            print str(item.text(0)), str(item.text(1)), str(item.text(2)) 
     126            tables = self.dbc.getData(sample=str(item.text(0)), treatment=str(item.text(1)), growthCond=str(item.text(2)), join=join, separate=separate) 
     127            for table in tables: 
     128                table.name = ".".join([str(item.text(0)), str(item.text(1)), str(item.text(2)), str(item.text(3))]) 
    120129            allTables.extend(tables) 
     130        end = int(time.time()-start) 
     131        print "End:","%ih:%im:%is" % (end/3600, (end/60)%60, end%60) 
     132         
    121133        self.send("Example tables", None) 
    122134        for i, table in enumerate(allTables): 
     
    125137if __name__ == "__main__": 
    126138    app  = QApplication(sys.argv) 
     139##    from pywin.debugger import set_trace 
     140##    set_trace() 
    127141    w = OWDicty() 
    128142    w.show() 
Note: See TracChangeset for help on using the changeset viewer.