예제 #1
0
    def build_selection_menu(self):
        """
        Submenu with options for managing a selection.
        """

        self.selection_context_submenu = QtWidgets.QMenu(
            'Selection', self.context_menu)
        self.context_menu.addMenu(self.selection_context_submenu)

        # Build the "Sequence" menu.
        self.build_selection_sequence_menu()
        self.selection_context_submenu.addSeparator()

        # Build the "Color" menu.
        self.build_selection_color_menu()

        # Build the "Structure" menu.
        if self.parent_group.pymod.all_sequences_have_structure(
        ) or self.parent_group.pymod.all_sequences_have_fetchable_pdbs():
            self.selection_context_submenu.addSeparator()
            self.build_selection_structure_menu()

        # Build the "Cluster" menu.
        if self.parent_group.pymod.all_sequences_are_children():
            self.selection_context_submenu.addSeparator()
            self.build_selection_cluster_menu()
예제 #2
0
    def build_models_submenu(self):
        """
        Build an "Modeling Session n" voice in the "Models" submenu once some models have been
        built.
        """

        # Delete the old models submenu.
        self.models_menu.clear()

        if self.pymod.modeling_session_list != []:
            for modeling_session in self.pymod.modeling_session_list:
                # Adds a modeling session submenu to the PyMod main menu.
                label_text = "Modeling Session %s" % (
                    modeling_session.session_id)
                modeling_session_submenu = QtWidgets.QMenu(label_text, self)
                self.models_menu.addMenu(modeling_session_submenu)
                add_qt_menu_command(modeling_session_submenu,
                                    "Export to File",
                                    lambda a=None, ms=modeling_session: self.
                                    pymod.save_modeling_session(ms))
                add_qt_menu_command(modeling_session_submenu,
                                    "DOPE Profile",
                                    lambda a=None, ms=modeling_session: self.
                                    pymod.show_session_profile(ms))
                add_qt_menu_command(modeling_session_submenu,
                                    "Assessment Table",
                                    lambda a=None, ms=modeling_session: self.
                                    pymod.show_assessment_table(ms))

        else:
            add_qt_menu_command(self.models_menu, "There aren't any models")
예제 #3
0
    def build_selection_structure_menu(self):
        self.selection_structure_context_submenu = QtWidgets.QMenu(
            'Structures', self.selection_context_submenu)
        self.selection_context_submenu.addMenu(
            self.selection_structure_context_submenu)

        if self.parent_group.pymod.all_sequences_have_structure():
            add_qt_menu_command(
                self.selection_structure_context_submenu,
                "Show chains in PyMOL",
                self.show_selected_chains_in_pymol_from_popup_menu)
            add_qt_menu_command(
                self.selection_structure_context_submenu,
                "Hide chains in PyMOL",
                self.hide_selected_chains_in_pymol_from_popup_menu)
            self.selection_structure_context_submenu.addSeparator()
            add_qt_menu_command(
                self.selection_structure_context_submenu,
                "Show Chains as Hedgehog",
                self.show_hedgehog_chains_in_pymol_from_popup_menu)
            add_qt_menu_command(self.selection_structure_context_submenu,
                                "Show Heteroatoms",
                                self.show_het_chains_in_pymol_from_popup_menu)
            add_qt_menu_command(self.selection_structure_context_submenu,
                                "Hide Heteroatoms",
                                self.hide_het_chains_in_pymol_from_popup_menu)

        elif self.parent_group.pymod.all_sequences_have_fetchable_pdbs():
            add_qt_menu_command(
                self.selection_structure_context_submenu, "Fetch PDB Files",
                lambda: self.parent_group.pymod.fetch_pdb_files(
                    "selection", None))
예제 #4
0
    def build_header_popup_menu(self):
        """
        Builds the popup menu that appears when users left-clicks with on the sequence header in the
        main window left pan.
        """

        self.context_menu = Header_context_menu(self)

        # Places the single sequence submenus in a separate submenu in order to distinguish it
        # from the selection submenu.
        if len(self.parent_group.pymod.get_selected_sequences()) > 1:
            self.single_sequence_context_submenu = QtWidgets.QMenu(
                self.parent_group.pymod_element.my_header, self.context_menu)
            self.context_menu.addMenu(self.single_sequence_context_submenu)
            self.single_element_target_submenu = self.single_sequence_context_submenu
        # Places the single sequence submenus in the main context menu.
        else:
            add_qt_menu_command(self.context_menu,
                                self.parent_group.pymod_element.my_header,
                                None)
            self.single_element_target_submenu = self.context_menu
        self.context_menu.addSeparator()

        # Builds a popup menu for sequence elements.
        if not self.parent_group.pymod_element.is_cluster():
            self.build_single_sequence_header_popup_menu()
        # For cluster elements (alignments or blast-search elements).
        else:
            self.build_cluster_popup_menu(self.single_element_target_submenu,
                                          mode="cluster",
                                          extra_spacer=True)

        self.update_left_popup_menu()
