Example #1
0
class Clustalo_base_window_qt:
    """
    Base class for ClustalOmega protocols.
    """

    def build_algorithm_options_widgets(self):

        # Use full distance matrix.
        self.use_full_dm_rds = PyMod_radioselect_qt(label_text="Use Full Distance Matrix",
                                                    buttons=('Yes', 'No'))
        self.use_full_dm_rds.setvalue("No")
        self.middle_formlayout.add_widget_to_align(self.use_full_dm_rds)

        # Number of (combined guide-tree/HMM) iterations.
        self.clustalo_iterations_enf = PyMod_entryfield_qt(label_text="Combined Iterations",
                                                           value='0',
                                                           validate={'validator': 'integer',
                                                                     'min': 0, 'max': 5})
        self.middle_formlayout.add_widget_to_align(self.clustalo_iterations_enf)

        self.middle_formlayout.set_input_widgets_width("auto")

    def get_iterations_value(self):
        return self.clustalo_iterations_enf.getvalue(validate=True)

    def get_use_full_dm_value(self):
        return self.use_full_dm_rds.getvalue() == "Yes"
Example #2
0
class Phmmer_options_window_qt(BLAST_base_options_window_qt):
    """
    Window for PHMMER searches.
    """
    def build_algorithm_standard_options_widgets(self):

        self.hmmer_database_labels_dict = {}

        # A list containing information about the databases present in PyMod hmmer database folder.
        db_list = []
        for db in self.protocol.databases_directories_list:
            db_label = "".join(db.split(".")[0:-1])
            db_list.append(db_label)
            self.hmmer_database_labels_dict[db_label] = db

        # Makes the user choose the folder where the hmmer database files are stored locally.
        self.hmmer_database_rds = PyMod_radioselect_qt(
            label_text="Database Selection", buttons=db_list)
        self.middle_formlayout.add_widget_to_align(self.hmmer_database_rds)

        self.build_additional_hmmer_widgets()

    def build_additional_hmmer_widgets(self):
        pass

    def build_algorithm_advanced_options_widgets(self):
        pass

    def get_phmmer_database(self):
        return self.hmmer_database_labels_dict.get(
            self.hmmer_database_rds.getvalue(), None)

    def get_additional_hmmer_parameters(self):
        return {}
Example #3
0
class Hmmscan_options_window_qt(PyMod_protocol_window_qt):
    def build_protocol_middle_frame(self):

        # Add the buttons to choose the database in which to search for domain profiles.
        if self.protocol.father_protocol.domain_search_mode == 'remote':

            self.hmmer_database_rds = PyMod_radioselect_qt(
                label_text="Database Selection", buttons=("PFAM", "Gene3D"))
            for button in self.hmmer_database_rds.get_buttons():
                button.clicked.connect(self.database_opt_cmd)

        elif self.protocol.father_protocol.domain_search_mode == 'local':

            # Build the list of database names.
            self.protocol.hmmscan_db_dict = {
            }  # This dictionary associates a database code (displayed in the GUI) to its filename.
            db_list = []
            for db_filename in self.protocol.hmmscan_db_list:
                db_name = "".join(db_filename.split(".")[0:-2])
                db_list.append(db_name)
                self.protocol.hmmscan_db_dict[db_name] = db_filename

            # Packs the PHMMER database selection widget.
            self.hmmer_database_rds = PyMod_radioselect_qt(
                label_text="Database Selection", buttons=db_list)

        self.middle_formlayout.add_widget_to_align(self.hmmer_database_rds)

        # E-value selection.
        self.e_value_threshold_enf = PyMod_entryfield_qt(
            label_text="E-value Threshold",
            value="1.0",
            validate={
                'validator': 'real',
                'min': 0.0,
                'max': 1000.0
            })
        self.middle_formlayout.add_widget_to_align(self.e_value_threshold_enf)

        # Note about the Gene3D and Evalues.
        if self.protocol.father_protocol.domain_search_mode == 'remote':
            info_note = ('Note: The Gene3D online database will\n'
                         'ignore custom cut-off parameters since\n'
                         'they use a post processing step that\n'
                         'involves preset thresholds.')
            self.notelabel = QtWidgets.QLabel(info_note)
            self.middle_formlayout.addRow(self.notelabel)

        self.middle_formlayout.set_input_widgets_width(140)

    def database_opt_cmd(self):
        if self.hmmer_database_rds.getvalue() == 'Gene3D':
            self.e_value_threshold_enf.entry.setStyleSheet(
                inactive_entry_style)
            self.e_value_threshold_enf.entry.setEnabled(False)
        else:
            self.e_value_threshold_enf.entry.setStyleSheet(active_entry_style)
            self.e_value_threshold_enf.entry.setEnabled(True)
