Example #1
0
    def add_middle_frame_widgets(self):

        # Entryfield for selecting the residues range.
        self.residue_range_enf = PyMod_entryfield_qt(
            label_text="Residue(s)", value=str(self.selected_residue.db_index))
        self.middle_formlayout.add_widget_to_align(self.residue_range_enf)

        # Entryfield for the feature name.
        self.feature_name_enf = PyMod_entryfield_qt(label_text="Feature Name",
                                                    value="new feature")
        self.middle_formlayout.add_widget_to_align(self.feature_name_enf)

        # Widgets for choosing a color for the feature.
        self.selected_rgb = (1.0, 0.0, 0.0)
        self.selected_hex = '#ff0000'
        self.feature_color_enf = PyMod_entryfield_button_qt(
            label_text="Feature Color",
            readonly=True,
            button_text="Pick",
            button_command=self.pick_color_dialog)
        self.middle_formlayout.add_widget_to_align(self.feature_color_enf)
        self.feature_color_enf.entry.setStyleSheet("background-color: %s" %
                                                   self.selected_hex)

        # Select in PyMOL.
        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(150)
Example #2
0
    def build_algorithm_standard_options_widgets(self):

        db_list = [text for (text, val) in self.protocol.ncbi_databases]
        self.ncbiblast_database_rds = PyMod_radioselect_qt(
            label_text="Database Selection", buttons=db_list)
        self.ncbiblast_database_rds.setvalue('PDB')
        self.middle_formlayout.add_widget_to_align(self.ncbiblast_database_rds)
Example #3
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 #4
0
    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)
Example #5
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 #6
0
 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")
Example #7
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 #8
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 #9
0
class SCR_FIND_window_qt(PyMod_protocol_window_qt):
    def add_middle_frame_widgets(self):

        # SC-score scalebar.
        self.sc_scale = PyMod_scalebar_qt(
            label_text="SC-score Limit",
            slider_value=3.0,
            slider_from=0.5,
            slider_to=5.0,
            slider_resoution=0.25,
            slider_tickinterval=1.0,
            slider_use_float=True,
            slider_binding=self.protocol.scr_window_submit,
            slider_width=375)
        self.middle_formlayout.add_widget_to_align(self.sc_scale)

        # Sliding Window size scalebar.
        self.sw_scale = PyMod_scalebar_qt(
            label_text="Sliding Window Min. Size",
            slider_value=3,
            slider_from=2,
            slider_to=50,
            slider_resoution=1,
            slider_tickinterval=5,
            slider_binding=self.protocol.scr_window_submit,
            slider_width=375)
        self.middle_formlayout.add_widget_to_align(self.sw_scale)

        # Gap penalty entry field.
        self.scr_find_gap_penalty_enf = PyMod_entryfield_qt(
            label_text="Gap Penalty",
            value='100',
            validate={
                'validator': 'integer',
                'min': 0,
                'max': 1000
            },
            enter_command=self.protocol.scr_window_submit)
        self.middle_formlayout.add_widget_to_align(
            self.scr_find_gap_penalty_enf)

        # Hide non-SCR residues or show them white.
        self.scr_find_hide_non_scrs = PyMod_radioselect_qt(
            label_text="Hide non SCRs", buttons=('Yes', 'No'))
        self.scr_find_hide_non_scrs.setvalue("No")
        self.scr_find_hide_non_scrs.buttons_dict["No"].clicked.connect(
            self.protocol.scr_window_submit)
        self.scr_find_hide_non_scrs.buttons_dict["Yes"].clicked.connect(
            self.protocol.scr_window_submit)
        self.middle_formlayout.add_widget_to_align(self.scr_find_hide_non_scrs)

        self.middle_formlayout.set_input_widgets_width(110)
Example #10
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)
Example #11
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 #12
0
    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")
Example #13
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 #14
0
    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")
Example #15
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 #16
0
    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()
