예제 #1
0
    def __init__(self, parent, selections_list, *args, **configs):

        self.selections_list = selections_list
        PyMod_tool_window_qt.__init__(self, parent, *args, **configs)

        # Builds a combobox for each PyMOL object to import.
        self.sele_checkbox_list = []
        for sele in selections_list:
            checkbox = QtWidgets.QCheckBox(sele)
            self.sele_checkbox_list.append(checkbox)
            self.middle_formlayout.addRow(checkbox)
예제 #2
0
    def build_protocol_middle_frame(self):
        """
        Allow to choose between plotting all amino acids types or only a subset
        of them.
        """

        # Radioselect.
        aa_select_choices = ("Use all amino acids", "Select amino acids types")
        aa_select_choices_values = ["all", "single"]
        self.aa_select_choices_dict = dict([
            (k, v)
            for (k, v) in zip(aa_select_choices, aa_select_choices_values)
        ])
        self.aa_select_rds = PyMod_radioselect_qt(
            label_text="Select Amino Acids", buttons=aa_select_choices)
        self.aa_select_rds.setvalue(aa_select_choices[0])
        self.aa_select_rds.buttons_dict[aa_select_choices[0]].clicked.connect(
            self.hide_select_single_aa_frame)
        self.aa_select_rds.buttons_dict[aa_select_choices[1]].clicked.connect(
            self.show_select_single_aa_frame)
        self.middle_formlayout.add_widget_to_align(self.aa_select_rds)

        # Checkboxes for selecting single amino acids.
        self.aa_select_grid_layout = QtWidgets.QGridLayout()
        self.aa_select_rds.input.addLayout(self.aa_select_grid_layout)

        self.aa_checkbutton = {}
        self.aa_freq_dict = {}
        self.aa_checkbutton_list = []

        for i, aa in enumerate(prot_standard_one_letter):

            # Get the number of aa in the sequence.
            aa_freq = str(self.protocol.target_sequence.my_sequence).count(aa)
            self.aa_freq_dict[aa] = aa_freq

            # Build a checkbox for the aa.
            checkbox = QtWidgets.QCheckBox(
                pmsm.one2three(aa) + " (" + str(aa_freq) + ")")
            checkbox.setEnabled(False)
            self.aa_select_grid_layout.addWidget(checkbox, int(i % 10),
                                                 int(i / 10))

            self.aa_checkbutton[aa] = checkbox
            self.aa_checkbutton_list.append(checkbox)

        self.aa_select_grid_layout.setAlignment(QtCore.Qt.AlignLeft)

        self.middle_formlayout.set_input_widgets_width("auto", padding=40)
예제 #3
0
파일: volume.py 프로젝트: icamps/AMDock-win
    def __init__(self, widget, window=None, name='', _self=None):

        if window:
            window.setWindowTitle(name + ' - Volume Color Map Editor')

        cmd = _self

        layout = QtWidgets.QVBoxLayout()
        widget.setLayout(layout)

        widget.editor = VolumeEditorWidget(widget, name, _self)
        layout.addWidget(widget.editor)
        layout.setContentsMargins(5, 5, 5, 5)
        get_colors_btn = QtWidgets.QPushButton("Get colors as script")
        get_colors_btn.setAutoDefault(False)
        get_colors_btn.clicked.connect(widget.editor.displayScript)
        help_btn = QtWidgets.QPushButton("Help")
        help_btn.setAutoDefault(False)
        help_btn.clicked.connect(widget.editor.displayHelp)
        reset_btn = QtWidgets.QPushButton("Reset Data Range")
        reset_btn.setAutoDefault(False)
        reset_btn.clicked.connect(widget.editor.reset)
        widget.editor.update_cb = QtWidgets.QCheckBox(
            "Update volume colors in real-time")
        widget.editor.update_cb.setObjectName("volume_checkbox")
        widget.editor.update_cb.setChecked(True)
        widget.editor.update_cb.setMinimumWidth(30)
        widget.editor.update_cb.toggled.connect(
            widget.editor.toggleRealTimeUpdates)

        button_layout = QtWidgets.QHBoxLayout()
        button_layout.addWidget(get_colors_btn)
        button_layout.addWidget(reset_btn)
        button_layout.addWidget(help_btn)
        button_layout.addStretch()
        button_layout.addWidget(widget.editor.update_cb)

        layout.addLayout(button_layout)

        histogram = cmd.get_volume_histogram(name)
        widget.editor.setHistogram(histogram)

        colors = cmd.volume_color(name)
        widget.editor.setColors(colors)
