def fillInUI(self, parent):
		import Pmw, Tkinter
		row = 0
		Tkinter.Label(parent, text="Create plane for selected atoms...").grid(
							row=row, columnspan=2)
		row += 1

		from chimera.tkoptions import StringOption, BooleanOption
		self.nameOpt = StringOption(parent, row, "Plane name", "plane", None)
		row += 1

		self.replaceExistingOpt = BooleanOption(parent, row,
										"Replace existing planes", False, None)
		row += 1

		from chimera.tkoptions import ColorOption, FloatOption
		self.colorOpt = ColorOption(parent, row, "Color", None, None,
			balloon="Plane color.  If No Color, then the plane"
			" will be colored to match the structure")
		row += 1

		self.autoRadiusOpt = BooleanOption(parent, row,
			"Set disk size to enclose atom projections", True, self._radCB)
		row += 1
		self.radRow = row
		self.radOffsetOpt = FloatOption(parent, row, "Extra radius"
			" (padding)", 0.0, None)
		self.radiusOpt = FloatOption(parent, row, "Fixed radius", 10.0, None)
		self.radiusOpt.forget()
		row += 1

		self.thicknessOpt = FloatOption(parent, row, "Disk thickness",
										prefs[PLANE_THICKNESS], None)
Esempio n. 2
0
	def fillInUI(self, parent):
		import Tkinter
		row = 0
		from VolumeViewer import Volume_Menu
		self.volumeMenu = Volume_Menu(parent, 'Volume data',
							open_button=True)
		self.volumeMenu.frame.grid(row=row, columnspan=2)
		row += 1

		from chimera.tkoptions import StringOption
		self.nameOption = StringOption(parent, row, 'Column name',
						'Density', None, width=10)
		row += 1
Esempio n. 3
0
class RenameDialog(ModelessDialog):
	buttons = ('OK', 'Cancel')
	default = 'OK'

	def __init__(self, geomUI, item):
		self.title = "Rename '%s'" % item.name
		self.geomUI = geomUI
		self.item = item
		ModelessDialog.__init__(self)

	def map(self, e=None):
		self.renameOpt._option.focus_set()

	def fillInUI(self, parent):
		from chimera.tkoptions import StringOption
		self.renameOpt = StringOption(parent, 0,
			"Rename %s to" % self.item.name, "", None)

	def Apply(self):
		newName = self.renameOpt.get().strip()
		if not newName:
			self.enter()
			from chimera import UserError
			raise UserError("Must supply a new item name or click Cancel")
		self.geomUI._renameItemCB(self.item, newName)

	def destroy(self):
		self.item = None
		self.geomUI = None
		ModelessDialog.destroy(self)
Esempio n. 4
0
	def fillInUI(self, parent):
		Tkinter.Label(parent, text="Collect positions of selected"
			" atoms over trajectory", relief="ridge", bd=4).grid(
			row=0, column=0, columnspan=2, sticky="ew")

		startFrame = self.movie.startFrame
		endFrame = self.movie.endFrame
		from chimera.tkoptions import IntOption, BooleanOption, \
						FloatOption, StringOption
		self.startFrame = IntOption(parent, 1, "Starting frame",
			startFrame, None, min=startFrame, max=endFrame, width=6)

		numFrames = endFrame - startFrame + 1
		defStride = 1 + int(numFrames/300)
		self.stride = IntOption(parent, 2, "Step size", defStride,
			None, min=1, max=numFrames, width=3)

		self.endFrame = IntOption(parent, 3, "Ending frame", endFrame,
			None, min=startFrame, max=endFrame, width=6)

		self.doCutoff = BooleanOption(parent, 4, 'Limit data collection'
			' to within cutoff distance of any "held steady" atoms',
			True, None)

		self.cutoff = FloatOption(parent, 5, "Cutoff distance",
				prefs[VOLUME_CUTOFF], None, width=4)
		self.resolution = FloatOption(parent, 6, "Volume grid spacing",
			prefs[VOLUME_RESOLUTION], None, min=0.0001, width=4)
		self.volumeName = StringOption(parent, 7, "Volume data name",
			self.movie.ensemble.name, None, width=20)
		self.byAtomType = BooleanOption(parent, 8, "Collect data"
			" separately for each atom type in selection",
			True, None, balloon="Create a volume data set for"
			" each type of atom type\n(sp2 oxygen, aromatic carbon,"
			" etc.) in current selection")
class RenameDialog(ModelessDialog):
	buttons = ('OK', 'Cancel')
	default = 'OK'

	def __init__(self, regionBrowser, region):
		self.title = "Rename '%s' Region" % regionName(region,
				regionBrowser.seqCanvas.mav.prefs)
		self.regionBrowser = regionBrowser
		self.region = region
		ModelessDialog.__init__(self)

	def map(self, e=None):
		self.renameOpt._option.focus_set()

	def fillInUI(self, parent):
		from chimera.tkoptions import StringOption
		self.renameOpt = StringOption(parent, 0, "Rename region to",
								"", None)
	def Apply(self):
		newName = self.renameOpt.get().strip()
		if not newName:
			self.enter()
			from chimera import UserError
			raise UserError("Must supply a new region name or "
							"click Cancel")
		self.regionBrowser.renameRegion(self.region, newName)

	def destroy(self):
		self.region = None
		self.regionBrowser = None
		ModelessDialog.destroy(self)
Esempio n. 6
0
	def fillInUI(self, parent):
		self.refMenu = Pmw.OptionMenu(parent, command=self._newRefCB,
			labelpos="nw", label_text="Reference structure:")
		self.refMenu.grid(row=0, column=0)
		self.alignList = Pmw.ScrolledListBox(parent, items=[],
					labelpos="nw", listbox_height=6,
					label_text="Structures to evaluate:",
					listbox_exportselection=0,
					listbox_selectmode='extended')
		self.alignList.grid(row=1, column=0, sticky="nsew")
		parent.rowconfigure(1, weight=1)
		parent.columnconfigure(0, weight=1)

		subFrame = Tkinter.Frame(parent)
		subFrame.grid(row=2, column=0)
		from chimera.tkoptions import StringOption
		self.attrNameOption = StringOption(subFrame, 2,
			"Create residue attribute named", "matchDist", None,
			balloon="Create a residue attribute"
			" measuring the CA/C4' distance between\nreference and"
			" evaluated structures.  The attribute will be shown\n"
			"in the select-by-attribute dialog after you hit OK.")

		Tkinter.Label(parent, text="The attribute-selection dialog will"
			" display when OK is chosen").grid(row=3, column=0)
		self.refresh(initial=1)
		self.assocHandlerID = self.mav.triggers.addHandler(MOD_ASSOC,
							self.refresh, None)
Esempio n. 7
0
class Projection(ModalDialog):
    buttons = ('Cancel', 'Apply')

    def __init__(self):
        self.name = None
        self.filename = None
        ModalDialog.__init__(self)

    def fillInUI(self, parent):
        from chimera.tkoptions import StringOption
        Tkinter.Label(parent, text='Data projection',
                        relief="ridge", bd=4).grid(row=0, column=0)
        self.name = StringOption(parent, 1, "Name for the projection", 'Projection', None)
        self.filename = Tkinter.Button(parent, text='Open data file',
                                        command=lambda: self.get_filename(parent)).grid(row=2, column=0)
        self.read_header = Tkinter.BooleanVar()
        self.check_header = Tkinter.Checkbutton(parent,
                                                text="Read header to define names for n-dim features",
                                                var=self.read_header).grid(row=3, column=0)

    def get_filename(self, parent):
        self.filename = askopenfilename()
        Tkinter.Label(parent, text='Filename: %s'%self.filename,
                            relief="ridge", bd=4).grid(row=2, column=1)

    def Apply(self):
        name = self.name.get()
        ModalDialog.Cancel(self, value=(name, self.filename, self.read_header.get()))

    def destroy(self):
        ModelessDialog.destroy(self)
