コード例 #1
0
ファイル: RmsdMap.py プロジェクト: davem22101/semanticscience
	def Apply(self):
		startFrame = self.startFrame.get()
		stride = self.stride.get()
		if (len(self.movie.ensemble) - (startFrame-1)) / stride > 1000:
			dlg = AskYesNoDialog("RMSD map will be %d pixels wide"
				" and tall. Okay?")
			if dlg.run(self.uiMaster()) == "no":
				self.enter()
				return
		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")
		prefs[RMSD_MIN] = self.minRmsd.get()
		prefs[RMSD_MAX] = self.maxRmsd.get()
		prefs[RMSD_AUTOCOLOR] = self.recolor.get()
		RmsdMapDialog(self.movie, startFrame, self.stride.get(),
			endFrame, self.useSel.get(), prefs[RMSD_MIN],
			prefs[RMSD_MAX], self.ignoreBulk.get(),
			self.ignoreHyds.get(), prefs[RMSD_AUTOCOLOR])
コード例 #2
0
ファイル: gui.py プロジェクト: davem22101/semanticscience
	def LoadStructure(self):
		sel = self.blastTable.selected()
		if not sel:
			sel = self.parser.matches
		sel = [ m for m in sel if m.pdb ]
		if len(sel) > 5:
			from chimera.baseDialog import AskYesNoDialog
			from chimera import tkgui
			d = AskYesNoDialog("This will load %d models."
					"  Proceed?" % len(sel),
					default="Yes")
			if d.run(self.uiMaster().winfo_toplevel()) != "yes":
				return
		mList = []
		for m in sel:
			if not m.pdb:
				continue
			parts = m.pdb.split('_')
			pdb = parts[0]
			mol = chimera.openModels.open(pdb, type="PDBID")[0]
			mList.append((m, mol))
		if self.reference is None:
			# Make the first model loaded the reference model
			# so others align to it.
			m, mol = mList[0]
			self._setReference(m, mol)
		for m, mol in mList:
			if mol is self.molecule:
				continue
			resList = self._getMatchResidues(m, mol)
			if resList:
				self._match(mol, m, resList)
コード例 #3
0
 def _readonlyCB(self, opt):
     prefFile = preferences.filename()
     if not prefFile:
         # If no file name, changes make no difference.
         return
     newState = opt.get()
     if ((newState and preferences.isReadonly())
             or (not newState and not preferences.isReadonly())):
         # No change in state
         return
     if newState:
         # Make readonly.  This is always okay.
         preferences.setReadonly(True)
     else:
         # Make not readonly.  See if the file is
         # writable.  If not, ask the user if he wants
         # to change permission.
         if not _canWrite(prefFile):
             from chimera.baseDialog import AskYesNoDialog
             d = AskYesNoDialog("File is not writable."
                                "  Try changing permissions?")
             answer = d.run(self._ui)
             if answer == "no":
                 opt.ui().set(1)
                 return
             try:
                 sbuf = os.stat(prefFile)
                 import stat
                 mode = sbuf.st_mode | stat.S_IWRITE
                 os.chmod(prefFile, mode)
             except os.error, s:
                 opt.ui().set(1)
                 raise chimera.UserError("cannot make %s "
                                         "writable: %s" % (prefFile, s))
         preferences.setReadonly(False)
