cb('toggle_surface_selectability', False))


add_accelerators()


# -----------------------------------------------------------------------------
# Register sop command.
#
def sop_cmd(cmdname, args):
    from Surface.sopcommand import sop_command
    sop_command(cmdname, args)


from Midas.midas_text import addCommand
addCommand('sop', sop_cmd, help=True)

# -----------------------------------------------------------------------------
# Register attributes of SurfaceModel and SurfacePiece.
# TODO:  Make all use of SurfaceModel import Surface instead of _surface.
#
from Surface import inspect


# -----------------------------------------------------------------------------
# Save surfaces in session file.
#
def save_session(trigger, arg, file):
    from Surface import session
    session.save_surface_state(file)
	from AddCharge import cmdAddStdCharge, \
					cmdAddNonstdCharge, cmdAddAllCharge
	from Midas.midas_text import doExtensionFunc, MidasError
	if not args:
		mode = 'a'
	else:
		fields = args.split(None, 1)
		if len(fields) > 1:
			fullMode, args = fields
		else:
			fullMode = fields[0]
			args = ""
		mode = fullMode[0].lower()

	if mode == 's':
		func = cmdAddStdCharge
		specInfo = [("spec", "molecules", "molecules")]
	elif mode == 'n':
		func = cmdAddNonstdCharge
		specInfo = [("resSpec", "residues", "residues")]
	elif mode == 'a':
		func = cmdAddAllCharge
		specInfo = [("spec", "molecules", "molecules")]
	else:
		raise MidasError("Unknown mode for %s: %s" % (cmdName,fullMode))
	doExtensionFunc(func, args, specInfo=specInfo)

from Midas.midas_text import addCommand
addCommand("addcharge", cmdAddCharge, help=True, changesDisplay=False)

				self.module('gui').AddionsDialog.name)
		return None

chimera.extension.manager.registerExtension(AddionsEMO(__file__))

def cmdAddions(cmdName, args):
	from Midas.midas_text import doExtensionFunc, MidasError
	from Addions import ValidIontypes, initiateAddions

	fields = args.split(" ")

	if len(fields) ==0:
		raise MidasError("No arguments were given for solvate.")

	iontype = fields[0]
	if not( shape in ValidIontypes ):
		raise MidasError("Unknown solvent shape: " + fields[1])

	numion = fields[1]


	import chimera
        mols = chimera.openModels.list(modelTypes=[chimera.Molecule])
	initiateAdions( mols, shape, model, extent, center, chimera.replyobj.status)
        


from Midas.midas_text import addCommand
addCommand("adions", cmdAddions, help=True)

Exemple #4
0
  def name(self):
    return 'Keyboard Shortcuts'
  def description(self):
    return 'Shows dialog listing keyboard shortcuts.'
  def categories(self):
    return ['General Controls']
  def icon(self):
    return None
  def activate(self):
    self.module().show_accelerator_dialog()
    return None

# -----------------------------------------------------------------------------
#
chimera.extension.manager.registerExtension(Accelerator_Browser_EMO(__file__))
    
# ----------------------------------------------------------------------------
# Add 'ac' Midas command to turn on accelerators.
#
def accel_cmd(cmdname, args):
  from Accelerators import accelerator_command
  accelerator_command(cmdname, args)
from Midas.midas_text import addCommand
addCommand('ac', accel_cmd, None, help = True, changesDisplay = True)

# ----------------------------------------------------------------------------
# Check for auto-start
#
import Accelerators
Accelerators.autostart_accelerators()
		return 'find hydrogen bonds'
	def categories(self):
		return ['Structure Analysis', 'Surface/Binding Analysis']
	def icon(self):
		return self.path('hbond.png')
	def activate(self):
		self.module('gui').showUI()
		return None

chimera.extension.manager.registerExtension(FindHBondEMO(__file__))

def cmdHBonds(cmdName, args):
	from Midas.midas_text import doExtensionFunc
	from FindHBond import createHBonds
	doExtensionFunc(createHBonds, args,
				specInfo=[("spec", "models", "molecules")])

def cmdUnHBonds(cmdName, args):
	from Midas.midas_text import doExtensionFunc, MidasError
	import chimera
	mgr = chimera.PseudoBondMgr.mgr()
	pbg = mgr.findPseudoBondGroup("hydrogen bonds")
	if pbg:
		chimera.openModels.close([pbg])
	else:
		raise MidasError, "No hydrogen bonds to remove"

from Midas.midas_text import addCommand
addCommand("hbonds", cmdHBonds, revFunc=cmdUnHBonds, help=True)
addCommand("findhbond", cmdHBonds, revFunc=cmdUnHBonds, help=True)
Exemple #6
0
def cmd_cone(cmdName, args):
    from Midas.midas_text import doExtensionFunc
    from Chimera_BILD import cone
    doExtensionFunc(cone, args)


def cmd_cylinder(cmdName, args):
    from Midas.midas_text import doExtensionFunc
    from Chimera_BILD import cylinder
    doExtensionFunc(cylinder, args)


def cmd_sphere(cmdName, args):
    from Midas.midas_text import doExtensionFunc
    from Chimera_BILD import sphere
    doExtensionFunc(sphere, args)


def cmd_vector(cmdName, args):
    from Midas.midas_text import doExtensionFunc
    from Chimera_BILD import vector
    doExtensionFunc(vector, args)


