def parse_color(fields, name):

    if len(fields) == 0:
        raise syn, 'Missing %s value' % name

    # Color from color dialog
    if fields[0] in ('colorpanel', 'fromeditor', 'editor'):
        from CGLtk.color import ColorWell
        if not ColorWell._colorPanel:
            from chimera import dialogs
            dialogs.display("color editor")
            raise syn, 'Choose color in panel first'
        return ColorWell.colorPanel().rgba

    # Chimera color defined with colordef
    from chimera import Color
    c = Color.lookup(fields[0])
    if c:
        return c.rgba()

    try:
        # Tk color name.
        from chimera.tkgui import app
        color = [c / 65535.0 for c in app.winfo_rgb(fields[0])]
    except:
        # Comma separated list of rgb or rgba float values.
        color = parse_values(fields, 'color', float, (3, 4))

    return color
示例#2
0
def show_side_view():
    'Show side view dialog'
    from chimera import dialogs
    from chimera import viewing
    dialogs.display(viewing.ViewerDialog.name)
    d = dialogs.find(viewing.ViewerDialog.name, create=1)
    d.nb.raise_page('pSideView')
def parse_color(fields, name):

    if len(fields) == 0:
        raise syn, 'Missing %s value' % name

    # Color from color dialog
    if fields[0] in ('colorpanel', 'fromeditor', 'editor'):
        from CGLtk.color import ColorWell
        if not ColorWell._colorPanel:
            from chimera import dialogs
            dialogs.display("color editor")
            raise syn, 'Choose color in panel first'
        return ColorWell.colorPanel().rgba

    # Chimera color defined with colordef
    from chimera import Color
    c = Color.lookup(fields[0])
    if c:
        return c.rgba()

    try:
        # Tk color name.
        from chimera.tkgui import app
        color = [c/65535.0 for c in app.winfo_rgb(fields[0])]
    except:
        # Comma separated list of rgb or rgba float values.
        color = parse_values(fields, 'color', float, (3,4))

    return color
def initiateAddHyd(models, cancelCB=None, okCB=None, hisScheme=None,
					addFunc=AddH.hbondAddHydrogens):
	"""Request the addition of hydrogens to the given models.

	If all atoms in the models have known hydrogen-adding geometries,
	the hydrogens are added immediately.  Otherwise, a dialog is
	started to request the missing information from the user.  Once
	the user 'Ok's the information-gathering dialog, the hydrogens are
	added.  The dialog can instead be cancelled, in which case no 
	hydrogens are added.

	This function may be called from the user interface or from other
	functions.  If the latter, then typically the cancelCB and okCB
	callback functions are provided so that the calling function can
	ascertain whether hydrogens were in fact added to the models.
	"""
	unks = AddH.gatherUnknowns(models)
	if unks:
		dialogs.display(addHinfoDialog.name)
		dialog = dialogs.find(addHinfoDialog.name)
		dialog.setAtoms(unks)
		dialog.models = models
		dialog.cancelCB = cancelCB
		dialog.okCB = okCB
		dialog.hisScheme = hisScheme
		dialog.addFunc = addFunc
	else:
		addFunc(models, hisScheme=hisScheme)
		if okCB:
			okCB()
	def Apply(self):
		val = self.seqMenu1.get()
		if val == self.ALL:
			seqs1 = self.mav.seqs
		else:
			seqs1 = [s for s in self.mav.seqs if s.name == val]
		val = self.seqMenu2.get()
		if val == self.ALL:
			seqs2 = self.mav.seqs
		else:
			seqs2 = [s for s in self.mav.seqs if s.name == val]

		denom = self.denominator.get()
		for s1 in seqs1:
			for s2 in seqs2:
				pi = percentIdentity(s1, s2, denominator=denom)
				self.mav.status("%s vs. %s:\n"
					"   %.2f%% identity\n" % (s1.name,
					s2.name, pi))
				# since once OK is clicked, the mouse may be
				# over a part of the alignment that causes a
				# status message, also send to regular status
				# line
				replyobj.status("%s vs. %s: %.2f%% identity\n"
					% (s1.name, s2.name, pi), log=True)
		if len(seqs1) > 1 or len(seqs2) > 1:
			self.mav.status("Percent identity info in Reply Log")
			from chimera import dialogs, tkgui
			dialogs.display(tkgui._ReplyDialog.name)
    def Apply(self):
        val = self.seqMenu1.get()
        if val == self.ALL:
            seqs1 = self.mav.seqs
        else:
            seqs1 = [s for s in self.mav.seqs if s.name == val]
        val = self.seqMenu2.get()
        if val == self.ALL:
            seqs2 = self.mav.seqs
        else:
            seqs2 = [s for s in self.mav.seqs if s.name == val]

        denom = self.denominator.get()
        for s1 in seqs1:
            for s2 in seqs2:
                pi = percentIdentity(s1, s2, denominator=denom)
                self.mav.status("%s vs. %s:\n"
                                "   %.2f%% identity\n" %
                                (s1.name, s2.name, pi))
                # since once OK is clicked, the mouse may be
                # over a part of the alignment that causes a
                # status message, also send to regular status
                # line
                replyobj.status("%s vs. %s: %.2f%% identity\n" %
                                (s1.name, s2.name, pi),
                                log=True)
        if len(seqs1) > 1 or len(seqs2) > 1:
            self.mav.status("Percent identity info in Reply Log")
            from chimera import dialogs, tkgui
            dialogs.display(tkgui._ReplyDialog.name)
 def showRainbowDialog(models):
     from chimera import dialogs
     from rainbow import RainbowDialog
     if len(models) > 1:
         target = "models"
     else:
         target = "residues"
     dialogs.display(RainbowDialog.name).configure(models=models,
                                                   target=target)