예제 #5
0
    def build_sequence_menu(self):
        """
        Submenu with options for manipulating a sequence loaded in PyMod.
        """

        self.sequence_context_submenu = QtWidgets.QMenu(
            'Sequence', self.single_element_target_submenu)
        self.single_element_target_submenu.addMenu(
            self.sequence_context_submenu)

        add_qt_menu_command(self.sequence_context_submenu,
                            "Save Sequence to File",
                            self.save_sequence_from_left_pane)
        add_qt_menu_command(self.sequence_context_submenu,
                            "Copy Sequence to Clipboard",
                            self.copy_sequence_to_clipboard)
        self.sequence_context_submenu.addSeparator()

        add_qt_menu_command(self.sequence_context_submenu, "Edit Sequence",
                            self.edit_sequence_from_context)
        add_qt_menu_command(self.sequence_context_submenu,
                            "Search Sub-sequence",
                            self.search_string_from_context)
        self.sequence_context_submenu.addSeparator()

        add_qt_menu_command(self.sequence_context_submenu,
                            "Duplicate Sequence",
                            self.duplicate_sequence_from_the_left_pane)
        add_qt_menu_command(self.sequence_context_submenu, "Delete Sequence",
                            self.delete_sequence_from_the_left_pane)
예제 #6
0
    def build_cluster_options_menu(self):
        """
        Submenu with options to manage a sequence within its cluster.
        """

        self.cluster_context_submenu = QtWidgets.QMenu(
            'Cluster Options', self.single_element_target_submenu)
        self.single_element_target_submenu.addMenu(
            self.cluster_context_submenu)

        add_qt_menu_command(self.cluster_context_submenu,
                            "Extract Sequence from Cluster",
                            self.extract_from_cluster)
예제 #7
0
 def builds_features_menu(self):
     self.features_context_submenu = QtWidgets.QMenu(
         'Features', self.single_element_target_submenu)
     add_qt_menu_command(
         self.features_context_submenu, "Show Features",
         lambda: self.parent_group.main_window.color_selection(
             "single", self.parent_group.pymod_element, "custom"))
     add_qt_menu_command(
         self.features_context_submenu, "Delete Features",
         lambda: self.parent_group.pymod.delete_features_from_context_menu(
             self.parent_group.pymod_element))
     self.single_element_target_submenu.addMenu(
         self.features_context_submenu)
예제 #8
0
    def build_color_palette_submenu(self, color_mode, elements_to_color,
                                    target_submenu, title, list_of_colors):
        new_palette_submenu = QtWidgets.QMenu(title, target_submenu)
        target_submenu.addMenu(new_palette_submenu)

        for color in list_of_colors:
            add_qt_menu_command(
                parent=new_palette_submenu,
                label=color,
                command=lambda a=None, c=color: self.parent_group.main_window.
                color_selection(color_mode, elements_to_color, "regular", c),
                fg_color=self.parent_group.main_window.
                get_regular_sequence_color(color),
                bg_color="#ABABAB")
예제 #9
0
    def build_structure_menu(self):
        """
        Submenu for elements that have a structure loaded in PyMOL.
        """

        self.structure_context_submenu = QtWidgets.QMenu(
            'Structure', self.single_element_target_submenu)

        if self.parent_group.pymod_element.has_structure():
            self.single_element_target_submenu.addMenu(
                self.structure_context_submenu)
            # add_qt_menu_command(self.structure_context_submenu, "PDB Chain Information", self.show_structure_info)
            add_qt_menu_command(self.structure_context_submenu,
                                "Save PDB Chain to File",
                                self.save_structure_from_left_pane)
            self.structure_context_submenu.addSeparator()
            add_qt_menu_command(self.structure_context_submenu,
                                "Center Chain in PyMOL",
                                self.center_chain_in_pymol_from_header_entry)
            # TODO: a switch would be nice.
            add_qt_menu_command(self.structure_context_submenu,
                                "Show Chain in PyMOL",
                                self.show_chain_in_pymol_from_header_entry)
            add_qt_menu_command(self.structure_context_submenu,
                                "Hide Chain in PyMOL",
                                self.hide_chain_in_pymol_from_header_entry)
            self.structure_context_submenu.addSeparator()
            add_qt_menu_command(self.structure_context_submenu,
                                "Show Chain as Hedgehog",
                                self.show_hedgehog_in_pymol_from_header_entry)
            add_qt_menu_command(self.structure_context_submenu,
                                "Show Heteroatoms",
                                self.show_het_in_pymol_from_header_entry)
            add_qt_menu_command(self.structure_context_submenu,
                                "Hide Heteroatoms",
                                self.hide_het_in_pymol_from_header_entry)
            self.single_element_target_submenu.addMenu(
                self.structure_context_submenu)
        else:
            if self.parent_group.pymod_element.pdb_is_fetchable():
                add_qt_menu_command(
                    self.structure_context_submenu, "Fetch PDB File",
                    lambda: self.parent_group.pymod.fetch_pdb_files(
                        "single", self.parent_group.pymod_element))
                # self.structure_context_submenu.addSeparator()
                # add_qt_menu_command(self.structure_context_submenu, "Associate 3D Structure", lambda: self.parent_group.pymod.associate_structure_from_popup_menu(self.parent_group.pymod_element))
                self.single_element_target_submenu.addMenu(
                    self.structure_context_submenu)
예제 #10
0
 def build_domains_menu(self):
     self.domains_context_submenu = QtWidgets.QMenu(
         'Domains', self.single_element_target_submenu)
     add_qt_menu_command(
         self.domains_context_submenu,
         "Split into Domains",
         lambda a=None, pe=self.parent_group.pymod_element: self.
         parent_group.pymod.launch_domain_splitting(pe))
     if self.parent_group.pymod_element.derived_domains_list:
         add_qt_menu_command(
             self.domains_context_submenu,
             "Fuse Domains Alignments",
             lambda a=None, pe=self.parent_group.pymod_element: self.
             parent_group.pymod.launch_domain_fuse(pe))
     self.single_element_target_submenu.addMenu(
         self.domains_context_submenu)