Esempio n. 8
0
 def fillInUI(self, parent):
     from chimera.tkoptions import StringOption
     Tkinter.Label(parent, text='Data projection',
                     relief="ridge", bd=4).grid(row=0, column=0)
     self.name = StringOption(parent, 1, "Name for the projection", 'Projection', None)
     self.filename = Tkinter.Button(parent, text='Open data file',
                                     command=lambda: self.get_filename(parent)).grid(row=2, column=0)
     self.read_header = Tkinter.BooleanVar()
     self.check_header = Tkinter.Checkbutton(parent,
                                             text="Read header to define names for n-dim features",
                                             var=self.read_header).grid(row=3, column=0)
Esempio n. 9
0
    def fillInUI(self, parent):
        self.refMenu = Pmw.OptionMenu(parent,
                                      command=self._newRefCB,
                                      labelpos="nw",
                                      label_text="Reference structure:")
        self.refMenu.grid(row=0, column=0)
        self.alignList = Pmw.ScrolledListBox(
            parent,
            items=[],
            labelpos="nw",
            listbox_height=6,
            label_text="Structures to evaluate:",
            listbox_exportselection=0,
            listbox_selectmode='extended')
        self.alignList.grid(row=1, column=0, sticky="nsew")
        parent.rowconfigure(1, weight=1)
        parent.columnconfigure(0, weight=1)

        subFrame = Tkinter.Frame(parent)
        subFrame.grid(row=2, column=0)
        from chimera.tkoptions import StringOption
        self.attrNameOption = StringOption(
            subFrame,
            2,
            "Create residue attribute named",
            "matchDist",
            None,
            balloon="Create a residue attribute"
            " measuring the CA/C4' distance between\nreference and"
            " evaluated structures.  The attribute will be shown\n"
            "in the select-by-attribute dialog after you hit OK.")

        Tkinter.Label(parent,
                      text="The attribute-selection dialog will"
                      " display when OK is chosen").grid(row=3, column=0)
        self.refresh(initial=1)
        self.assocHandlerID = self.mav.triggers.addHandler(
            MOD_ASSOC, self.refresh, None)
Esempio n. 10
0
    def fillInUI(self, parent):
        OpenModeless.fillInUI(self, parent)

        group = Pmw.Group(self.clientArea, tag_text='Further info')
        group.grid(row=0, column=0, sticky='nsew')
        self.catName = StringOption(group.interior(), 0, "group name", None,
                                    None)

        class PBLineWidthOption(LineWidthOption):
            default = prefs["line width"]
            balloon = "Width of pseudobonds (in pixels)"

        self.lineWidth = PBLineWidthOption(group.interior(), 1, None, None,
                                           None)
        self.clearCat = BooleanOption(group.interior(), 2,
                                      "clear group of previous pseudobonds", 1,
                                      None)
        self.leftModel = IntOption(group.interior(), 3,
                                   "first column specifiers default to model",
                                   0, None)
        self.rightModel = IntOption(
            group.interior(), 4, "second column specifiers default to model",
            0, None)
Esempio n. 11
0
class PBreaderDialog(OpenModeless):
    title = "Pseudobond Reader"
    help = "ContributedSoftware/pbreader/pbreader.html"

    def __init__(self):
        OpenModeless.__init__(self,
                              title="Pseudobond File to Read",
                              historyID="PBReader open",
                              clientPos='s')

    def fillInUI(self, parent):
        OpenModeless.fillInUI(self, parent)

        group = Pmw.Group(self.clientArea, tag_text='Further info')
        group.grid(row=0, column=0, sticky='nsew')
        self.catName = StringOption(group.interior(), 0, "group name", None,
                                    None)

        class PBLineWidthOption(LineWidthOption):
            default = prefs["line width"]
            balloon = "Width of pseudobonds (in pixels)"

        self.lineWidth = PBLineWidthOption(group.interior(), 1, None, None,
                                           None)
        self.clearCat = BooleanOption(group.interior(), 2,
                                      "clear group of previous pseudobonds", 1,
                                      None)
        self.leftModel = IntOption(group.interior(), 3,
                                   "first column specifiers default to model",
                                   0, None)
        self.rightModel = IntOption(
            group.interior(), 4, "second column specifiers default to model",
            0, None)

    def Apply(self):
        if not self.getPaths():
            replyobj.error("No pseudobond file chosen\n")
        lineWidth = self.lineWidth.get()
        prefs["line width"] = lineWidth
        for path in self.getPaths():
            readPBinfo(path,
                       category=self.catName.get(),
                       clearCategory=self.clearCat.get(),
                       lineWidth=lineWidth,
                       drawMode=None,
                       leftModel=str(self.leftModel.get()),
                       rightModel=str(self.rightModel.get()),
                       defColor=None)
Esempio n. 12
0
	def fillInUI(self, parent):
		from chimera.widgets import MoleculeScrolledListBox
		self.molListBox = MoleculeScrolledListBox(parent,
			listbox_selectmode='extended', labelpos='w',
			label_text="Molecules to combine/copy:")
		if self.initModels:
			self.molListBox.setvalue(self.initModels)
		self.molListBox.grid(row=0, column=0, columnspan=2,
							sticky="nsew")
		parent.rowconfigure(0, weight=1)
		parent.columnconfigure(1, weight=1)
		from chimera.tkoptions import StringOption, IntOption
		self.molNameEntry = StringOption(parent, 1, "New model's"
						" name", "combination", None)

		curIDs = set([i1 for i1, i2 in openModels.listIds()])
		mid = 0
		while mid in curIDs:
			mid += 1
		self.modelID = IntOption(parent, 2, "New model's ID", mid, None)

		from chimera.widgets import MoleculeOptionMenu
		self.refMolMenu = MoleculeOptionMenu(parent, labelpos='w',
			label_text="Coordinate system of:",
			initialitem=self.initModels[0])
		self.refMolMenu.grid(row=3, column=0, columnspan=2, sticky='w')

		import Pmw
		chb = self.chainHandlingButtons = Pmw.RadioSelect(parent,
			buttontype="radiobutton", labelpos='w',
			label_text="If original molecules have duplicate\n"
			"single-letter chain IDs, then:", orient="vertical")
		self.buttonTexts = ["rename them uniquely",
				"retain them (residues may be renumbered)"]
		for bt in self.buttonTexts:
			chb.add(bt)
		chb.setvalue(self.buttonTexts[0])
		chb.grid(row=4, column=0, columnspan=2)

		import Tkinter
		self.closeModelsVar = Tkinter.IntVar(parent)
		self.closeModelsVar.set(False)
		Tkinter.Checkbutton(parent, text="Close source models",
					variable=self.closeModelsVar).grid(
					row=5, column=0, columnspan=2)
