Пример #1
0
    def __init__(self, parent):
        from Trajectory.prefs import prefs, INPUT_FILES
        inputPrefs = prefs[INPUT_FILES].setdefault('Gromacs', {})
        self.topologyOption = InputFileOption(parent,
                                              1,
                                              "Run input (.tpr)",
                                              inputPrefs.get('Topology', True),
                                              None,
                                              filters=[("Topology", ["*.tpr"])
                                                       ],
                                              title="Choose .tpr File",
                                              entryWidth=20,
                                              historyID="GromacsTop")

        self.trajectoryOption = InputFileOption(
            parent,
            2,
            "Trajectory (.trr)",
            inputPrefs.get('Trajectory', True),
            None,
            entryWidth=20,
            title="Choose Trajectory File",
            filters=[("Portable trajectory", ["*.trr"])],
            defaultFilter=0,
            historyID="GromacsTrajectory")
        parent.columnconfigure(1, weight=1)
Пример #2
0
	def __init__(self, parent):
		from Trajectory.prefs import prefs, INPUT_FILES, PDB_STYLE
		inputPrefs = prefs[INPUT_FILES].setdefault(formatName, {})
		class PdbStyleOption(EnumOption):
			values = ["single file", "multiple files"]
		self.style = PdbStyleOption(parent, 0,
				"PDB frames contained in", prefs[PDB_STYLE],
				self._styleChangeCB)
		self.options = {}
		globs = []
		for ext in chimera.fileInfo.extensions("PDB"):
			globs.append("*" + ext)
		filters = [("PDB", globs)]
		self.singleFrame = Tkinter.Frame(parent)
		self.singleFrame.columnconfigure(1, weight=1)
		self.options[self.single] = InputFileOption(self.singleFrame,
			0, self.single, inputPrefs.get(self.single, True), None,
			filters=filters, title="Choose Multi-model PDB File",
			defaultFilter="PDB", historyID="PDB traj multi-model")
		self.multiFrame = Tkinter.Frame(parent)
		self.multiFrame.columnconfigure(1, weight=1)
		self.options[self.multiStart] = InputFileOption(
			self.multiFrame, 0, self.multiStart,
			inputPrefs.get(self.multiStart, True), None,
			title="Choose First PDB File", defaultFilter="PDB",
			filters=filters, historyID="PDB traj multi start")
		self.options[self.multiEnd] = InputFileOption(self.multiFrame,
			1, self.multiEnd, inputPrefs.get(self.multiEnd, True),
			None, title="Choose Last PDB File", defaultFilter="PDB",
			filters=filters, historyID="PDB traj multi end")
		parent.columnconfigure(1, weight=1)
		self._styleChangeCB(self.style)