addCommand("arrow", cmd_arrow)
addCommand("box", cmd_box)
addCommand("cone", cmd_cone)
addCommand("cylinder", cmd_cylinder)
addCommand("sphere", cmd_sphere)
addCommand("vector", cmd_vector)
Exemple #7
0
        return self.path('icon.png')

    def categories(self):
        return ['Structure Analysis']

    def activate(self):
        import chimera.dialogs
        chimera.dialogs.display(self.module('gui').AnisoDialog.name)
        return None


chimera.extension.manager.registerExtension(AnisoEMO(__file__))


def cmdAniso(cmdName, args):
    import Aniso
    from Midas.midas_text import doExtensionFunc
    doExtensionFunc(Aniso.aniso, args, specInfo=[("spec", "targets", "atoms")])


def cmdUnaniso(cmdName, args):
    import Aniso
    from Midas.midas_text import doExtensionFunc
    doExtensionFunc(Aniso.unaniso,
                    args,
                    specInfo=[("spec", "targets", "atoms")])


from Midas.midas_text import addCommand
addCommand("aniso", cmdAniso, revFunc=cmdUnaniso, help=True)
# -----------------------------------------------------------------------------
# Register mcopy command.
#
def mcopy_cmd(cmdname, args):
    from MoleculeCopy import mcopy_command
    mcopy_command(cmdname, args)

from Midas.midas_text import addCommand
addCommand('mcopy', mcopy_cmd, help = True)
# -----------------------------------------------------------------------------
# Register shape command.
#
def shape_cmd(cmdname, args):
    from Shape import shape_command
    shape_command(cmdname, args)


from Midas.midas_text import addCommand

addCommand('shape', shape_cmd, help=True)


# -----------------------------------------------------------------------------
# Register surface resize mouse mode keyboard shortcut.
#
def resize_mouse_mode():
    from Shape.resizemode import enable_resize_surface_mouse_mode as e
    e(one_use=True)


from Accelerators import add_accelerator

add_accelerator('sz', 'Resize selected surfaces', resize_mouse_mode)
import os
import os.path

import chimera.extension

class BlastEMO(chimera.extension.EMO):

	def name(self):
		return "Blast Protein"
	def description(self):
		return "find similar protein sequences using BLAST"
	def categories(self):
		return ["Sequence"]
	def activate(self):
		from chimera.dialogs import display
		display(self.module("gui").BlastChainDialog.name)

	def cmdLine(self, cmdName, args):
		self.module("cmdline").run(cmdName, args)
	def modelPanel(self, molecules):
		self.module("gui").run(molecules[0])

emo = BlastEMO(__file__)
chimera.extension.manager.registerExtension(emo)

from Midas.midas_text import addCommand
addCommand("blast", emo.cmdLine, help=True, changesDisplay=False)
addCommand("psiblast", emo.cmdLine, help=True, changesDisplay=False)
Exemple #11
0
    def activate(self):
        from chimera.dialogs import display
        display(self.module('gui').mmmdDialog.name)
        return None

    def cmdMMMD(self, cmdName, args):
        from Midas.midas_text import doExtensionFunc
        func = getattr(self.module('cmdline'), cmdName)
        doExtensionFunc(func,
                        args,
                        specInfo=[("spec", "molecules", "molecules")])

    def modelPanelMM_CB(self, molecules):
        self.module('modelpanel').minimize(molecules)

    def modelPanelMD_CB(self, molecules):
        self.module('modelpanel').dynamics(molecules)


emo = mmmdEMO(__file__)

chimera.extension.manager.registerExtension(emo)

import ModelPanel
ModelPanel.addButton("minimize...", emo.modelPanelMM_CB, defaultFrequent=False)
#ModelPanel.addButton("run MD", emo.modelPanelMD_CB)

from Midas.midas_text import addCommand
addCommand("minimize", emo.cmdMMMD, help=True)
#addCommand("dynamics", emo.cmdMMMD, help=True)
		return 'Find local energy minimum of molecules'
	def categories(self):
		return ['Structure Editing']
	#def icon(self):
	#	return self.path("Template.png")
	def activate(self):
		from chimera.dialogs import display
		display(self.module('gui').mmmdDialog.name)
		return None
	def cmdMMMD(self, cmdName, args):
		from Midas.midas_text import doExtensionFunc
		func = getattr(self.module('cmdline'), cmdName)
		doExtensionFunc(func, args,
				specInfo=[("spec", "molecules", "molecules")])
	def modelPanelMM_CB(self, molecules):
		self.module('modelpanel').minimize(molecules)
	def modelPanelMD_CB(self, molecules):
		self.module('modelpanel').dynamics(molecules)

emo = mmmdEMO(__file__)

chimera.extension.manager.registerExtension(emo)

import ModelPanel
ModelPanel.addButton("minimize...", emo.modelPanelMM_CB, defaultFrequent=False)
#ModelPanel.addButton("run MD", emo.modelPanelMD_CB)

from Midas.midas_text import addCommand
addCommand("minimize", emo.cmdMMMD, help=True)
#addCommand("dynamics", emo.cmdMMMD, help=True)
    fi.register(descrip, open_cb, suffixes, prefix_list,
                canDecompress = False, category = fi.VOLUME,
                batch = batch)

# -----------------------------------------------------------------------------
#
register_file_types()

# -----------------------------------------------------------------------------
# Register volume command.
#
def volume_cmd(cmdname, args):
    from VolumeViewer.volumecommand import volume_command
    volume_command(cmdname, args)
from Midas.midas_text import addCommand
addCommand('volume', volume_cmd, help = True)