Esempio n. 13
0
	def fillInUI(self, parent):
		OpenModeless.fillInUI(self, parent)

		group = Pmw.Group(self.clientArea, tag_text='Further info')
		group.grid(row=0, column=0, sticky='nsew')
		self.catName = StringOption(group.interior(), 0,
			"group name", None, None)
		class PBLineWidthOption(LineWidthOption):
			default = prefs["line width"]
			balloon = "Width of pseudobonds (in pixels)"
		self.lineWidth = PBLineWidthOption(group.interior(), 1, None,
								None, None)
		self.clearCat = BooleanOption(group.interior(), 2,
			"clear group of previous pseudobonds", 1, None)
		self.leftModel = IntOption(group.interior(), 3,
			"first column specifiers default to model", 0, None)
		self.rightModel = IntOption(group.interior(), 4,
			"second column specifiers default to model", 0, None)
Esempio n. 14
0
class PBreaderDialog(OpenModeless):
	title = "Pseudobond Reader"
	help = "ContributedSoftware/pbreader/pbreader.html"

	def __init__(self):
		OpenModeless.__init__(self, title="Pseudobond File to Read",
				historyID="PBReader open", clientPos='s')

	def fillInUI(self, parent):
		OpenModeless.fillInUI(self, parent)

		group = Pmw.Group(self.clientArea, tag_text='Further info')
		group.grid(row=0, column=0, sticky='nsew')
		self.catName = StringOption(group.interior(), 0,
			"group name", None, None)
		class PBLineWidthOption(LineWidthOption):
			default = prefs["line width"]
			balloon = "Width of pseudobonds (in pixels)"
		self.lineWidth = PBLineWidthOption(group.interior(), 1, None,
								None, None)
		self.clearCat = BooleanOption(group.interior(), 2,
			"clear group of previous pseudobonds", 1, None)
		self.leftModel = IntOption(group.interior(), 3,
			"first column specifiers default to model", 0, None)
		self.rightModel = IntOption(group.interior(), 4,
			"second column specifiers default to model", 0, None)

	def Apply(self):
		if not self.getPaths():
			replyobj.error("No pseudobond file chosen\n")
		lineWidth = self.lineWidth.get()
		prefs["line width"] = lineWidth
		for path in self.getPaths():
			readPBinfo(path, category=self.catName.get(),
				clearCategory=self.clearCat.get(),
				lineWidth=lineWidth, drawMode=None,
				leftModel=str(self.leftModel.get()),
				rightModel=str(self.rightModel.get()),
				defColor=None)
Esempio n. 15
0
			class NewAnnotationDialog(ModelessDialog):
				title = "New Annotation"
				buttons = ('OK', 'Cancel')
				default = 'OK'
				help = "ContributedSoftware/multalignviewer/multalignviewer.html#anno-ali"

				def __init__(self, noteDialog):
					self.noteDialog = noteDialog
					ModelessDialog.__init__(self)

				def fillInUI(self, parent):
					from chimera.tkoptions \
							import StringOption
					self.noteOption = StringOption(parent,
						0, "New annotation name", "",
						None)

				def Apply(self):
					name = self.noteOption.get().strip()
					if not name:
						self.enter()
						from chimera import UserError
						raise UserError("No annotation"
							" name specified")
					self.noteDialog._addAttrWidgets(name,"")
					self.uiMaster().update_idletasks()
					top, bottom = self.noteDialog.attrFrame\
									.yview()
					if bottom < 1.0:
						newTop = top + 1.0 - bottom
						self.noteDialog.attrFrame.yview(
								mode='moveto',
								value=newTop)
					self.noteDialog.attrWidgets[name][1]\
									.focus()
				def destroy(self):
					self.noteDialog = None
					ModelessDialog.destroy(self)
Esempio n. 16
0
class VolumeDialog(ModelessDialog):
	title = "Volume Map Selection"
	buttons = ("OK", "Apply", "Close")
	help = "ContributedSoftware/rotamers/rotamers.html#density"

	def __init__(self, rotDialog):
		self.rotDialog = rotDialog
		ModelessDialog.__init__(self)

	def fillInUI(self, parent):
		import Tkinter
		row = 0
		from VolumeViewer import Volume_Menu
		self.volumeMenu = Volume_Menu(parent, 'Volume data',
							open_button=True)
		self.volumeMenu.frame.grid(row=row, columnspan=2)
		row += 1

		from chimera.tkoptions import StringOption
		self.nameOption = StringOption(parent, row, 'Column name',
						'Density', None, width=10)
		row += 1

	def Apply(self):
		from chimera import UserError
		dr = self.volumeMenu.data_region()
		if not dr:
			self.enter()
			raise UserError("No volume chosen")
		name = self.nameOption.get().strip()
		if not name:
			self.enter()
			raise UserError("Column name must not be blank")
		self.rotDialog.addVolumeColumn(name, dr)

	def destroy(self):
		self.rotDialog = None
		ModelessDialog.destroy(self)
            class NewAnnotationDialog(ModelessDialog):
                title = "New Annotation"
                buttons = ('OK', 'Cancel')
                default = 'OK'
                help = "ContributedSoftware/multalignviewer/multalignviewer.html#anno-ali"

                def __init__(self, noteDialog):
                    self.noteDialog = noteDialog
                    ModelessDialog.__init__(self)

                def fillInUI(self, parent):
                    from chimera.tkoptions \
                      import StringOption
                    self.noteOption = StringOption(parent, 0,
                                                   "New annotation name", "",
                                                   None)

                def Apply(self):
                    name = self.noteOption.get().strip()
                    if not name:
                        self.enter()
                        from chimera import UserError
                        raise UserError("No annotation" " name specified")
                    self.noteDialog._addAttrWidgets(name, "")
                    self.uiMaster().update_idletasks()
                    top, bottom = self.noteDialog.attrFrame\
                        .yview()
                    if bottom < 1.0:
                        newTop = top + 1.0 - bottom
                        self.noteDialog.attrFrame.yview(mode='moveto',
                                                        value=newTop)
                    self.noteDialog.attrWidgets[name][1]\
                        .focus()

                def destroy(self):
                    self.noteDialog = None
                    ModelessDialog.destroy(self)