Example #4
0
class Structural_alignment_base_window_qt:

    def build_rmsd_option(self):
        # Decide whether to compute the RMSD matrix if the structural alignment.
        self.compute_rmsd_rds = PyMod_radioselect_qt(label_text="Compute RMSD Matrix",
                                                     buttons=('Yes', 'No'))
        self.compute_rmsd_rds.setvalue("Yes")
        self.middle_formlayout.add_widget_to_align(self.compute_rmsd_rds)

    def get_compute_rmsd_option_value(self):
        return pmdt.yesno_dict[self.compute_rmsd_rds.getvalue()]
Example #5
0
class Clustalw_base_window_qt:
    """
    Base class for ClustalW protocols.
    """
    def build_algorithm_options_widgets(self):

        # Scoring matrix radioselect.
        self.clustal_matrices = ["Blosum", "Pam", "Gonnet", "Id"]
        self.clustal_matrices_dict = {
            "Blosum": "blosum",
            "Pam": "pam",
            "Gonnet": "gonnet",
            "Id": "id"
        }
        self.matrix_rds = PyMod_radioselect_qt(
            label_text="Scoring Matrix Selection",
            buttons=self.clustal_matrices)
        self.matrix_rds.setvalue("Blosum")
        self.middle_formlayout.add_widget_to_align(self.matrix_rds)

        # Gap open entryfield.
        self.gapopen_enf = PyMod_entryfield_qt(
            label_text="Gap Opening Penalty",
            value="10.0",
            validate={
                'validator': 'real',
                'min': 0,
                'max': 1000
            })
        self.middle_formlayout.add_widget_to_align(self.gapopen_enf)

        # Gap extension entryfield.
        self.gapextension_enf = PyMod_entryfield_qt(
            label_text="Gap Extension Penalty",
            value="0.2",
            validate={
                'validator': 'real',
                'min': 0,
                'max': 1000
            })
        self.middle_formlayout.add_widget_to_align(self.gapextension_enf)

        self.middle_formlayout.set_input_widgets_width("auto")

    def get_matrix_value(self):
        return self.clustal_matrices_dict[self.matrix_rds.getvalue()]

    def get_gapopen_value(self):
        return self.gapopen_enf.getvalue(validate=True)

    def get_gapextension_value(self):
        return self.gapextension_enf.getvalue(validate=True)