# -----------------------------------------------------------------------------
# Delay importing module until function is actually called.
#
def function(name):
  def f(*args, **kw):
    from VolumeViewer import shortcuts
    getattr(shortcuts, name)(*args, **kw)
  return f

# -----------------------------------------------------------------------------
# Register keyboard shortcuts.
#
ks = (('bv', 'Make volume bounding selected atoms from periodic volume',
       'bounding_map'),
	def description(self):
		return 'Find steric clashes or atomic contacts'
	def icon(self):
		return self.path('dc2.png')
	def categories(self):
		return ['Structure Analysis', 'Surface/Binding Analysis']
	def activate(self):
		import chimera.dialogs
		chimera.dialogs.display(
				self.module('gui').DetectClashDialog.name)
		return None

chimera.extension.manager.registerExtension(DetectClashEMO(__file__))

def cmdDetectClash(cmdName, args):
	import DetectClash
	from Midas.midas_text import doExtensionFunc
	doExtensionFunc(DetectClash.cmdDetectClash, args,
				specInfo=[("atomSpec", "testAtoms", "atoms")])

def cmdUndetectClash(cmdName, args):
	import DetectClash
	if DetectClash._continuousID != None:
		from chimera import triggers
		triggers.deleteHandler('OpenState', DetectClash._continuousID)
		DetectClash._continuousID = None
	DetectClash.nukeGroup()

from Midas.midas_text import addCommand
addCommand("findclash", cmdDetectClash, revFunc=cmdUndetectClash, help=True)
    def open_cb(path, ftype=name):
      from VolumeViewer import open_volume_file
      vlist = open_volume_file(path, ftype, open_models = False,
			       show_data = False, show_dialog = False)
      import chimera
      if len(vlist) > 0 and not chimera.nogui:
        from SurfaceColor.gui import show_surface_color_dialog
	d = show_surface_color_dialog()
	d.use_electrostatics_colormap()
	# TODO: Should set volume menu entry, but volumes are not yet opened.
      return vlist
    suffixes = map(lambda s: '.' + s, suffix_list)      # fileInfo wants '.'
    import chimera
    fi = chimera.fileInfo
    fi.register(descrip, open_cb, suffixes, prefix_list,
                canDecompress = False, category = fi.VOLUME, batch = batch)

# -----------------------------------------------------------------------------
#
register_file_types()

# -----------------------------------------------------------------------------
# Register scolor command.
#
def scolor_cmd(cmdname, args):
    from SurfaceColor import scolor
    scolor.scolor_command(cmdname, args)
from Midas.midas_text import addCommand
addCommand('scolor', scolor_cmd, scolor_cmd, help = True)
addCommand('scolour', scolor_cmd, scolor_cmd, help = True)
Exemple #16
0
    def activate(self):
        #from chimera.dialogs import display
        #display(self.module('gui').AddHDialog.name)
        return None

    def modelPanelCB(self, molecules):
        self.module('gui').CombineDialog(models=molecules)


emo = CombineEMO(__file__)
#chimera.extension.manager.registerExtension(emo)
import ModelPanel
ModelPanel.addButton("copy/combine...",
                     emo.modelPanelCB,
                     balloon="Combine molecular models into new model",
                     moleculesOnly=True)


def cmdCombine(cmdName, args):
    from Midas.midas_text import doExtensionFunc
    import Combine
    doExtensionFunc(Combine.cmdCombine,
                    args,
                    specInfo=[("spec", "mols", "molecules"),
                              ("refSpec", "refMol", "molecules")])


from Midas.midas_text import addCommand
addCommand("combine", cmdCombine, help=True)
Exemple #17
0
    from AddCharge import cmdAddStdCharge, \
        cmdAddNonstdCharge, cmdAddAllCharge
    from Midas.midas_text import doExtensionFunc, MidasError
    if not args:
        mode = 'a'
    else:
        fields = args.split(None, 1)
        if len(fields) > 1:
            fullMode, args = fields
        else:
            fullMode = fields[0]
            args = ""
        mode = fullMode[0].lower()

    if mode == 's':
        func = cmdAddStdCharge
        specInfo = [("spec", "molecules", "molecules")]
    elif mode == 'n':
        func = cmdAddNonstdCharge
        specInfo = [("resSpec", "residues", "residues")]
    elif mode == 'a':
        func = cmdAddAllCharge
        specInfo = [("spec", "molecules", "molecules")]
    else:
        raise MidasError("Unknown mode for %s: %s" % (cmdName, fullMode))
    doExtensionFunc(func, args, specInfo=specInfo)


from Midas.midas_text import addCommand
addCommand("addcharge", cmdAddCharge, help=True, changesDisplay=False)
    if shape == "cap":
        if len(fields) != 4:
            raise MidasError(
                "Syntax for solvate cap: solvate cap solvent_model center radius"
            )
        center = fields[2]
        extent = fields[3]
    else:
        center = ""
        extent = fields[2]

    import chimera
    mols = chimera.openModels.list(modelTypes=[chimera.Molecule])
    if not chimera.nogui:
        from AddH.gui import checkNoHyds
        checkNoHyds(
            mols,
            lambda mols=mols, shape=shape, model=model, extent=extent, center=
            center, status=chimera.replyobj.status: initiateSolvate(
                mols, shape, model, extent, center, status),
            process="solvation")
        return
    initiateSolvate(mols, shape, model, extent, center,
                    chimera.replyobj.status)


from Midas.midas_text import addCommand

addCommand("solvate", cmdSolvate, help=True)
		return 'match conformer members of two ensembles'
	def categories(self):
		return ['Structure Comparison', 'MD/Ensemble Analysis']
	def activate(self):
		self.module('choose').EnsembleMatchCB()
		# Instance will register itself
		return None

class EnsembleClusterEMO(chimera.extension.EMO):
	def name(self):
		return 'Ensemble Cluster'
	def description(self):
		return 'cluster conformer members of an ensemble'
	def categories(self):
		return ['Structure Comparison', 'MD/Ensemble Analysis']
	def activate(self):
		self.module('choose').EnsembleClusterCB()
		# Instance will register itself
		return None

chimera.extension.manager.registerExtension(TileStructuresEMO(__file__))
chimera.extension.manager.registerExtension(EnsembleMatchEMO(__file__))
chimera.extension.manager.registerExtension(EnsembleClusterEMO(__file__))

# Register tile command.
def tile_cmd(cmdname, args):
    from EnsembleMatch import tilecommand
    tilecommand.tile_command(cmdname, args)
from Midas.midas_text import addCommand
addCommand('tile', tile_cmd, tile_cmd, help = True)
# -----------------------------------------------------------------------------
# Register measure command.
#
def measure_cmd(cmdname, args):
    import Measure
    Measure.measure_command(cmdname, args)


from Midas.midas_text import addCommand
addCommand('measure', measure_cmd, help=True)
Exemple #21
0
# -----------------------------------------------------------------------------
# Register topography command to surface from volume plane.
#
def topo(*args):
    from Topography import topography_command
    topography_command(*args)


from Midas.midas_text import addCommand
addCommand('topography', topo, help=True)
Exemple #22
0
#
def fsc_plot(fscMap):
    fig = update_plot(fscMap)
    from chimera import triggers
    h = triggers.addHandler('OpenState', motion_cb, (fscMap, fig))


# -----------------------------------------------------------------------------
#


def motion_cb(trigger_name, mf, trigger_data):
    if 'transformation change' in trigger_data.reasons:
        fsc_map, fig = mf
        update_plot(fsc_map, fig)


# -----------------------------------------------------------------------------
#
def fscplot_cmd(cmdname, args):
    from Commands import volume_arg, parse_arguments
    req_args = [('fscMap', volume_arg)]
    kw = parse_arguments(cmdname, args, req_args)
    fsc_plot(**kw)


# -----------------------------------------------------------------------------
#
from Midas.midas_text import addCommand
addCommand('fscplot', fscplot_cmd)
			if len(fields) > 1:
				return fields
			else:
				return fields[0], ""
		else:
			for i in range(1, len(args)):
				if args[i] == '"':
					if args[i - 1] == '\\':
						continue
					return args[1:i], args[i+1:].strip()
			from chimera import UserError
			raise UserError("unterminated quoted string")
emo = ViewDockEMO(__file__)
chimera.extension.manager.registerExtension(emo)
from Midas.midas_text import addCommand
addCommand("viewdock", emo.cmdViewdock, help=True)

try:
	import Midi
except ImportError:
	# Nothing out there for sound
	pass
else:
	class HearDockEMO(chimera.extension.EMO):
		def name(self):
			return 'HearDock'
		def description(self):
			return 'display, sonify and manage dock results'
		def categories(self):
			return ['Surface/Binding Analysis']
		def icon(self):
    def activate(self):
        import chimera.dialogs
        chimera.dialogs.display(self.module('gui').DetectClashDialog.name)
        return None


chimera.extension.manager.registerExtension(DetectClashEMO(__file__))


def cmdDetectClash(cmdName, args):
    import DetectClash
    from Midas.midas_text import doExtensionFunc
    doExtensionFunc(DetectClash.cmdDetectClash,
                    args,
                    specInfo=[("atomSpec", "testAtoms", "atoms")])


def cmdUndetectClash(cmdName, args):
    import DetectClash
    if DetectClash._continuousID != None:
        from chimera import triggers
        triggers.deleteHandler('OpenState', DetectClash._continuousID)
        DetectClash._continuousID = None
    DetectClash.nukeGroup()


from Midas.midas_text import addCommand

addCommand("findclash", cmdDetectClash, revFunc=cmdUndetectClash, help=True)
	def description(self):
		return 'align sequences/structures'
	def categories(self):
		return ['Structure Comparison']
	def icon(self):
		return self.path('matchmaker.png')
	def activate(self, molecules=None):
		from chimera import dialogs
		d = dialogs.display(self.module('gui').MatchMaker.name)
		if molecules:
			d.refMolList.setvalue(molecules[0])
			d.matchMolList.setvalue(molecules[1:])
			d.showSeqVar.set(False)
		return None

emo = MatchMakerEMO(__file__)
chimera.extension.manager.registerExtension(emo)
if not chimera.nogui:
	import ModelPanel
	ModelPanel.addButton("match...", emo.activate, minModels=2,
		moleculesOnly=True, balloon="align sequences/structures")

def cmdMatchMaker(cmdName, args):
	from MatchMaker import cmdMatch
	from Midas.midas_text import doExtensionFunc
	doExtensionFunc(cmdMatch, args, specInfo=[("refSpec", "refSel", None),
					("matchSpec", "matchSel", None)])
from Midas.midas_text import addCommand
addCommand("mmaker", cmdMatchMaker, help=True)
addCommand("matchmaker", cmdMatchMaker, help=True)
# -----------------------------------------------------------------------------
# Register measure command.
#
def measure_cmd(cmdname, args):
  import Measure
  Measure.measure_command(cmdname, args)
from Midas.midas_text import addCommand
addCommand('measure', measure_cmd, help = True)
    help = "add/change attributes of atoms/residues/models"

    def name(self):
        return 'Define Attribute'

    def description(self):
        return self.help

    def categories(self):
        return ['Structure Analysis']

    def activate(self):
        from chimera import dialogs
        dialogs.display(self.module('gui').AddAttrDialog.name)
        return None


chimera.extension.manager.registerExtension(AddAttrEMO(__file__))


def cmdAddAttr(cmdName, args):
    from AddAttr import addAttributes
    from Midas.midas_text import doExtensionFunc
    doExtensionFunc(addAttributes,
                    args,
                    specInfo=[("spec", "models", "molecules")])


from Midas.midas_text import addCommand
addCommand("defattr", cmdAddAttr, help=True, changesDisplay=False)
  def icon(self):
    return None
  def activate(self):
    self.module('gui').show_volume_filter_dialog()
    return None

manager.registerExtension(Volume_Filter_EMO(__file__))

# -----------------------------------------------------------------------------
# Register vop command.
#
def vop_cmd(cmdname, args):
    from VolumeFilter.vopcommand import vop_command
    vop_command(cmdname, args)
from Midas.midas_text import addCommand
addCommand('vop', vop_cmd, help = True)

# ---------------------------------------------------------------------------
# Register keyboard shortcuts for filtering.
#
def fourier():
  from VolumeFilter import fourier_transform
  fourier_transform()
def laplace():
  from VolumeFilter import laplacian
  laplacian()

from Accelerators import add_accelerator
add_accelerator('FT', 'Fourier transform active volume', fourier)
add_accelerator('LT', 'Calculate Laplacian active volume', laplace)
from median import make_test_volume
	model = fields[1]
        if not( model in ValidSolventModels ):
		raise MidasError("Unknown solvent model: " + fields[2])

	if shape=="cap":
		if len(fields) != 4:
			raise MidasError("Syntax for solvate cap: solvate cap solvent_model center radius")
		center = fields[2]
		extent = fields[3]
	else:
		center = ""
		extent = fields[2]

	import chimera
        mols = chimera.openModels.list(modelTypes=[chimera.Molecule])
	if not chimera.nogui:
		from AddH.gui import checkNoHyds
		checkNoHyds(mols, lambda mols=mols, shape=shape, model=model,
			extent=extent, center=center, status=
			chimera.replyobj.status: initiateSolvate(mols, shape,
			model, extent, center, status), process="solvation")
		return
	initiateSolvate( mols, shape, model, extent, center, chimera.replyobj.status)
        


from Midas.midas_text import addCommand
addCommand("solvate", cmdSolvate, help=True)

	def name(self):
		return 'Combine Molecular Models'
	def description(self):
		return 'combine molecular models'
	def categories(self):
		return []
	def icon(self):
		return None
	def activate(self):
		#from chimera.dialogs import display
		#display(self.module('gui').AddHDialog.name)
		return None
	def modelPanelCB(self, molecules):
		self.module('gui').CombineDialog(models=molecules)

emo = CombineEMO(__file__)
#chimera.extension.manager.registerExtension(emo)
import ModelPanel
ModelPanel.addButton("copy/combine...", emo.modelPanelCB,
	balloon="Combine molecular models into new model", moleculesOnly=True)

def cmdCombine(cmdName, args):
        from Midas.midas_text import doExtensionFunc
	import Combine
        doExtensionFunc(Combine.cmdCombine, args,
                                specInfo=[("spec", "mols", "molecules"),
					("refSpec", "refMol", "molecules")])

from Midas.midas_text import addCommand
addCommand("combine", cmdCombine, help=True)
    # arguments (raising MidasError if any are found) and directly calling
    # the mainchain() function otherwise.  As implemented here, using
    # doExtensionFunc, if the user does provide arguments then
    # doExtensionFunc will raise an error complaining that there
    # were unknown keyword arguments supplied.
    from Midas.midas_text import doExtensionFunc
    doExtensionFunc(mainchain, args)


# The function for "~mainchain"
def revMainchainCmd(cmdName, args):
    # We are going to implement ~mainchain as a synonym for "display",
    # so we import runCommand which simplifies doing that.
    from chimera import runCommand
    from Midas import MidasError
    if args:
        # Raising MidasError will cause the error message
        # to show up in the status line as red text
        raise MidasError("~mainchain takes no arguments")
    # runCommand takes any legal command-line command and executes it.
    runCommand("display")


# Now actually register the "mainchain" command with the command interpreter
# by using addCommand().  The first argument is the command name and the
# second is the callback function for doing the work.  The 'revFunc' keyword
# specifies the function to implement "~mainchain".  The 'help' keyword has
# been omitted, therefore no help will be provided.
from Midas.midas_text import addCommand
addCommand("mainchain", mainchainCmd, revFunc=revMainchainCmd)
# All rights reserved.  This software provided pursuant to a
# license agreement containing restrictions on its disclosure,
# duplication and use.  This notice must be embedded in or
# attached to all copies, including partial copies, of the
# software or any revisions or derivations thereof.
# --- UCSF Chimera Copyright ---

import chimera.extension

class NucleotideEMO(chimera.extension.EMO):
	def name(self):
		return 'Nucleotides'
	def description(self):
		return 'abstract A, C, G, T, and U'
	def categories(self):
		return ['Depiction']
	def icon(self):
		return self.path('na.png')
	def activate(self):
		self.module('gui').gui()
		return None

chimera.extension.manager.registerExtension(NucleotideEMO(__file__))

# Register nucleotides command.
def nucleotides(cmdname, args):
	from NucleicAcids.cmd import nucleotides
	nucleotides(cmdname, args)
from Midas.midas_text import addCommand
addCommand('nucleotides', nucleotides, help=True)
Exemple #33
0
class ColorKeyEMO(chimera.extension.EMO):
	def name(self):
		return 'Color Key'
	def description(self):
		return 'place color key'
	def categories(self):
		return ['Utilities']
	def icon(self):
		return self.path('keyIcon.png')
	def activate(self):
		from chimera import dialogs
		d = dialogs.display(self.module('gui').IlabelDialog.name)
		d.notebook.selectpage(d.COLOR_KEY)
		return None

chimera.extension.manager.registerExtension(ColorKeyEMO(__file__))

def doLabel2DCmd(cmdName, args):
    from Midas.midas_text import doExtensionFunc
    from Midas import MidasError
    import Ilabel

    try:
        doExtensionFunc(Ilabel.processLabel2DCmd, args)
    except MidasError, what:
        raise

from Midas.midas_text import addCommand
addCommand("2dlabels", doLabel2DCmd, help=True)
	for pbg in mgr.pseudoBondGroups:
		unsel.extend(filter(lambda pb: pb not in selEdges,
							pbg.pseudoBonds))
	return unsel

def unselResidues():
	from chimera.selection import currentResidues
	selResidues = currentResidues(asDict=True)
	unsel = []
	for m in chimera.openModels.list(modelTypes=[chimera.Molecule]):
		unsel.extend(filter(lambda r: r not in selResidues, m.residues))
	return unsel

def unselMolecules():
	from chimera.selection import currentMolecules
	selMolecules = currentMolecules(asDict=True)
	return filter(lambda m: m not in selMolecules,
		chimera.openModels.list(modelTypes=[chimera.Molecule]))

def unselModels():
	from chimera.selection import currentGraphs
	selModels = currentGraphs(asDict=True)
	return filter(lambda m: m not in selModels, chimera.openModels.list())

def midasCmd(cmdName, typedArgs):
	from Midas.midas_text import doExtensionFunc
	doExtensionFunc(writeSel, typedArgs)

from Midas.midas_text import addCommand
addCommand("writesel", midasCmd, help=True)
	def name(self):
		return 'Thermal Ellipsoids'
	def description(self):
		return 'show/hide atomic displacement ellipsoids'
	def icon(self):
		return self.path('icon.png')
	def categories(self):
		return ['Structure Analysis']
	def activate(self):
		import chimera.dialogs
		chimera.dialogs.display(
				self.module('gui').AnisoDialog.name)
		return None

chimera.extension.manager.registerExtension(AnisoEMO(__file__))

def cmdAniso(cmdName, args):
	import Aniso
	from Midas.midas_text import doExtensionFunc
	doExtensionFunc(Aniso.aniso, args,
				specInfo=[("spec", "targets", "atoms")])

def cmdUnaniso(cmdName, args):
	import Aniso
	from Midas.midas_text import doExtensionFunc
	doExtensionFunc(Aniso.unaniso, args,
				specInfo=[("spec", "targets", "atoms")])

from Midas.midas_text import addCommand
addCommand("aniso", cmdAniso, revFunc=cmdUnaniso, help=True)
import chimera.extension


class BlastEMO(chimera.extension.EMO):
    def name(self):
        return "Blast Protein"

    def description(self):
        return "find similar protein sequences using BLAST"

    def categories(self):
        return ["Sequence"]

    def activate(self):
        from chimera.dialogs import display
        display(self.module("gui").BlastChainDialog.name)

    def cmdLine(self, cmdName, args):
        self.module("cmdline").run(cmdName, args)

    def modelPanel(self, molecules):
        self.module("gui").run(molecules[0])


emo = BlastEMO(__file__)
chimera.extension.manager.registerExtension(emo)

from Midas.midas_text import addCommand
addCommand("blast", emo.cmdLine, help=True, changesDisplay=False)
addCommand("psiblast", emo.cmdLine, help=True, changesDisplay=False)
# -----------------------------------------------------------------------------
# Register command to make a molecule model from a mesh.
#
def mesh_to_molecule(*args):
    import MeshToMolecule
    MeshToMolecule.mesh_to_molecule(*args)
from Midas.midas_text import addCommand
addCommand('meshmol', mesh_to_molecule, help = True)
# -----------------------------------------------------------------------------
# Register topography command to surface from volume plane.
#
def topo(*args):
    from Topography import topography_command
    topography_command(*args)
from Midas.midas_text import addCommand
addCommand('topography', topo, help = True)
# --- UCSF Chimera Copyright ---
#
# $Id: ChimeraExtension.py 26655 2009-01-07 22:02:30Z gregc $

import chimera.extension

class AddAttrEMO(chimera.extension.EMO):
	help = "add/change attributes of atoms/residues/models"
	def name(self):
		return 'Define Attribute'
	def description(self):
		return self.help
	def categories(self):
		return ['Structure Analysis']
	def activate(self):
		from chimera import dialogs
		dialogs.display(self.module('gui').AddAttrDialog.name)
		return None

chimera.extension.manager.registerExtension(AddAttrEMO(__file__))

def cmdAddAttr(cmdName, args):
	from AddAttr import addAttributes
	from Midas.midas_text import doExtensionFunc
	doExtensionFunc(addAttributes, args,
				specInfo=[("spec", "models", "molecules")])

from Midas.midas_text import addCommand
addCommand("defattr", cmdAddAttr, help=True, changesDisplay=False)

Exemple #40
0
# -----------------------------------------------------------------------------
# Register fly command.
#
def fly_cmd(cmdname, args):
  import Fly
  Fly.fly_command(cmdname, args)
from Midas.midas_text import addCommand
addCommand('fly', fly_cmd, help = True)
#     def description(self):
#         return 'Substructure Alignment'

#     def categories(self):
#         return ['InsiliChem']

#     def icon(self):
#         pass

#     def activate(self):
#         pass

# chimera.extension.manager.registerExtension(SubAlignEMO(__file__))


def cmd_subalign(cmdName, args):
    from Midas.midas_text import doExtensionFunc
    from subalign.core import cmd_align
    doExtensionFunc(cmd_align, args, specInfo=[("refSpec", "reference_sel", None),
                                               ("probeSpec", "probe_sel", None)])

def cmd_subrmsd(cmdName, args):
    from Midas.midas_text import doExtensionFunc
    from subalign.core import cmd_rmsd
    doExtensionFunc(cmd_rmsd, args, specInfo=[("refSpec", "reference_sel", None),
                                               ("probeSpec", "probe_sel", None)])

addCommand("subalign", cmd_subalign)
addCommand("subrmsd", cmd_subrmsd)
Exemple #42
0
class EnsembleClusterEMO(chimera.extension.EMO):
    def name(self):
        return 'Ensemble Cluster'

    def description(self):
        return 'cluster conformer members of an ensemble'

    def categories(self):
        return ['Structure Comparison', 'MD/Ensemble Analysis']

    def activate(self):
        self.module('choose').EnsembleClusterCB()
        # Instance will register itself
        return None


chimera.extension.manager.registerExtension(TileStructuresEMO(__file__))
chimera.extension.manager.registerExtension(EnsembleMatchEMO(__file__))
chimera.extension.manager.registerExtension(EnsembleClusterEMO(__file__))


# Register tile command.
def tile_cmd(cmdname, args):
    from EnsembleMatch import tilecommand
    tilecommand.tile_command(cmdname, args)


from Midas.midas_text import addCommand
addCommand('tile', tile_cmd, tile_cmd, help=True)
Exemple #43
0
#
chimera.extension.manager.registerExtension(Crystal_Contacts_EMO(__file__))


# -----------------------------------------------------------------------------
#
def show_contacts(distance=1.0):
    import chimera
    for m in chimera.openModels.list(modelTypes=[chimera.Molecule]):
        from CrystalContacts import show_crystal_contacts
        show_crystal_contacts(m, distance)


from Accelerators import add_accelerator

add_accelerator('xx', 'Show crystal contacts', show_contacts)


# -----------------------------------------------------------------------------
#
def crystal_contacts_command(cmdname, args):
    from CrystalContacts.command import crystal_contacts
    crystal_contacts(cmdname, args)


# -----------------------------------------------------------------------------
#
from Midas.midas_text import addCommand

addCommand('crystalcontacts', crystal_contacts_command, help=True)
Exemple #44
0
        return 'Rotamers'

    def description(self):
        return 'choose side-chain rotamers'

    def categories(self):
        return ['Structure Editing']

    def icon(self):
        return self.path('beanie.png')

    def activate(self):
        self.module('gui')._prd()
        return None


chimera.extension.manager.registerExtension(FindHBondEMO(__file__))


def cmdRotamers(cmdName, args):
    from Midas.midas_text import doExtensionFunc
    from Rotamers import useBestRotamers
    doExtensionFunc(useBestRotamers,
                    args,
                    specInfo=[("spec", "targets", "residues"),
                              ("densitySpec", "density", "models")])


from Midas.midas_text import addCommand
addCommand("swapaa", cmdRotamers, help=True)
        import chimera.dialogs
        chimera.dialogs.display(self.module('gui').AddionsDialog.name)
        return None


chimera.extension.manager.registerExtension(AddionsEMO(__file__))


def cmdAddions(cmdName, args):
    from Midas.midas_text import doExtensionFunc, MidasError
    from Addions import ValidIontypes, initiateAddions

    fields = args.split(" ")

    if len(fields) == 0:
        raise MidasError("No arguments were given for solvate.")

    iontype = fields[0]
    if not (shape in ValidIontypes):
        raise MidasError("Unknown solvent shape: " + fields[1])

    numion = fields[1]

    import chimera
    mols = chimera.openModels.list(modelTypes=[chimera.Molecule])
    initiateAdions(mols, shape, model, extent, center, chimera.replyobj.status)


from Midas.midas_text import addCommand
addCommand("adions", cmdAddions, help=True)
# -----------------------------------------------------------------------------
# Register shape command.
#
def shape_cmd(cmdname, args):
    from Shape import shape_command
    shape_command(cmdname, args)
from Midas.midas_text import addCommand
addCommand('shape', shape_cmd, help = True)

# -----------------------------------------------------------------------------
# Register surface resize mouse mode keyboard shortcut.
#
def resize_mouse_mode():
    from Shape.resizemode import enable_resize_surface_mouse_mode as e
    e(one_use = True)
from Accelerators import add_accelerator
add_accelerator('sz', 'Resize selected surfaces', resize_mouse_mode)
     cb('show_surfaces_as_mesh'))
  aa('Sc', 'Split connected surface pieces',
     cb('split_selected_surfaces', False))
  aa('ts', 'Toggle surface selectability',
     cb('toggle_surface_selectability', False))

