Ejemplo n.º 1
0
    def __init__(self, label_text="Input", buttons=[]):
        PyMod_form_item.__init__(self)

        # Label.
        self.label = QtWidgets.QLabel(label_text)

        # Buttons.
        self.input = QtWidgets.QVBoxLayout()

        if not buttons:
            raise ValueError("Please provide a list of button names")
        if len(buttons) != len(set(buttons)):
            raise ValueError("Please provide a non redundant list of buttons")

        self.button_group = QtWidgets.QButtonGroup()
        self.buttons_names = []
        self.buttons_dict = {}

        for button_name in buttons:
            button = QtWidgets.QPushButton(button_name)
            button.setCheckable(True)
            self.input.addWidget(button)
            self.buttons_names.append(button_name)
            self.buttons_dict[button_name] = button
            self.button_group.addButton(button)
Ejemplo n.º 2
0
    def build_alignment_mode_frame(self):
        """
        Builds a frame with some options to choose the alignment mode.
        """

        # Vbox which will store all the widgets for the alignment mode options.
        self.alignment_mode_vbox = QtWidgets.QVBoxLayout()
        self.alignment_mode_label = QtWidgets.QLabel("Alignment Mode")
        self.alignment_mode_vbox.addWidget(self.alignment_mode_label)

        self.alignment_mode_button_group = QtWidgets.QButtonGroup()
        self.build_strategy_specific_modes_frames() # Defined in child classes.

        self.middle_formlayout.addRow(self.alignment_mode_vbox)
Ejemplo n.º 3
0
    def __init__(self, *args, **kwargs):

        super(PyMod_plot_window_qt, self).__init__(*args, **kwargs)

        # Central widget.
        self.central_widget = QtWidgets.QWidget()
        self.setCentralWidget(self.central_widget)
        self.central_widget_layout = QtWidgets.QGridLayout()
        self.central_widget.setLayout(self.central_widget_layout)


        #------------------------------------------------
        # Upper frame (contains the plot and controls). -
        #------------------------------------------------

        expanding_size_policy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding,
                                                      QtWidgets.QSizePolicy.Expanding)

        preferred_size_policy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred,
                                                      QtWidgets.QSizePolicy.Preferred)

        # The upper frame contains three frames: info, plot and controls frames.
        # The infor and controls frames will be displayed only if the 'use_controls'
        # argument is set to 'True' when calling the 'build_plotting_area' method.
        self.upper_frame = QtWidgets.QFrame()
        self.upper_frame.setStyleSheet("background-color: #646464")
        self.upper_frame_layout = QtWidgets.QGridLayout()
        self.upper_frame.setLayout(self.upper_frame_layout)
        self.upper_frame.setSizePolicy(expanding_size_policy)
        self.central_widget_layout.addWidget(self.upper_frame, 0, 0)

        # Info frame, it contains the messagebar of the plot.
        self.info_frame = QtWidgets.QFrame()
        self.info_frame_layout = QtWidgets.QHBoxLayout()
        self.info_frame.setLayout(self.info_frame_layout)
        self.info_frame.setSizePolicy(preferred_size_policy)

        self.info_label = QtWidgets.QLabel("")
        self.info_frame_layout.addWidget(self.info_label)

        # Plot frame.
        self.plot_frame = QtWidgets.QFrame()
        # self.plot_frame.setStyleSheet("background-color: red")
        self.plot_frame_layout = QtWidgets.QGridLayout()
        self.plot_frame.setLayout(self.plot_frame_layout)
        self.plot_frame.setSizePolicy(expanding_size_policy)
        self.build_plot_widget()


        # Controls frame.
        self.controls_frame = QtWidgets.QWidget()
        self.controls_frame.setStyleSheet("background-color: #747474")
        self.controls_frame_layout = QtWidgets.QGridLayout()
        self.controls_frame.setLayout(self.controls_frame_layout)
        self.controls_frame_layout.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop)

        self.controls_scrollarea = QtWidgets.QScrollArea()
        self.controls_scrollarea.setWidgetResizable(True)
        self.controls_scrollarea.setWidget(self.controls_frame)

        self.labels_title = QtWidgets.QLabel("Plots list")


        # Middle splitter.
        self.middle_splitter = QtWidgets.QSplitter(QtCore.Qt.Horizontal)
        self.middle_splitter.setSizePolicy(expanding_size_policy)


        #---------------------------------------
        # Lower frame (contains some options). -
        #---------------------------------------

        self.lower_frame = QtWidgets.QFrame()
        self.lower_frame_layout = QtWidgets.QGridLayout()
        self.lower_frame.setLayout(self.lower_frame_layout)
        self.central_widget_layout.addWidget(self.lower_frame, 1, 0)

        # View buttons.
        self.view_label = QtWidgets.QLabel("View:")
        self.lower_frame_layout.addWidget(self.view_label, 0, 0)

        self.home_view_button = QtWidgets.QPushButton("Fit to data")
        self.home_view_button.clicked.connect(self.on_home_button_click)
        self.lower_frame_layout.addWidget(self.home_view_button, 0, 1)

        # On click behaviour. The buttons will be shown later, in the
        # 'build_plotting_area' metohd.
        self.interact_buttons_group = QtWidgets.QButtonGroup()

        self.on_click_label = QtWidgets.QLabel("Interact on click:")

        self.interact_button = QtWidgets.QPushButton("Yes")
        self.interact_button.setCheckable(True)
        self.interact_buttons_group.addButton(self.interact_button)
        self.interact_button.clicked.connect(self.on_interact_button_click)

        self.no_interaction_button = QtWidgets.QPushButton("No")
        self.no_interaction_button.setCheckable(True)
        self.no_interaction_button.setChecked(True)
        self.interact_buttons_group.addButton(self.no_interaction_button)
        self.no_interaction_button.clicked.connect(self.on_no_interaction_button_click)


        # Show/hide all buttons. They will be shown later, in the 'build_plotting_area'
        # method.
        self.show_label = QtWidgets.QLabel("Show:")

        self.show_all_button = QtWidgets.QPushButton("All")
        self.show_all_button.clicked.connect(self.show_all_command)

        self.hide_all_button = QtWidgets.QPushButton("None")
        self.hide_all_button.clicked.connect(self.hide_all_command)

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


        #---------------------
        # Build a main menu. -
        #---------------------

        self.save_to_csv_action = QtWidgets.QAction('Save to CSV', self)
        self.save_to_csv_action.triggered.connect(lambda a=None: self.save_to_csv_event())
        self.save_to_png_action = QtWidgets.QAction('Save to PNG', self)
        self.save_to_png_action.triggered.connect(lambda a=None: self.save_to_png_event())

        self.main_menubar = self.menuBar()
        self.file_menu = self.main_menubar.addMenu('File')