class VolumeDialog(ModelessDialog):
    title = "Calculate Atomic Occupancy"
    help = "ContributedSoftware/movie/movie.html#occupancy"
    provideStatus = True
    statusPosition = "left"
    buttons = ('OK', 'Close')
    default = 'OK'

    def __init__(self, movie):
        self.movie = movie
        movie.subdialogs.append(self)
        ModelessDialog.__init__(self)

    def map(self, e=None):
        if not self.movie.holdingSteady:
            self.status("No atoms being held steady -- see Help", color="red")

    def fillInUI(self, parent):
        Tkinter.Label(parent,
                      text="Collect positions of selected"
                      " atoms over trajectory",
                      relief="ridge",
                      bd=4).grid(row=0, column=0, columnspan=2, sticky="ew")

        startFrame = self.movie.startFrame
        endFrame = self.movie.endFrame
        from chimera.tkoptions import IntOption, BooleanOption, \
            FloatOption, StringOption
        self.startFrame = IntOption(parent,
                                    1,
                                    "Starting frame",
                                    startFrame,
                                    None,
                                    min=startFrame,
                                    max=endFrame,
                                    width=6)

        numFrames = endFrame - startFrame + 1
        defStride = 1 + int(numFrames / 300)
        self.stride = IntOption(parent,
                                2,
                                "Step size",
                                defStride,
                                None,
                                min=1,
                                max=numFrames,
                                width=3)

        self.endFrame = IntOption(parent,
                                  3,
                                  "Ending frame",
                                  endFrame,
                                  None,
                                  min=startFrame,
                                  max=endFrame,
                                  width=6)

        self.doCutoff = BooleanOption(
            parent, 4, 'Limit data collection'
            ' to within cutoff distance of any "held steady" atoms', True,
            None)

        self.cutoff = FloatOption(parent,
                                  5,
                                  "Cutoff distance",
                                  prefs[VOLUME_CUTOFF],
                                  None,
                                  width=4)
        self.resolution = FloatOption(parent,
                                      6,
                                      "Volume grid spacing",
                                      prefs[VOLUME_RESOLUTION],
                                      None,
                                      min=0.0001,
                                      width=4)
        self.volumeName = StringOption(parent,
                                       7,
                                       "Volume data name",
                                       self.movie.ensemble.name,
                                       None,
                                       width=20)
        self.byAtomType = BooleanOption(
            parent,
            8, "Collect data"
            " separately for each atom type in selection",
            True,
            None,
            balloon="Create a volume data set for"
            " each type of atom type\n(sp2 oxygen, aromatic carbon,"
            " etc.) in current selection")

    def Apply(self):
        from chimera import UserError
        atoms = chimera.selection.currentAtoms()
        if not atoms:
            self.enter()
            raise UserError("No atoms selected")
        startFrame = self.startFrame.get()
        endFrame = self.endFrame.get()
        if endFrame <= startFrame:
            self.enter()
            raise UserError("Start frame must be less" " than end frame")
        if startFrame < self.movie.startFrame \
        or endFrame > self.movie.endFrame:
            self.enter()
            raise UserError("Start or end frame outside" " of trajectory")
        if self.doCutoff.get():
            bound = prefs[VOLUME_CUTOFF] = self.cutoff.get()
        else:
            bound = None
        prefs[VOLUME_RESOLUTION] = self.resolution.get()
        step = self.stride.get()
        spacing = self.resolution.get()
        name = self.volumeName.get()
        atomTypes = {}
        if self.byAtomType.get():
            for a in atoms:
                atomTypes.setdefault(a.idatmType, []).append(a)
        if len(atomTypes) > 1:
            for atomType, atAtoms in atomTypes.items():
                self.movie.computeVolume(atAtoms,
                                         startFrame=startFrame,
                                         endFrame=endFrame,
                                         step=step,
                                         bound=bound,
                                         spacing=spacing,
                                         volumeName=name + " [" + atomType +
                                         "]")
        else:
            self.movie.computeVolume(atoms,
                                     startFrame=startFrame,
                                     endFrame=endFrame,
                                     step=step,
                                     bound=bound,
                                     spacing=spacing,
                                     volumeName=name)
Esempio n. 19
0
				def fillInUI(self, parent):
					from chimera.tkoptions \
							import StringOption
					self.noteOption = StringOption(parent,
						0, "New annotation name", "",
						None)
    def fillInUI(self, parent):
        Tkinter.Label(parent,
                      text="Collect positions of selected"
                      " atoms over trajectory",
                      relief="ridge",
                      bd=4).grid(row=0, column=0, columnspan=2, sticky="ew")

        startFrame = self.movie.startFrame
        endFrame = self.movie.endFrame
        from chimera.tkoptions import IntOption, BooleanOption, \
            FloatOption, StringOption
        self.startFrame = IntOption(parent,
                                    1,
                                    "Starting frame",
                                    startFrame,
                                    None,
                                    min=startFrame,
                                    max=endFrame,
                                    width=6)

        numFrames = endFrame - startFrame + 1
        defStride = 1 + int(numFrames / 300)
        self.stride = IntOption(parent,
                                2,
                                "Step size",
                                defStride,
                                None,
                                min=1,
                                max=numFrames,
                                width=3)

        self.endFrame = IntOption(parent,
                                  3,
                                  "Ending frame",
                                  endFrame,
                                  None,
                                  min=startFrame,
                                  max=endFrame,
                                  width=6)

        self.doCutoff = BooleanOption(
            parent, 4, 'Limit data collection'
            ' to within cutoff distance of any "held steady" atoms', True,
            None)

        self.cutoff = FloatOption(parent,
                                  5,
                                  "Cutoff distance",
                                  prefs[VOLUME_CUTOFF],
                                  None,
                                  width=4)
        self.resolution = FloatOption(parent,
                                      6,
                                      "Volume grid spacing",
                                      prefs[VOLUME_RESOLUTION],
                                      None,
                                      min=0.0001,
                                      width=4)
        self.volumeName = StringOption(parent,
                                       7,
                                       "Volume data name",
                                       self.movie.ensemble.name,
                                       None,
                                       width=20)
        self.byAtomType = BooleanOption(
            parent,
            8, "Collect data"
            " separately for each atom type in selection",
            True,
            None,
            balloon="Create a volume data set for"
            " each type of atom type\n(sp2 oxygen, aromatic carbon,"
            " etc.) in current selection")
Esempio n. 21
0
class VolumeDialog(ModelessDialog):
	title = "Calculate Atomic Occupancy"
	help = "ContributedSoftware/movie/movie.html#occupancy"
	provideStatus = True
	statusPosition = "left"
	buttons = ('OK', 'Close')
	default= 'OK'

	def __init__(self, movie):
		self.movie = movie
		movie.subdialogs.append(self)
		ModelessDialog.__init__(self)

	def map(self, e=None):
		if not self.movie.holdingSteady:
			self.status("No atoms being held steady -- see Help",
							color="red")
	def fillInUI(self, parent):
		Tkinter.Label(parent, text="Collect positions of selected"
			" atoms over trajectory", relief="ridge", bd=4).grid(
			row=0, column=0, columnspan=2, sticky="ew")

		startFrame = self.movie.startFrame
		endFrame = self.movie.endFrame
		from chimera.tkoptions import IntOption, BooleanOption, \
						FloatOption, StringOption
		self.startFrame = IntOption(parent, 1, "Starting frame",
			startFrame, None, min=startFrame, max=endFrame, width=6)

		numFrames = endFrame - startFrame + 1
		defStride = 1 + int(numFrames/300)
		self.stride = IntOption(parent, 2, "Step size", defStride,
			None, min=1, max=numFrames, width=3)

		self.endFrame = IntOption(parent, 3, "Ending frame", endFrame,
			None, min=startFrame, max=endFrame, width=6)

		self.doCutoff = BooleanOption(parent, 4, 'Limit data collection'
			' to within cutoff distance of any "held steady" atoms',
			True, None)

		self.cutoff = FloatOption(parent, 5, "Cutoff distance",
				prefs[VOLUME_CUTOFF], None, width=4)
		self.resolution = FloatOption(parent, 6, "Volume grid spacing",
			prefs[VOLUME_RESOLUTION], None, min=0.0001, width=4)
		self.volumeName = StringOption(parent, 7, "Volume data name",
			self.movie.ensemble.name, None, width=20)
		self.byAtomType = BooleanOption(parent, 8, "Collect data"
			" separately for each atom type in selection",
			True, None, balloon="Create a volume data set for"
			" each type of atom type\n(sp2 oxygen, aromatic carbon,"
			" etc.) in current selection")

	def Apply(self):
		from chimera import UserError
		atoms = chimera.selection.currentAtoms()
		if not atoms:
			self.enter()
			raise UserError("No atoms selected")
		startFrame = self.startFrame.get()
		endFrame = self.endFrame.get()
		if endFrame <= startFrame:
			self.enter()
			raise UserError("Start frame must be less"
							" than end frame")
		if startFrame < self.movie.startFrame \
		or endFrame > self.movie.endFrame:
			self.enter()
			raise UserError("Start or end frame outside"
							" of trajectory")
		if self.doCutoff.get():
			bound = prefs[VOLUME_CUTOFF] = self.cutoff.get()
		else:
			bound = None
		prefs[VOLUME_RESOLUTION] = self.resolution.get()
		step = self.stride.get()
		spacing = self.resolution.get()
		name = self.volumeName.get()
		atomTypes = {}
		if self.byAtomType.get():
			for a in atoms:
				atomTypes.setdefault(a.idatmType, []).append(a)
		if len(atomTypes) > 1:
			for atomType, atAtoms in atomTypes.items():
				self.movie.computeVolume(atAtoms,
					startFrame=startFrame,
					endFrame=endFrame, step=step,
					bound=bound, spacing=spacing,
					volumeName=name+" ["+atomType+"]")
		else:
			self.movie.computeVolume(atoms, startFrame=startFrame,
				endFrame=endFrame, step=step, bound=bound,
				spacing=spacing, volumeName=name)
