Exemplo n.º 1
0
def set_center_of_rotation():
    'Set center of rotation to center of selected atoms or use center of models mode if no atoms are selected'
    from chimera import selection
    if selection.currentEmpty():
        chimera.runCommand('~cofr')
    else:
        chimera.runCommand('cofr sel')
Exemplo n.º 2
0
def transpSurf(amount):
	if amount != -1:
		aopacity = opacity = min(1.0, 1 - amount)
	else:
		opacity = 1
		aopacity = -1
	atoms = selAtoms()
	import Midas
	surfatoms = Midas.atomMSMSModels(atoms)
	for s,atoms in surfatoms.items():
		adjustMSMSTransparency(s, atoms, opacity, aopacity)

	splist = selectedSurfacePieces(implied = True)
	from chimera import MSMSModel
	for p in splist:
		s = p.model
		if isinstance(s, MSMSModel) and s.molecule:
			adjustMSMSTransparency(s, s.atoms, opacity, aopacity)
		else:
			adjustSurfacePieceTransparency(p, opacity)

	if (len(atoms) > 0 and not selection.currentEmpty()
	    and len(surfatoms) == 0 and len(splist) == 0):
		from replyobj import warning
		warning('No surfaces shown for selected atoms.\n')
Exemplo n.º 3
0
def focus():
    disped = [x for x in selAtoms() + selBonds() if x.shown()]
    ribbons = [
        x for x in selResidues()
        if x.ribbonDisplay and x.hasRibbon() and x.molecule.display
    ]
    disped.extend(ribbons)
    disped.extend([
        p for p in selectedSurfacePieces()
        if p.display and p.model.display and p.triangleCount > 0
    ])
    if not disped:
        from chimera import replyobj
        replyobj.error(
            "No target atoms/bonds/ribbons/surfaces currently shown\n")
        return
    sel = selection.ItemizedSelection()
    sel.add(disped)
    sel.addImplied(edges=False)
    from Midas import window, cofr
    window(sel)
    from chimera import openModels as om
    if selection.currentEmpty():
        from chimera import viewing, viewer
        om.cofrMethod = viewing.defaultCofrMethod
        viewer.clipping = False
    else:
        om.cofrMethod = om.CenterOfView
Exemplo n.º 4
0
def showSurface(warnLarge=True):
    if warnLarge:
        numSurfaces = len(selMolecules())
        if numSurfaces > 20:
            import tkgui
            tkgui.SurfaceWarningDialog(numSurfaces,
                                       lambda: showSurface(warnLarge=False))
            return
    empty = selection.currentEmpty()
    atoms = selAtoms()
    for a in atoms:
        a.surfaceDisplay = True
    import Midas
    Midas.surfaceVisibilityByAtom(atoms)
    plist = selectedSurfacePieces(implied=True)
    if plist:
        pa, pb = surfacePieceAtomsAndBonds(plist)
        if pa:
            # Don't surface atoms that have non-MSMS surface.
            paset = set(pa)
            atoms = [a for a in atoms if a not in paset]
    for p in plist:
        p.display = True
        p.model.display = True
    from Midas import surfaceNew
    molcat = list(set([(a.molecule, a.surfaceCategory) for a in atoms]))
    if empty:
        # Only surface main category if nothing selected.
        molcat = [mc for mc in molcat if mc[1] == 'main']
    molcat.sort(lambda mc1, mc2: cmp(mc1[0].id, mc2[0].id))
    for mol, cat in molcat:
        surfaceNew(cat, models=[mol])
Exemplo n.º 5
0
def showSurface(warnLarge=True):
	if warnLarge:
		numSurfaces = len(selMolecules())
		if numSurfaces > 20:
			import tkgui
			tkgui.SurfaceWarningDialog(numSurfaces,
				lambda : showSurface(warnLarge=False))
			return
	empty = selection.currentEmpty()
	atoms = selAtoms()
	for a in atoms:
		a.surfaceDisplay = True
	import Midas
	Midas.surfaceVisibilityByAtom(atoms)
	plist = selectedSurfacePieces(implied = True)
	if plist:
		pa, pb = surfacePieceAtomsAndBonds(plist)
		if pa:
			# Don't surface atoms that have non-MSMS surface.
			paset = set(pa)
			atoms = [a for a in atoms if a not in paset]
	for p in plist:
		p.display = True
		p.model.display = True
	from Midas import surfaceNew
	molcat = list(set([(a.molecule, a.surfaceCategory) for a in atoms]))
	if empty:
		# Only surface main category if nothing selected.
		molcat = [mc for mc in molcat if mc[1] == 'main']
	molcat.sort(lambda mc1,mc2: cmp(mc1[0].id, mc2[0].id))
	for mol, cat in molcat:
		surfaceNew(cat, models=[mol])