コード例 #4
0
def runDemo(script, demo_name):
    global _currentDemo

    if _currentDemo:
        import tkMessageBox

        ## get some info about the demo user wants to open
        import ChimeraDemo
        try:
            d = ChimeraDemo.ChimeraDemo(script, demo_name)
        except DemoError:
            demo_title = ' '.join(demo_name.split("_"))
        else:
            demo_title = d.getTitle()
            del d

        if _currentDemo.demo.getSrcText() == script:
            dlg_msg = "You are already running the demo '%s'.\n\n "  \
                      "Would you like close this demo, and all "     \
                      "associated models, and start over?"           \
                      % _currentDemo.getTitle()
        else:
            dlg_msg = "You already have a demo in progress ('%s').\n\n" \
                      "Would you like to close this demo, and "         \
                      "all associated models, and open up the "         \
                      "'%s' demo?"                                      \
                      % ( _currentDemo.getTitle(), demo_title)

        dlg = AskYesNoDialog(dlg_msg,
                             title="Demo in progress",
                             help="ContributedSoftware/demos/demos.html")
        res = dlg.run(chimera.tkgui.app)
        #res = tkMessageBox.askquestion(master=chimera.tkgui.app,
        #                               title="Demo in progress",
        #                               message=dlg_msg
        #                               )
        if res == 'yes':
            ## a demo *is* currently running, and user wants to start
            ## this new demo...
            _currentDemo.Cancel()
            d = createDemoFromScript(script, title=demo_name)
            if d:
                _currentDemo = d
                return True
            else:
                return False
        elif res == 'no':
            ## a demo *is* currently running, and user doesn't want
            ## to start this new demo
            return False

    else:
        d = createDemoFromScript(script, title=demo_name)
        if d:
            ## no demo is currently running, start this new one...
            _currentDemo = d
            return True
        else:
            return False
コード例 #5
0
def runDemo(script, demo_name):
    global _currentDemo

    if _currentDemo:
        import tkMessageBox

        ## get some info about the demo user wants to open
        import ChimeraDemo
        try:
            d = ChimeraDemo.ChimeraDemo(script, demo_name)
        except DemoError:
            demo_title = ' '.join( demo_name.split("_"))
        else:
            demo_title = d.getTitle()
            del d
        
        if _currentDemo.demo.getSrcText() == script:
            dlg_msg = "You are already running the demo '%s'.\n\n "  \
                      "Would you like close this demo, and all "     \
                      "associated models, and start over?"           \
                      % _currentDemo.getTitle()
        else:
            dlg_msg = "You already have a demo in progress ('%s').\n\n" \
                      "Would you like to close this demo, and "         \
                      "all associated models, and open up the "         \
                      "'%s' demo?"                                      \
                      % ( _currentDemo.getTitle(), demo_title)

            
        dlg = AskYesNoDialog(dlg_msg, title="Demo in progress",
				help="ContributedSoftware/demos/demos.html")
        res = dlg.run(chimera.tkgui.app)
        #res = tkMessageBox.askquestion(master=chimera.tkgui.app,
        #                               title="Demo in progress",
        #                               message=dlg_msg
        #                               )
        if res == 'yes':
            ## a demo *is* currently running, and user wants to start
            ## this new demo...
            _currentDemo.Cancel()
            d = createDemoFromScript(script, title=demo_name)
            if d:
                _currentDemo = d
                return True
            else:
                return False
        elif res == 'no':
            ## a demo *is* currently running, and user doesn't want
            ## to start this new demo
            return False
            
    else:
        d = createDemoFromScript(script, title=demo_name)
        if d:
            ## no demo is currently running, start this new one...
            _currentDemo = d
            return True
        else:
            return False
コード例 #6
0
 def __init__(self):
     AskYesNoDialog.__init__(
         self,
         "Please include your email address so we can notify\n"
         "you when the bug is fixed or ask for additional\n"
         "information.  Otherwise, please describe what you\n"
         "where doing when the bug occurred.",
         justify='left')
コード例 #7
0
 def Save(self):
     from chimera.tkgui import GENERAL, CONFIRM_OVERWRITE
     from chimera.preferences import preferences
     if preferences.get(GENERAL, CONFIRM_OVERWRITE):
         for path in self.millerBrowser.getPaths():
             import os
             if (os.path.exists(path) and not os.path.isdir(path)):
                 dlg = AskYesNoDialog("Overwrite %s?" % path)
                 if dlg.run(self.uiMaster()) == "no":
                     self.enter()
                     return
     getattr(self, self.keepEquiv())()