Пример #3
0
	def fillInUI(self, parent):
		from chimera.widgets import MoleculeOptionMenu
		from chimera.tkoptions import IntOption, BooleanOption, \
				InputFileOption, StringOption, EnumOption
		import itertools
		info = Tk.Label(parent, justify=Tk.LEFT, wraplength=300, text=
				"Model alternate conformations of loops using "
				"Modeller from <http://salilab.org/>.\n"
				"First select the loops you wish to model."
				"  Then choose the number of models "
				"you wish to generate.")
		info.pack(ipadx=2, ipady=2)
		options = Tk.Frame(parent)
		options.columnconfigure(0, pad=2)
		options.columnconfigure(1, pad=2)
		row = itertools.count()
		molRow = row.next()
		text = Tk.Label(options,
				text="Restrict selections to molecule:")
		text.grid(row=molRow, column=0)
		self.molecules = MoleculeOptionMenu(options)
		self.molecules.grid(row=molRow, column=1, sticky=Tk.W)
		self.turnsOnly = BooleanOption(options, row.next(),
				"Restrict selections to turns", True, None)
		self.hetatms = BooleanOption(options, row.next(),
				"Include HETATM residues", False, None)
		self.waters = BooleanOption(options, row.next(),
				"Include waters", False, None)
		self.waters.disable()
		self.nucleic = BooleanOption(options, row.next(),
				"Include nucleic acids", False, None)
		self.nucleic.disable()
		self.count = IntOption(options, row.next(), "Number of models",
				10, None, min=1, sticky=Tk.W)
		#self.start = IntOption(options, row.next(),
		#		"Starting model number", 1, None, min=0)
		class Refinement(EnumOption):
			values = ('very fast', 'fast', 'slow', 'very slow',
				'slow large', 'none')
		self.refine = Refinement(options, row.next(), "Refinement",
								'fast', None)
		button = Tk.Button(options, text="Prune selection",
				command=self.prune)
		button.grid(row=row.next(), column=0, columnspan=2, pady=2)
		self.start = 1
		hr = Tk.Frame(options, relief=Tk.GROOVE, borderwidth=1, height=2)
		hr.grid(row=row.next(), columnspan=2, sticky='ew')
		# modeller location
		self.modeller = InputFileOption(options, row.next(),
				"Modeller location", "mod9v2", None)
		# temporary prefix -- TODO: add unique id
		#self.tempdir = StringOption(options, row.next(),
		#		"Temporary file prefix", "modtmp", None)
		options.pack()
 def __init__(self, parent):
     from Trajectory.prefs import prefs, INPUT_FILES, GROMOS_SCALING
     inputPrefs = prefs[INPUT_FILES].setdefault('Gromos', {})
     self.options = []
     for i in range(len(self.labels)):
         label = self.labels[i]
         self.options.append(
             InputFileOption(parent,
                             i,
                             label,
                             inputPrefs.get(label, True),
                             None,
                             title="Choose %s File" % label,
                             historyID="Gromos %s" % label))
     self.scalingOption = FloatOption(
         parent,
         len(self.labels),
         "Angstrom conversion",
         prefs[GROMOS_SCALING],
         None,
         balloon="scale factor to convert trajectory\n"
         "coordinates to angstroms",
         width=4,
         sticky='w')
     parent.columnconfigure(1, weight=1)
Пример #5
0
 def __init__(self, parent):
     from Trajectory.prefs import prefs, INPUT_FILES
     inputPrefs = prefs[INPUT_FILES].setdefault(self.formatName, {})
     self.options = []
     for i in range(len(self.labels)):
         label = self.labels[i]
         self.options.append(
             InputFileOption(parent,
                             i,
                             label,
                             inputPrefs.get(label, True),
                             None,
                             title="Choose %s File" % label,
                             historyID="%s %s" % (self.formatName, label)))
     parent.columnconfigure(1, weight=1)
     f = Tkinter.Frame(parent)
     f.grid(row=len(self.labels), column=0, columnspan=2)
     Tkinter.Label(f, text="PSF/DCD support courtesy of").grid(row=0,
                                                               column=0,
                                                               sticky='e')
     from chimera import help
     Tkinter.Button(f,
                    text="MDTools",
                    padx=0,
                    pady=0,
                    command=lambda: help.display(
                        "http://www.ks.uiuc.edu/~jim/mdtools/")).grid(
                            row=0, column=1, sticky='w')
Пример #6
0
class ParamGUI:
    def __init__(self, parent):
        from Trajectory.prefs import prefs, INPUT_FILES
        inputPrefs = prefs[INPUT_FILES].setdefault('Gromacs', {})
        self.topologyOption = InputFileOption(parent,
                                              1,
                                              "Run input (.tpr)",
                                              inputPrefs.get('Topology', True),
                                              None,
                                              filters=[("Topology", ["*.tpr"])
                                                       ],
                                              title="Choose .tpr File",
                                              entryWidth=20,
                                              historyID="GromacsTop")

        self.trajectoryOption = InputFileOption(
            parent,
            2,
            "Trajectory (.trr)",
            inputPrefs.get('Trajectory', True),
            None,
            entryWidth=20,
            title="Choose Trajectory File",
            filters=[("Portable trajectory", ["*.trr"])],
            defaultFilter=0,
            historyID="GromacsTrajectory")
        parent.columnconfigure(1, weight=1)

    def loadEnsemble(self, startFrame, endFrame, callback):
        topology = self.topologyOption.get()
        trajectory = self.trajectoryOption.get()
        if not os.path.exists(topology):
            raise ValueError("Topology file does not exist!")
        if not os.path.exists(trajectory):
            raise ValueError("Trajectory file does not exist!")
        from Trajectory.prefs import prefs, INPUT_FILES
        # need to change a _copy_ of the dictionary, otherwise
        # when we try to save the "original" dictionary will also
        # have our changes and no save will occur
        from copy import deepcopy
        inputPrefs = deepcopy(prefs[INPUT_FILES])
        inputPrefs['Gromacs']['Topology'] = topology
        inputPrefs['Gromacs']['Trajectory'] = trajectory
        prefs[INPUT_FILES] = inputPrefs

        loadEnsemble((topology, trajectory), startFrame, endFrame, callback)