Example #6
0
class CAMPO_options_window_qt(PyMod_protocol_window_qt):
    """
    Window for CAMPO options.
    """

    def add_middle_frame_widgets(self):

        # Scoring matrix combobox.
        self.matrix_cbx = PyMod_combobox_qt(label_text="Scoring Matrix Selection",
                                            items=self.protocol.campo_matrices)
        self.matrix_cbx.combobox.setCurrentIndex(2)
        self.middle_formlayout.add_widget_to_align(self.matrix_cbx)

        # Gap open entryfield.
        self.campo_gap_penalty_enf = PyMod_entryfield_qt(label_text="Gap Score",
                                                         value="-1",
                                                         validate={'validator': 'integer',
                                                                   'min': -1000, 'max': 0})
        self.middle_formlayout.add_widget_to_align(self.campo_gap_penalty_enf)

        # Gap extension entryfield.
        self.campo_gap_to_gap_score_enf = PyMod_entryfield_qt(label_text="Gap to Gap Score",
                                                              value="0",
                                                              validate={'validator': 'integer',
                                                                        'min': -1000, 'max': 0})
        self.middle_formlayout.add_widget_to_align(self.campo_gap_to_gap_score_enf)

        # Toss gaps.
        self.campo_exclude_gaps_rds = PyMod_radioselect_qt(label_text="Toss gaps",
                                                           buttons=('Yes', 'No'))
        self.campo_exclude_gaps_rds.setvalue("Yes")
        self.middle_formlayout.add_widget_to_align(self.campo_exclude_gaps_rds)

        self.middle_formlayout.set_input_widgets_width("auto", padding=10)


    def validate_input(self):

        params_from_gui = {}

        try:
            params_from_gui["mutational_matrix"] = self.protocol.campo_matrices_dict[self.matrix_cbx.get()]
            params_from_gui["gap_score"] = self.campo_gap_penalty_enf.getvalue(validate=True)
            params_from_gui["gap_gap_score"] = self.campo_gap_to_gap_score_enf.getvalue(validate=True)
            params_from_gui["toss_gaps"] = pymod_vars.yesno_dict[self.campo_exclude_gaps_rds.getvalue()]
        except (ValueError, KeyError) as e:
            return None, str(e)

        return params_from_gui, None
Example #7
0
class SALIGN_seq_base_window_qt:
    def build_algorithm_options_widgets(self):
        if self.protocol.structures_are_selected:
            # Use structure information to guide sequence alignment.
            self.salign_seq_struct_rds = PyMod_radioselect_qt(
                label_text="Use structural information", buttons=('Yes', 'No'))
            self.salign_seq_struct_rds.setvalue("No")
            self.middle_formlayout.add_widget_to_align(
                self.salign_seq_struct_rds)
            self.middle_formlayout.set_input_widgets_width("auto")

    def get_use_str_information_var(self):
        if self.protocol.structures_are_selected:
            return pmdt.yesno_dict[self.salign_seq_struct_rds.getvalue()]
        else:
            return False
Example #8
0
class MUSCLE_regular_window_qt(Regular_alignment_window_qt):
    def build_algorithm_options_widgets(self):

        # MUSCLE mode radioselect (for more information see: https://www.drive5.com/muscle/manual/).
        self.muscle_modes = ["Highest Accuracy", "Large Datasets", "Fastest"]
        self.muscle_modes_short = [
            "highest_accuracy", "large_datasets", "fastest"
        ]
        self.muscle_modes_dict = dict(
            (k, v)
            for (k, v) in zip(self.muscle_modes, self.muscle_modes_short))

        self.muscle_mode_rds = PyMod_radioselect_qt(label_text="MUSCLE Mode",
                                                    buttons=self.muscle_modes)
        self.muscle_mode_rds.setvalue(self.muscle_modes[0])
        self.middle_formlayout.add_widget_to_align(self.muscle_mode_rds)
        self.middle_formlayout.set_input_widgets_width("auto")

    def get_muscle_mode(self):
        return self.muscle_modes_dict[self.muscle_mode_rds.getvalue()]