コード例 #8
0
	def Save(self):
		from chimera.tkgui import GENERAL, CONFIRM_OVERWRITE
		from chimera.preferences import preferences
		if preferences.get(GENERAL, CONFIRM_OVERWRITE):
			for path in self.millerBrowser.getPaths():
				import os
				if (os.path.exists(path) and
				    not os.path.isdir(path)):
					dlg = AskYesNoDialog("Overwrite %s?"
									% path)
					if dlg.run(self.uiMaster()) == "no":
						self.enter()
						return
		getattr(self, self.keepEquiv())()
コード例 #9
0
 def Apply(self):
     selectedResidues = chimera.selection.currentResidues()
     if not selectedResidues:
         self.enter()
         raise UserError("No residues selected")
     if len(selectedResidues) > 10:
         from chimera.baseDialog import AskYesNoDialog
         numSel = len(selectedResidues)
         if AskYesNoDialog("You have %d residues selected which"
                           " could bring up %d rotamer dialogs.\n"
                           "Continue?" % (numSel, numSel)).run(
                               chimera.tkgui.app) == "no":
             self.enter()
             return
     resType = self.resType.get()
     lib = self.rotLib.get()
     from Rotamers import NoResidueRotamersError
     try:
         for sr in selectedResidues:
             RotamerDialog(sr, resType, lib)
     except NoResidueRotamersError:
         from SwapRes import swap
         for sr in selectedResidues:
             replyobj.info("Swapping %s to %s\n" % (sr, resType))
             swap(sr, resType, bfactor=None)
         replyobj.status("Swapped %d residue(s)\n" % len(selectedResidues))
コード例 #10
0
	def _readonlyCB(self, opt):
		prefFile = preferences.filename()
		if not prefFile:
			# If no file name, changes make no difference.
			return
		newState = opt.get()
		if ((newState and preferences.isReadonly())
		or (not newState and not preferences.isReadonly())):
			# No change in state
			return
		if newState:
			# Make readonly.  This is always okay.
			preferences.setReadonly(True)
		else:
			# Make not readonly.  See if the file is
			# writable.  If not, ask the user if he wants
			# to change permission.
			if not _canWrite(prefFile):
				from chimera.baseDialog import AskYesNoDialog
				d = AskYesNoDialog("File is not writable."
						"  Try changing permissions?")
				answer = d.run(self._ui)
				if answer == "no":
					opt.ui().set(1)
					return
				try:
					sbuf = os.stat(prefFile)
					import stat
					mode = sbuf.st_mode | stat.S_IWRITE
					os.chmod(prefFile, mode)
				except os.error, s:
					opt.ui().set(1)
					raise chimera.UserError(
							"cannot make %s "
							"writable: %s" %
							(prefFile, s))
			preferences.setReadonly(False)
コード例 #11
0
 def Apply(self):
     startFrame = self.startFrame.get()
     stride = self.stride.get()
     if (len(self.movie.ensemble) - (startFrame - 1)) / stride > 1000:
         dlg = AskYesNoDialog("RMSD map will be %d pixels wide"
                              " and tall. Okay?")
         if dlg.run(self.uiMaster()) == "no":
             self.enter()
             return
     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")
     prefs[RMSD_MIN] = self.minRmsd.get()
     prefs[RMSD_MAX] = self.maxRmsd.get()
     prefs[RMSD_AUTOCOLOR] = self.recolor.get()
     RmsdMapDialog(self.movie, startFrame, self.stride.get(), endFrame,
                   self.useSel.get(), prefs[RMSD_MIN], prefs[RMSD_MAX],
                   self.ignoreBulk.get(), self.ignoreHyds.get(),
                   prefs[RMSD_AUTOCOLOR])
コード例 #12
0
 def _surfaceCheck(self):
     if getattr(self, "_surfaceOkayed", False):
         return True
     mol = self.model.Molecule()
     assocSurfs = chimera.openModels.list(mol.id,
                                          mol.subid,
                                          modelTypes=[chimera.MSMSModel])
     if not assocSurfs:
         return True
     from chimera.baseDialog import AskYesNoDialog
     answer = AskYesNoDialog(
         "A surface model exists for this"
         " trajectory.\nThe surface will be recalculated for each frame"
         " which will slow playback significantly.\nYou may want to close"
         " the surface before playing the trajectory.\nContinue anyway?"
     ).run(self.uiMaster())
     self._surfaceOkayed = answer == "yes"
     return self._surfaceOkayed