Пример #7
0
	def __init__(self, parent):
		from Trajectory.prefs import prefs, INPUT_FILES
		inputPrefs = prefs[INPUT_FILES].setdefault('Gromacs', {})
		self.topologyOption = InputFileOption(parent, 1,
				"Run input (.tpr)",
				inputPrefs.get('Topology', True),
				None, filters=[("Topology", ["*.tpr"])],
				title="Choose .tpr File",
				entryWidth=20, historyID="GromacsTop")
		
		self.trajectoryOption = InputFileOption(parent, 2,
			"Trajectory (.trr)",
			inputPrefs.get('Trajectory', True), None,
			entryWidth=20, title="Choose Trajectory File",
			filters=[("Portable trajectory", ["*.trr"])],
			defaultFilter=0, historyID="GromacsTrajectory")
		parent.columnconfigure(1, weight=1)
	def __init__(self, parent):
		from Trajectory.prefs import prefs, INPUT_FILES
		inputPrefs = prefs[INPUT_FILES].setdefault('Amber', {})
		self.prmtopOption = InputFileOption(parent, 0, "Prmtop",
				inputPrefs.get('Prmtop', True),
				None, filters=[("Prmtop", ["*.top"])],
				title="Choose Prmtop File",
				entryWidth=20, historyID="AmberPrmtop")
		
		defaultTrajs = inputPrefs.get('Trajectories', None)
		if defaultTrajs is None and 'Trajectory' in inputPrefs:
			defaultTrajs = [inputPrefs['Trajectory']]
		from Amber import Amber
		self.trajectoriesOption = OrderedFileListOption(parent, 1,
						"Trajectory", defaultTrajs,
						None, addKw=Amber.AddTrajKw)
		parent.columnconfigure(1, weight=1)
		parent.rowconfigure(1, weight=1)
Пример #9
0
	def __init__(self, parent):
		from Trajectory.prefs import prefs, INPUT_FILES
		inputPrefs = prefs[INPUT_FILES].setdefault(formatName, {})
		self.options = {}
		globs = []
		for ext in chimera.fileInfo.extensions("XYZ"):
			globs.append("*" + ext)
		filters = [("XYZ", globs)]
		self.multiFrame = Tkinter.Frame(parent)
		self.multiFrame.columnconfigure(1, weight=1)
		self.options[self.multiStart] = InputFileOption(
			self.multiFrame, 0, self.multiStart,
			inputPrefs.get(self.multiStart, True), None,
			title="Choose First XYZ File", defaultFilter="XYZ",
			filters=filters, historyID="XYZ traj multi start")
		self.options[self.multiEnd] = InputFileOption(self.multiFrame,
			1, self.multiEnd, inputPrefs.get(self.multiEnd, True),
			None, title="Choose Last XYZ File", defaultFilter="XYZ",
			filters=filters, historyID="XYZ traj multi end")
		parent.columnconfigure(1, weight=1)
		self.multiFrame.grid(row=1, columnspan=2, sticky="ew")