Exemplo n.º 6
0
def transpSurf(amount):
    if amount != -1:
        aopacity = opacity = min(1.0, 1 - amount)
    else:
        opacity = 1
        aopacity = -1
    atoms = selAtoms()
    import Midas
    surfatoms = Midas.atomMSMSModels(atoms)
    for s, atoms in surfatoms.items():
        adjustMSMSTransparency(s, atoms, opacity, aopacity)

    splist = selectedSurfacePieces(implied=True)
    from chimera import MSMSModel
    for p in splist:
        s = p.model
        if isinstance(s, MSMSModel) and s.molecule:
            adjustMSMSTransparency(s, s.atoms, opacity, aopacity)
        else:
            adjustSurfacePieceTransparency(p, opacity)

    if (len(atoms) > 0 and not selection.currentEmpty() and len(surfatoms) == 0
            and len(splist) == 0):
        from replyobj import warning
        warning('No surfaces shown for selected atoms.\n')
Exemplo n.º 7
0
	def NDBColors(self):
		from chimera import selection
		if selection.currentEmpty():
			import Midas
			residues = Midas._selectedResidues('#')
		else:
			residues = selection.currentResidues()
		NA.NDBColors(residues)
Exemplo n.º 8
0
def extendSelection(objects,
                    objectName,
                    noneReturnsAll=True,
                    implied=False,
                    create=False):
    if not objects and noneReturnsAll and selection.currentEmpty():
        objects.extend(allObjects(objectName))
    elif implied:
        addImpliedSelection(objects, objectName, create, noneReturnsAll)
Exemplo n.º 9
0
def outline_box():
  'Toggle outline boxes for selected volumes'
  from VolumeViewer import volume_list, Volume
  from chimera import selection
  if selection.currentEmpty():
    vlist = volume_list()
  else:
    vlist = [v for v in selection.currentGraphs() if isinstance(v, Volume)]
  for v in vlist:
    if v.display:
      shown = v.rendering_options.show_outline_box
      v.set_parameters(show_outline_box = not shown)
      v.show()
def outline_box():
    'Toggle outline boxes for selected volumes'
    from VolumeViewer import volume_list, Volume
    from chimera import selection
    if selection.currentEmpty():
        vlist = volume_list()
    else:
        vlist = [v for v in selection.currentGraphs() if isinstance(v, Volume)]
    for v in vlist:
        if v.display:
            shown = v.rendering_options.show_outline_box
            v.set_parameters(show_outline_box=not shown)
            v.show()
Exemplo n.º 11
0
def selectedSurfacePieces(excludeMSMS = False, noneReturnsAll = True,
			  implied = False):
	import Surface
	if noneReturnsAll and selection.currentEmpty():
		plist = Surface.all_surface_pieces()
	else:
		plist = Surface.selected_surface_pieces()
		if implied and surfacesWithAtomsAndBonds():
			atoms = selAtoms(noneReturnsAll)
			bonds = selBonds(noneReturnsAll)
			pset = set(plist)
			pab = atomAndBondSurfacePieces(atoms, bonds)
			plist.extend([p for p in pab if p not in pset])
	if excludeMSMS:
		plist = [p for p in plist
			 if (not isinstance(p.model, chimera.MSMSModel)
			     or p.model.molecule is None)]
	return plist
Exemplo n.º 12
0
def selectedSurfacePieces(excludeMSMS=False,
                          noneReturnsAll=True,
                          implied=False):
    import Surface
    if noneReturnsAll and selection.currentEmpty():
        plist = Surface.all_surface_pieces()
    else:
        plist = Surface.selected_surface_pieces()
        if implied and surfacesWithAtomsAndBonds():
            atoms = selAtoms(noneReturnsAll)
            bonds = selBonds(noneReturnsAll)
            pset = set(plist)
            pab = atomAndBondSurfacePieces(atoms, bonds)
            plist.extend([p for p in pab if p not in pset])
    if excludeMSMS:
        plist = [
            p for p in plist if (not isinstance(p.model, chimera.MSMSModel)
                                 or p.model.molecule is None)
        ]
    return plist