Example #9
0
class Contact_map_options_window_qt(PyMod_protocol_window_qt):
    """
    Window with options for the contact map analysis.
    """

    feature_types_list = [
        "Contacts", "Distances", "Distance Difference", "Distance Mean",
        "Distance Std"
    ]
    interaction_centers_list = ["Carbon alpha", "Carbon beta"]
    default_contact_threshold = 8.0
    default_distance_threshold = 18.0
    default_distance_diff_threshold = 3.5
    default_distance_mean_threshold = default_distance_threshold
    default_distance_std_threshold = default_distance_diff_threshold

    def build_protocol_middle_frame(self):

        # Feature type selection.
        if len(self.protocol.target_sequences) == 1:  # Contact and distance.
            sel_option_idx = 0
            all_options_idx = (0, 1)
        elif len(self.protocol.target_sequences
                 ) == 2:  # Distance difference, mean and std.
            sel_option_idx = 2
            all_options_idx = (2, 3, 4)
        elif len(self.protocol.target_sequences) > 2:  # Distance mean and std.
            sel_option_idx = 3
            all_options_idx = (3, 4)

        features_buttons = [
            self.feature_types_list[i] for i in all_options_idx
        ]
        self.feature_type_rds = PyMod_radioselect_qt(label_text="Feature Type",
                                                     buttons=features_buttons)
        for button, option_idx in zip(self.feature_type_rds.get_buttons(),
                                      all_options_idx):
            button.clicked.connect(
                lambda e=None, o=option_idx: self.feature_type_state(o))
        self.feature_type_rds.setvalue(self.feature_types_list[sel_option_idx])
        self.middle_formlayout.add_widget_to_align(self.feature_type_rds)

        # Distance threshold for contacts.
        if len(self.protocol.target_sequences) == 1:
            threshold = self.default_contact_threshold
        elif len(self.protocol.target_sequences) == 2:
            threshold = self.default_distance_diff_threshold
        else:
            threshold = self.default_distance_threshold

        self.dist_threshold_enf = PyMod_entryfield_qt(
            label_text="Contact Threshold (%s)" % ("\u212B"),
            value=str(threshold),
            validate={
                'validator': 'real',
                'min': 1.0,
                'max': 100.0
            })
        self.middle_formlayout.add_widget_to_align(self.dist_threshold_enf)

        # Interaction center selection.
        self.interaction_center_rds = PyMod_radioselect_qt(
            label_text="Interaction Center",
            buttons=self.interaction_centers_list)
        self.interaction_center_rds.setvalue(self.interaction_centers_list[0])
        self.middle_formlayout.add_widget_to_align(self.interaction_center_rds)

        # Reference structure combobox.
        if len(self.protocol.target_sequences) > 1:
            structures_list = [
                element.my_header for element in self.protocol.target_sequences
            ]
            self.reference_combobox = PyMod_combobox_qt(
                label_text="Reference Structure", items=structures_list)
            self.reference_combobox.combobox.setCurrentIndex(0)
            self.middle_formlayout.add_widget_to_align(self.reference_combobox)

        self.middle_formlayout.set_input_widgets_width("auto", padding=10)

    def feature_type_state(self, state):
        """
        Launched when the user changes the "Feature Type" in the Options window.
        """
        # Change the status of the Tkinter checkbutton.
        if state == 0:
            self.feature_type_rds.setvalue(self.feature_types_list[0])
            self.dist_threshold_enf.setvalue(
                str(self.default_contact_threshold))
        elif state == 1:
            self.feature_type_rds.setvalue(self.feature_types_list[1])
            self.dist_threshold_enf.setvalue(
                str(self.default_distance_threshold))
        elif state == 2:
            self.feature_type_rds.setvalue(self.feature_types_list[2])
            self.dist_threshold_enf.setvalue(
                str(self.default_distance_diff_threshold))
        elif state == 3:
            self.feature_type_rds.setvalue(self.feature_types_list[3])
            self.dist_threshold_enf.setvalue(
                str(self.default_distance_mean_threshold))
        elif state == 4:
            self.feature_type_rds.setvalue(self.feature_types_list[4])
            self.dist_threshold_enf.setvalue(
                str(self.default_distance_std_threshold))
        else:
            KeyError(state)

    def get_feature_type(self):
        feature_type = self.feature_type_rds.getvalue()
        if feature_type == self.feature_types_list[0]:
            return "contact", feature_type
        elif feature_type == self.feature_types_list[1]:
            return "distance", feature_type
        elif feature_type == self.feature_types_list[2]:
            return "distances_difference", feature_type
        elif feature_type == self.feature_types_list[3]:
            return "distances_mean", feature_type
        elif feature_type == self.feature_types_list[4]:
            return "distances_std", feature_type
        else:
            raise KeyError(feature_type)

    def get_interaction_center(self):
        int_center_string = self.interaction_center_rds.getvalue()
        if int_center_string == self.interaction_centers_list[0]:
            return "ca"
        elif int_center_string == self.interaction_centers_list[1]:
            return "cb"
        else:
            raise KeyError(int_center_string)

    def get_reference_id(self):
        try:
            return self.reference_combobox.get_index()
        except:
            print("- WARNING: could not obtain the reference structure id.")
            return 0