예제 #11
0
    def build_selection_sequence_menu(self):

        self.selection_sequence_context_submenu = QtWidgets.QMenu(
            'Sequences', self.selection_context_submenu)
        self.selection_context_submenu.addMenu(
            self.selection_sequence_context_submenu)

        add_qt_menu_command(self.selection_sequence_context_submenu,
                            "Save Selection to File",
                            self.save_selection_from_left_pane)
        add_qt_menu_command(self.selection_sequence_context_submenu,
                            "Copy Selection to Clipboard", self.copy_selection)
        self.selection_sequence_context_submenu.addSeparator()
        add_qt_menu_command(self.selection_sequence_context_submenu,
                            "Duplicate Selection", self.duplicate_selection)
        add_qt_menu_command(self.selection_sequence_context_submenu,
                            "Delete Selection", self.delete_many_sequences)
예제 #12
0
    def build_cluster_edit_menu(self, target_menu):

        self.cluster_edit_context_submenu = QtWidgets.QMenu(
            'Edit Cluster', target_menu)
        target_menu.addMenu(self.cluster_edit_context_submenu)

        add_qt_menu_command(self.cluster_edit_context_submenu,
                            "Save Alignment To File",
                            self.save_alignment_from_left_pan)
        self.cluster_edit_context_submenu.addSeparator()
        add_qt_menu_command(self.cluster_edit_context_submenu,
                            "Delete Gap Only Columns",
                            self.delete_gap_only_columns_from_left_pane)
        add_qt_menu_command(self.cluster_edit_context_submenu,
                            "Transfer Alignment",
                            self.transfer_alignment_from_left_pane)
        self.cluster_edit_context_submenu.addSeparator()
        add_qt_menu_command(self.cluster_edit_context_submenu,
                            "Delete Cluster",
                            self.delete_alignment_from_left_pane)
예제 #13
0
    def build_selection_cluster_menu(self):

        self.selection_cluster_context_submenu = QtWidgets.QMenu(
            'Cluster Options', self.selection_context_submenu)
        self.selection_context_submenu.addMenu(
            self.selection_cluster_context_submenu)

        add_qt_menu_command(self.selection_cluster_context_submenu,
                            "Extract Sequences from their Clusters",
                            self.extract_selection_from_cluster)

        selected_sequences = self.parent_group.pymod.get_selected_sequences()
        mothers_set = set([s.mother for s in selected_sequences])
        if len(mothers_set) == 1:
            if len(selected_sequences) < len(
                    self.parent_group.pymod_element.mother.get_children()):
                add_qt_menu_command(
                    self.selection_cluster_context_submenu,
                    "Extract Sequences to New Cluster",
                    self.extract_selection_to_new_cluster_from_left_menu)
예제 #14
0
    def build_alignment_submenu(self):
        """
        Build an "Alignment N" voice in the "Alignments" submenu when alignment N is performed.
        """

        # Delete the old alignment submenu.
        self.alignments_menu.clear()

        # Then rebuilds it with the new alignments.
        alignment_list = self.pymod.get_cluster_elements()

        if alignment_list != []:

            for alignment_element in alignment_list:

                # Adds the alignment submenu for each cluster loaded in PyMod to the PyMod main menu.
                label_text = alignment_element.my_header
                single_alignment_submenu = QtWidgets.QMenu(label_text, self)
                self.alignments_menu.addMenu(single_alignment_submenu)

                # Save to a file dialog.
                add_qt_menu_command(
                    single_alignment_submenu,
                    "Save to File",
                    # The first argument in Qt is a 'False' value, therefore we need to add a dummy 'a' variable
                    # in order to pass the 'alignment_element' object.
                    lambda a=None, e=alignment_element: self.pymod.
                    save_alignment_to_file_from_ali_menu(e))
                single_alignment_submenu.addSeparator()

                # Matrices submenu.
                single_alignment_matrices_submenu = QtWidgets.QMenu(
                    'Matrices', self)
                single_alignment_submenu.addMenu(
                    single_alignment_matrices_submenu)

                add_qt_menu_command(single_alignment_matrices_submenu,
                                    "Sequence Identity Matrix",
                                    lambda a=None, e=alignment_element: self.
                                    pymod.display_identity_matrix(e))
                add_qt_menu_command(
                    single_alignment_matrices_submenu,
                    "RMSD Matrix",
                    lambda a=None, e=alignment_element: self.pymod.
                    display_rmsd_matrix_from_alignments_menu(e))

                # Trees.
                if alignment_element.initial_number_of_sequences > 2:
                    single_alignment_trees_submenu = QtWidgets.QMenu(
                        'Trees', self)
                    single_alignment_submenu.addMenu(
                        single_alignment_trees_submenu)

                    if alignment_element.algorithm in pymod_vars.can_show_guide_tree:
                        add_qt_menu_command(
                            single_alignment_trees_submenu,
                            "Show Guide Tree",
                            lambda a=None, e=alignment_element: self.pymod.
                            show_guide_tree_from_alignments_menu(e))
                    if alignment_element.algorithm in pymod_vars.can_show_dendrogram and alignment_element.tree_file_path is not None:
                        add_qt_menu_command(
                            single_alignment_trees_submenu,
                            "Show SALIGN Dendrogram",
                            lambda a=None, e=alignment_element: self.pymod.
                            show_dendrogram_from_alignments_menu(e))
                    if len(alignment_element.get_children()) >= 2:
                        add_qt_menu_command(
                            single_alignment_trees_submenu,
                            "Build Tree from Alignment",
                            lambda a=None, e=alignment_element: self.pymod.
                            build_tree_from_alignments_menu(e))

                # Evolutionary conservation.
                single_alignment_evolutionary_submenu = QtWidgets.QMenu(
                    'Evolutionary Conservation', self)
                single_alignment_submenu.addMenu(
                    single_alignment_evolutionary_submenu)

                single_seq_evolutionary_submenu = QtWidgets.QMenu(
                    'Sequence Conservation', self)
                single_alignment_evolutionary_submenu.addMenu(
                    single_seq_evolutionary_submenu)
                add_qt_menu_command(
                    single_seq_evolutionary_submenu,
                    "Entropy",
                    lambda a=None, e=alignment_element: self.pymod.
                    launch_entropy_scorer_from_main_menu(e))
                add_qt_menu_command(single_seq_evolutionary_submenu,
                                    "CAMPO",
                                    lambda a=None, e=alignment_element: self.
                                    pymod.launch_campo_from_main_menu(e))
                add_qt_menu_command(single_seq_evolutionary_submenu,
                                    "Pair Conservation",
                                    lambda a=None, e=alignment_element: self.
                                    pymod.launch_pc_from_main_menu(e))

                single_str_evolutionary_submenu = QtWidgets.QMenu(
                    'Structural Conservation', self)
                single_alignment_evolutionary_submenu.addMenu(
                    single_str_evolutionary_submenu)
                add_qt_menu_command(single_str_evolutionary_submenu,
                                    "SCR_FIND",
                                    lambda a=None, e=alignment_element: self.
                                    pymod.launch_scr_find_from_main_menu(e))

                # Render alignment.
                single_alignment_render_submenu = QtWidgets.QMenu(
                    'Render Alignment', self)
                single_alignment_submenu.addMenu(
                    single_alignment_render_submenu)

                add_qt_menu_command(single_alignment_render_submenu,
                                    "Generate Logo through WebLogo 3",
                                    lambda a=None, e=alignment_element: self.
                                    pymod.launch_weblogo_from_main_menu(e))
                add_qt_menu_command(single_alignment_render_submenu,
                                    "Launch ESPript in Web Browser",
                                    lambda a=None, e=alignment_element: self.
                                    pymod.launch_espript_from_main_menu(e))

        else:

            add_qt_menu_command(self.alignments_menu,
                                "There aren't any alignments")