示例#8
0
		def showRainbowDialog(models):
			from chimera import dialogs
			from rainbow import RainbowDialog
			if len(models) > 1:
				target = "models"
			else:
				target = "residues"
			dialogs.display(RainbowDialog.name).configure(
						models=models, target=target)
示例#9
0
def _showBondRotUI(trigger, myData, br):
	if chimera.nogui:
		return
	if trigger == bondRotMgr.CREATED:
		# some window managers are slow to raise windows
		# only auto-raise the dialog if a new rotation is created
		dialogs.display(StructMeasure.name)
	d = dialogs.find(StructMeasure.name)
	d.setCategoryMenu(BONDROTS)
	d.rotChange(trigger, br)
def _reportStatus(msg, assigned, propList, modelList, rba):
	if len(assigned) == 1:
		phrase = "one atom"
	else:
		phrase = "%d atoms" % len(assigned)
	pList = [ repr(p) for p in propList ]
	if len(pList) == 1:
		s = pList[0]
		plural = ""
		verb = "was"
	else:
		s = ", ".join(pList[:-1]) + " and " + pList[-1]
		plural = "s"
		verb = "were"
	msg += ("Attribute%s %s %s created for %s.\n"
		% (plural, s, verb, phrase))
	chimera.replyobj.status(msg)
	chimera.replyobj.message(msg)
	if rba and assigned:
		try:
			from ShowAttr import ShowAttrDialog
		except ImportError:
			# No "render by attribute", just ignore
			pass
		else:
			from chimera import dialogs
			d = dialogs.display(ShowAttrDialog.name)
			d.configure(models=modelList, attrsOf="atoms",
					attrName=None)
			d.refreshAttrs()
			d.configure(models=modelList, attrsOf="atoms",
					attrName=propList[0])