Пример #10
0
class ParamGUI:
	def __init__(self, parent):
		from Trajectory.prefs import prefs, INPUT_FILES
		inputPrefs = prefs[INPUT_FILES].setdefault('Gromacs', {})
		self.topologyOption = InputFileOption(parent, 1,
				"Run input (.tpr)",
				inputPrefs.get('Topology', True),
				None, filters=[("Topology", ["*.tpr"])],
				title="Choose .tpr File",
				entryWidth=20, historyID="GromacsTop")
		
		self.trajectoryOption = InputFileOption(parent, 2,
			"Trajectory (.trr)",
			inputPrefs.get('Trajectory', True), None,
			entryWidth=20, title="Choose Trajectory File",
			filters=[("Portable trajectory", ["*.trr"])],
			defaultFilter=0, historyID="GromacsTrajectory")
		parent.columnconfigure(1, weight=1)

	def loadEnsemble(self, startFrame, endFrame, callback):
		topology = self.topologyOption.get()
		trajectory = self.trajectoryOption.get()
		if not os.path.exists(topology):
			raise ValueError("Topology file does not exist!")
		if not os.path.exists(trajectory):
			raise ValueError("Trajectory file does not exist!")
		from Trajectory.prefs import prefs, INPUT_FILES
		# need to change a _copy_ of the dictionary, otherwise
		# when we try to save the "original" dictionary will also
		# have our changes and no save will occur
		from copy import deepcopy
		inputPrefs = deepcopy(prefs[INPUT_FILES])
		inputPrefs['Gromacs']['Topology'] = topology
		inputPrefs['Gromacs']['Trajectory'] = trajectory
		prefs[INPUT_FILES] = inputPrefs

		loadEnsemble((topology, trajectory),
						startFrame, endFrame, callback)
Пример #11
0
 def __init__(self, parent):
     from Trajectory.prefs import prefs, INPUT_FILES
     inputPrefs = prefs[INPUT_FILES].setdefault('MMTK', {})
     self.options = []
     for i in range(len(self.labels)):
         label = self.labels[i]
         self.options.append(
             InputFileOption(parent,
                             i,
                             label,
                             inputPrefs.get(label, True),
                             None,
                             title="Choose %s File" % label,
                             historyID="MMTK %s" % label))
     parent.columnconfigure(1, weight=1)
class ParamGUI:
	def __init__(self, parent):
		from Trajectory.prefs import prefs, INPUT_FILES
		inputPrefs = prefs[INPUT_FILES].setdefault('Amber', {})
		self.prmtopOption = InputFileOption(parent, 0, "Prmtop",
				inputPrefs.get('Prmtop', True),
				None, filters=[("Prmtop", ["*.top"])],
				title="Choose Prmtop File",
				entryWidth=20, historyID="AmberPrmtop")
		
		defaultTrajs = inputPrefs.get('Trajectories', None)
		if defaultTrajs is None and 'Trajectory' in inputPrefs:
			defaultTrajs = [inputPrefs['Trajectory']]
		from Amber import Amber
		self.trajectoriesOption = OrderedFileListOption(parent, 1,
						"Trajectory", defaultTrajs,
						None, addKw=Amber.AddTrajKw)
		parent.columnconfigure(1, weight=1)
		parent.rowconfigure(1, weight=1)

	def loadEnsemble(self, startFrame, endFrame, callback):
		prmtop = self.prmtopOption.get()
		trajectories = self.trajectoriesOption.get()
		from chimera import UserError
		if not os.path.exists(prmtop):
			raise UserError("Parmtop file does not exist!")
		if not trajectories:
			raise UserError("No trajectory files specified")
		for traj in trajectories:
			if not os.path.exists(traj):
				raise UserError("Trajectory coordinate file"
					" (%s) does not exist!" % traj)
		from Trajectory.prefs import prefs, INPUT_FILES
		# need to change a _copy_ of the dictionary, otherwise
		# when we try to save the "original" dictionary will also
		# have our changes and no save will occur
		from copy import deepcopy
		inputPrefs = deepcopy(prefs[INPUT_FILES])
		inputPrefs['Amber']['Prmtop'] = prmtop
		inputPrefs['Amber']['Trajectories'] = trajectories
		prefs[INPUT_FILES] = inputPrefs

		loadEnsemble([prmtop] + trajectories, startFrame, endFrame,
								callback)
 def __init__(self, parent):
     from Trajectory.prefs import prefs, INPUT_FILES
     inputPrefs = prefs[INPUT_FILES].setdefault(formatName, {})
     self.options = []
     globs = ["*.ptrj"]
     for ext in chimera.fileInfo.extensions("NetCDF generic array"):
         globs.append("*" + ext)
     filters = [("Particle trajectory", globs)]
     for i, label in enumerate(self.labels):
         self.options.append(
             InputFileOption(parent,
                             i,
                             label,
                             inputPrefs.get(label, True),
                             None,
                             title="Choose %s File" % label,
                             filters=filters,
                             historyID="Particle %s" % label))
     parent.columnconfigure(1, weight=1)
 def fillInUI(self, parent):
     from chimera.widgets import MoleculeOptionMenu
     from chimera.tkoptions import IntOption, BooleanOption, \
       InputFileOption, StringOption
     import itertools
     info = Tk.Label(parent,
                     justify=Tk.LEFT,
                     wraplength=300,
                     text="Select a molecule with gaps")
     info.pack(ipadx=2, ipady=2)
     options = Tk.Frame(parent)
     options.columnconfigure(0, pad=2)
     options.columnconfigure(1, pad=2)
     row = itertools.count()
     molRow = row.next()
     text = Tk.Label(options, text="Restrict selections to molecule:")
     text.grid(row=molRow, column=0)
     self.molecules = MoleculeOptionMenu(options,
                                         command=self.updateMolecule)
     self.molecules.grid(row=molRow, column=1, sticky=Tk.W)
     self.turnsOnly = BooleanOption(options, row.next(),
                                    "Skip gaps at ends of chains", False,
                                    None)
     self.hetatms = BooleanOption(options, row.next(),
                                  "Include HETATM residues", False, None)
     #self.waters = BooleanOption(options, row.next(),
     #		"Include waters", False, None)
     self.nucleic = BooleanOption(options, row.next(),
                                  "Include nucleic acids", False, None)
     self.nucleic.disable()
     hr = Tk.Frame(options, relief=Tk.GROOVE, borderwidth=1, height=2)
     hr.grid(row=row.next(), columnspan=2, sticky='ew')
     # modeller location
     self.modeller = InputFileOption(options, row.next(),
                                     "Modeller location", "mod8v2", None)
     # temporary prefix -- TODO: add unique id
     #self.tempdir = StringOption(options, row.next(),
     #		"Temporary file prefix", "modtmp", None)
     options.pack()
