Пример #1
0
 def launch_modeller(self):
     from chimerax.core.commands import run, FileNameArg, StringArg
     from chimerax.core.errors import UserError
     alignments = self.alignment_list.value
     if not alignments:
         raise UserError("No alignments chosen for modeling")
     aln_seq_args = []
     for aln in alignments:
         seq_menu = self.seq_menu[aln]
         seq = seq_menu.value
         if not seq:
             raise UserError("No target sequence chosen for alignment %s" %
                             aln.ident)
         aln_seq_args.append(
             StringArg.unparse("%s:%d" %
                               (aln.ident, aln.seqs.index(seq) + 1)))
     from .settings import get_settings
     settings = get_settings(self.session)
     run(
         self.session,
         "modeller comparative %s multichain %s numModels %d fast %s hetPreserve %s"
         " hydrogens %s%s waterPreserve %s" %
         (" ".join(aln_seq_args), repr(
             settings.multichain).lower(), settings.num_models,
          repr(settings.fast).lower(), repr(settings.het_preserve).lower(),
          repr(settings.hydrogens).lower(), " tempPath %s" %
          FileNameArg.unparse(settings.temp_path) if settings.temp_path else
          "", repr(settings.water_preserve).lower()))
     self.delete()
Пример #2
0
    def fill_context_menu(self, menu, x, y):
        from PyQt5.QtWidgets import QAction
        file_menu = menu.addMenu("File")
        save_as_menu = file_menu.addMenu("Save As")
        from chimerax.core.commands import run, StringArg
        fmts = [
            fmt for fmt in self.session.save_command.save_data_formats
            if fmt.category == "Sequence"
        ]
        fmts.sort(key=lambda fmt: fmt.synopsis.casefold())
        for fmt in fmts:
            action = QAction(fmt.synopsis, save_as_menu)
            action.triggered.connect(lambda arg, fmt=fmt: run(
                self.session, "save browse format %s alignment %s" %
                (fmt.nicknames[0], StringArg.unparse(self.alignment.ident))))
            save_as_menu.addAction(action)
        scf_action = QAction("Load Sequence Coloring File...", file_menu)
        scf_action.triggered.connect(lambda arg: self.load_scf_file(None))
        file_menu.addAction(scf_action)

        structure_menu = menu.addMenu("Structure")
        assoc_action = QAction("Associations...", structure_menu)
        assoc_action.triggered.connect(lambda arg: self.show_associations())
        from chimerax.atomic import AtomicStructure
        for m in self.session.models:
            if isinstance(m, AtomicStructure):
                break
        else:
            assoc_action.setEnabled(False)
        structure_menu.addAction(assoc_action)

        headers_menu = menu.addMenu("Headers")
        headers = self.alignment.headers
        headers.sort(key=lambda hdr: hdr.ident.casefold())
        from chimerax.core.commands import run
        for hdr in headers:
            action = QAction(hdr.name, headers_menu)
            action.setCheckable(True)
            action.setChecked(hdr.shown)
            if not hdr.relevant:
                action.setEnabled(False)
            align_arg = "%s " % self.alignment if len(
                self.session.alignments.alignments) > 1 else ""
            action.triggered.connect(
                lambda checked, hdr=hdr, align_arg=align_arg, self=self: run(
                    self.session, "seq header %s%s %s" %
                    (align_arg, hdr.ident, "show" if checked else "hide")))
            headers_menu.addAction(action)
        headers_menu.addSeparator()
        hdr_save_menu = headers_menu.addMenu("Save")
        for hdr in headers:
            if not hdr.relevant:
                continue
            action = QAction(hdr.name, hdr_save_menu)
            align_arg = "%s " % self.alignment if len(
                self.session.alignments.alignments) > 1 else ""
            action.triggered.connect(
                lambda checked, hdr=hdr, align_arg=align_arg, self=self: run(
                    self.session, "seq header %s%s save browse" %
                    (align_arg, hdr.ident)))
            hdr_save_menu.addAction(action)

        # Whenever Region Browser and UniProt Annotations happen, the thought is to
        # put them in an "Annotations" menu (rather than "Info")

        tools_menu = menu.addMenu("Tools")
        comp_model_action = QAction("Modeller Comparative Modeling...",
                                    tools_menu)
        comp_model_action.triggered.connect(lambda arg: run(
            self.session, "ui tool show 'Modeller Comparative'"))
        if not self.alignment.associations:
            comp_model_action.setEnabled(False)
        tools_menu.addAction(comp_model_action)
        if len(self.alignment.seqs) == 1:
            blast_action = QAction("Blast Protein...", tools_menu)
            blast_action.triggered.connect(lambda arg: run(
                self.session, "blastprotein %s" %
                (StringArg.unparse("%s:1" % self.alignment.ident))))
            tools_menu.addAction(blast_action)
        else:
            blast_menu = tools_menu.addMenu("Blast Protein")
            for i, seq in enumerate(self.alignment.seqs):
                blast_action = QAction(seq.name, blast_menu)
                blast_action.triggered.connect(lambda arg: run(
                    self.session, "blastprotein %s" % (StringArg.unparse(
                        "%s:%d" % (self.alignment.ident, i + 1)))))
                blast_menu.addAction(blast_action)

        settings_action = QAction("Settings...", menu)
        settings_action.triggered.connect(lambda arg: self.show_settings())
        menu.addAction(settings_action)
Пример #3
0
 def callback(ses = self.session, tool_name=tool.name, vmenu = self):
     from chimerax.core.commands import run, StringArg
     run(ses, "ui tool show %s" % StringArg.unparse(tool_name))