示例#11
0
	def _selectModelCB(self, tableSel):
		if self.treatmentSelAtom.get():
			from chimera import selection
			selection.clearCurrent()
			selection.addCurrent(tableSel)
			selection.addImpliedCurrent()
		if self.treatmentSelModel.get():
			from ModelPanel import ModelPanel
			from chimera import dialogs
			d = dialogs.display(ModelPanel.name)
			d.selectionChange(tableSel)
		shown = {}
		if self.treatmentHideOthers.get():
			for m in self.molList:
				key = (m.id, m.subid)
				shown[key] = m in tableSel or not tableSel
		else:
			for m in tableSel:
				key = (m.id, m.subid)
				shown[key] = True
		for m in chimera.openModels.list():
			key = (m.id, m.subid)
			try:
				m.display = shown[key]
			except KeyError:
				pass
示例#12
0
 def _getParameters(self, mols, nogui, addhyd):
     timestamp("_getParameters")
     import DockPrep
     import chimera
     self.originalAtoms = set([])
     for m in mols:
         self.originalAtoms.update(m.atoms)
     from AddCharge import AMBER99SB
     kw = {
         "doneCB": self._finishDockPrep,
         "gaffType": True,
         "chargeModel": AMBER99SB
     }
     if nogui or chimera.nogui:
         if not addhyd:
             kw["addHFunc"] = None
         DockPrep.prep(mols, nogui=nogui, **kw)
     else:
         from DockPrep.gui import DockPrepDialog
         from chimera import dialogs
         d = dialogs.display(DockPrepDialog.name, wait=True)
         d.addHydVar.set(addhyd)
         d.applyKeywords = kw
         d.molListBox.setvalue(mols)
         d.writeMol2Var.set(False)
     """
示例#13
0
 def Apply(self):
     minimize = self.minimizeVar.get()
     steps = 60
     ef = self.stepsCounter.component("entryfield")
     if ef.valid():
         value = int(ef.getvalue())
         if value > 0:
             steps = value
     self.state.makeMovie(minimize=minimize, steps=steps)
     action = self.createActionMenu.getvalue()
     if action == ActionShowModelPanel:
         from ModelPanel import ModelPanel
         from chimera import dialogs
         dialogs.display(ModelPanel.name)
     elif action == ActionHideConformations:
         self.state.hideConformations()
示例#14
0
    def Apply(self):
        from chimera import UserError
        attrName = self.attrNameOption.get()
        from chimera.misc import stringToAttr
        fixedAttrName = stringToAttr(attrName, collapse=False)
        if fixedAttrName != attrName:
            self.enter()
            raise UserError("Attribute name must be composed only"
                            " of letters, digits, and underscores and must"
                            " not start with a digit.")
        refName = self.refMenu.getvalue()

        sels = self.alignList.getcurselection()
        if len(sels) == 0:
            self.enter()
            raise UserError('Select at least one evaluation '
                            'structure to assess')
        refMol = self.mols[refName]
        evalMols = []
        for sel in sels:
            evalMols.append(self.mols[sel])
        self.mav.assessMatch(refMol, evalMols, attrName)
        from chimera import dialogs
        from ShowAttr import ShowAttrDialog
        d = dialogs.display(ShowAttrDialog.name)
        d.configure(models=evalMols,
                    attrsOf="residues",
                    attrName=attrName,
                    mode="Select")
示例#15
0
	def Apply(self):
		minimize = self.minimizeVar.get()
		steps = 60
		ef = self.stepsCounter.component("entryfield")
		if ef.valid():
			value = int(ef.getvalue())
			if value > 0:
				steps = value
		self.state.makeMovie(minimize=minimize, steps=steps)
		action = self.createActionMenu.getvalue()
		if action == ActionShowModelPanel:
			from ModelPanel import ModelPanel
			from chimera import dialogs
			dialogs.display(ModelPanel.name)
		elif action == ActionHideConformations:
			self.state.hideConformations()
示例#16
0
	def Apply(self):
		from chimera import UserError
		attrName = self.attrNameOption.get()
		from chimera.misc import stringToAttr
		fixedAttrName = stringToAttr(attrName, collapse=False)
		if fixedAttrName != attrName:
			self.enter()
			raise UserError("Attribute name must be composed only"
				" of letters, digits, and underscores and must"
				" not start with a digit.")
		refName = self.refMenu.getvalue()

		sels = self.alignList.getcurselection()
		if len(sels) == 0:
			self.enter()
			raise UserError('Select at least one evaluation '
						'structure to assess')
		refMol = self.mols[refName]
		evalMols = []
		for sel in sels:
			evalMols.append(self.mols[sel])
		self.mav.assessMatch(refMol, evalMols, attrName)
		from chimera import dialogs
		from ShowAttr import ShowAttrDialog
		d = dialogs.display(ShowAttrDialog.name)
		d.configure(models=evalMols, attrsOf="residues",
					attrName=attrName, mode="Select")
示例#17
0
	def _colorKeyCB(self):
		for entry in self.values:
			entry.invoke()
		from Ilabel.gui import IlabelDialog
		from chimera import dialogs
		d = dialogs.display(IlabelDialog.name)
		d.keyConfigure(zip([w.rgba for w in self.wells],
					[e.getvalue() for e in self.values]))
示例#18
0
def show_seg_marker_dialog():
    """Shows the Segment Marker dialog.

    show_seg_marker_dialog()
    """
    
    from chimera import dialogs
    return dialogs.display(Segment_Marker.name)
示例#19
0
 def color_key_cb(self, *args):
   if self.n < 2:
     raise chimera.UserError("At least two colors needed to create key")
   from Ilabel.gui import IlabelDialog
   from chimera import dialogs
   d = dialogs.display(IlabelDialog.name)
   d.keyConfigure([(w.rgba, h.variable.get()) for w, h in zip(self.colorwells,
                     self.entry_fields)[:self.n]])
示例#20
0
def show_vol_morph_dialog():
    """Shows the Volume Morph dialog.

    show_vol_morph_dialog()
    """
    
    from chimera import dialogs
    return dialogs.display(Volume_Morph.name)
示例#21
0
def show_simple_distance_dialog():
    """Shows the Measure Stick dialog.

    show_simple_distance_dialog()
    """
    
    from chimera import dialogs
    return dialogs.display(Measure_Stick.name)
示例#22
0
def displayDialog(wait=False):
    if dialogs.find(BugReportGUI.name):
	replyobj.status("Bug report already in progress!",
			color="red", blankAfter=15)
	return None
    else:
	br_gui = dialogs.display(BugReportGUI.name, wait)
	return br_gui
	def activate(self, molecules=None):
		from chimera import dialogs
		d = dialogs.display(self.module('gui').MatchMaker.name)
		if molecules:
			d.refMolList.setvalue(molecules[0])
			d.matchMolList.setvalue(molecules[1:])
			d.showSeqVar.set(False)
		return None
 def _colorKeyCB(self):
     for entry in self.values:
         entry.invoke()
     from Ilabel.gui import IlabelDialog
     from chimera import dialogs
     d = dialogs.display(IlabelDialog.name)
     d.keyConfigure(
         zip([w.rgba for w in self.wells],
             [e.getvalue() for e in self.values]))
示例#25
0
def displayDialog(wait=False):
    if dialogs.find(BugReportGUI.name):
        replyobj.status("Bug report already in progress!",
                        color="red",
                        blankAfter=15)
        return None
    else:
        br_gui = dialogs.display(BugReportGUI.name, wait)
        return br_gui
示例#26
0
def color_secondary_structure():
    'Color secondary structure using ColorSS extension'
    import ColorSS
    from chimera import dialogs
    d = dialogs.find(ColorSS.ColorSSDialog.name, create=False)
    if d == None:
        d = dialogs.display(ColorSS.ColorSSDialog.name)
        d.Close()
    d.Apply()
示例#27
0
 def color_key_cb(self, *args):
     if self.n < 2:
         raise chimera.UserError("At least two colors needed to create key")
     from Ilabel.gui import IlabelDialog
     from chimera import dialogs
     d = dialogs.display(IlabelDialog.name)
     d.keyConfigure([
         (w.rgba, h.variable.get())
         for w, h in zip(self.colorwells, self.entry_fields)[:self.n]
     ])
def show_attribute_histogram(molecule, attribute_name):

    import ShowAttr
    from chimera import dialogs
    d = dialogs.display(ShowAttr.ShowAttrDialog.name)
    d.configure(models=[molecule],
                mode='Render',
                attrsOf=ShowAttr.ATTRS_ATOMS,
                attrName=attribute_name)
    d.renderNotebook.selectpage('Colors')
def _prepDialog(nogui, mols, **kw):
    if nogui or chimera.nogui:
        prep(mols, **kw)
        return None
    from gui import DockPrepDialog
    from chimera import dialogs
    d = dialogs.display(DockPrepDialog.name, wait=True)
    d.applyKeywords = kw
    d.molListBox.setvalue(mols)
    return d
示例#30
0
def _prepDialog(nogui, mols, **kw):
	if nogui or chimera.nogui:
		prep(mols, **kw)
		return None
	from gui import DockPrepDialog
	from chimera import dialogs
	d = dialogs.display(DockPrepDialog.name, wait=True)
	d.applyKeywords = kw
	d.molListBox.setvalue(mols)
	return d
示例#31
0
def show_attribute_histogram(molecule, attribute_name):

    import ShowAttr
    from chimera import dialogs
    d = dialogs.display(ShowAttr.ShowAttrDialog.name)
    d.configure(models = [molecule],
                mode = 'Render',
                attrsOf = ShowAttr.ATTRS_ATOMS,
                attrName = attribute_name)
    d.renderNotebook.selectpage('Colors')
def seqCmd(items):
    global _seqInspectors
    todo = []
    for item in items:
        if not _seqInspectors.has_key(item):
            from chimera.Sequence import StructureSequence
            if isinstance(item, StructureSequence):
                from MultAlignViewer.MAViewer import MAViewer
                copySeq = StructureSequence.__copy__(item)
                copySeq.name = item.fullName()
                _addSeqInspector(item, mavSeq=copySeq)
            else:
                todo.extend(item.sequences())
                continue
        _seqInspectors[item].enter()
    if todo:
        if len(todo) > 1:
            from seqPanel import SeqPickerDialog
            from chimera import dialogs
            d = dialogs.display(SeqPickerDialog.name)
            d.molListBox.setvalue(todo)
        else:
            seqCmd(todo)
示例#33
0
	def _getParameters(self, mols, nogui, addhyd):
		timestamp("_getParameters")
		import DockPrep
		import chimera
		self.originalAtoms = set([])
		for m in mols:
			self.originalAtoms.update(m.atoms)
		from AddCharge import AMBER99SB
		kw = { "doneCB": self._finishDockPrep, "gaffType": True,
			"chargeModel": AMBER99SB }
		if nogui or chimera.nogui:
			if not addhyd:
				kw["addHFunc"] = None
			DockPrep.prep(mols, nogui=nogui, **kw)
		else:
			from DockPrep.gui import DockPrepDialog
			from chimera import dialogs
			d = dialogs.display(DockPrepDialog.name, wait=True)
			d.addHydVar.set(addhyd)
			d.applyKeywords = kw
			d.molListBox.setvalue(mols)
			d.writeMol2Var.set(False)
		"""