예제 #15
0
    def make_main_menu(self):
        """
        This method is called when initializing the main window in order to build its main menu.
        """

        self.menubar = self.menuBar()
        self.menubar.setNativeMenuBar(False)

        #---------------
        # "File" menu. -
        #---------------

        self.file_menu = self.menubar.addMenu('File')

        # Sequences submenu.
        self.sequences_submenu = QtWidgets.QMenu('Sequences and Structures',
                                                 self)
        self.file_menu.addMenu(self.sequences_submenu)
        add_qt_menu_command(self.sequences_submenu, 'Open from File',
                            self.pymod.open_file_from_the_main_menu)
        add_qt_menu_command(self.sequences_submenu, 'Add Raw Sequence',
                            self.pymod.show_raw_seq_input_window)
        add_qt_menu_command(self.sequences_submenu, 'Import PyMOL Objects',
                            self.pymod.import_pymol_selections_from_main_menu)

        # self.file_menu.addSeparator()

        # Submenu to open alignments.
        self.alignment_files_submenu = QtWidgets.QMenu('Alignments', self)
        self.file_menu.addMenu(self.alignment_files_submenu)
        add_qt_menu_command(self.alignment_files_submenu, 'Open from File',
                            self.pymod.open_alignment_from_main_menu)

        # Submenu to open results files from external programs.
        self.external_results_submenu = QtWidgets.QMenu(
            'External Programs Results', self)
        self.file_menu.addMenu(self.external_results_submenu)

        self.hhsuite_results_submenu = QtWidgets.QMenu('HH-suite', self)
        self.external_results_submenu.addMenu(self.hhsuite_results_submenu)
        add_qt_menu_command(self.hhsuite_results_submenu,
                            'Template Search (.hhr)',
                            self.pymod.open_hhsuite_hhr_from_main_menu)
        add_qt_menu_command(self.hhsuite_results_submenu,
                            'Multiple Sequence Alignment (.a3m)',
                            self.pymod.open_hhsuite_a3m_from_main_menu)

        self.file_menu.addSeparator()

        # Workspace submenu.
        self.sessions_submenu = QtWidgets.QMenu('Sessions', self)
        self.file_menu.addMenu(self.sessions_submenu)
        add_qt_menu_command(self.sessions_submenu, 'New',
                            self.pymod.start_new_session_from_main_menu)
        add_qt_menu_command(self.sessions_submenu, 'Save',
                            self.pymod.save_session_from_main_menu)
        add_qt_menu_command(self.sessions_submenu, 'Open',
                            self.pymod.open_session_from_main_menu)

        self.file_menu.addSeparator()

        # Exit command.
        add_qt_menu_command(self.file_menu, 'Exit',
                            self.pymod.exit_from_main_menu)

        #----------------
        # "Tools" menu. -
        #----------------

        self.tools_menu = self.menubar.addMenu('Tools')

        # Database search for homologous sequences.
        self.database_search_submenu = QtWidgets.QMenu('Database Search', self)
        self.tools_menu.addMenu(self.database_search_submenu)

        self.blast_tools_submenu = QtWidgets.QMenu('BLAST', self)
        self.database_search_submenu.addMenu(self.blast_tools_submenu)
        add_qt_menu_command(
            self.blast_tools_submenu, 'Local BLAST',
            lambda: self.pymod.launch_blast_algorithm("blastp"))
        add_qt_menu_command(self.blast_tools_submenu, 'Remote BLAST',
                            lambda: self.pymod.launch_blast_algorithm("blast"))
        add_qt_menu_command(
            self.database_search_submenu, 'PSI-BLAST',
            lambda: self.pymod.launch_blast_algorithm("psi-blast"))
        self.database_search_submenu.addSeparator()
        add_qt_menu_command(
            self.database_search_submenu, 'phmmer',
            lambda: self.pymod.launch_hmmer_algorithm("phmmer"))
        add_qt_menu_command(
            self.database_search_submenu, 'jackhmmer',
            lambda: self.pymod.launch_hmmer_algorithm("jackhmmer"))
        add_qt_menu_command(
            self.database_search_submenu, 'hmmsearch',
            lambda: self.pymod.launch_hmmer_algorithm("hmmsearch"))

        # Alignment tools
        self.alignments_tools_submenu = QtWidgets.QMenu(
            'Alignment Tools', self)
        self.tools_menu.addMenu(self.alignments_tools_submenu)

        # Sequence alignment tools.
        self.sequence_alignments_submenu = QtWidgets.QMenu(
            'Sequence Alignment', self)
        self.alignments_tools_submenu.addMenu(self.sequence_alignments_submenu)
        add_qt_menu_command(
            self.sequence_alignments_submenu, 'ClustalW',
            lambda: self.pymod.launch_alignment_from_the_main_menu(
                "clustalw", "regular"))
        add_qt_menu_command(
            self.sequence_alignments_submenu, 'Clustal Omega',
            lambda: self.pymod.launch_alignment_from_the_main_menu(
                "clustalo", "regular"))
        add_qt_menu_command(
            self.sequence_alignments_submenu, 'MUSCLE',
            lambda: self.pymod.launch_alignment_from_the_main_menu(
                "muscle", "regular"))
        add_qt_menu_command(
            self.sequence_alignments_submenu, 'SALIGN (Sequence Alignment)',
            lambda: self.pymod.launch_alignment_from_the_main_menu(
                "salign-seq", "regular"))

        # Profile alignment tools.
        self.sequence_profile_alignments_submenu = QtWidgets.QMenu(
            'Profile Alignment', self)
        self.alignments_tools_submenu.addMenu(
            self.sequence_profile_alignments_submenu)
        add_qt_menu_command(
            self.sequence_profile_alignments_submenu, 'ClustalW',
            lambda: self.pymod.launch_alignment_from_the_main_menu(
                "clustalw", "profile"))
        add_qt_menu_command(
            self.sequence_profile_alignments_submenu, 'Clustal Omega',
            lambda: self.pymod.launch_alignment_from_the_main_menu(
                "clustalo", "profile"))
        add_qt_menu_command(
            self.sequence_profile_alignments_submenu,
            'SALIGN (Sequence Alignment)',
            lambda: self.pymod.launch_alignment_from_the_main_menu(
                "salign-seq", "profile"))

        # Structural alignment tools.
        self.structural_alignment_submenu = QtWidgets.QMenu(
            'Structural Alignment', self)
        self.alignments_tools_submenu.addMenu(
            self.structural_alignment_submenu)
        # add_qt_menu_command(self.structural_alignment_submenu, 'Superpose', self.pymod.superpose_from_main_menu)
        add_qt_menu_command(
            self.structural_alignment_submenu, 'CE Alignment',
            lambda: self.pymod.launch_alignment_from_the_main_menu(
                "ce", "regular"))
        add_qt_menu_command(
            self.structural_alignment_submenu, 'SALIGN (Structure Alignment)',
            lambda: self.pymod.launch_alignment_from_the_main_menu(
                "salign-str", "regular"))

        # Domain tools.
        self.domain_analysis_submenu = QtWidgets.QMenu('Domains Analysis',
                                                       self)
        self.tools_menu.addMenu(self.domain_analysis_submenu)
        self.hmmscan_tools_submenu = QtWidgets.QMenu('hmmscan', self)
        self.domain_analysis_submenu.addMenu(self.hmmscan_tools_submenu)
        add_qt_menu_command(self.hmmscan_tools_submenu, 'Local hmmscan',
                            lambda: self.pymod.launch_domain_analysis("local"))
        add_qt_menu_command(
            self.hmmscan_tools_submenu, 'Remote hmmscan',
            lambda: self.pymod.launch_domain_analysis("remote"))

        # Structural analysis.
        self.structural_analysis_submenu = QtWidgets.QMenu(
            'Structural Analysis', self)
        self.tools_menu.addMenu(self.structural_analysis_submenu)
        add_qt_menu_command(self.structural_analysis_submenu,
                            'Ramachandran Plot',
                            self.pymod.ramachandran_plot_from_main_menu)
        add_qt_menu_command(self.structural_analysis_submenu, 'Contact Map',
                            self.pymod.contact_map_from_main_menu)
        add_qt_menu_command(self.structural_analysis_submenu,
                            'Structural Divergence Plot',
                            self.pymod.sda_from_main_menu)
        self.structural_analysis_submenu.addSeparator()
        add_qt_menu_command(self.structural_analysis_submenu,
                            'Assess with DOPE', self.pymod.dope_from_main_menu)
        self.structural_analysis_submenu.addSeparator()
        add_qt_menu_command(self.structural_analysis_submenu, 'PSIPRED',
                            self.pymod.launch_psipred_from_main_menu)

        # Modeling.
        self.modeling_submenu = QtWidgets.QMenu('Modeling', self)
        self.tools_menu.addMenu(self.modeling_submenu)
        add_qt_menu_command(self.modeling_submenu,
                            "MODELLER (Homology Modeling)",
                            self.pymod.launch_modeller_hm_from_main_menu)
        add_qt_menu_command(self.modeling_submenu, "MODELLER (Loop Modeling)",
                            self.pymod.launch_modeller_lr_from_main_menu)

        # Options.
        self.tools_menu.addSeparator()
        add_qt_menu_command(self.tools_menu, 'Options',
                            self.pymod.show_pymod_options_window)

        #---------------------
        # "Alignments" menu. -
        #---------------------

        self.alignments_menu = self.menubar.addMenu('Alignments')
        self.build_alignment_submenu()

        #-----------------
        # "Models" menu. -
        #-----------------

        # When the plugin is started there are no models.
        self.models_menu = self.menubar.addMenu('Models')
        self.build_models_submenu()

        #--------------------
        # "Selection" menu. -
        #--------------------

        self.main_selection_menu = self.menubar.addMenu('Selection')
        add_qt_menu_command(self.main_selection_menu, 'Select All [Ctrl+a]',
                            self.pymod.select_all_from_main_menu)
        add_qt_menu_command(self.main_selection_menu, 'Deselect All [Esc]',
                            self.pymod.deselect_all_from_main_menu)

        # Structures selection submenu.
        self.selection_structures_menu = QtWidgets.QMenu('Structures', self)
        self.main_selection_menu.addMenu(self.selection_structures_menu)
        add_qt_menu_command(self.selection_structures_menu,
                            'Show All in PyMOL [Ctrl+s]',
                            self.pymod.show_all_structures_from_main_menu)
        add_qt_menu_command(self.selection_structures_menu,
                            'Hide All in PyMOL [Ctrl+h]',
                            self.pymod.hide_all_structures_from_main_menu)
        self.selection_structures_menu.addSeparator()
        add_qt_menu_command(self.selection_structures_menu, 'Select All',
                            self.pymod.select_all_structures_from_main_menu)
        add_qt_menu_command(self.selection_structures_menu, 'Deselect All',
                            self.pymod.deselect_all_structures_from_main_menu)
        # Clusters selection submenu.
        self.selection_clusters_menu = QtWidgets.QMenu('Clusters', self)
        self.main_selection_menu.addMenu(self.selection_clusters_menu)
        add_qt_menu_command(self.selection_clusters_menu, 'Expand All',
                            self.pymod.expand_all_clusters_from_main_menu)
        add_qt_menu_command(self.selection_clusters_menu, 'Collapse All',
                            self.pymod.collapse_all_clusters_from_main_menu)

        #------------------
        # "Display" menu. -
        #------------------

        self.display_menu = self.menubar.addMenu('Display')
        if self.pymod.DEVELOP:
            add_qt_menu_command(self.display_menu,
                                'Print Selected Sequences',
                                command=self.print_selected)

        # Color menu.
        self.main_color_menu = QtWidgets.QMenu('Color all Sequences', self)
        self.display_menu.addMenu(self.main_color_menu)
        add_qt_menu_command(
            self.main_color_menu,
            'By Default Color',
            command=lambda: self.color_selection("all", None, "regular"))
        self.main_residues_colors_menu = QtWidgets.QMenu(
            'By Residue Properties', self)
        self.main_color_menu.addMenu(self.main_residues_colors_menu)
        add_qt_menu_command(
            self.main_residues_colors_menu,
            'Residue Type',
            command=lambda: self.color_selection("all", None, "residue_type"))
        add_qt_menu_command(
            self.main_residues_colors_menu,
            'Polarity',
            command=lambda: self.color_selection("all", None, "polarity"))
        add_qt_menu_command(self.main_color_menu,
                            'By Secondary Structure',
                            command=lambda: self.color_selection(
                                "all", None, "secondary-auto"))

        # Font selection.
        self.font_selection_menu = QtWidgets.QMenu('Font Selection', self)
        self.display_menu.addMenu(self.font_selection_menu)
        if self.pymod.DEVELOP:
            add_qt_menu_command(self.display_menu, 'Font Type and Size',
                                self.pymod.change_font_from_main_menu)

        # Font size selection.
        self.font_size_selection_menu = QtWidgets.QMenu('Font Size', self)
        self.font_selection_menu.addMenu(self.font_size_selection_menu)
        font_size_action_group = QtWidgets.QActionGroup(
            self.font_size_selection_menu)
        font_size_action_group.setExclusive(True)
        for font_size in ("6", "7", "8", "9", "10", "11", "12", "13", "14",
                          "15", "16"):
            action = font_size_action_group.addAction(
                QtWidgets.QAction(font_size,
                                  self.font_size_selection_menu,
                                  checkable=True))
            self.font_size_selection_menu.addAction(action)
            if font_size == str(self.font_size):
                action.setChecked(True)
            action.triggered.connect(lambda a=None, t=None, s=font_size: self.
                                     pymod.change_font_from_action(t, s))

        # Font type selection.
        self.font_type_selection_menu = QtWidgets.QMenu('Font Type', self)
        self.font_selection_menu.addMenu(self.font_type_selection_menu)
        font_type_action_group = QtWidgets.QActionGroup(
            self.font_type_selection_menu)
        font_type_action_group.setExclusive(True)
        for font_type in self.get_available_fonts():
            action = font_type_action_group.addAction(
                QtWidgets.QAction(font_type,
                                  self.font_type_selection_menu,
                                  checkable=True))
            self.font_type_selection_menu.addAction(action)
            if font_type == str(self.font):
                action.setChecked(True)
            action.triggered.connect(lambda a=None, t=font_type, s=None: self.
                                     pymod.change_font_from_action(t, s))

        #---------------
        # "Help" menu. -
        #---------------

        self.help_menu = self.menubar.addMenu('Help')
        if self.pymod.DEVELOP:
            add_qt_menu_command(self.help_menu, 'Test',
                                self.pymod.launch_default)
        add_qt_menu_command(self.help_menu, 'Online Documentation',
                            self.pymod.open_online_documentation)
        add_qt_menu_command(self.help_menu, 'About',
                            self.pymod.show_about_dialog)
        self.help_menu.addSeparator()
        add_qt_menu_command(self.help_menu, "Install PyMod Components",
                            self.pymod.launch_components_installation)
        add_qt_menu_command(self.help_menu, "Check for Database Updates",
                            self.pymod.launch_databases_update)

        if self.pymod.TEST:
            self.help_menu.addSeparator()
            self.examples_menu = QtWidgets.QMenu('Examples', self)
            self.help_menu.addMenu(self.examples_menu)
            add_qt_menu_command(
                self.examples_menu,
                "Load random sequence from UniProt",
                lambda a=None: self.pymod.load_uniprot_random())
            add_qt_menu_command(self.examples_menu,
                                "Load random PDB entry",
                                lambda a=None: self.pymod.load_pdb_random())