Esempio n. 22
0
class AssessDialog(ModelessDialog):
    """Dialog to allow the user to show regions that are matched
	   closely or that are poorly matched
	"""

    buttons = ("OK", "Close")
    default = "OK"
    help = "ContributedSoftware/multalignviewer/multalignviewer.html" \
          "#assessment"

    def __init__(self, mav, *args, **kw):
        self.mav = mav
        self.title = "Show Match Quality for %s" % mav.title
        ModelessDialog.__init__(self, *args, **kw)

    def fillInUI(self, parent):
        self.refMenu = Pmw.OptionMenu(parent,
                                      command=self._newRefCB,
                                      labelpos="nw",
                                      label_text="Reference structure:")
        self.refMenu.grid(row=0, column=0)
        self.alignList = Pmw.ScrolledListBox(
            parent,
            items=[],
            labelpos="nw",
            listbox_height=6,
            label_text="Structures to evaluate:",
            listbox_exportselection=0,
            listbox_selectmode='extended')
        self.alignList.grid(row=1, column=0, sticky="nsew")
        parent.rowconfigure(1, weight=1)
        parent.columnconfigure(0, weight=1)

        subFrame = Tkinter.Frame(parent)
        subFrame.grid(row=2, column=0)
        from chimera.tkoptions import StringOption
        self.attrNameOption = StringOption(
            subFrame,
            2,
            "Create residue attribute named",
            "matchDist",
            None,
            balloon="Create a residue attribute"
            " measuring the CA/C4' distance between\nreference and"
            " evaluated structures.  The attribute will be shown\n"
            "in the select-by-attribute dialog after you hit OK.")

        Tkinter.Label(parent,
                      text="The attribute-selection dialog will"
                      " display when OK is chosen").grid(row=3, column=0)
        self.refresh(initial=1)
        self.assocHandlerID = self.mav.triggers.addHandler(
            MOD_ASSOC, self.refresh, None)

    def destroy(self):
        self.mav.triggers.deleteHandler(MOD_ASSOC, self.assocHandlerID)
        self.mav = None
        ModelessDialog.destroy(self)

    def refresh(self, trig1=None, trig2=None, trig3=None, initial=0):
        self.matchMaps = {}
        self.mols = {}
        sortableNames = []
        for aseq in self.mav.seqs:
            if not hasattr(aseq, 'matchMaps'):
                continue
            for mol, matchMap in aseq.matchMaps.items():
                name = "%s (%s), %s" % (mol.name, mol.oslIdent(),
                                        matchMap['mseq'].name)
                sortableNames.append((mol.oslIdent(), name))
                self.matchMaps[name] = matchMap
                self.mols[name] = mol
        if len(sortableNames) < 2:
            self.mav._disableAssessDialog()
            return

        sortableNames.sort(oslModelCmp)
        self.names = []
        for osl, name in sortableNames:
            self.names.append(name)

        if initial:
            self.refMenu.setitems(self.names)
            self._newRefCB(self.names[0])
        else:
            refsel = self.refMenu.getvalue()
            if refsel in self.names:
                selItem = refsel
            else:
                selItem = self.names[0]
            self.refMenu.setitems(self.names, index=selItem)
            self._newRefCB(selItem)

    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")

    def _newRefCB(self, ref):
        self.alignList.setlist([n for n in self.names if n != ref])
        lb = self.alignList.component("listbox")
        lb.selection_set(0, 'end')