Example #17
0
    def add_middle_frame_widgets(self):
        # Type of entropy measure.
        self.entropy_scorer_function_rds = PyMod_radioselect_qt(
            label_text="Entropy Measure",
            buttons=self.protocol.entropy_func_labels)
        self.entropy_scorer_function_rds.setvalue(
            self.protocol.entropy_func_labels[0])
        self.middle_formlayout.add_widget_to_align(
            self.entropy_scorer_function_rds)

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

        self.middle_formlayout.set_input_widgets_width("auto", padding=10)
Example #18
0
class BLAST_options_window_qt(BLAST_base_options_window_qt):
    """
    Window for BLAST searches.
    """

    # input_widget_width = 16
    # geometry_string = "450x650"

    def build_algorithm_standard_options_widgets(self):

        db_list = [text for (text, val) in self.protocol.ncbi_databases]
        self.ncbiblast_database_rds = PyMod_radioselect_qt(
            label_text="Database Selection", buttons=db_list)
        self.ncbiblast_database_rds.setvalue('PDB')
        self.middle_formlayout.add_widget_to_align(self.ncbiblast_database_rds)

    def build_algorithm_advanced_options_widgets(self):
        pass
Example #19
0
class Tree_building_window_qt(PyMod_protocol_window_qt):
    def build_protocol_middle_frame(self):

        # Add some options.
        self.algorithm_rds = PyMod_radioselect_qt(
            label_text="Clustering Algorithm",
            buttons=list(sorted(tree_building_alg_dict.keys())))
        self.algorithm_rds.setvalue("Neighbor Joining")
        self.middle_formlayout.add_widget_to_align(self.algorithm_rds)

        if self.protocol.tree_building_software == "clustalw":
            # Kimura distance correction.
            self.distance_correction_rds = PyMod_radioselect_qt(
                label_text="Use Distance Correction", buttons=('Yes', 'No'))
            self.distance_correction_rds.setvalue("No")
            self.middle_formlayout.add_widget_to_align(
                self.distance_correction_rds)

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

        self.middle_formlayout.set_input_widgets_width("auto", padding=10)
Example #20
0
    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")
Example #21
0
    def build_algorithm_standard_options_widgets(self):

        # Makes the user chose the folder where the BLAST database files are stored locally.
        # A list containing information about the databases present in PyMod BLAST database
        # folder.
        db_list = [
            k["prefix"] for k in self.protocol.databases_directories_list
        ]
        self.psiblast_database_rds = PyMod_radioselect_qt(
            label_text="Database Selection", buttons=db_list)
        self.middle_formlayout.add_widget_to_align(self.psiblast_database_rds)

        # Number of PSI-BLAST iterations.
        if self.protocol.blast_version == "psi-blast":
            self.psiblast_iterations_enf = PyMod_entryfield_qt(
                label_text="PSI-BLAST Iterations",
                value='3',
                validate={
                    'validator': 'integer',
                    'min': 1,
                    'max': 10
                })
            self.middle_formlayout.add_widget_to_align(
                self.psiblast_iterations_enf, validate=True)
Example #22
0
class Add_feature_window_qt(PyMod_tool_window_qt):
    def __init__(self, parent, pymod_element, selected_residue, *args,
                 **configs):

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

    def add_middle_frame_widgets(self):

        # Entryfield for selecting the residues range.
        self.residue_range_enf = PyMod_entryfield_qt(
            label_text="Residue(s)", value=str(self.selected_residue.db_index))
        self.middle_formlayout.add_widget_to_align(self.residue_range_enf)

        # Entryfield for the feature name.
        self.feature_name_enf = PyMod_entryfield_qt(label_text="Feature Name",
                                                    value="new feature")
        self.middle_formlayout.add_widget_to_align(self.feature_name_enf)

        # Widgets for choosing a color for the feature.
        self.selected_rgb = (1.0, 0.0, 0.0)
        self.selected_hex = '#ff0000'
        self.feature_color_enf = PyMod_entryfield_button_qt(
            label_text="Feature Color",
            readonly=True,
            button_text="Pick",
            button_command=self.pick_color_dialog)
        self.middle_formlayout.add_widget_to_align(self.feature_color_enf)
        self.feature_color_enf.entry.setStyleSheet("background-color: %s" %
                                                   self.selected_hex)

        # Select in PyMOL.
        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(150)

    def get_residue_range(self):
        return self.residue_range_enf.getvalue()

    def get_feature_name(self):
        return self.feature_name_enf.getvalue()

    def pick_color_dialog(self):
        selected_color = open_color_dialog(color_format="all")
        if selected_color is not None:
            self.selected_rgb, self.selected_hex = selected_color
            # self.feature_color_enf.setvalue(self.selected_hex)
            self.feature_color_enf.entry.setStyleSheet("background-color: %s" %
                                                       self.selected_hex)

    def get_selected_colors(self):
        return self.selected_rgb, self.selected_hex

    def get_select_in_pymol(self):
        return _get_select_in_pymol(self)