예제 #4
0
    def add_plot(self, x_data, y_data,
                 label=None,
                 additional_data=None):
        """
        Adds a plot to the pyqtgraph PlotWidget.
        """

        # Check and prepare the data.
        if len(x_data) != len(y_data):
            raise ValueError(("The x series and the y series do not have the same"
                              " number of elements (%s and %s respectively)" % (len(x_data), len(y_data))))
        if additional_data:
            if not len(x_data) == len(additional_data):
                raise ValueError(("The 'additional_data' series does not have the"
                                  " same number of elements of the data to plot"
                                  " (%s and %s respectively)" % (len(x_data), len(additional_data))))

        _x_data, _y_data = self.remove_none(x_data, y_data)


        # Add the plot to the PlotWidget.
        plot_color = self.plot_colors[self.plot_color_index]
        self.change_plot_color_index()

        curve_pen = pyqtgraph.mkPen(width=2, color=plot_color) # Color and width of the curve.

        plot_item = self.graphWidget.plot(_x_data, _y_data,
                                          name=label,
                                          connect="finite",
                                          pen=curve_pen,
                                          clickable=True)
        plot_item._pymod_id = self.plot_count
        plot_item.curve._pymod_id = self.plot_count

        plot_item.curve.setClickable(True)
        # plot_item.curve.sigClicked.connect(self.on_curve_click)
        plot_item.sigClicked.connect(self.on_curve_click)


        # Store information about the plot.
        self.plot_items[self.plot_count] = {}
        # The 'plot' key will store the pyqtgraph object for the plot.
        self.plot_items[self.plot_count]["plot"] = plot_item
        # The 'state' will be 1 if the plot is shown, and 0 it is hidden.
        self.plot_items[self.plot_count]["state"] = 1
        # Add a label.
        if label is None:
            label = "Plot %s" % self.plot_count
        self.plot_items[self.plot_count]["label"] = label
        # Data.
        self.plot_items[self.plot_count]["x_data"] = x_data
        self.plot_items[self.plot_count]["y_data"] = y_data
        # Additional data.
        self.plot_items[self.plot_count]["additional_data"] = additional_data


        # Stores all the data in a single list.
        for idx, (xi, yi) in enumerate(zip(x_data, y_data)):
            if yi is not None:
                self.all_points.append((xi, yi))
                self.all_points_info.append((self.plot_count, idx))


        # Add a checkbox in the controls frame. Used for showing/hiding the plot.
        if self.use_controls:
            plot_checkbox = QtWidgets.QCheckBox(label)
            plot_checkbox.setStyleSheet(small_font_style)
            plot_checkbox.setChecked(True)
            plot_checkbox.clicked.connect(lambda a=None, i=self.plot_count: self.toggle_plot(i))
            plot_color_label = QtWidgets.QLabel("---") # \u2796") # "\u25CF"
            plot_color_label.setStyleSheet("color: %s; font-weight: bold" % plot_color)
            self.controls_frame_layout.addWidget(plot_color_label, self.plot_count+1, 0, 1, 1)
            self.controls_frame_layout.addWidget(plot_checkbox, self.plot_count+1, 1, 1, 1)

            self.plot_items[self.plot_count]["checkbox"] = plot_checkbox

        # Increase the plot counter.
        self.plot_count += 1
