def clip_selected_models(): 'Toggle per-model clipping for selected models' from chimera import selection, openModels mlist = [m for m in selection.currentGraphs() if m.display] if len(mlist) == 0: mlist = [m for m in openModels.list() if m.display and m.useClipPlane] if len(mlist) == 0: mlist = [m for m in openModels.list() if m.display] if len(mlist) == 0: return from chimera import tkgui for m in mlist: if m.useClipPlane: m.useClipPlane = False elif m.bbox()[0]: tkgui.setClipModel(m) # Set initial clip plane placement. # Turn off clip adjust mouse mode. cm = tkgui.getClipModel() if cm is None or not cm.useClipPlane: from chimera import dialogs import ModelClip cd = dialogs.find(ModelClip.ClipDialog.name) if cd: cd.stopMouseClip()
def activate_only(): 'Activate only selected models' from chimera import selection, Model osactive = set([ m.openState for m in selection.currentGraphs() if isinstance(m, Model) ]) osall = set([m.openState for m in chimera.openModels.list()]) for os in osall: os.active = (os in osactive)
def mark_zero(): from VolumePath import place_marker, show_volume_path_dialog from chimera import selection as s, Point mlist = s.currentGraphs() if len(mlist) == 0: place_marker((0, 0, 0)) else: for m in mlist: m0 = m.openState.xform.apply(Point(0, 0, 0)).data() place_marker(m0) show_volume_path_dialog()
def test(spacing=200.0, tip_length=50): from Segger.regions import Segmentation from chimera import selection segs = [ m for m in selection.currentGraphs() if isinstance(m, Segmentation) ] for seg in segs: for r in seg.selected_regions(): mset = trace_spine(r, spacing, tip_length, r.color) mset.region = r
def mark_zero(): from VolumePath import place_marker, show_volume_path_dialog from chimera import selection as s, Point mlist = s.currentGraphs() if len(mlist) == 0: place_marker((0,0,0)) else: for m in mlist: m0 = m.openState.xform.apply(Point(0,0,0)).data() place_marker(m0) show_volume_path_dialog()
def _selChangeCB(self, *args): selGraphs = set(selection.currentGraphs()) itemModels = set([item.model for item in geomManager.items]) selItems = selGraphs & itemModels chosenItems = set([item.model for item in self.table.selected()]) if chosenItems != selItems: items = [item for item in geomManager.items if item.model in selItems] self.table.select(items) if self.geomSelAtomsVar.get(): self._itemsSelectAtoms(items, add=True) self.feedback(items)
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()
def clip_adjust(): 'Toggle mouse modes to move per-model clip plane of selected model' from chimera import selection, openModels, tkgui mlist = [ m for m in selection.currentGraphs() if m.useClipPlane and m.display ] if len(mlist) == 0: mlist = [m for m in openModels.list() if m.useClipPlane and m.display] if clip_adjust_enabled(): if len(mlist) == 0 or tkgui.getClipModel() in mlist: enable_clip_adjust(False) else: tkgui.setClipModel(mlist[0]) elif mlist: enable_clip_adjust(mlist[0])
def _any_selected(self): from chimera import selection, Molecule, MSMSModel, PseudoBondGroup text = "" numAtoms = len(selection.currentAtoms()) if numAtoms: text = "%d atom" % numAtoms if numAtoms > 1: text += "s" numBonds = len(selection.currentBonds()) if numBonds: if text: text += ", " text += "%d bond" % numBonds if numBonds > 1: text += "s" numEdges = len(selection.currentEdges()) if numEdges != numBonds: if text: text += ", " numPBonds = numEdges - numBonds text += "%d pbond" % numPBonds if numPBonds > 1: text += "s" graphs = selection.currentGraphs() numSurfs = numObjs = 0 for g in graphs: if isinstance(g, (Molecule, PseudoBondGroup)): continue if isinstance(g, MSMSModel) or "surf" in g.__class__.__name__.lower(): numSurfs += 1 else: numObjs += 1 if numSurfs: if text: text += ", " text += "%d surf" % numSurfs if numSurfs > 1: text += "s" if numObjs: if text: text += ", " text += "%d obj" % numObjs if numObjs > 1: text += "s" import help if not text: help.register(self.selections_button, balloon="no selection") show_message("selection cleared", blankAfter=5) return False else: help.register(self.selections_button, balloon=text) if self.first_selection: self.first_selection = False show_message(text, followWith="up-arrow to increase selection " "(atoms->residues->chains etc.)") else: show_message(text) return True
def unselModels(): from chimera.selection import currentGraphs selModels = currentGraphs(asDict=True) return filter(lambda m: m not in selModels, chimera.openModels.list())
rc("open " + fn) #Add Gasteiger charges initiateAddCharges(method='gasteiger', nogui=True) rc('surface vertexDensity 2') # Add surface to molecule rc('coulombic -10 red 0 white 10 blue' ) # Colr surface by coulombic charge rc( 'select' ) # Select the molecule from the model panel, also selects the surface for processing #------------------------------------------------------------------ # Surface processing #------------------------------------------------------------------ #Surface processing section slist = [m for m in selection.currentGraphs() if isinstance(m, MSMSModel) ] # initiates selected surface to object vertices = [] # empty list to populate with vertices s = slist[0] # takes the surface from the surface object p = s.surfacePieces[0] # Function of MSMSModel va, ta = p.geometry #Extract the list of vertices and triangles rgba = p.vertexColors ''' coords = [] for i, v in enumerate(va): x, y, z = v #Get cartesian coordinates of vertex point = (x, y, z) #Convert coords to tuple.....durh, probably could have just used the v vertex object here coords.append(point) #Add the distance to the coords list '''
def unselModels(): from chimera.selection import currentGraphs selModels = currentGraphs(asDict=True) return filter(lambda m: m not in selModels, chimera.openModels.list())
def _any_selected(self): from chimera import selection, Molecule, MSMSModel, PseudoBondGroup text = "" numAtoms = len(selection.currentAtoms()) if numAtoms: text = "%d atom" % numAtoms if numAtoms > 1: text += "s" numBonds = len(selection.currentBonds()) if numBonds: if text: text += ", " text += "%d bond" % numBonds if numBonds > 1: text += "s" numEdges = len(selection.currentEdges()) if numEdges != numBonds: if text: text += ", " numPBonds = numEdges - numBonds text += "%d pbond" % numPBonds if numPBonds > 1: text += "s" graphs = selection.currentGraphs() numSurfs = numObjs = 0 for g in graphs: if isinstance(g, (Molecule, PseudoBondGroup)): continue if isinstance(g, MSMSModel) or "surf" in g.__class__.__name__.lower(): numSurfs += 1 else: numObjs += 1 if numSurfs: if text: text += ", " text += "%d surf" % numSurfs if numSurfs > 1: text += "s" if numObjs: if text: text += ", " text += "%d obj" % numObjs if numObjs > 1: text += "s" import help if not text: help.register(self.selections_button, balloon="no selection") show_message("selection cleared", blankAfter=5) return False else: help.register(self.selections_button, balloon=text) if self.first_selection: self.first_selection = False show_message(text, followWith="up-arrow to increase selection " "(atoms->residues->chains etc.)") else: show_message(text) return True