예제 #16
0
    def build_multiple_color_menu(self, mode, cluster_target_menu=None):
        """
        Used to build the color menu of both Selection and cluster elements popup menus.
        """

        if mode == "selection":
            target_menu = self.context_menu
            color_selection_mode = "selection"
            color_selection_target = None
            sequences_list = self.parent_group.pymod.get_selected_sequences()
            # color_selection_target = sequences_list
            color_target_label = "Selection"

        elif mode == "cluster":
            target_menu = cluster_target_menu
            color_selection_mode = "multiple"
            if self.parent_group.pymod_element.is_cluster():
                color_selection_target = self.parent_group.pymod_element.get_children(
                )
                sequences_list = self.parent_group.pymod_element.get_children()
            else:
                color_selection_target = self.parent_group.pymod_element.mother.get_children(
                )
                sequences_list = self.parent_group.pymod_element.mother.get_children(
                )
            color_target_label = "Cluster"

        # Builds the selection color menu.
        multiple_color_menu = QtWidgets.QMenu('Color', target_menu)

        # A submenu to choose a single color used to color all the residues of a sequence.
        multiple_regular_colors_menu = QtWidgets.QMenu(
            "Color whole %s by" % (color_target_label), multiple_color_menu
        )  # Menu(multiple_color_menu, tearoff=0, bg='white', activebackground='black', activeforeground='white')
        self.build_regular_colors_submenu(
            multiple_regular_colors_menu,
            color_selection_mode,
            elements_to_color=color_selection_target)
        multiple_color_menu.addMenu(multiple_regular_colors_menu)
        # multiple_color_menu.addSeparator()

        # Colors each kind of residue in a sequence in a different way.
        multiple_residues_colors_menu = QtWidgets.QMenu(
            'By Residue Properties', target_menu)
        add_qt_menu_command(
            multiple_residues_colors_menu,
            "Residue Type",
            command=lambda: self.parent_group.main_window.color_selection(
                color_selection_mode, color_selection_target, "residue_type"))
        add_qt_menu_command(
            multiple_residues_colors_menu,
            "Polarity",
            command=lambda: self.parent_group.main_window.color_selection(
                color_selection_mode, color_selection_target, "polarity"))
        multiple_color_menu.addMenu(multiple_residues_colors_menu)

        # Secondary structure colors.
        n_selected_seqs = len(sequences_list)
        n_structures = len([e for e in sequences_list if e.has_structure()])
        n_seq_with_predicted_sec_str = len([
            e for e in sequences_list if e.has_predicted_secondary_structure()
        ])

        if n_structures + n_seq_with_predicted_sec_str == n_selected_seqs:
            # multiple_color_menu.addSeparator()
            multiple_sec_str_color_menu = QtWidgets.QMenu(
                'By Secondary Structure', multiple_color_menu)
            multiple_color_menu.addMenu(multiple_sec_str_color_menu)

            # Available when all the selected sequences have a 3D structure.
            if n_structures == n_selected_seqs:
                add_qt_menu_command(
                    multiple_sec_str_color_menu, "Observed",
                    lambda: self.parent_group.main_window.color_selection(
                        color_selection_mode, color_selection_target,
                        "secondary-observed"))

            # Available only if all the sequences have a predicted secondary structure.
            if n_seq_with_predicted_sec_str == n_selected_seqs:
                add_qt_menu_command(
                    multiple_sec_str_color_menu, "Predicted by PSIPRED",
                    lambda: self.parent_group.main_window.color_selection(
                        color_selection_mode, color_selection_target,
                        "secondary-predicted"))

            # Available if there is at least one element with a 3D structure or a secondary
            # structure prediction.
            if not n_structures == n_selected_seqs:
                add_qt_menu_command(
                    multiple_sec_str_color_menu, "Auto (Observed + Predicted)",
                    lambda: self.parent_group.main_window.color_selection(
                        color_selection_mode, color_selection_target,
                        "secondary-auto"))

        # Conservation colors.
        sel_has_campo_scores = all(
            [e.has_campo_scores() for e in sequences_list])
        sel_has_entropy_scores = all(
            [e.has_entropy_scores() for e in sequences_list])
        if sel_has_campo_scores or sel_has_entropy_scores:
            multiple_cons_colors_menu = QtWidgets.QMenu(
                'By Conservation', multiple_color_menu)
            multiple_color_menu.addMenu(multiple_cons_colors_menu)
            if sel_has_campo_scores:
                add_qt_menu_command(
                    multiple_cons_colors_menu, "CAMPO scores",
                    lambda: self.parent_group.main_window.color_selection(
                        color_selection_mode, color_selection_target,
                        "campo-scores"))
            if sel_has_entropy_scores:
                add_qt_menu_command(
                    multiple_cons_colors_menu, "Entropy scores",
                    lambda: self.parent_group.main_window.color_selection(
                        color_selection_mode, color_selection_target,
                        "entropy-scores"))

        # Energy colors.
        if all([e.has_dope_scores() for e in sequences_list]):
            # multiple_color_menu.addSeparator()
            multiple_energy_colors_menu = QtWidgets.QMenu(
                'By Energy', multiple_color_menu)
            multiple_color_menu.addMenu(multiple_energy_colors_menu)
            add_qt_menu_command(
                multiple_energy_colors_menu, "DOPE scores",
                lambda: self.parent_group.main_window.color_selection(
                    color_selection_mode, color_selection_target, "dope"))

        # Color by domain.
        if all([e.has_domains() for e in sequences_list]):
            add_qt_menu_command(
                multiple_color_menu, "By Domain",
                lambda: self.parent_group.main_window.color_selection(
                    color_selection_mode, color_selection_target, "domains"))

        return multiple_color_menu
