コード例 #1
0
ファイル: pacfm_cl.py プロジェクト: ecotox/pacfm
    def plot_circos(self):
        """
            Draws the final plot!
        """
        if self.output_type == 0 or self.output_type == 2: 
            h= HighlightContainer()
            h.load()
            
            l=LinkContainer()
            l.load()

            p=PlotContainer()
            p.load()

            for ide in self.input_builder.assembler.ideograms:
                p.get_by_index(ide.level-1).min_value= ide.get_min_value()
                p.get_by_index(ide.level-1).max_value= ide.get_max_value()
            
            self.input_builder.build_circos_inputs_and_run(plots= p, links= l, highlights= h)
            
            d= Drawer(l, p, self.colorbar_title) 
            self.result_image= d.get_output_image()
コード例 #2
0
ファイル: pacfm_gui.py プロジェクト: ecotox/pacfm
    def onCircosPlot(self, e):
        """
            GUI: Runs CIRCOS and displays a modified version of the plot in PACFM.
        """
        hc= HighlightContainer()
        hc.load()
        
        l=LinkContainer()
        l.load()

        p=PlotContainer()
        p.load()

        for ide in self.input_builder.assembler.ideograms:
            p.get_by_index(ide.level-1).min_value= ide.get_min_value()
            p.get_by_index(ide.level-1).max_value= ide.get_max_value()

        
        self.circos_controller = CircosController(self.biodb_selector, p, l, hc)
        if self.normalized:
            self.circos_controller.view.plotType.rbNorm.SetValue(1)
        else:
            self.circos_controller.view.plotType.rbRaw.SetValue(1)
       
        
        
        status_text= "Drawing the plot. Please wait..."
        self.view.statusBar.SetStatusText("PACFM: %s"%status_text)

        response= self.circos_controller.view.ShowModal()
    
        if response ==  wx.ID_OK:   
            plots = self.circos_controller.view.plotType.plots
            links= self.circos_controller.view.links.links
            ### filter links that are not found in the dataset
            #print self.input_builder.assembler.ideograms[l.level-1].names
            for name in links.names:
                if name not in self.input_builder.assembler.ideograms[l.level-1].names:
                    links.remove(name)
            
            highlights= self.circos_controller.view.highlights.highlights
            
            
            self.input_builder.build_circos_inputs_and_run(plots= plots,
                    links= links, highlights= highlights)
            
            d= Drawer(links, plots, self.colorbar_title) 
            result_image= d.get_output_image()
            wx_image= PilImageToWxImage(result_image)
           
            self.view.nb.ChangeSelection(1)
            
            if not self.normalized:
                self.pltRawData= CircosPanel(self.view.nb.pltRawData, wx_image)
                # There should be a simpler pnl.Refresh() method!
                
                self.view.nb.circosBook.ChangeSelection(0)
                
                sizer= wx.BoxSizer()
                sizer.Add(self.pltRawData, 1, wx.EXPAND)
                # 
                self.view.nb.pltRawData.SetSizer(sizer)
                self.view.nb.pltRawData.Layout()
            else:
                
                self.pltNormData= CircosPanel(self.view.nb.pltNormData, wx_image)
                # There should be a simpler pnl.Refresh() method!
                
                self.view.nb.circosBook.ChangeSelection(1)
                
                sizer= wx.BoxSizer()
                sizer.Add(self.pltNormData, 1, wx.EXPAND)
                self.view.nb.pltNormData.SetSizer(sizer)
                self.view.nb.pltNormData.Layout()

            self.circos_controller.view.Destroy()
            
            self.normalized= self.circos_controller.view.plotType.rbNorm.GetValue()     
            status_text= "The PACFM plot has been successfully drawn!"
            self.view.statusBar.SetStatusText("PACFM: %s"%status_text)