Esempio n. 23
0
class RecorderDialog(SaveModeless):
    title = "Record Animation of Trajectory"
    help = "ContributedSoftware/movie/movie.html#recording"
    default = "Record"

    def __init__(self, movie):
        self.movie = movie
        movie.subdialogs.append(self)
        from MovieRecorder import RecorderGUI
        formats = []
        exts = []
        for fmtInfo in RecorderGUI.formats:
            fmt, ext = fmtInfo[:2]
            formats.append(fmt)
            exts.append("." + ext)
        filters = []
        for i, fmt in enumerate(formats):
            ext = exts[i]
            filters.append((fmt, '*' + ext, ext))
        SaveModeless.__init__(self,
                              clientPos='s',
                              clientSticky='ew',
                              defaultFilter=prefs[RECORDER_FORMAT],
                              filters=filters,
                              historyID="MD recorder")

    def map(self, e=None):
        from MovieRecorder import checkLicense
        if not checkLicense():
            self.Close()

    def fillInUI(self, parent):
        SaveModeless.fillInUI(self, parent)
        self.clientArea.columnconfigure(1, weight=1)

        startFrame = self.movie.startFrame
        endFrame = self.movie.endFrame
        from chimera.tkoptions import IntOption, BooleanOption, \
            FloatOption, StringOption
        self.startFrame = IntOption(self.clientArea,
                                    0,
                                    "Starting frame",
                                    startFrame,
                                    None,
                                    min=startFrame,
                                    max=endFrame,
                                    width=6)

        numFrames = endFrame - startFrame + 1
        defStride = 1 + int(numFrames / 300)
        self.stride = IntOption(self.clientArea,
                                2,
                                "Step size",
                                defStride,
                                None,
                                min=1,
                                max=numFrames,
                                width=3)

        self.endFrame = IntOption(self.clientArea,
                                  3,
                                  "Ending frame",
                                  endFrame,
                                  None,
                                  min=startFrame,
                                  max=endFrame,
                                  width=6)

        self.roundtrip = BooleanOption(
            self.clientArea,
            4, "Encode"
            ' forward then backward ("roundtrip")',
            prefs[RECORDER_ROUNDTRIP],
            None,
            balloon="Encode the frames in forward and then reverse\n"
            "order so that if the movie is played as a loop\n"
            "the motion seems continuous")

        class FrameQuality(BooleanOption):
            labels = ["screen", "supersampled"]

        self.supersample = FrameQuality(
            self.clientArea,
            5,
            "Frame quality",
            prefs[RECORDER_SUPERSAMPLE],
            self.supersampleCB,
            balloon="Whether each frame should be taken as is from\n"
            "the screen (fast) or redrawn at higher quality\n"
            "with several samples per pixel.")

        from chimera.printer import SupersampleOption
        self.samples = SupersampleOption(self.clientArea, 6, "Samples",
                                         prefs[RECORDER_SAMPLES], None)
        self.supersampleCB()

        self.raytrace = BooleanOption(self.clientArea, 7, "Raytrace"
                                      " with POV-Ray",
                                      prefs[RECORDER_RAYTRACE], None)

        def povOptCB():
            from chimera.dialogs import display
            d = display("preferences")
            from chimera.printer import POVRAY_SETUP
            d.setCategoryMenu(POVRAY_SETUP)

        Tkinter.Button(self.clientArea,
                       text="POV-Ray Options",
                       pady=0,
                       command=povOptCB).grid(row=8, column=0, columnspan=2)

        self.recordArgs = StringOption(
            self.clientArea,
            9,
            "Additional recording options",
            prefs[RECORDER_RECORD_ARGS],
            None,
            balloon="Options (other than 'supersample' and 'raytrace')\n"
            "for recording frames as per Chimera's 'movie record'"
            " command")

        self.encodeArgs = StringOption(
            self.clientArea,
            10,
            "Additional encoding options",
            prefs[RECORDER_ENCODE_ARGS],
            None,
            balloon="Options (other than 'mformat', 'output', and\n"
            "'roundtrip') for composing the frames into the\n"
            "final animation as per Chimera's 'movie encode'\n"
            "command")

        Tkinter.Label(self.clientArea,
                      text="On some computers it may be necessary to make sure"
                      " that no\nwindows occlude the main Chimera graphics"
                      " window (even\npartially) during non-raytraced movie"
                      " recording").grid(row=11, column=0, columnspan=2)

    def Apply(self):
        from chimera import UserError
        startFrame = self.startFrame.get()
        endFrame = self.endFrame.get()
        if endFrame <= startFrame:
            self.enter()
            raise UserError("Start frame must be less" " than end frame")
        if startFrame < self.movie.startFrame \
        or endFrame > self.movie.endFrame:
            self.enter()
            raise UserError("Start or end frame outside" " of trajectory")
        path, format = self.getPathsAndTypes()[0]
        prefs[RECORDER_FORMAT] = format
        recordArgs = self.recordArgs.get()
        prefs[RECORDER_RECORD_ARGS] = recordArgs
        encodeArgs = self.encodeArgs.get()
        prefs[RECORDER_ENCODE_ARGS] = encodeArgs
        roundtrip = self.roundtrip.get()
        prefs[RECORDER_ROUNDTRIP] = roundtrip
        supersample = self.supersample.get()
        prefs[RECORDER_SUPERSAMPLE] = supersample
        if supersample:
            samples = self.samples.get()
            prefs[RECORDER_SAMPLES] = samples
            recordArgs = " ".join([recordArgs, "supersample", str(samples)])
        raytrace = self.raytrace.get()
        prefs[RECORDER_RAYTRACE] = raytrace
        from MovieRecorder import RecorderGUI
        for ext, fmtInfo in RecorderGUI.command_formats.items():
            if fmtInfo[0] == format:
                break
        recordArgs = " ".join([recordArgs, "raytrace", str(raytrace)])
        reprPath = repr(path)
        if reprPath[0] == 'u':
            # strip unicode indicator
            reprPath = reprPath[1:]
        encodeArgs = " ".join([
            encodeArgs, "roundtrip",
            str(roundtrip), "mformat", ext, "output", reprPath
        ])
        self.movie.recordAnimation(startFrame=startFrame,
                                   endFrame=endFrame,
                                   step=self.stride.get(),
                                   recordArgs=recordArgs,
                                   encodeArgs=encodeArgs)

    Record = SaveModeless.Save

    def supersampleCB(self, *args):
        if self.supersample.get():
            self.samples.enable()
        else:
            self.samples.disable()
Esempio n. 24
0
	def fillInUI(self, parent):
		from chimera.tkoptions import StringOption
		self.renameOpt = StringOption(parent, 0, "Rename region to",
								"", None)
Esempio n. 25
0
	def fillInUI(self, parent):
		from chimera.tkoptions import StringOption
		self.renameOpt = StringOption(parent, 0,
			"Rename %s to" % self.item.name, "", None)
class CreatePlaneDialog(ModelessDialog):
	title = "Define Plane"
	help = "ContributedSoftware/structuremeas/structuremeas.html#define-plane"
	provideStatus = True
	statusPosition = "above"

	def fillInUI(self, parent):
		import Pmw, Tkinter
		row = 0
		Tkinter.Label(parent, text="Create plane for selected atoms...").grid(
							row=row, columnspan=2)
		row += 1

		from chimera.tkoptions import StringOption, BooleanOption
		self.nameOpt = StringOption(parent, row, "Plane name", "plane", None)
		row += 1

		self.replaceExistingOpt = BooleanOption(parent, row,
										"Replace existing planes", False, None)
		row += 1

		from chimera.tkoptions import ColorOption, FloatOption
		self.colorOpt = ColorOption(parent, row, "Color", None, None,
			balloon="Plane color.  If No Color, then the plane"
			" will be colored to match the structure")
		row += 1

		self.autoRadiusOpt = BooleanOption(parent, row,
			"Set disk size to enclose atom projections", True, self._radCB)
		row += 1
		self.radRow = row
		self.radOffsetOpt = FloatOption(parent, row, "Extra radius"
			" (padding)", 0.0, None)
		self.radiusOpt = FloatOption(parent, row, "Fixed radius", 10.0, None)
		self.radiusOpt.forget()
		row += 1

		self.thicknessOpt = FloatOption(parent, row, "Disk thickness",
										prefs[PLANE_THICKNESS], None)

	def Apply(self):
		from chimera import UserError
		if self.replaceExistingOpt.get():
			planeManager.removePlanes(planeManager.planes)
		kw = {
			'color': self.colorOpt.get(),
			'thickness': self.thicknessOpt.get()
		}
		prefs[PLANE_THICKNESS] = kw['thickness']
		if self.autoRadiusOpt.get():
			kw['radiusOffset'] = self.radOffsetOpt.get()
		else:
			kw['radius'] = self.radiusOpt.get()

		replyobj.info("Creating plane\n")
		selAtoms = selection.currentAtoms()
		if len(selAtoms) < 3:
			self.enter()
			raise UserError("Need to select at least three"
					" atoms to define a plane")
		planeManager.createPlane(self.nameOpt.get().strip(), selAtoms, **kw)

	def _radCB(self, opt):
		if opt.get():
			self.radiusOpt.forget()
			self.radOffsetOpt.manage()
		else:
			self.radOffsetOpt.forget()
			self.radiusOpt.manage()