예제 #17
0
    def build_color_menu(self):
        """
        Color submenu containing all the option to color for a single sequence.
        """

        self.color_context_submenu = QtWidgets.QMenu(
            'Color', self.single_element_target_submenu)
        self.single_element_target_submenu.addMenu(self.color_context_submenu)

        # A submenu to choose a single color used to color all the residues of a sequence.
        self.regular_colors_context_submenu = QtWidgets.QMenu(
            'Color whole Sequence by', self.color_context_submenu)
        self.color_context_submenu.addMenu(self.regular_colors_context_submenu)
        self.build_regular_colors_submenu(self.regular_colors_context_submenu,
                                          "single")

        # Colors each kind of residue in a sequence in a different way.
        self.residues_colors_context_submenu = QtWidgets.QMenu(
            'By Residue Properties', self.color_context_submenu)
        self.color_context_submenu.addMenu(
            self.residues_colors_context_submenu)
        add_qt_menu_command(
            self.residues_colors_context_submenu, "Residue Type",
            lambda: self.parent_group.main_window.color_selection(
                "single", self.parent_group.pymod_element, "residue_type"))
        add_qt_menu_command(
            self.residues_colors_context_submenu, "Polarity",
            lambda: self.parent_group.main_window.color_selection(
                "single", self.parent_group.pymod_element, "polarity"))

        # Secondary structure colors.
        if self.parent_group.can_be_colored_by_secondary_structure():
            # self.color_context_submenu.addSeparator()
            self.sec_str_color_submenu = QtWidgets.QMenu(
                'By Secondary Structure', self.color_context_submenu)
            self.color_context_submenu.addMenu(self.sec_str_color_submenu)
            if self.parent_group.pymod_element.has_structure():
                add_qt_menu_command(
                    self.sec_str_color_submenu, "Observed",
                    lambda: self.parent_group.main_window.color_selection(
                        "single", self.parent_group.pymod_element,
                        "secondary-observed"))
            if self.parent_group.pymod_element.has_predicted_secondary_structure(
            ):
                add_qt_menu_command(
                    self.sec_str_color_submenu, "Predicted by PSIPRED",
                    lambda: self.parent_group.main_window.color_selection(
                        "single", self.parent_group.pymod_element,
                        "secondary-predicted"))

        # Conservation colors.
        if self.parent_group.pymod_element.has_campo_scores(
        ) or self.parent_group.pymod_element.has_entropy_scores():
            # self.color_context_submenu.addSeparator()
            self.conservation_colors_menu = QtWidgets.QMenu(
                'By Conservation', self.color_context_submenu)
            self.color_context_submenu.addMenu(self.conservation_colors_menu)
            if self.parent_group.pymod_element.has_campo_scores():
                add_qt_menu_command(
                    self.conservation_colors_menu, "CAMPO scores",
                    lambda: self.parent_group.main_window.color_selection(
                        "single", self.parent_group.pymod_element,
                        "campo-scores"))
            if self.parent_group.pymod_element.has_entropy_scores():
                add_qt_menu_command(
                    self.conservation_colors_menu, "Entropy scores",
                    lambda: self.parent_group.main_window.color_selection(
                        "single", self.parent_group.pymod_element,
                        "entropy-scores"))

        # Energy colors.
        if self.parent_group.pymod_element.has_dope_scores():
            # self.color_context_submenu.addSeparator()
            self.energy_colors_menu = QtWidgets.QMenu(
                'By Energy', self.color_context_submenu)
            self.color_context_submenu.addMenu(self.energy_colors_menu)
            add_qt_menu_command(
                self.energy_colors_menu, "DOPE scores",
                lambda: self.parent_group.main_window.color_selection(
                    "single", self.parent_group.pymod_element, "dope"))

        # Color by domain.
        if self.parent_group.pymod_element.has_domains():
            add_qt_menu_command(
                self.color_context_submenu, "By Domain",
                lambda: self.parent_group.main_window.color_selection(
                    "single", self.parent_group.pymod_element, "domains"))