示例#34
0
def seqCmd(items):
	global _seqInspectors
	todo = []
	for item in items:
		if not _seqInspectors.has_key(item):
			from chimera.Sequence import StructureSequence
			if isinstance(item, StructureSequence):
				from MultAlignViewer.MAViewer import MAViewer
				copySeq = StructureSequence.__copy__(item)
				copySeq.name = item.fullName()
				_addSeqInspector(item, mavSeq=copySeq)
			else:
				todo.extend(item.sequences())
				continue
		_seqInspectors[item].enter()
	if todo:
		if len(todo) > 1:
			from seqPanel import SeqPickerDialog
			from chimera import dialogs
			d = dialogs.display(SeqPickerDialog.name)
			d.molListBox.setvalue(todo)
		else:
			seqCmd(todo)
示例#35
0
		def showTileDialog(models):
			from chimera import dialogs
			from EnsembleMatch.choose import TileStructuresCB
			dialogs.display(TileStructuresCB.name).configure(
								models=models)
示例#36
0
def show_memory_use_dialog():

    from chimera import dialogs
    return dialogs.display(Memory_Use_Dialog.name)
示例#37
0
def show_seg_mask_dialog():
    """show_seg_mask_dialog() - shows the Segment Mask dialog.
    """
    
    from chimera import dialogs
    return dialogs.display(Segment_Mask.name)