コード例 #13
0
		def __init__(self):
		    AskYesNoDialog.__init__(self, 
			"Please include your email address so we can notify\n"
			"you when the bug is fixed or ask for additional\n"
			"information.  Otherwise, please describe what you\n"
			"where doing when the bug occurred.", justify='left')
コード例 #14
0
def writePrmtop(m, topfile, parmset, unchargedAtoms=None):
	import os
	import chimera
	from chimera import replyobj
	from WriteMol2 import writeMol2
	from tempfile import mkdtemp

	status = replyobj.status

	if unchargedAtoms and parmset.lower().endswith("ua"):
		# united atom
		replyobj.warning("Some uncharged/untyped protons expected due"
			" to use of united-atom force field.\n")
		unchargedHeavy = []
		skip = []
		for uncharged in unchargedAtoms.values():
			for uc in uncharged:
				if uc.element.number == 1:
					skip.append(uc)
				else:
					unchargedHeavy.append(uc)
		unchargedAtoms = unchargedHeavy
	else:
		skip = []
	if unchargedAtoms:
		if chimera.nogui:
			raise ValueError("Some atoms don't have charges/types")
		from chimera.baseDialog import AskYesNoDialog
		d = AskYesNoDialog("Some atoms don't have charges/types"
			" assigned.  Write prmtop anyway?")
		if d.run(chimera.tkgui.app) == "no":
			return
	tempDir = mkdtemp()

	def _clean():
		for fn in os.listdir(tempDir):
			os.unlink(os.path.join(tempDir, fn))
		os.rmdir(tempDir)

	sleapIn = os.path.join(tempDir, "sleap.in.mol2")
	writeMol2([m], sleapIn, status=status, gaffType=True, skip=skip)

	leaprc = os.path.join(tempDir, "solvate.cmd")
	writeLeaprc(tempDir, topfile, parmset, leaprc)

	chimeraRoot = os.environ["CHIMERA"]
        amberHome = os.path.join(chimeraRoot, "bin", "amber10")
        acHome = os.path.join(chimeraRoot, "bin", "antechamber")


	command = [os.path.join(amberHome, "exe", "sleap"), "-f", leaprc]

	
	print 'command: ', command
	if status:
		status("Running sleap" )
	from subprocess import Popen, STDOUT, PIPE
	# For some reason on Windows, if shell==False then antechamber
	# cannot run bondtype via system().
	import sys
	if sys.platform == "win32":
		shell = True
	else:
		shell = False
	replyobj.info("Running sleap command: %s\n" % " ".join(command))
	import os
	os.environ["AMBERHOME"]=amberHome
        os.environ["ACHOME"]=acHome
	sleapMessages = Popen(command, stdin=PIPE, stdout=PIPE, stderr=STDOUT,
			cwd=tempDir, shell=shell, bufsize=1).stdout
	while True:
		line = sleapMessages.readline()
		if not line:
			break
		replyobj.status("(writeprmtop) %s" % line, log=True)
	if not os.path.exists(topfile):
		_clean()
		from chimera import NonChimeraError
		raise NonChimeraError("Failure running sleap \n"
			"Check reply log for details\n")
	else:
		replyobj.status("Wrote parmtop file %s\n" % topfile, log=True)