Example #23
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)
Example #24
0
    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)
Example #25
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 #26
0
    def add_middle_frame_widgets(self):

        # Units combobox.
        self.unit_combobox = PyMod_combobox_qt(label_text="Unit Selection",
                                               items=self.protocol.units_list)
        self.unit_combobox.combobox.setCurrentIndex(0)
        self.middle_formlayout.add_widget_to_align(self.unit_combobox)

        # Color combobox.
        self.color_combobox = PyMod_combobox_qt(label_text="Color Scheme Selection",
                                                items=self.protocol.colorscheme_list)
        self.color_combobox.combobox.setCurrentIndex(5)
        self.middle_formlayout.add_widget_to_align(self.color_combobox)

        # Sub-frame created to display entries for Logo Range option.
        self.range_subframe = PyMod_hbox_option_qt(label_text="Logo Range")

        # Logo start position spinbox.
        self.logo_start = QtWidgets.QSpinBox()
        self.logo_start.setRange(1, self.protocol.ali_length)
        self.range_subframe.hbox.addWidget(self.logo_start)
        # Separator dash.
        self.logo_range_dash = QtWidgets.QLabel(" - ")
        self.range_subframe.hbox.addWidget(self.logo_range_dash)
        # Logo end position spinbox.
        self.logo_end = QtWidgets.QSpinBox()
        self.logo_end.setRange(1, self.protocol.ali_length)
        self.logo_end.setValue(self.protocol.ali_length)
        self.range_subframe.hbox.addWidget(self.logo_end)
        self.range_subframe.set_auto_input_widget_width()
        self.middle_formlayout.add_widget_to_align(self.range_subframe)


        # ADVANCED OPTIONS.
        self.show_advanced_button()

        # Logo format combobox.
        self.format_combobox = PyMod_combobox_qt(label_text='Logo Format',
                                                 items=self.protocol.format_list)
        self.format_combobox.combobox.setCurrentIndex(0)
        self.middle_formlayout.add_widget_to_align(self.format_combobox, advanced_option=True)

        # LOGO title entry.
        self.logo_title_enf = PyMod_entryfield_qt(label_text="Logo Title",
                                                  value='')
        self.middle_formlayout.add_widget_to_align(self.logo_title_enf, advanced_option=True)

        # Stacks per line entry.
        self.logo_stacks_enf = PyMod_entryfield_qt(label_text="Stacks per line",
                                                   value='80',
                                                   validate={'validator': 'integer',
                                                             'min': 0, 'max': 100})
        self.middle_formlayout.add_widget_to_align(self.logo_stacks_enf, advanced_option=True)

        # Scale stacks width.
        self.scale_width_rds = PyMod_radioselect_qt(label_text="Scale stacks width",
                                                    buttons=('Yes', 'No'))
        self.scale_width_rds.setvalue("No")
        self.middle_formlayout.add_widget_to_align(self.scale_width_rds, advanced_option=True)

        # Show error bars.
        self.show_error_rds = PyMod_radioselect_qt(label_text="Show error bars",
                                                    buttons=('Yes', 'No'))
        self.show_error_rds.setvalue("No")
        self.middle_formlayout.add_widget_to_align(self.show_error_rds, advanced_option=True)

        self.middle_formlayout.set_input_widgets_width(175)
Example #27
0
 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)