add_accelerators()

# -----------------------------------------------------------------------------
# Register sop command.
#
def sop_cmd(cmdname, args):
    from Surface.sopcommand import sop_command
    sop_command(cmdname, args)
from Midas.midas_text import addCommand
addCommand('sop', sop_cmd, help = True)

# -----------------------------------------------------------------------------
# Register attributes of SurfaceModel and SurfacePiece.
# TODO:  Make all use of SurfaceModel import Surface instead of _surface.
#
from Surface import inspect

# -----------------------------------------------------------------------------
# Save surfaces in session file.
#
def save_session(trigger, arg, file):
  from Surface import session
  session.save_surface_state(file)
from SimpleSession import SAVE_SESSION
from chimera import triggers as t
# -----------------------------------------------------------------------------
# Register command to make a molecule model from a mesh.
#
def mesh_to_molecule(*args):
    import MeshToMolecule
    MeshToMolecule.mesh_to_molecule(*args)


from Midas.midas_text import addCommand
addCommand('meshmol', mesh_to_molecule, help=True)
from Midas.midas_text import doExtensionFunc, addCommand
from plipgui.core import cmd_plip, cmd_unplip


class PLIPExtension(chimera.extension.EMO):
    def name(self):
        return 'Tangram PLIP'

    def description(self):
        return 'Protein-Ligand Interaction Profiler'

    def categories(self):
        return ['InsiliChem']

    def icon(self):
        return

    def activate(self):
        self.module('gui').showUI()


