# ----------------------------------------------------------------------------- # Place a new atom some distance past a specified atom along a ray from the # center of mass of the molecule. # def place_atom(near_atom, distance, element, atom_name, residue_name, residue_number): m = near_atom.molecule d = near_atom.coord() - center_of_mass(m) # Vector from center to atom d.normalize() xyz = near_atom.coord() + distance*d from chimera import MolResId a = m.newAtom(atom_name, element) r = m.newResidue(residue_name, MolResId(residue_number)) r.addAtom(a) a.setCoord(xyz) # Set atom coordinates a.drawMode = a.Sphere # Set display style to sphere # ----------------------------------------------------------------------------- # def center_of_mass(molecule): from Measure.inertia import atoms_inertia c = atoms_inertia(molecule.atoms)[2] # Center of mass coordinates from chimera import Point p = Point(*c) # Transform from global coordinates to molecule coordinate system. pm = molecule.openState.xform.inverse().apply(p) return pm # ----------------------------------------------------------------------------- # Place a helium atom 2A past a selected atom along a ray from the center of # mass of the molecule. # from chimera import selection atoms = selection.currentAtoms() if len(atoms) != 1: from chimera.replyobj import error error("Need to select exactly one atom") else: from chimera import elements place_atom(atoms[0], 2, elements.He, 'X', 'R1', 1000)