def show_crystal_contacts_dialog():

  from chimera import dialogs
  return dialogs.display(Crystal_Contacts_Dialog.name)
	def activate(self):
		from chimera.dialogs import display
		display(self.module('gui').WritePrmtopDialog.name)
		return None
示例#40
0
def show_fit_map_dialog():

    from chimera import dialogs
    return dialogs.display(Fit_Map_Dialog.name)
示例#41
0
def show_track_xform_dialog():
    """show_track_xform_dialog() - shows the Track Transform dialog.
    """
    
    from chimera import dialogs
    return dialogs.display(TrackXformDialog.name)
示例#42
0
 def activate(self):
     from chimera import dialogs
     gui = self.module('gui')
     dlg = dialogs.display(gui.BuildStructureDialog.name)
     dlg.notebook.selectpage(gui.ADD_ATOMS)
     return None
示例#43
0
    def Results(self):

        from chimera import dialogs, tkgui
        dialogs.display(tkgui._ReplyDialog.name)
def showDialog(models, mode):
	import ShowAttr
	from chimera import dialogs
	d = dialogs.display(ShowAttr.ShowAttrDialog.name)
	d.configure(models=models, mode=mode)
	def activate(self):
		from chimera import dialogs
		dialogs.display(self.module().ShowAttrDialog.name).configure(
								mode="Render")
		return None
