Changeset 1621:dad955df95e8 in orange-bioinformatics


Ignore:
Timestamp:
05/17/12 16:22:58 (2 years ago)
Author:
Ales Erjavec <ales.erjavec@…>
Branch:
default
Message:

Open dictyExpress links with selected genes only.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • widgets/OWGeneInfo.py

    r1614 r1621  
    242242        self.dictyExpressBox = OWGUI.widgetBox(self.controlArea, "Dicty Express") 
    243243        self.linkLabel = OWGUI.widgetLabel(self.dictyExpressBox, "") 
    244         self.linkLabel.setOpenExternalLinks(True) 
     244        self.linkLabel.setOpenExternalLinks(False) 
     245        self.connect(self.linkLabel, SIGNAL("linkActivated(QString)"), 
     246                     self.onDictyExpressLink) 
    245247        self.dictyExpressBox.hide() 
    246248         
     
    500502        if show: 
    501503            genes = [fix(gene) for gene in genes if fix(gene)] 
    502             link1 = '<a href="http://www.ailab.si/dictyexpress/run/index.php?gene=%s">Microarray profile</a>' % (" ".join(genes)) 
    503             link2 = '<a href="http://www.ailab.si/dictyexpress/run/index.php?gene=%s&db=rnaseq">RNA-Seq profile</a>' % (" ".join(genes)) 
     504            link1 = '<a href="http://dictyexpress.biolab.si/run/index.php?gene=%s">Microarray profile</a>' 
     505            link2 = '<a href="http://dictyexpress.biolab.si/run/index.php?gene=%s&db=rnaseq">RNA-Seq profile</a>' 
    504506            self.linkLabel.setText(link1 + "<br/>" + link2) 
    505507             
     
    510512        else: 
    511513            self.dictyExpressBox.hide() 
     514 
     515    def onDictyExpressLink(self, link): 
     516        if not self.data: 
     517            return 
     518 
     519        selectedIndexes = self.treeWidget.selectedIndexes() 
     520        if not len(selectedIndexes): 
     521            QMessageBox.information(self, "No gene ids selected", "Please select some genes and try again.") 
     522            return 
     523        model = self.treeWidget.model() 
     524        mapToSource = model.mapToSource 
     525        selectedIds = [self.cells[mapToSource(index).row()][0] for index in selectedIndexes] 
     526        selectedRows = self.treeWidget.selectedIndexes() 
     527        selectedRows = [mapToSource(index).row() for index in selectedRows] 
     528        model = model.sourceModel() 
     529 
     530        selectedGeneids = [self.row2geneinfo[row] for row in selectedRows] 
     531        selectedIds = [self.geneinfo[i][0] for i in selectedGeneids] 
     532        selectedIds = set(selectedIds) 
     533 
     534        def fix(ddb): 
     535            if ddb.startswith("DDB"): 
     536                if not ddb.startswith("DDB_G"): 
     537                    ddb = ddb.replace("DDB", "DDB_G") 
     538                return ddb 
     539            return None 
     540 
     541        genes = [fix(gene) for gene in selectedIds if fix(gene)] 
     542        url = str(link) % " ".join(genes) 
     543        QDesktopServices.openUrl(QUrl(url)) 
    512544             
    513545    def onAltSourceChange(self): 
Note: See TracChangeset for help on using the changeset viewer.