예제 #5
0
def qtdialog():
    dialog = QtWidgets.QDialog()
    uifile = os.path.join(os.path.dirname(__file__), 'excelexporter.ui')
    form = pymolqtutils.loadUi(uifile, dialog)
    form._dialog = dialog

    # pre-fill form with likely data
    names = pymol.cmd.get_object_list()
    names += ['(' + n + ')' for n in pymol.cmd.get_names('public_selections')]
    form.input_sele.addItems(names)

    checkboxes = {
        'x': form.check_x,
        'y': form.check_y,
        'z': form.check_z,
    }

    prop_names = [
        'model', 'segi', 'chain', 'resi', 'resv', 'resn', 'name', 'alt', 'b',
        'q', 'elem', 'type', 'formal_charge', 'partial_charge', 'numeric_type',
        'text_type', 'stereo', 'ID', 'rank', 'index', 'vdw', 'ss', 'color',
        'reps', 'protons', 'state'
    ]

    # user properties
    p_set = set()
    pymol.cmd.iterate('all',
                      'p_set_update(p)',
                      space={'p_set_update': p_set.update})
    prop_names.extend('p.' + prop for prop in sorted(p_set))

    ncols = 3

    for i, prop in enumerate(prop_names):
        check = QtWidgets.QCheckBox(prop, form.groupBox)
        form.gridLayout.addWidget(check, i // ncols, i % ncols, 1, 1)
        checkboxes[prop] = check

    # add state properties to list
    prop_names.extend('xyz')

    for prop in ['chain', 'resi', 'resn', 'name']:
        checkboxes[prop].setChecked(True)

    @form.button_ok.clicked.connect
    def _(*args):
        props = [p for p in prop_names if checkboxes[p].isChecked()]
        sele = form.input_sele.currentText()
        statetext = form.input_state.checkedButton().text()

        if statetext.startswith('current'):
            state = -1
        elif statetext.startswith('all'):
            state = 0
        else:
            state = STATELESS
            props = [p for p in props if p not in ['x', 'y', 'z']]

        if not _check_xlwings():
            return

        with pymolqtutils.PopupOnException():
            dumpexcel(sele, props, state)

    form._dialog.show()
예제 #6
0
    def display_blast_hits(self):
        """
        This is used to display in the BLAST results window information for each
        hit and a checkbutton to select it for importing it inside PyMod.
        """

        # Shows the headers of the columns.
        headers_font_style = "%s; color: %s; font-weight: bold" % (small_font_style, highlight_color)
        self.blast_seq_label = QtWidgets.QLabel("Name")
        self.blast_seq_label.setStyleSheet(headers_font_style)
        self.results_grid.addWidget(self.blast_seq_label, 0, 0)

        if not self.protocol.blast_version in hmmer_protocols_names:
            evalue_header_text = "E-Value"
        else:
            evalue_header_text = "E-Value (c-Evalue)"
        self.blast_e_val_label = QtWidgets.QLabel(evalue_header_text)
        self.blast_e_val_label.setStyleSheet(headers_font_style)
        self.results_grid.addWidget(self.blast_e_val_label, 0, 1)

        if self.protocol.protocol_name != "hmmsearch":
            self.blast_iden_label = QtWidgets.QLabel("Identity")
            self.blast_iden_label.setStyleSheet(headers_font_style)
            self.results_grid.addWidget(self.blast_iden_label, 0, 2)

        self.query_span_label = QtWidgets.QLabel("Query span")
        self.query_span_label.setStyleSheet(headers_font_style)
        self.results_grid.addWidget(self.query_span_label, 0, 3)

        self.subject_span_label = QtWidgets.QLabel("Subject span")
        self.subject_span_label.setStyleSheet(headers_font_style)
        self.results_grid.addWidget(self.subject_span_label, 0, 4)


        # Displays in the results window the hsps found in the output file of the
        # similarity search program.
        self.blast_output_row = 1

        self.sbjct_checkbuttons_list = [] # List containing the checkbutton widgets.

        for hsp in self.protocol.hsp_list:

            # Hit name and checkbox.
            subject_name = self.protocol.get_subject_name(hsp)
            hsp_checkbox = QtWidgets.QCheckBox(subject_name)
            hsp_checkbox.setStyleSheet(small_font_style)
            self.sbjct_checkbuttons_list.append(hsp_checkbox)
            self.results_grid.addWidget(hsp_checkbox, self.blast_output_row, 0)

            # E-value info.
            if not self.protocol.blast_version in hmmer_protocols_names:
                evalue_label_text = "%.2e" % (self.protocol.get_hsp_evalue(hsp))
            else:
                evalue_tuple = self.protocol.get_hsp_evalue(hsp)
                evalue_label_text = "%.1e (%.1e)" % (evalue_tuple[0], evalue_tuple[1])
                # evalue_label_text = "%.1e" % (evalue_tuple[0])
            evalue_label = QtWidgets.QLabel(evalue_label_text)
            evalue_label.setStyleSheet(small_font_style)
            self.results_grid.addWidget(evalue_label, self.blast_output_row, 1)

            # HSP seqid info.
            if self.protocol.protocol_name != "hmmsearch":
                id_text = "%s/%s (%.1f%%)" % (hsp.pymod_info["identities"], int(hsp.pymod_info["matches"]), hsp.pymod_info["seqid"]*100)
                identities_label = QtWidgets.QLabel(id_text)
                identities_label.setStyleSheet(small_font_style)
                self.results_grid.addWidget(identities_label, self.blast_output_row, 2)

            # Query span info.
            span_info_text = "%s-%s (%.1f%%)" % (hsp.pymod_info["query_start"], hsp.pymod_info["query_end"], hsp.pymod_info["query_span"]*100)
            span_info_label = QtWidgets.QLabel(span_info_text)
            span_info_label.setStyleSheet(small_font_style)
            self.results_grid.addWidget(span_info_label, self.blast_output_row, 3)

            # Subject span info.
            hspan_info_text = "%s-%s" % (hsp.pymod_info["sbjct_start"], hsp.pymod_info["sbjct_end"])
            hspan_info_label = QtWidgets.QLabel(hspan_info_text)
            hspan_info_label.setStyleSheet(small_font_style)
            self.results_grid.addWidget(hspan_info_label, self.blast_output_row, 4)

            self.blast_output_row += 1
예제 #7
0
    def __init__(self, parent=None, app=None):
        super(_BuilderPanel, self).__init__(parent)

        self.setWindowTitle("Builder")
        self.setObjectName("builder")
        self.cmd = app.pymol.cmd

        self.layout = QtWidgets.QVBoxLayout()
        self.setLayout(self.layout)
        self.buttons_layout = QtWidgets.QVBoxLayout()

        self.tabs = QtWidgets.QTabWidget(self)
        self.layout.setContentsMargins(5, 5, 5, 5);
        self.layout.setSpacing(5);
        self.layout.addWidget(self.tabs)
        self.layout.addLayout(self.buttons_layout)
        self.layout.addStretch()

        self.fragments_layout = QtWidgets.QGridLayout()
        self.fragments_layout.setContentsMargins(5, 5, 5, 5);
        self.fragments_layout.setSpacing(5);
        self.fragments_tab = QtWidgets.QWidget()
        self.fragments_tab.setLayout(self.fragments_layout)
        self.protein_layout = QtWidgets.QGridLayout()
        self.protein_layout.setContentsMargins(5, 5, 5, 5);
        self.protein_layout.setSpacing(5);
        self.protein_tab = QtWidgets.QWidget()
        self.protein_tab.setLayout(self.protein_layout)

        self.tabs.addTab(self.fragments_tab, "Chemical")
        self.tabs.addTab(self.protein_tab, "Protein")

        self.getIcons()

        buttons = [
            [ ("H", "Hydrogen", lambda: self.replace("H", 1, 1, "Hydrogen")),
              ("C", "Carbon", lambda: self.replace("C", 4, 4, "Carbon")),
              ("N", "Nitrogen", lambda: self.replace("N", 4, 3, "Nitrogen")),
              ("O", "Oxygen", lambda: self.replace("O", 4, 2, "Oxygen")),
              ("P", "Phosphorus", lambda: self.replace("P",4,3, "Phosphorous")),
              ("S", "Sulfur", lambda: self.replace("S",2,2, "Sulfur")),
              ("F", "Fluorine", lambda: self.replace("F",1,1, "Fluorine")),
              ("Cl", "Chlorrine", lambda: self.replace("Cl",1,1, "Chlorine")),
              ("Br", "Bromine", lambda: self.replace("Br",1,1, "Bromine")),
              ("I", "Iodine", lambda: self.replace("I",1,1, "Iodine")),
              ("-CF3", "Trifluoromethane", lambda: self.replace("trifluoromethane",4,0, "trifluoro")),
              ("-OMe", "Methanol", lambda: self.replace("methanol",5,0, "methoxy")),
            ],
            [ ("CH4", "Methyl", lambda: self.grow("methane",1,0,"methyl")),
              ("C=C", "Ethylene", lambda: self.grow("ethylene",4,0,"vinyl")),
              ("C#C", "Acetylene", lambda: self.grow("acetylene",2,0,"alkynl")),
              ("C#N", "Cyanide", lambda: self.grow("cyanide",2,0,"cyano")),
              ("C=O", "Aldehyde", lambda: self.grow("formaldehyde",2,0,"carbonyl",)),
              ("C=OO", "Formic Acid", lambda: self.grow("formic",4,0,"carboxyl")),
              ("C=ON", "C->N amide", lambda: self.grow("formamide",5,0,"C->N amide")),
              ("NC=O", "N->C amide", lambda: self.grow("formamide",3,1,"N->C amide")),
              ("S=O2", "Sulfone", lambda: self.grow("sulfone",3,1,"sulfonyl")),
              ("P=O3", "Phosphite", lambda: self.grow("phosphite",4,0,"phosphoryl")),
              ("N=O2", "Nitro", lambda: self.grow("nitro",3,0,"nitro")),
            ],
            [
              ("#cyc3", "Cyclopropane", lambda: self.grow("cyclopropane",4,0,"cyclopropyl")),
              ("#cyc4", "Cyclobutane", lambda: self.grow("cyclobutane",4,0,"cyclobutyl")),
              ("#cyc5", "Cyclopentane", lambda: self.grow("cyclopentane",5,0,"cyclopentyl")),
              ("#cyc6", "Cyclohexane", lambda: self.grow("cyclohexane",7,0,"cyclohexyl")),
              ("#cyc7", "Cycloheptane", lambda: self.grow("cycloheptane",8,0,"cycloheptyl")),
              ("#aro5", "Cyclopentadiene", lambda: self.grow("cyclopentadiene",5,0,"cyclopentadienyl")),
              ("#aro6", "Benzene", lambda: self.grow("benzene",6,0,"phenyl")),
              ("#aro65", "Indane", lambda: self.grow("indane",12,0,"indanyl")),
              ("#aro66", "Napthylene", lambda: self.grow("napthylene",13,0,"napthyl")),
              ("#aro67", "Benzocycloheptane", lambda: self.grow("benzocycloheptane",13,0, "benzocycloheptyl")),
            ]
        ]

        self.btn_icons = {}

        requestsize = QtCore.QSize(48, 48)
        for row, btn_row in enumerate(buttons):
            for col, bb in enumerate(btn_row):
                btn_label, btn_tooltip, btn_command = bb
                btn = makeFragmentButton()
                if btn_label.startswith('#'):
                    icons = self.icons[btn_label[1:]]
                    btn.setIcon(icons[0])
                    btn.setIconSize(icons[1].actualSize(requestsize))
                    self.btn_icons[btn] = icons
                else:
                    btn.setText(btn_label)
                btn.setToolTip(btn_tooltip)
                btn.clicked.connect(btn_command)
                self.fragments_layout.addWidget(btn, row, col)

        buttons = [
            [ 'Ace', 'Ala', 'Arg', 'Asn', 'Asp', 'Cys', 'Gln', 'Glu', 'Gly', 'His', 'Ile', 'Leu' ],
            [ 'Lys', 'Met', 'Phe', 'Pro', 'Ser', 'Thr', 'Trp', 'Tyr', 'Val', 'NMe', 'NHH' ]
        ]
        for row, btn_row in enumerate(buttons):
            for col, btn_label in enumerate(btn_row):
                btn = makeFragmentButton()
                btn.setText(btn_label)
                btn.setToolTip("Build %s residue" % btn_label)
                res = btn_label.lower()
                slot = lambda val=None, s=self,r=res: s.attach(r)
                btn.clicked.connect(slot)
                self.protein_layout.addWidget(btn, row, col)

        lab = QtWidgets.QLabel('Secondary Structure:')
        lab_cols = 3
        self.ss_cbox = QtWidgets.QComboBox()
        self.ss_cbox.addItem("Alpha Helix")
        self.ss_cbox.addItem("Beta Sheet (Anti-Parallel)")
        self.ss_cbox.addItem("Beta Sheet (Parallel)")
        self.protein_layout.addWidget(lab, 2, 0, 1, lab_cols)
        self.protein_layout.addWidget(self.ss_cbox, 2, lab_cols, 1, 4)
        self.ss_cbox.currentIndexChanged[int].connect(self.ssIndexChanged)

        buttons = [
            [
              ( "@Atoms:", None, None),
              ( "Fix H", "Fix hydrogens on picked atoms", self.fixH),
              ( "Add H", "Add hydrogens to entire molecule", self.addH),
              ( "Invert", "Invert stereochemistry around pk1 (pk2 and pk3 will remain fixed)", self.invert),
              ( "Delete", "Remove atoms", self.removeAtom),
              ( "Clear", "Delete everything", self.clear),
              ( "@   Charge:", None, None),
              ( " +1 ", "Positive Charge", lambda: self.setCharge(1,"+1")),
              ( "  0 ", "Neutral Charge", lambda: self.setCharge(0,"neutral")),
              ( " -1 ", "Negative Charge", lambda: self.setCharge(-1,"-1")),
            ],
            [
              ( "@Bonds:", None, None),
              ( "Create", "Create bond between pk1 and pk2", self.createBond),
              ( "Delete", "Delete bond between pk1 and pk2", self.deleteBond),
              ( "Cycle", "Cycle bond valence", self.cycleBond),
              ( "  |  ", "Create single bond", lambda: self.setOrder("1", "single")),
              ( " || ", "Create double bond", lambda: self.setOrder("2", "double")),
              ( " ||| ", "Create triple bond", lambda: self.setOrder("3", "triple")),
              ( "Arom", "Create aromatic bond", lambda: self.setOrder("4", "aromatic")),
              ( "@   Model:", None, None),
              ( "Clean", "Cleanup structure", self.clean),
              ( "Sculpt", "Molecular sculpting", self.sculpt),
              ( "Fix", "Fix atom positions", self.fix),
              ( "Rest", "Restrain atom positions", self.rest),
            ],
            [
              ( "$El-stat", "Electrostatics term for 'Clean' action", "clean_electro_mode"),
              ( "@   ", None, None),
              ( "$Bumps", "Show VDW contacts during sculpting", "sculpt_vdw_vis_mode"),
              ( "@   ", None, None),
              ( "#Undo Enabled", "", "suspend_undo"),
              ( "Undo", "Undo last change", self.undo),
              ( "Redo", "Redo last change", self.redo),
            ]
        ]

        for row, btn_row in enumerate(buttons):
            btn_row_layout = QtWidgets.QHBoxLayout()
            self.buttons_layout.addLayout(btn_row_layout)
            for col, bb in enumerate(btn_row):
                btn_label, btn_tooltip, btn_command = bb
                if btn_label[0] == '@':
                    btn = QtWidgets.QLabel(btn_label[1:])
                elif btn_label[0] in ('#', '$'):
                    btn = QtWidgets.QCheckBox(btn_label[1:])
                    setting = btn_command
                    value = self.cmd.get_setting_int(setting)
                    if btn_label[0] == '$':
                        btn.setChecked(bool(value))
                        @btn.toggled.connect
                        def _(checked, n=setting):
                            self.cmd.set(n, checked, quiet=0)
                    else:
                        btn.setChecked(not value)
                        @btn.toggled.connect
                        def _(checked, n=setting):
                            self.cmd.set(n, not checked, quiet=0)
                else:
                    btn = makeFragmentButton()
                    btn.setText(btn_label)
                    btn.clicked.connect(btn_command)
                if btn_tooltip:
                    btn.setToolTip(btn_tooltip)
                btn_row_layout.addWidget(btn)
            btn_row_layout.addStretch()
예제 #8
0
파일: _gui.py 프로젝트: speleo3/pymod
    def display_hmmscan_hits(self):
        """
        This is used to display in the HMMSCAN results window information for
        each hit and a checkbutton to select it for importing it inside PyMod.
        """

        #------------------------------------
        # Shows the headers of the columns. -
        #------------------------------------

        headers_font_style = "%s; color: %s" % (small_font_style,
                                                highlight_color)
        headers_font_style = "%s; font-weight: bold" % (small_font_style)

        self.hmmscan_seq_label = QtWidgets.QLabel("Name")
        self.hmmscan_seq_label.setStyleSheet(headers_font_style)
        self.results_grid.addWidget(self.hmmscan_seq_label, 0, 0)

        self.description_label = QtWidgets.QLabel("Description")
        self.description_label.setStyleSheet(headers_font_style)
        self.results_grid.addWidget(self.description_label, 0, 1)

        self.hmmscan_e_val_label = QtWidgets.QLabel("E-Value")
        self.hmmscan_e_val_label.setStyleSheet(headers_font_style)
        self.results_grid.addWidget(self.hmmscan_e_val_label, 0, 2)

        self.query_span_label = QtWidgets.QLabel("Query span")
        self.query_span_label.setStyleSheet(headers_font_style)
        self.results_grid.addWidget(self.query_span_label, 0, 3)

        self.hmm_span_label = QtWidgets.QLabel("HMM span")
        self.hmm_span_label.setStyleSheet(headers_font_style)
        self.results_grid.addWidget(self.hmm_span_label, 0, 4)

        #----------------------
        # Prepare the colors. -
        #----------------------

        self.color_palette_dec = domain_colors_ordered
        # self.color_palette = [[j*255 for j in i[1]] for i in self.color_palette_dec]
        self.color_palette_hex = [
            convert_rgb_to_hex(i[1]) for i in self.color_palette_dec
        ]

        color_idx = 0
        for hit in self.protocol.parsed_res:
            hit.update({
                'dom_color': self.color_palette_dec[color_idx],
                'dom_color_hex': self.color_palette_hex[color_idx]
            })
            color_idx += 1
            if color_idx == len(self.color_palette_dec):
                color_idx = 0

        #---------------------------------------
        # Show the hits in the results window. -
        #---------------------------------------

        # Keep track of the rows in the grid.
        hmmscan_output_row = 1

        # This is going to contain the list of values of each checkbutton.
        self.color_square_lst = []  # all in a row
        self.domain_check_states = []  # clustered
        self.domain_widgets_dict = {}
        domain_counter = 0

        # Process all the hits. Eeach hit is a different HMM profile, that is, a
        # different domain type.
        for hit in self.protocol.parsed_res:

            # Hit name.
            hit_name_label = QtWidgets.QLabel(hit['id'])
            hit_name_label.setStyleSheet(small_font_style)
            self.results_grid.addWidget(hit_name_label, hmmscan_output_row, 0)

            # Hit description.
            if 'desc' in hit:
                descr_text = hit['desc'][:40] + '...' if len(
                    hit['desc']) > 41 else hit['desc']
            else:
                descr_text = '-'
            hit_descr_label = QtWidgets.QLabel(descr_text)
            hit_descr_label.setStyleSheet(small_font_style)
            self.results_grid.addWidget(hit_descr_label, hmmscan_output_row, 1)

            # E-value info.
            evalue_label = QtWidgets.QLabel(str(hit['evalue']))
            evalue_label.setStyleSheet(
                "%s; color: %s" %
                (small_font_style,
                 hit['dom_color_hex']))  # results_row_options
            self.results_grid.addWidget(evalue_label, hmmscan_output_row, 2)

            hmmscan_output_row += 1

            self.domain_check_states.append([])

            for domain_hit in hit['location']:

                domain_widgets = {"checkbox": None, "rect": None}

                # Domain rectangle shown in the upper frame of the window.
                domain_rect = self.add_domain_representation(hit, domain_hit)
                domain_widgets["rect"] = domain_rect

                # Checkbox for selection.
                color_square = QtWidgets.QCheckBox(" ")
                self.color_square_lst.append(color_square)
                self.domain_check_states[-1].append(color_square)
                color_square.clicked.connect(
                    lambda a=None, x=domain_counter: self.toggle_domain(x))
                self.results_grid.addWidget(color_square, hmmscan_output_row,
                                            0)
                domain_widgets["checkbox"] = color_square

                # Grahical representation of the domain in the query sequence.
                graphics_view = self.create_little_canvas(hit, domain_hit)
                self.results_grid.addWidget(graphics_view, hmmscan_output_row,
                                            1)

                # Individual E-value info.
                hsp_ievalue_label = QtWidgets.QLabel(str(domain_hit['evalue']))
                hsp_ievalue_label.setStyleSheet(small_font_style)
                self.results_grid.addWidget(hsp_ievalue_label,
                                            hmmscan_output_row, 2)

                # Query span info.
                span_info_label = QtWidgets.QLabel(
                    str(domain_hit['start']) + ' - ' + str(domain_hit['end']))
                span_info_label.setStyleSheet(small_font_style)
                self.results_grid.addWidget(span_info_label,
                                            hmmscan_output_row, 3)

                # HMM span info.
                hspan_info_text = str(domain_hit['hmm_start']) + ' - ' + str(
                    domain_hit['hmm_end'])
                hspan_info_label = QtWidgets.QLabel(hspan_info_text)
                hspan_info_label.setStyleSheet(small_font_style)
                self.results_grid.addWidget(hspan_info_label,
                                            hmmscan_output_row, 4)

                hmmscan_output_row += 1

                self.domain_widgets_dict[domain_counter] = domain_widgets
                domain_counter += 1
예제 #9
0
    def display_blast_hits(self):
        """
        This is used to display in the BLAST results window information for each
        hit and a checkbutton to select it for importing it inside PyMod.
        """

        # Shows the headers of the columns.
        headers_font_style = "%s; color: %s; font-weight: bold" % (
            small_font_style, highlight_color)
        self.blast_seq_label = QtWidgets.QLabel("Name")
        self.blast_seq_label.setStyleSheet(headers_font_style)
        self.results_grid.addWidget(self.blast_seq_label, 0, 0)

        self.blast_e_val_label = QtWidgets.QLabel("E-Value")
        self.blast_e_val_label.setStyleSheet(headers_font_style)
        self.results_grid.addWidget(self.blast_e_val_label, 0, 1)

        self.prob_val_label = QtWidgets.QLabel("Probability")
        self.prob_val_label.setStyleSheet(headers_font_style)
        self.results_grid.addWidget(self.prob_val_label, 0, 2)

        self.blast_iden_label = QtWidgets.QLabel("Identity")
        self.blast_iden_label.setStyleSheet(headers_font_style)
        self.results_grid.addWidget(self.blast_iden_label, 0, 3)

        self.query_span_label = QtWidgets.QLabel("Query span")
        self.query_span_label.setStyleSheet(headers_font_style)
        self.results_grid.addWidget(self.query_span_label, 0, 4)

        self.subject_span_label = QtWidgets.QLabel("Template span")
        self.subject_span_label.setStyleSheet(headers_font_style)
        self.results_grid.addWidget(self.subject_span_label, 0, 5)

        # Displays in the results window the hsps found in the output file of the
        # similarity search program.
        self.blast_output_row = 1

        self.sbjct_checkbuttons_list = [
        ]  # List containing the checkbutton widgets.

        for hsp in self.protocol.hhr_results:

            # Hit name and checkbox.
            hsp_checkbox = QtWidgets.QCheckBox(
                self.protocol.get_subject_name(hsp))
            hsp_checkbox.setStyleSheet(small_font_style)
            self.sbjct_checkbuttons_list.append(hsp_checkbox)
            self.results_grid.addWidget(hsp_checkbox, self.blast_output_row, 0)

            # E-value info.
            evalue_label = QtWidgets.QLabel(
                "%.2e" % (self.protocol.get_hsp_evalue(hsp)))
            evalue_label.setStyleSheet(small_font_style)
            self.results_grid.addWidget(evalue_label, self.blast_output_row, 1)

            # Probability.
            probability_label = QtWidgets.QLabel(
                str(self.protocol.get_prob_value(hsp)))
            probability_label.setStyleSheet(small_font_style)
            self.results_grid.addWidget(probability_label,
                                        self.blast_output_row, 2)

            # Get alignment stats.
            matches_count, identities_count = self.protocol.get_hsp_matches(
                hsp)
            seqid = identities_count / matches_count

            # Sequence identity.
            identities_label = QtWidgets.QLabel("{}/{} ({:.1f}%)".format(
                identities_count, matches_count, seqid * 100))
            identities_label.setStyleSheet(small_font_style)
            self.results_grid.addWidget(identities_label,
                                        self.blast_output_row, 3)

            # Query span info.
            query_span_val = (hsp.end[0] - hsp.start[0]) / hsp.query_length
            query_span_info_text = "{}-{} ({:.1f}%)".format(
                hsp.start[0], hsp.end[0], query_span_val * 100)
            span_info_label = QtWidgets.QLabel(query_span_info_text)
            span_info_label.setStyleSheet(small_font_style)
            self.results_grid.addWidget(span_info_label, self.blast_output_row,
                                        4)

            # Subject span info.
            tem_span_val = (hsp.end[1] - hsp.start[1]) / hsp.template_length
            tem_span_info_text = "{}-{} ({:.1f}%)".format(
                hsp.start[1], hsp.end[1], tem_span_val * 100)
            hspan_info_label = QtWidgets.QLabel(tem_span_info_text)
            hspan_info_label.setStyleSheet(small_font_style)
            self.results_grid.addWidget(hspan_info_label,
                                        self.blast_output_row, 5)

            self.blast_output_row += 1
예제 #10
0
    def __init__(self, parent=None):
        super(SurfStampFrame, self).__init__(parent)

        self.layout = QtWidgets.QVBoxLayout()
        self.setLayout(self.layout)

        glayout1 = QtWidgets.QGridLayout()
        self.label_message = QtWidgets.QLabel(self)
        self.label_message.setText("SurfStamp PyMOL plugin")
        self.layout.addWidget(self.label_message)

        self.combo_model = QtWidgets.QComboBox()
        self.combo_model.addItems([])
        self.layout.addWidget(self.combo_model)

        self.label_reso = QtWidgets.QLabel(self)
        self.label_reso.setText("Surface Resolution")
        glayout1.addWidget(self.label_reso, 1, 0)
        self.spin_reso = QtWidgets.QDoubleSpinBox(self)
        self.spin_reso.setRange(0.1, 1.0)
        self.spin_reso.setSingleStep(0.05)
        self.spin_reso.setValue(0.7)
        glayout1.addWidget(self.spin_reso, 1, 1)

        self.label_imagesize = QtWidgets.QLabel(self)
        self.label_imagesize.setText("Image Size")
        glayout1.addWidget(self.label_imagesize, 2, 0)
        self.spin_imagesize = QtWidgets.QSpinBox(self)
        self.spin_imagesize.setRange(1000, 10000)
        #PILLOW?は 13000 くらいが Max っぽい
        self.spin_imagesize.setSingleStep(100)
        self.spin_imagesize.setValue(4000)
        glayout1.addWidget(self.spin_imagesize, 2, 1)

        self.label_fontsize = QtWidgets.QLabel(self)
        self.label_fontsize.setText("Font Size")
        glayout1.addWidget(self.label_fontsize, 3, 0)
        self.spin_fontsize = QtWidgets.QSpinBox(self)
        self.spin_fontsize.setRange(3, 100)
        self.spin_fontsize.setSingleStep(1)
        self.spin_fontsize.setValue(20)
        glayout1.addWidget(self.spin_fontsize, 3, 1)

        glayout2 = QtWidgets.QGridLayout()
        self.check_outline = QtWidgets.QCheckBox('Outline')
        self.check_outline.setChecked(True)
        glayout2.addWidget(self.check_outline, 0, 0)

        self.check_nowater = QtWidgets.QCheckBox('Remove Waters')
        self.check_nowater.setChecked(True)
        glayout2.addWidget(self.check_nowater, 0, 1)

        self.check_colorall = QtWidgets.QCheckBox('Color All')
        self.check_colorall.setChecked(False)
        glayout2.addWidget(self.check_colorall, 1, 0)

        self.check_tile = QtWidgets.QCheckBox('Repeating Tile')

        self.check_tile.clicked.connect(self.checkTileOn)
        self.check_tile.setChecked(False)
        glayout2.addWidget(self.check_tile, 1, 1)

        self.check_oneletter = QtWidgets.QCheckBox('One Letter')
        glayout2.addWidget(self.check_oneletter, 2, 0)

        self.check_nochainname = QtWidgets.QCheckBox('No Chain Name')
        glayout2.addWidget(self.check_nochainname, 2, 1)

        self.check_ignore_occupancy = QtWidgets.QCheckBox('Ignore Occupancy')
        glayout2.addWidget(self.check_ignore_occupancy, 3, 0)
        self.check_cartoon = QtWidgets.QCheckBox('Cartoon')
        self.check_cartoon.clicked.connect(self.checkCartoonOn)
        glayout2.addWidget(self.check_cartoon, 3, 1)

        self.check_mmcif = QtWidgets.QCheckBox('Use MMCIF')
        glayout2.addWidget(self.check_mmcif, 4, 0)

        self.check_builtin = QtWidgets.QCheckBox('Built-in Surface Generator')
        glayout2.addWidget(self.check_builtin, 4, 1)
        self.check_builtin.clicked.connect(self.checkBuiltinOn)

        #MMCIF は AUTH が不完全だ!
        #self.check_label = QtWidgets.QCheckBox('ID Label');
        #self.layout.addWidget(self.check_label);

        # Text field for output file
        glayout4 = QtWidgets.QVBoxLayout()

        self.label_outprefix = QtWidgets.QLabel(
            'Output Prefix (Prefix+<something> will be overwritten.)')
        glayout4.addWidget(self.label_outprefix)

        glayout4b = QtWidgets.QGridLayout()
        self.text_outprefix = QtWidgets.QLineEdit(self)
        self.text_outprefix.setReadOnly(True)
        glayout4b.addWidget(self.text_outprefix, 0, 0)

        self.button_outprefix = QtWidgets.QPushButton(self)
        self.button_outprefix.setText("Save As")

        self.button_outprefix.clicked.connect(self.getFile)
        self.text_outprefix.setStyleSheet("background-color: lightgray;")

        glayout4b.addWidget(self.button_outprefix, 0, 1)
        glayout4.addLayout(glayout4b)

        glayout3 = QtWidgets.QGridLayout()
        self.button_ok = QtWidgets.QPushButton('Create')
        self.button_ok.clicked.connect(self.runSurfStamp)
        glayout3.addWidget(self.button_ok, 0, 0)

        self.button_close = QtWidgets.QPushButton('Close')
        self.button_close.clicked.connect(self.hide)
        glayout3.addWidget(self.button_close, 0, 1)

        self.layout.addLayout(glayout1)
        self.layout.addLayout(glayout2)
        self.layout.addLayout(glayout4)
        self.layout.addLayout(glayout3)

        screengeom = QtWidgets.qApp.desktop().screenGeometry()

        wwidth = 300
        hheight = 200
        self.setGeometry(screengeom.width() / 2 - wwidth / 2,
                         screengeom.height() / 2 - hheight / 2, wwidth,
                         hheight)
        self.setWindowTitle('SurfStamp')
        self.checkTileOn()
        self.checkBuiltinOn()
        self.checkCartoonOn()
        self.show()