示例#46
0
def show_unit_cell_dialog():

  from chimera import dialogs
  return dialogs.display(Unit_Cell_Dialog.name)
示例#47
0
def raiseViewingTab(tab):
	from chimera import dialogs, viewing
	d = dialogs.display(viewing.ViewerDialog.name)
	d.nb.raise_page('p' + tab)
	def activate(self):
		from chimera.dialogs import display
		display(self.module('gui').WriteMol2Dialog.name)
		return None
示例#49
0
def raiseStructMeasureTab(tab):
	from chimera import dialogs
	from StructMeasure.gui import StructMeasure
	d = dialogs.display(StructMeasure.name)
	d.notebook.selectpage(tab)
示例#50
0
	def showPreferences(self):
		from chimera import dialogs
		d = dialogs.display('preferences')
		d.menu.invoke(index = FETCH_PREFERENCES)
示例#51
0
	def activate(self):
		from chimera.dialogs import display
		display(self.module("gui").StructureDiagramDialog.name)
		return None
def show_morph_map_dialog():

    from chimera import dialogs
    return dialogs.display(Morph_Map_Dialog.name)
 def showPreferences(self):
     from chimera import dialogs
     d = dialogs.display('preferences')
     d.menu.invoke(index=FETCH_PREFERENCES)
 def activate(self):
     from chimera import dialogs
     dialogs.display(
         self.module().ShowAttrDialog.name).configure(mode="Render")
     return None
def show_benchmark_dialog():

    from chimera import dialogs
    return dialogs.display(Benchmark_Dialog.name)
def showDialog(models, mode):
    import ShowAttr
    from chimera import dialogs
    d = dialogs.display(ShowAttr.ShowAttrDialog.name)
    d.configure(models=models, mode=mode)