Ejemplo n.º 4
0
    def build_protocol_middle_frame(self):

        #------------------
        # Simple options. -
        #------------------

        # Let users decide how to import new sequences when the query is a child element (that
        # is, it is already present in a cluster).
        if self.protocol.blast_query_element.is_child():

            self.import_mode_vbox = QtWidgets.QVBoxLayout()
            self.import_mode_label = QtWidgets.QLabel("Hit Import Mode")
            self.import_mode_vbox.addWidget(self.import_mode_label)

            self.import_mode_button_group = QtWidgets.QButtonGroup()
            self.middle_formlayout.addRow(self.import_mode_vbox)

            # Build new alignment.
            new_alignment_radiobutton = QtWidgets.QRadioButton("Build a new alignment with the query and the new hit sequences")
            new_alignment_radiobutton._value = "build-new"
            new_alignment_radiobutton.setChecked(True)
            self.import_mode_vbox.addWidget(new_alignment_radiobutton)
            self.import_mode_button_group.addButton(new_alignment_radiobutton)

            # Expand alignment.
            expand_alignment_radiobutton = QtWidgets.QRadioButton("Expand the existing alignment by appending the new hit sequences")
            # "Expand the already existing cluster by appending to it the new hit sequences"
            expand_alignment_radiobutton._value = "expand"
            self.import_mode_vbox.addWidget(expand_alignment_radiobutton)
            self.import_mode_button_group.addButton(expand_alignment_radiobutton)


        # Each algorithm will have its own standard widgets.
        self.build_algorithm_standard_options_widgets()


        # E-value selection.
        if self.protocol.protocol_name in hmmer_protocols_names:
            e_value_threshold_enf_text = "c-Evalue Threshold"
        else:
            e_value_threshold_enf_text = "E-value Threshold"

        self.e_value_threshold_enf = PyMod_entryfield_qt(label_text=e_value_threshold_enf_text,
                                                         value=str(self.protocol.e_value_threshold_default),
                                                         validate={'validator': 'real',
                                                                   'min': 0.0, 'max': 1000.0})
        self.middle_formlayout.add_widget_to_align(self.e_value_threshold_enf, validate=True)


        # Max hit number selection.
        self.max_hits_enf = PyMod_entryfield_qt(label_text="Max Number of Hits",
                                                value=str(self.protocol.default_max_number_of_hits),
                                                validate={'validator': 'integer',
                                                          'min': 1, 'max': 5000})
        self.middle_formlayout.add_widget_to_align(self.max_hits_enf, validate=True)


        # -------------------
        # Advanced options. -
        # -------------------

        self.show_advanced_button()

        # Minimum id% on with query.
        self.min_id_enf = PyMod_entryfield_qt(label_text="Min Id% Threshold",
                                              value="0",
                                              validate={'validator': 'integer',
                                                        'min': 0, 'max': 100})
        self.middle_formlayout.add_widget_to_align(self.min_id_enf, advanced_option=True, validate=True)


        # Maximum id% on with query.
        self.max_id_enf = PyMod_entryfield_qt(label_text="Max Id% Threshold",
                                              value="100",
                                              validate={'validator': 'integer',
                                                        'min': 0, 'max': 100})
        self.middle_formlayout.add_widget_to_align(self.max_id_enf, advanced_option=True, validate=True)


        # Minimum coverage on the query.
        self.min_coverage_enf = PyMod_entryfield_qt(label_text="Min Coverage% Threshold",
                                                    value="0",
                                                    validate={'validator': 'integer',
                                                              'min': 0, 'max': 100})
        self.middle_formlayout.add_widget_to_align(self.min_coverage_enf, advanced_option=True, validate=True)


        # Advanced options for a specific algorithm.
        self.build_algorithm_advanced_options_widgets()


        self.middle_formlayout.set_input_widgets_width("auto")