Esempio n. 27
0
	def fillInUI(self, parent):
		SaveModeless.fillInUI(self, parent)
		self.clientArea.columnconfigure(1, weight=1)

		startFrame = self.movie.startFrame
		endFrame = self.movie.endFrame
		from chimera.tkoptions import IntOption, BooleanOption, \
						FloatOption, StringOption
		self.startFrame = IntOption(self.clientArea, 0,
					"Starting frame", startFrame, None,
					min=startFrame, max=endFrame, width=6)

		numFrames = endFrame - startFrame + 1
		defStride = 1 + int(numFrames/300)
		self.stride = IntOption(self.clientArea, 2, "Step size",
			defStride, None, min=1, max=numFrames, width=3)

		self.endFrame = IntOption(self.clientArea, 3, "Ending frame",
			endFrame, None, min=startFrame, max=endFrame, width=6)

		self.roundtrip = BooleanOption(self.clientArea, 4, "Encode"
			' forward then backward ("roundtrip")', prefs[
			RECORDER_ROUNDTRIP], None, balloon=
			"Encode the frames in forward and then reverse\n"
			"order so that if the movie is played as a loop\n"
			"the motion seems continuous")

		class FrameQuality(BooleanOption):
			labels = ["screen", "supersampled"]
		self.supersample = FrameQuality(self.clientArea, 5,
			"Frame quality", prefs[RECORDER_SUPERSAMPLE],
			self.supersampleCB, balloon=
			"Whether each frame should be taken as is from\n"
			"the screen (fast) or redrawn at higher quality\n"
			"with several samples per pixel.")

		from chimera.printer import SupersampleOption
		self.samples = SupersampleOption(self.clientArea, 6,
			"Samples", prefs[RECORDER_SAMPLES], None)
		self.supersampleCB()

		self.raytrace = BooleanOption(self.clientArea, 7, "Raytrace"
			" with POV-Ray", prefs[RECORDER_RAYTRACE], None)
			
		def povOptCB():
			from chimera.dialogs import display
			d = display("preferences")
			from chimera.printer import POVRAY_SETUP
			d.setCategoryMenu(POVRAY_SETUP)
		Tkinter.Button(self.clientArea, text="POV-Ray Options", pady=0,
			command=povOptCB).grid(row=8, column=0, columnspan=2)
			
		self.recordArgs = StringOption(self.clientArea, 9,
			"Additional recording options",
			prefs[RECORDER_RECORD_ARGS], None, balloon=
			"Options (other than 'supersample' and 'raytrace')\n"
			"for recording frames as per Chimera's 'movie record'"
			" command")

		self.encodeArgs = StringOption(self.clientArea, 10,
			"Additional encoding options",
			prefs[RECORDER_ENCODE_ARGS], None, balloon=
			"Options (other than 'mformat', 'output', and\n"
			"'roundtrip') for composing the frames into the\n"
			"final animation as per Chimera's 'movie encode'\n"
			"command")
		
		Tkinter.Label(self.clientArea, text=
			"On some computers it may be necessary to make sure"
			" that no\nwindows occlude the main Chimera graphics"
			" window (even\npartially) during non-raytraced movie"
			" recording").grid(row=11, column=0, columnspan=2)
Esempio n. 28
0
class RecorderDialog(SaveModeless):
	title = "Record Animation of Trajectory"
	help = "ContributedSoftware/movie/movie.html#recording"
	default = "Record"

	def __init__(self, movie):
		self.movie = movie
		movie.subdialogs.append(self)
		from MovieRecorder import RecorderGUI
		formats = []
		exts = []
		for fmtInfo in RecorderGUI.formats:
			fmt, ext = fmtInfo[:2]
			formats.append(fmt)
			exts.append("." + ext)
		filters = []
		for i, fmt in enumerate(formats):
			ext = exts[i]
			filters.append((fmt, '*'+ext, ext))
		SaveModeless.__init__(self, clientPos='s', clientSticky='ew',
				defaultFilter=prefs[RECORDER_FORMAT],
				filters=filters, historyID="MD recorder")
	def map(self, e=None):
		from MovieRecorder import checkLicense
		if not checkLicense():
			self.Close()

	def fillInUI(self, parent):
		SaveModeless.fillInUI(self, parent)
		self.clientArea.columnconfigure(1, weight=1)

		startFrame = self.movie.startFrame
		endFrame = self.movie.endFrame
		from chimera.tkoptions import IntOption, BooleanOption, \
						FloatOption, StringOption
		self.startFrame = IntOption(self.clientArea, 0,
					"Starting frame", startFrame, None,
					min=startFrame, max=endFrame, width=6)

		numFrames = endFrame - startFrame + 1
		defStride = 1 + int(numFrames/300)
		self.stride = IntOption(self.clientArea, 2, "Step size",
			defStride, None, min=1, max=numFrames, width=3)

		self.endFrame = IntOption(self.clientArea, 3, "Ending frame",
			endFrame, None, min=startFrame, max=endFrame, width=6)

		self.roundtrip = BooleanOption(self.clientArea, 4, "Encode"
			' forward then backward ("roundtrip")', prefs[
			RECORDER_ROUNDTRIP], None, balloon=
			"Encode the frames in forward and then reverse\n"
			"order so that if the movie is played as a loop\n"
			"the motion seems continuous")

		class FrameQuality(BooleanOption):
			labels = ["screen", "supersampled"]
		self.supersample = FrameQuality(self.clientArea, 5,
			"Frame quality", prefs[RECORDER_SUPERSAMPLE],
			self.supersampleCB, balloon=
			"Whether each frame should be taken as is from\n"
			"the screen (fast) or redrawn at higher quality\n"
			"with several samples per pixel.")

		from chimera.printer import SupersampleOption
		self.samples = SupersampleOption(self.clientArea, 6,
			"Samples", prefs[RECORDER_SAMPLES], None)
		self.supersampleCB()

		self.raytrace = BooleanOption(self.clientArea, 7, "Raytrace"
			" with POV-Ray", prefs[RECORDER_RAYTRACE], None)
			
		def povOptCB():
			from chimera.dialogs import display
			d = display("preferences")
			from chimera.printer import POVRAY_SETUP
			d.setCategoryMenu(POVRAY_SETUP)
		Tkinter.Button(self.clientArea, text="POV-Ray Options", pady=0,
			command=povOptCB).grid(row=8, column=0, columnspan=2)
			
		self.recordArgs = StringOption(self.clientArea, 9,
			"Additional recording options",
			prefs[RECORDER_RECORD_ARGS], None, balloon=
			"Options (other than 'supersample' and 'raytrace')\n"
			"for recording frames as per Chimera's 'movie record'"
			" command")

		self.encodeArgs = StringOption(self.clientArea, 10,
			"Additional encoding options",
			prefs[RECORDER_ENCODE_ARGS], None, balloon=
			"Options (other than 'mformat', 'output', and\n"
			"'roundtrip') for composing the frames into the\n"
			"final animation as per Chimera's 'movie encode'\n"
			"command")
		
		Tkinter.Label(self.clientArea, text=
			"On some computers it may be necessary to make sure"
			" that no\nwindows occlude the main Chimera graphics"
			" window (even\npartially) during non-raytraced movie"
			" recording").grid(row=11, column=0, columnspan=2)

	def Apply(self):
		from chimera import UserError
		startFrame = self.startFrame.get()
		endFrame = self.endFrame.get()
		if endFrame <= startFrame:
			self.enter()
			raise UserError("Start frame must be less"
							" than end frame")
		if startFrame < self.movie.startFrame \
		or endFrame > self.movie.endFrame:
			self.enter()
			raise UserError("Start or end frame outside"
							" of trajectory")
		path, format = self.getPathsAndTypes()[0]
		prefs[RECORDER_FORMAT] = format
		recordArgs = self.recordArgs.get()
		prefs[RECORDER_RECORD_ARGS] = recordArgs
		encodeArgs = self.encodeArgs.get()
		prefs[RECORDER_ENCODE_ARGS] = encodeArgs
		roundtrip = self.roundtrip.get()
		prefs[RECORDER_ROUNDTRIP] = roundtrip
		supersample = self.supersample.get()
		prefs[RECORDER_SUPERSAMPLE] = supersample
		if supersample:
			samples = self.samples.get()
			prefs[RECORDER_SAMPLES] = samples
			recordArgs = " ".join([recordArgs,
						"supersample", str(samples)])
		raytrace = self.raytrace.get()
		prefs[RECORDER_RAYTRACE] = raytrace
		from MovieRecorder import RecorderGUI
		for ext, fmtInfo in RecorderGUI.command_formats.items():
			if fmtInfo[0] == format:
				break
		recordArgs = " ".join([recordArgs, "raytrace", str(raytrace)])
		reprPath = repr(path)
		if reprPath[0] == 'u':
			# strip unicode indicator
			reprPath = reprPath[1:]
		encodeArgs = " ".join([encodeArgs, "roundtrip", str(roundtrip),
				"mformat", ext, "output", reprPath])
		self.movie.recordAnimation(startFrame=startFrame,
				endFrame=endFrame, step=self.stride.get(),
				recordArgs=recordArgs, encodeArgs=encodeArgs)

	Record = SaveModeless.Save

	def supersampleCB(self, *args):
		if self.supersample.get():
			self.samples.enable()
		else:
			self.samples.disable()