def _cmd_plip(cmdName, args):
    doExtensionFunc(cmd_plip, args, specInfo=[("selSpec", "selection", None)])


def _cmd_unplip(cmdName, args):
    doExtensionFunc(cmd_unplip, args)


addCommand("plip", _cmd_plip, revFunc=_cmd_unplip)
chimera.extension.manager.registerExtension(PLIPExtension(__file__))
# --- UCSF Chimera Copyright ---
# Copyright (c) 2006 Regents of the University of California.
# All rights reserved.  This software provided pursuant to a
# license agreement containing restrictions on its disclosure,
# duplication and use.  This notice must be embedded in or
# attached to all copies, including partial copies, of the
# software or any revisions or derivations thereof.
# --- UCSF Chimera Copyright ---

import chimera.extension

class MorphEMO(chimera.extension.EMO):
	def name(self):
		return 'Morph Conformations'
	def description(self):
		return 'Interpolate among molecular conformations'
	def categories(self):
		return ['Structure Comparison']
	def icon(self):
		return self.path('morph.png')
	def activate(self):
		self.module('gui').MorphDialog()
		return None
	def cmdMorph(self, cmdName, args):
		self.module('cmdline').run(cmdName, args)

emo = MorphEMO(__file__)
chimera.extension.manager.registerExtension(emo)
from Midas.midas_text import addCommand
addCommand("morph", emo.cmdMorph, help=True)
Exemple #51
0
	def description(self):
		return "Show 2D structure diagram"
	def categories(self):
		return ["Utilities"]
	def icon(self):
		return self.path("SDicon.png")
	def activate(self):
		from chimera.dialogs import display
		display(self.module("gui").StructureDiagramDialog.name)
		return None
	def cmdLine(self, cmdName, args):
		self.module("cmdline").run(cmdName, args)
	def modelPanelCB(self, molecules):
		self.module("modelpanel").callback(molecules)

