def atomsel(self): """ Returns respective 'VMD.atomsel' instance. """ if self._atomsel is None: self._atomsel = _atomsel('segname "%s"' % self.name, frame=self._frame, molid=self._molecule.molid) return self._atomsel
def atomsel(self): """ Returns respective 'VMD.atomsel' instance. """ if self._atomsel is None: self._atomsel = _atomsel('residue %d' % self._index, frame=self._frame, molid=self._molecule.molid) return self._atomsel
def __init__(self, selection, molecule=None, frame=NOW): """ Creates selection. @param selection: Selection text @param molecule: Molecule to select from. Top if not provider. @type molecule: Molecule or None @param frame: Selection frame @type frame: Non-negative integer or NOW """ super(Selection, self).__init__(molecule=molecule, frame=frame) self._selection = selection # No need to delay creation of the atomsel. This also checks if the selection text makes sense. self._atomsel = _atomsel(selection, frame=frame, molid=self._molecule.molid) # _update_frame is the frame that have been used to filter coordinate based selection in last update. self._update_frame = self._get_active_frame()
def pick(cls, selection, molecule=None, frame=NOW): """ Creates atom from selection text. @param selection: Selection text @param molecule: Molecule to select from. Top if not defined. @type molecule: Molecule @param frame: Atom's frame @type frame: Non-negative integer or NOW """ if molecule is None: molecule = MOLECULES.top else: assert isinstance(molecule, Molecule) assert frame == NOW or frame >= 0 sel = _atomsel(selection, frame=frame, molid=molecule.molid) if len(sel) != 1: raise ValueError("Selection '%s' doesn't define single atom in '%s' at %s" % (selection, molecule, frame)) self = cls(sel.get('index')[0], molecule, frame) return self