Esempio n. 29
0
class AssessDialog(ModelessDialog):
	"""Dialog to allow the user to show regions that are matched
	   closely or that are poorly matched
	"""

	buttons = ("OK", "Close")
	default = "OK"
	help = "ContributedSoftware/multalignviewer/multalignviewer.html" \
							"#assessment"

	def __init__(self, mav, *args, **kw):
		self.mav = mav
		self.title = "Show Match Quality for %s" % mav.title
		ModelessDialog.__init__(self, *args, **kw)

	def fillInUI(self, parent):
		self.refMenu = Pmw.OptionMenu(parent, command=self._newRefCB,
			labelpos="nw", label_text="Reference structure:")
		self.refMenu.grid(row=0, column=0)
		self.alignList = Pmw.ScrolledListBox(parent, items=[],
					labelpos="nw", listbox_height=6,
					label_text="Structures to evaluate:",
					listbox_exportselection=0,
					listbox_selectmode='extended')
		self.alignList.grid(row=1, column=0, sticky="nsew")
		parent.rowconfigure(1, weight=1)
		parent.columnconfigure(0, weight=1)

		subFrame = Tkinter.Frame(parent)
		subFrame.grid(row=2, column=0)
		from chimera.tkoptions import StringOption
		self.attrNameOption = StringOption(subFrame, 2,
			"Create residue attribute named", "matchDist", None,
			balloon="Create a residue attribute"
			" measuring the CA/C4' distance between\nreference and"
			" evaluated structures.  The attribute will be shown\n"
			"in the select-by-attribute dialog after you hit OK.")

		Tkinter.Label(parent, text="The attribute-selection dialog will"
			" display when OK is chosen").grid(row=3, column=0)
		self.refresh(initial=1)
		self.assocHandlerID = self.mav.triggers.addHandler(MOD_ASSOC,
							self.refresh, None)
	def destroy(self):
		self.mav.triggers.deleteHandler(MOD_ASSOC, self.assocHandlerID)
		self.mav = None
		ModelessDialog.destroy(self)

	def refresh(self, trig1=None, trig2=None, trig3=None, initial=0):
		self.matchMaps = {}
		self.mols = {}
		sortableNames = []
		for aseq in self.mav.seqs:
			if not hasattr(aseq, 'matchMaps'):
				continue
			for mol, matchMap in aseq.matchMaps.items():
				name = "%s (%s), %s" % (mol.name,
					mol.oslIdent(), matchMap['mseq'].name)
				sortableNames.append((mol.oslIdent(), name))
				self.matchMaps[name] = matchMap
				self.mols[name] = mol
		if len(sortableNames) < 2:
			self.mav._disableAssessDialog()
			return

		sortableNames.sort(oslModelCmp)
		self.names = []
		for osl, name in sortableNames:
			self.names.append(name)

		if initial:
			self.refMenu.setitems(self.names)
			self._newRefCB(self.names[0])
		else:
			refsel = self.refMenu.getvalue()
			if refsel in self.names:
				selItem = refsel
			else:
				selItem = self.names[0]
			self.refMenu.setitems(self.names, index=selItem)
			self._newRefCB(selItem)

	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")

	def _newRefCB(self, ref):
		self.alignList.setlist([n for n in self.names if n != ref])
		lb = self.alignList.component("listbox")
		lb.selection_set(0, 'end')
Esempio n. 30
0
    def fillInUI(self, parent):
        SaveModeless.fillInUI(self, parent)
        self.clientArea.columnconfigure(1, weight=1)

        startFrame = self.movie.startFrame
        endFrame = self.movie.endFrame
        from chimera.tkoptions import IntOption, BooleanOption, \
            FloatOption, StringOption
        self.startFrame = IntOption(self.clientArea,
                                    0,
                                    "Starting frame",
                                    startFrame,
                                    None,
                                    min=startFrame,
                                    max=endFrame,
                                    width=6)

        numFrames = endFrame - startFrame + 1
        defStride = 1 + int(numFrames / 300)
        self.stride = IntOption(self.clientArea,
                                2,
                                "Step size",
                                defStride,
                                None,
                                min=1,
                                max=numFrames,
                                width=3)

        self.endFrame = IntOption(self.clientArea,
                                  3,
                                  "Ending frame",
                                  endFrame,
                                  None,
                                  min=startFrame,
                                  max=endFrame,
                                  width=6)

        self.roundtrip = BooleanOption(
            self.clientArea,
            4, "Encode"
            ' forward then backward ("roundtrip")',
            prefs[RECORDER_ROUNDTRIP],
            None,
            balloon="Encode the frames in forward and then reverse\n"
            "order so that if the movie is played as a loop\n"
            "the motion seems continuous")

        class FrameQuality(BooleanOption):
            labels = ["screen", "supersampled"]

        self.supersample = FrameQuality(
            self.clientArea,
            5,
            "Frame quality",
            prefs[RECORDER_SUPERSAMPLE],
            self.supersampleCB,
            balloon="Whether each frame should be taken as is from\n"
            "the screen (fast) or redrawn at higher quality\n"
            "with several samples per pixel.")

        from chimera.printer import SupersampleOption
        self.samples = SupersampleOption(self.clientArea, 6, "Samples",
                                         prefs[RECORDER_SAMPLES], None)
        self.supersampleCB()

        self.raytrace = BooleanOption(self.clientArea, 7, "Raytrace"
                                      " with POV-Ray",
                                      prefs[RECORDER_RAYTRACE], None)

        def povOptCB():
            from chimera.dialogs import display
            d = display("preferences")
            from chimera.printer import POVRAY_SETUP
            d.setCategoryMenu(POVRAY_SETUP)

        Tkinter.Button(self.clientArea,
                       text="POV-Ray Options",
                       pady=0,
                       command=povOptCB).grid(row=8, column=0, columnspan=2)

        self.recordArgs = StringOption(
            self.clientArea,
            9,
            "Additional recording options",
            prefs[RECORDER_RECORD_ARGS],
            None,
            balloon="Options (other than 'supersample' and 'raytrace')\n"
            "for recording frames as per Chimera's 'movie record'"
            " command")

        self.encodeArgs = StringOption(
            self.clientArea,
            10,
            "Additional encoding options",
            prefs[RECORDER_ENCODE_ARGS],
            None,
            balloon="Options (other than 'mformat', 'output', and\n"
            "'roundtrip') for composing the frames into the\n"
            "final animation as per Chimera's 'movie encode'\n"
            "command")

        Tkinter.Label(self.clientArea,
                      text="On some computers it may be necessary to make sure"
                      " that no\nwindows occlude the main Chimera graphics"
                      " window (even\npartially) during non-raytraced movie"
                      " recording").grid(row=11, column=0, columnspan=2)
 def fillInUI(self, parent):
     from chimera.tkoptions \
       import StringOption
     self.noteOption = StringOption(parent, 0,
                                    "New annotation name", "",
                                    None)