Пример #1
0
    def show(self):
        sumtree.SumTree.show(self)

        # set bindings
        self.win.set_binding(input_key("g"), lambda: self.set_mode("gene"))
        self.win.set_binding(input_key("e"), lambda: self.set_mode("events"))
        self.win.set_binding(input_key("r"), lambda: self.set_mode("reroot"))
        self.win.set_binding(input_key("s"), lambda: self.set_mode("swap"))
        self.win.set_binding(input_key("S", "shift"),
                             lambda: self.swap(self.tree.root))

        # build sidebar menu
        if self.bar is None:
            self.bar = hud.SideBar(self.win, width=150)
            self.bar.add_item(
                hud.MenuItem("gene mode (g)", lambda: self.set_mode("gene")))
            self.bar.add_item(
                hud.MenuItem("events mode (e)",
                             lambda: self.set_mode("events")))
            self.bar.add_item(
                hud.MenuItem("reroot mode (r)",
                             lambda: self.set_mode("reroot")))
            self.bar.add_item(
                hud.MenuItem("swap mode (s,S)", lambda: self.set_mode("swap")))

        if self.events:
            self.win.add_group(self.draw_events())
Пример #2
0
    def show(self):
        """Make visualization window visible"""

        # tree visualization
        if self.vistree != None:
            self.vistree.show()
            #self.vistree.win.set_size(*self.tree_win_size)

            self.windows.append(self.vistree.win)
            self.coords.append(
                max(node.y for node in self.current_tree.nodes.itervalues()))

            # add additional menu options
            self.vistree.bar.add_item(
                hud.MenuItem("next tree (n)", self.next_tree))
            self.vistree.bar.add_item(
                hud.MenuItem("prev tree (p)", self.prev_tree))

            # add additional key binding
            self.vistree.win.set_binding(input_key("n"), self.next_tree)
            self.vistree.win.set_binding(input_key("p"), self.prev_tree)

        # distance matrix visualization
        if self.visdist != None:
            self.visdist.show()
            self.visdist.win.set_name(self.distmat_names[0])

            self.windows.append(self.visdist.win)
            self.coords.append(0)

            # add additional menu options
            self.visdist.bar.add_item(
                hud.MenuItem("next matrix (n)", self.next_matrix))
            self.visdist.bar.add_item(
                hud.MenuItem("prev matrix (p)", self.prev_matrix))

            # add additional key binding
            self.visdist.win.set_binding(input_key("n"), self.next_matrix)
            self.visdist.win.set_binding(input_key("p"), self.prev_matrix)

        # alignment visualization
        if self.visalign != None:
            self.visalign.show()
            self.windows.append(self.visalign.vis.win)
            self.coords.append(-1.5)

            # add additional key binding
            self.visalign.win.set_binding(input_key("n"), self.next_align)
            self.visalign.win.set_binding(input_key("p"), self.prev_align)

        # tie all windows by their y-coordinate
        if len(self.windows) > 1:
            self.ensembl = multiwindow.WindowEnsemble(self.windows,
                                                      stacky=True,
                                                      sameh=True,
                                                      tiey=True,
                                                      coordsy=self.coords)
Пример #3
0
    def show(self):
        matrix.MatrixViewer.show(self)

        # build sidebar menu
        self.bar = hud.SideBar(self.win, width=150)
        self.bar.add_item(hud.MenuItem("align gene (a)", self.show_align))
        self.bar.add_item(hud.MenuItem("clear genes (d)",
                                       self.clear_selection))
        self.bar.add_item(hud.MenuItem("show genes (s)", self.show_selection))
        self.bar.add_item(
            hud.MenuItem("toggle labels (l)", self.toggle_label_windows))

        # register key bindings
        self.win.set_binding(input_key("a"), self.show_align)
        self.win.set_binding(input_key("d"), self.clear_selection)
        self.win.set_binding(input_key("s"), self.show_selection)
Пример #4
0
    def show(self):
        newwin = (self.vis.win == None)

        self.vis.show()
        self.win = self.vis.win  # for convenience

        if newwin:
            self.win.set_name(self.title)
            self.win.set_size(*self.winsize)

        if self.bar == None:
            # build sidebar menu
            self.bar = hud.SideBar(self.win, width=150)
            self.bar.add_item(
                hud.MenuItem("toggle color (c)", self.toggle_color_bases))
            self.bar.add_item(
                hud.MenuItem("toggle leftwin (l)", self.toggle_left_window))
            self.bar.add_item(
                hud.MenuItem("always color",
                             lambda: self.set_min_color_bases(0)))

        # register key bindings
        self.win.set_binding(input_key("c"), self.toggle_color_bases)
        self.win.set_binding(input_key("l"), self.toggle_left_window)
Пример #5
0
    def show(self):
        """Display browser"""
        self.enable_updating(False)

        # create window
        if self.win == None or not self.win.is_open():
            newwin = True
            self.win = summon.Window(position=self.winpos, size=self.winsize)

            self.win.set_bgcolor(1, 1, 1)
            self.win.select.set_callback(self.on_select)

            # zooming
            self.win.set_binding(input_click("right", "down"), "focus")
            self.win.set_binding(input_motion("right", "down"), "zoomx")
            self.win.set_binding(input_click("right", "down", "shift"),
                                 "focus")
            self.win.set_binding(input_motion("right", "down", "shift"),
                                 "zoomy")

            # create left window
            pos = self.win.get_position()
            self.leftwin = summon.Window(
                " ",
                size=(150, self.win.get_size()[1]),
                position=(pos[0] - 150 - self.win.get_decoration()[0], pos[1]))

            self.leftwin.set_bgcolor(1, 1, 1)

            self.left_ensemble = multiwindow.WindowEnsemble(
                [self.leftwin, self.win],
                stacky=True,
                sameh=True,
                tiey=True,
                piny=True,
                master=self.win)

            # menu
            self.sidebar = hud.SideBar(self.win, width=150)
            self.sidebar.add_item(
                hud.MenuItem("toggle ruler (r)", self.toggle_ruler))
            self.win.set_binding(input_key("r"), self.toggle_ruler)

        else:
            newwin = False
            self.win.clear_groups()

        # determine largest chromosome size
        maxchrom = max(x.length() for x in self.chroms)

        # add line to left window
        maxname = max(len(x.seqname) for x in self.chroms) * 20
        self.leftwin.add_group(
            lines(color(1, 1, 1), 0, 0, -maxname, 0, 0, 0, 0,
                  self.chrom_step * len(self.chroms), 0,
                  self.chrom_step * len(self.chroms), -maxname,
                  self.chrom_step * len(self.chroms)))

        # draw chromosome labels
        self.win.add_group(self.draw_chrom_labels())
        self.leftwin.add_group(self.draw_chrom_labels())

        # draw all tracks
        for track in self._tracks:
            self.win.add_group(track.draw())

        if newwin:
            # setup left window
            self.leftwin.home()

            # setup window
            w, h = self.win.get_size()
            bottom = float(
                min(self.chrom_pos[i][1]
                    for i in self.chroms) + 2 * self.chrom_step)

            self.win.set_visible(0, -2 * self.chrom_step, maxchrom, bottom)
            self.win.focus(w / 2, h / 2)
            self.win.zoom(1, maxchrom / abs(-2 * self.chrom_step - bottom))
            self.win.zoom(.9, .9)

        self.enable_updating(True)