Пример #15
0
class Interface(ModelessDialog):

	title = "Model Loops with Modeller"
	buttons = ("OK", "Cancel")
	help = "ContributedSoftware/model/model.html"

	def __init__(self, *args, **kw):
		ModelessDialog.__init__(self, *args, **kw)
		# TODO: initialize instance variables

	def fillInUI(self, parent):
		from chimera.widgets import MoleculeOptionMenu
		from chimera.tkoptions import IntOption, BooleanOption, \
				InputFileOption, StringOption, EnumOption
		import itertools
		info = Tk.Label(parent, justify=Tk.LEFT, wraplength=300, text=
				"Model alternate conformations of loops using "
				"Modeller from <http://salilab.org/>.\n"
				"First select the loops you wish to model."
				"  Then choose the number of models "
				"you wish to generate.")
		info.pack(ipadx=2, ipady=2)
		options = Tk.Frame(parent)
		options.columnconfigure(0, pad=2)
		options.columnconfigure(1, pad=2)
		row = itertools.count()
		molRow = row.next()
		text = Tk.Label(options,
				text="Restrict selections to molecule:")
		text.grid(row=molRow, column=0)
		self.molecules = MoleculeOptionMenu(options)
		self.molecules.grid(row=molRow, column=1, sticky=Tk.W)
		self.turnsOnly = BooleanOption(options, row.next(),
				"Restrict selections to turns", True, None)
		self.hetatms = BooleanOption(options, row.next(),
				"Include HETATM residues", False, None)
		self.waters = BooleanOption(options, row.next(),
				"Include waters", False, None)
		self.waters.disable()
		self.nucleic = BooleanOption(options, row.next(),
				"Include nucleic acids", False, None)
		self.nucleic.disable()
		self.count = IntOption(options, row.next(), "Number of models",
				10, None, min=1, sticky=Tk.W)
		#self.start = IntOption(options, row.next(),
		#		"Starting model number", 1, None, min=0)
		class Refinement(EnumOption):
			values = ('very fast', 'fast', 'slow', 'very slow',
				'slow large', 'none')
		self.refine = Refinement(options, row.next(), "Refinement",
								'fast', None)
		button = Tk.Button(options, text="Prune selection",
				command=self.prune)
		button.grid(row=row.next(), column=0, columnspan=2, pady=2)
		self.start = 1
		hr = Tk.Frame(options, relief=Tk.GROOVE, borderwidth=1, height=2)
		hr.grid(row=row.next(), columnspan=2, sticky='ew')
		# modeller location
		self.modeller = InputFileOption(options, row.next(),
				"Modeller location", "mod9v2", None)
		# temporary prefix -- TODO: add unique id
		#self.tempdir = StringOption(options, row.next(),
		#		"Temporary file prefix", "modtmp", None)
		options.pack()

	def prune(self):
		from chimera import selection
		molecule = self.molecules.getvalue()
		import ModUtil
		pairs, residues = ModUtil.convertSelection(
				selection._currentSelection,
				minLen=4, molecule=molecule,
				keepHet=self.hetatms.get(),
				keepNA=self.nucleic.get(),
				turnsOnly=self.turnsOnly.get())
		sel = selection.ItemizedSelection()
		sel.add(residues)
		sel.addImplied()
		selection.mergeCurrent(selection.INTERSECT, sel)
		return pairs, residues

	def Apply(self):
		pairs, residues = self.prune()
		if not pairs:
			from chimera import replyobj
			replyobj.status("no residues meet loop modelling criteria")
			return

		# create a temporary directory to work in
		import tempfile
		tempdir = tempfile.mkdtemp(prefix="modeller")
		print 'Modeller temporary directory:', tempdir

		# write PDB file with original coordinates
		import os
		fname = os.path.join(tempdir, 'original.pdb')
		molecule = self.molecules.getvalue()
		xform = molecule.openState.xform
		xform.invert()	# want original coordinates
		chimera.viewer.pdbWrite([molecule], xform, fname)
		# write out Modeller input file
		count = self.count.get()
		refine = self.refine.get()
		fname = os.path.join(tempdir, "loopopt.py")
		f = file(fname, 'w')
		writeModeller(f, 'original.pdb', 'loop', pairs, count, refine)
		f.close()

		#  run Modeller -- put up progress dialog
		import ModUtil
		def cb(process, dirname=tempdir, count=count):
			return loopFileCount(dirname, count)
		try:
			prog = self.modeller.get()
			p = ModUtil.run([prog, "loopopt.py"], cb, cwd=tempdir)
		except OSError, e:
			from chimera import replyobj
			replyobj.error("Unable to run modeller: %s\n" % e)
			return

		# Do concurrent work here

		# find atoms that are connected to the residues we will model
		atoms = set()
		for r in residues:
			for a in r.atoms:
				atoms.add(a)
		outsideAtoms = set()
		for a in atoms:
			for b in a.bonds:
				oa = b.otherAtom(a)
				if oa.residue not in residues:
					outsideAtoms.add(oa)
		outsideAtoms = [(a.residue.id, a.name) for a in outsideAtoms]

		residueIds = set([r.id for r in residues])

		# TODO: use triggers to monitor process
		# and then startup dock interface
		# For now, we just wait
		returncode = p.wait()
		if returncode != 0:
			from chimera import replyobj
			replyobj.error("Modeller failed\n")
			return

		# create ViewDock input file from output files
		path = makedock(tempdir, residueIds, outsideAtoms)
		if not path:
			from chimera import replyobj
			replyobj.error("No models were generated\n")
			return

		# undisplay selected residues
		for r in residues:
			for a in r.atoms:
				a.display = False

		# startup dock
		import ViewDock
		v = ViewDock.ViewDock(path, 'Modeller')

		# remove long bonds since makedock can't put TERs
		# from both the model and the "longbond" PseudoBondGroup
		models = [c.chimeraModel for c in v.results.compoundList]
		length = 3
		sqLen = length * length
		for m in models:
			for b in m.bonds:
				if b.sqlength() >= sqLen:
					# get rid of longbond PseudoBonds
					a0, a1 = b.atoms
					pbs = a0.associations(
						chimera.LONGBOND_PBG_NAME, a1)
					for pb in pbs:
						pb.pseudoBondGroup.deletePseudoBond(pb)
					# get rid of bond
					m.deleteBond(b)