コード例 #15
0
ファイル: Motion.py プロジェクト: davem22101/semanticscience
	def interpolate(self, m, xform, **kw):
		"""Interpolate to new conformation 'm'."""

		#
		# Get all the options
		#
		if kw.has_key("method"):
			self.method = kw["method"]
		if kw.has_key("rate"):
			self.rate = kw["rate"]
		if kw.has_key("frames"):
			self.frames = kw["frames"]
		if kw.has_key("cartesian"):
			self.cartesian = kw["cartesian"]
		if kw.has_key("minimize"):
			self.minimize = kw["minimize"]
		if kw.has_key("steps"):
			self.steps = kw["steps"]
		if self.minimize:
			self.callback = self.minimizeCallback
		else:
			self.callback = self.interpolateCallback

		#
		# Find matching set of residues.  First try for
		# one-to-one residue match, and, if that fails,
		# then finding a common set of residues.
		#
		import Segment
		sm = self.mol
		try:
			results = Segment.segmentHingeExact(sm, m)
		except ValueError:
			results = Segment.segmentHingeApproximate(sm, m)
		segments, atomMap, unusedResidues, unusedAtoms = results
		for r in unusedResidues:
			sm.deleteResidue(r)
		for a in unusedAtoms:
			sm.deleteAtom(a)
		if unusedResidues or unusedAtoms:
			from chimera import Sequence
			Sequence.invalidate(sm)
			if self.minimize:
				from chimera.baseDialog import AskYesNoDialog
				from chimera.tkgui import app
				d = AskYesNoDialog(
					"Cannot minimize with non-identical models.\n"
					"Continue without minimization?",
					default="Yes")
				if d.run(app) != "yes":
					raise ValueError("terminated at user request")
				self.minimize = False
				self.callback = self.interpolateCallback

		#
		# Interpolate between last conformation in trajectory
		# and new conformations
		#
		sm.activeCoordSet = sm.coordSets[max(sm.coordSets.keys())]
		from Interpolate import interpolate
		import chimera
		combinedXform = chimera.Xform(self.inverseXform)
		combinedXform.multiply(xform)
		interpolate(sm, combinedXform,
				segments, atomMap, self.method,
				self.rate, self.frames,
				self.cartesian, self.callback)
コード例 #16
0
    def interpolate(self, m, xform, **kw):
        """Interpolate to new conformation 'm'."""

        #
        # Get all the options
        #
        if kw.has_key("method"):
            self.method = kw["method"]
        if kw.has_key("rate"):
            self.rate = kw["rate"]
        if kw.has_key("frames"):
            self.frames = kw["frames"]
        if kw.has_key("cartesian"):
            self.cartesian = kw["cartesian"]
        if kw.has_key("minimize"):
            self.minimize = kw["minimize"]
        if kw.has_key("steps"):
            self.steps = kw["steps"]
        if self.minimize:
            self.callback = self.minimizeCallback
        else:
            self.callback = self.interpolateCallback

        #
        # Find matching set of residues.  First try for
        # one-to-one residue match, and, if that fails,
        # then finding a common set of residues.
        #
        import Segment
        sm = self.mol
        try:
            results = Segment.segmentHingeExact(sm, m)
        except ValueError:
            results = Segment.segmentHingeApproximate(sm, m)
        segments, atomMap, unusedResidues, unusedAtoms = results
        for r in unusedResidues:
            sm.deleteResidue(r)
        for a in unusedAtoms:
            sm.deleteAtom(a)
        if unusedResidues or unusedAtoms:
            from chimera import Sequence
            Sequence.invalidate(sm)
            if self.minimize:
                from chimera.baseDialog import AskYesNoDialog
                from chimera.tkgui import app
                d = AskYesNoDialog(
                    "Cannot minimize with non-identical models.\n"
                    "Continue without minimization?",
                    default="Yes")
                if d.run(app) != "yes":
                    raise ValueError("terminated at user request")
                self.minimize = False
                self.callback = self.interpolateCallback

        #
        # Interpolate between last conformation in trajectory
        # and new conformations
        #
        sm.activeCoordSet = sm.coordSets[max(sm.coordSets.keys())]
        from Interpolate import interpolate
        import chimera
        combinedXform = chimera.Xform(self.inverseXform)
        combinedXform.multiply(xform)
        interpolate(sm, combinedXform, segments, atomMap, self.method,
                    self.rate, self.frames, self.cartesian, self.callback)