Ejemplo n.º 5
0
        def __init__(self):
            QtWidgets.QWidget.__init__(self, parent, Qt.Window)
            self.setMinimumSize(400, 500)
            self.setWindowTitle('Register File Extensions')

            self.model = QtGui.QStandardItemModel(self)

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

            label = QtWidgets.QLabel(
                "Select file types to register them with PyMOL", self)
            layout.addWidget(label)

            alluserslayout = QtWidgets.QHBoxLayout()
            alluserslayout.setObjectName("alluserslayout")
            layout.addLayout(alluserslayout)

            buttonlayout = QtWidgets.QHBoxLayout()
            buttonlayout.setObjectName("buttonlayout")
            layout.addLayout(buttonlayout)

            self.table = QtWidgets.QTableView(self)
            self.table.setModel(self.model)
            layout.addWidget(self.table)

            button = QtWidgets.QPushButton("Register Recommended (*)", self)
            buttonlayout.addWidget(button)
            button.pressed.connect(self.setRecommended)

            button = QtWidgets.QPushButton("Register All", self)
            buttonlayout.addWidget(button)
            button.pressed.connect(self.setAll)

            button = QtWidgets.QPushButton("Clear", self)
            button.setToolTip("Clean up Registry")
            buttonlayout.addWidget(button)
            button.pressed.connect(self.clear)

            if isAdmin():
                r0 = QtWidgets.QRadioButton("Only for me")
                r0.setToolTip("HKEY_CURRENT_USER registry branch")
                r0.setChecked(True)
                r1 = QtWidgets.QRadioButton("For all users")
                r1.setToolTip("HKEY_LOCAL_MACHINE registry branch")
                allusersgroup = QtWidgets.QButtonGroup(self)
                allusersgroup.addButton(r0)
                allusersgroup.addButton(r1)
                allusersgroup.buttonClicked.connect(self.populateData)
                alluserslayout.addWidget(r0)
                alluserslayout.addWidget(r1)
                alluserslayout.addStretch()
                self.allusersbutton = r1
            else:
                self.allusersbutton = None

            self.finalize_timer = QtCore.QTimer()
            self.finalize_timer.setSingleShot(True)
            self.finalize_timer.setInterval(500)
            self.finalize_timer.timeout.connect(finalize)

            self.populateData()

            # keep reference to window, otherwise Qt will auto-close it
            self._self_ref = self