emo = StructureDiagramEMO(__file__)

# Don't register if no GUI
chimera.extension.manager.registerExtension(emo)

# Don't add if no Model Panel button
import ModelPanel
ModelPanel.addButton("2D Diagram", emo.modelPanelCB,
			moleculesOnly=True,
			defaultFrequent=False,
			balloon="draw molecules in 2D")

# Don't register if no command line (Shame on you!)
from Midas.midas_text import addCommand
addCommand("struct2d", emo.cmdLine, help=True, changesDisplay=False)
	# function below and simply test for the presence of any
	# arguments (raising MidasError if any are found) and directly calling
	# the mainchain() function otherwise.  As implemented here, using
	# doExtensionFunc, if the user does provide arguments then
	# doExtensionFunc will raise an error complaining that there
	# were unknown keyword arguments supplied.
	from Midas.midas_text import doExtensionFunc
	doExtensionFunc(mainchain, args)

# The function for "~mainchain"
def revMainchainCmd(cmdName, args):
	# We are going to implement ~mainchain as a synonym for "display",
	# so we import runCommand which simplifies doing that.
	from chimera import runCommand
	from Midas import MidasError
	if args:
		# Raising MidasError will cause the error message
		# to show up in the status line as red text
		raise MidasError("~mainchain takes no arguments")
	# runCommand takes any legal command-line command and executes it.
	runCommand("display")

# Now actually register the "mainchain" command with the command interpreter
# by using addCommand().  The first argument is the command name and the
# second is the callback function for doing the work.  The 'revFunc' keyword
# specifies the function to implement "~mainchain".  The 'help' keyword has
# been omitted, therefore no help will be provided.
from Midas.midas_text import addCommand
addCommand("mainchain", mainchainCmd, revFunc=revMainchainCmd)