Example #10
0
class Ramachandran_plot_options_window_qt(PyMod_protocol_window_qt):
    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)

    def show_select_single_aa_frame(self):
        for aa in prot_standard_one_letter:
            # Only enable selection of aa present in primary sequence.
            if self.aa_freq_dict[aa] != 0:
                self.aa_checkbutton[aa].setEnabled(True)

    def hide_select_single_aa_frame(self):
        for checkbox in self.aa_checkbutton_list:
            checkbox.setEnabled(False)

    def get_aa_selection_mode(self):
        return self.aa_select_choices_dict[self.aa_select_rds.getvalue()]
Example #11
0
class Search_string_window_qt(PyMod_tool_window_qt):

    inactive_results_color = inactive_bg_color
    found_results_color = success_bg_color
    not_found_results_color = failure_bg_color
    default_message = "Type a pattern and press Enter..."

    def __init__(self, parent, pymod_elements, *args, **configs):

        self.pymod_element = pymod_elements[0]
        PyMod_tool_window_qt.__init__(self, parent, *args, **configs)

    def add_middle_frame_widgets(self):

        #-------------------------------------
        # Form layout for input and results. -
        #-------------------------------------

        entries_width = 340

        # Entryfield for inserting a subsequence.
        self.search_string_enf = PyMod_entryfield_qt(
            label_text="Search For",
            value="",
            enter_command=self.submit_command)
        self.search_string_enf.set_input_widget_width(entries_width)
        self.middle_formlayout.add_widget_to_align(self.search_string_enf,
                                                   align=False)

        # Entryfield for showing the results.
        self.results_enf = PyMod_entryfield_qt(label_text="",
                                               value=self.default_message,
                                               readonly=True)
        self.set_results_entry_bg(self.inactive_results_color)
        self.results_enf.set_input_widget_width(entries_width)
        self.middle_formlayout.add_widget_to_align(self.results_enf,
                                                   align=False)

        #---------------------------
        # Form layout for options. -
        #---------------------------

        # Use regular expressions.
        self.use_regex_rds = PyMod_radioselect_qt(label_text="Use Regex",
                                                  buttons=("Yes", "No"))
        self.use_regex_rds.setvalue("No")
        self.middle_formlayout.add_widget_to_align(self.use_regex_rds)

        # Highlight color selection.
        color_buttons = ("yellow", "red", "green", "cyan")  # "violet"
        self.highlight_color_rds = PyMod_radioselect_qt(
            label_text='Highlight Color', buttons=color_buttons)
        self.highlight_color_rds.setvalue('yellow')
        self.middle_formlayout.add_widget_to_align(self.highlight_color_rds)

        if self.pymod_element.has_structure():
            self.select_in_pymol_rds = PyMod_radioselect_qt(
                label_text='Select in PyMOL', buttons=("Yes", "No"))
            self.select_in_pymol_rds.setvalue('No')
            self.middle_formlayout.add_widget_to_align(
                self.select_in_pymol_rds)

        self.middle_formlayout.set_input_widgets_width(width="auto")

    def get_search_string(self):
        return self.search_string_enf.getvalue()

    def get_regex_use(self):
        use_regex_val = self.use_regex_rds.getvalue()
        if use_regex_val == "Yes":
            return True
        elif use_regex_val == "No":
            return False
        else:
            raise KeyError(use_regex_val)

    def get_highlight_color(self):
        return self.highlight_color_rds.getvalue()

    def show_results(self, message, state):
        self.results_enf.setvalue(message)

        if state == "found":
            self.set_results_entry_bg(self.found_results_color)
        elif state == "not_found":
            self.set_results_entry_bg(self.not_found_results_color)
        elif state == "empty":
            self.set_results_entry_bg(self.inactive_results_color)
        else:
            raise KeyError(state)

    def set_results_entry_bg(self, color):
        self.results_enf.input.setStyleSheet(
            "background-color: %s; color: black" % color)

    def get_select_in_pymol(self):
        return _get_select_in_pymol(self)