Exemplo n.º 13
0
	def setFixed(self, which):
		from chimera import selection
		if which == "none" or selection.currentEmpty():
			for ma in self.universe.atomList():
				ma.fixed = False
		elif which == "selected":
			import chimera
			for ma in self.universe.atomList():
				ma.fixed = False
			for a in selection.currentAtoms():
				if a.molecule in self.mols:
					ma = self.atomMap[a]
					ma.fixed = True
		else:
			import chimera
			for ma in self.universe.atomList():
				ma.fixed = True
			for a in selection.currentAtoms():
				if a.molecule in self.mols:
					ma = self.atomMap[a]
					ma.fixed = False
Exemplo n.º 14
0
 def setFixed(self, which):
     from chimera import selection
     if which == "none" or selection.currentEmpty():
         for ma in self.universe.atomList():
             ma.fixed = False
     elif which == "selected":
         import chimera
         for ma in self.universe.atomList():
             ma.fixed = False
         for a in selection.currentAtoms():
             if a.molecule in self.mols:
                 ma = self.atomMap[a]
                 ma.fixed = True
     else:
         import chimera
         for ma in self.universe.atomList():
             ma.fixed = True
         for a in selection.currentAtoms():
             if a.molecule in self.mols:
                 ma = self.atomMap[a]
                 ma.fixed = False
Exemplo n.º 15
0
def focus():
	disped = [x for x in selAtoms() + selBonds() if x.shown()]
	ribbons = [x for x in selResidues()
		   if x.ribbonDisplay and x.hasRibbon() and x.molecule.display]
	disped.extend(ribbons)
	disped.extend([p for p in selectedSurfacePieces()
		       if p.display and p.model.display and p.triangleCount > 0])
	if not disped:
		from chimera import replyobj
		replyobj.error(
			"No target atoms/bonds/ribbons/surfaces currently shown\n")
		return
	sel = selection.ItemizedSelection()
	sel.add(disped)
	sel.addImplied(edges=False)
	from Midas import window, cofr
	window(sel)
	from chimera import openModels as om
	if selection.currentEmpty():
		from chimera import viewing, viewer
		om.cofrMethod = viewing.defaultCofrMethod
		viewer.clipping = False
	else:
		om.cofrMethod = om.CenterOfView
Exemplo n.º 16
0
def extendSelection(objects, objectName, noneReturnsAll=True,
		    implied=False, create=False):
	if not objects and noneReturnsAll and selection.currentEmpty():
		objects.extend(allObjects(objectName))
	elif implied:
		addImpliedSelection(objects, objectName, create, noneReturnsAll)
Exemplo n.º 17
0
	def Apply(self):
		from chimera import selection
		if not self.restrict.get() or selection.currentEmpty():
			molecules = chimera.openModels.list(
						modelTypes=[chimera.Molecule])
			residues = []
			for mol in molecules:
				residues.extend(mol.residues)
		else:
			residues = selection.currentResidues()
			molecules = tuple(set(r.molecule for r in residues))
		residues = [r for r in residues
					if r.ribbonResidueClass.isNucleic()]

		backbone = self.showBackbone.get()
		display = backbone != 'atoms & bonds'
		for r in residues:
			r.ribbonDisplay = display

		side = self.showSide.get()
		if side == 'ladder':
			distSlop = 0.0
			angleSlop = 0.0
			relax = self.relaxParams.relaxConstraints
			if relax:
				distSlop = self.relaxParams.relaxDist
				angleSlop = self.relaxParams.relaxAngle
			NA.set_ladder(molecules, residues,
				rungRadius=self.rungRadius.get(),
				showStubs=self.showStubs.get(),
				skipNonBaseHBonds=self.skipNonBase.get(),
				useExisting=self.useExisting.get(),
				distSlop=distSlop, angleSlop=angleSlop)
			return
		if side.endswith('slab'):
			if self.currentStyle is None:
				info = self._getInfo()
				NA.addStyle(None, info)
			showGly = self.anchor.get() != NA.SUGAR
			if showGly and side.startswith('tube'):
				showGly = self.showGlycosidic.get()
			NA.set_slab(side, molecules, residues,
				style=self.currentStyle,
				thickness=self.thickness.get(),
				orient=self.showOrientation.get(),
				shape=self.shape.get(), showGly=showGly,
				hide=self.hideBases.get())
		if side.startswith('fill'):
			for r in residues:
				r.fillDisplay = True
		else:
			for r in residues:
				r.fillDisplay = False
		if side.endswith('fill'):
			if self.showOrientation.get():
				NA.set_orient(molecules, residues)
			else:
				NA.set_normal(molecules, residues)
		elif side.startswith('atoms'):
			NA.set_normal(molecules, residues)
		return