def rotate(molecule, at, alpha): if len(at) == 3: try: a1, a2, a3 = [a.coord() for a in at] except AttributeError: a1, a2, a3 = at axis_a = a1 - a2 axis_b = a3 - a2 delta = chimera.angle(a1, a2, a3) - alpha axis = chimera.cross(axis_a, axis_b) if axis.data() == (0.0, 0.0, 0.0): axis = chimera.cross(axis_a, axis_b + chimera.Vector(1, 0, 0)) logger.warning("Had to choose arbitrary normal vector") pivot = a2 elif len(at) == 4: try: a1, a2, a3, a4 = [a.coord() for a in at] except AttributeError: a1, a2, a3, a4 = at axis = a3 - a2 delta = chimera.dihedral(a1, a2, a3, a4) - alpha pivot = a3 else: raise ValueError( "Atom list must contain 3 (angle) or 4 (dihedral) atoms only") r = X.translation(pivot - ZERO) # move to origin r.multiply(X.rotation(axis, -delta)) # rotate r.multiply(X.translation(ZERO - pivot)) # return to orig pos for a in molecule.atoms: a.setCoord(r.apply(a.coord()))
def symmetry_xform(mol_xform, sym_xform, ref_xform): from chimera import Xform xf = Xform(mol_xform) xf.premultiply(ref_xform.inverse()) xf.premultiply(sym_xform) xf.premultiply(ref_xform) return xf
def triangle_transformation(t1, t2): tf1 = triangle_frame(t1) tf2 = triangle_frame(t2) xf = frame_transform(tf1, tf2) c1 = center(t1) from chimera import Xform xf.multiply(Xform.translation(-c1[0], -c1[1], -c1[2])) c2 = center(t2) xf.premultiply(Xform.translation(c2[0], c2[1], c2[2])) return xf
def rotate_mouse_drag_cb(self, viewer, event): # Get rotation about origin. xf = viewer.vsphere(event.time, event.x, event.y, event.state % 2 == 1) cx, cy, cz = self.rotation_center # Change center of rotation to act about center of movable objects. from chimera import Xform xf.multiply(Xform.translation(-cx, -cy, -cz)) xf.premultiply(Xform.translation(cx, cy, cz)) self.move_objects(xf)
def rotation_axis_angle(r): from chimera import Xform xf = Xform.xform(r[0][0], r[0][1], r[0][2], 0, r[1][0], r[1][1], r[1][2], 0, r[2][0], r[2][1], r[2][2], 0) axis, angle = xf.getRotation() return tuple(axis.data()), angle
def rotation_from_axis_angle(axis, angle): from chimera import Xform, Vector r = Xform.rotation(Vector(*axis), angle) m = r.getOpenGLMatrix() rm = ((m[0], m[4], m[8]), (m[1], m[5], m[9]), (m[2], m[6], m[10])) return rm
def map_overlap_and_correlation(map1, map2, above_threshold, xform = None): p, w1 = map_points_and_weights(map1, above_threshold) if xform is None: from chimera import Xform xform = Xform() w2 = map2.interpolated_values(p, xform, subregion = None, step = None) return overlap_and_correlation(w1, w2)
def euler_rotation(phi, theta, psi): from chimera import Xform, Vector xf1 = Xform.rotation(Vector(0, 0, 1), phi) # Rotate about z-axis xp = xf1.apply(Vector(1, 0, 0)) # New x-axis xf2 = Xform.rotation(xp, theta) # Rotate about new x-axis zp = xf2.apply(Vector(0, 0, 1)) # New z-axis xf3 = Xform.rotation(zp, psi) # Rotate about new z-axis xf = Xform() xf.premultiply(xf1) xf.premultiply(xf2) xf.premultiply(xf3) return xf
def atoms_outside_contour(atoms, volume = None): if volume is None: from VolumeViewer import active_volume volume = active_volume() points = atom_coordinates(atoms) from chimera import Xform poc, clevel = points_outside_contour(points, Xform(), volume) return poc, clevel
def translate(molecule, anchor, target): if isinstance(anchor, chimera.Atom): anchor = anchor.coord() if isinstance(target, chimera.Atom): target = target.coord() t = X.translation(target - anchor) for a in molecule.atoms: a.setCoord(t.apply(a.coord()))
def atoms_outside_map(atoms, dr, contour_level): from _multiscale import get_atom_coordinates xyz = get_atom_coordinates(atoms, transformed=True) from chimera import Xform values = dr.interpolated_values(xyz, Xform()) from numpy import compress aolist = list(compress(values < contour_level, atoms)) return aolist
def same_xform(xf1, xf2, angle_tolerance=0, shift_tolerance=0): if angle_tolerance == 0 and shift_tolerance == 0: return xf1.getOpenGLMatrix() == xf2.getOpenGLMatrix() from chimera import Xform xf = Xform() xf.multiply(xf1) xf.multiply(xf2.inverse()) trans = xf.getTranslation() axis, angle = xf.getRotation() if (abs(angle) > angle_tolerance or trans.length > shift_tolerance): return False return True
def show_cumulative_transform(self, m): from chimera import Xform mxf = getattr(m, 'applied_xform', Xform()) import Matrix tf = Matrix.xform_matrix(mxf) angles = Matrix.euler_angles(tf) shift = mxf.getTranslation().data() text = ('Cumulative:\n' + ' Euler angles %.5g %.5g %.5g\n' % angles + ' Shift: %.5g %.5g %.5g' % shift) self.cumulative['text'] = text
def coordinate_transform_xforms(xflist, from_xf, to_xf): cxf = from_xf.inverse() cxf.multiply(to_xf) cxfinv = cxf.inverse() from chimera import Xform xftlist = [] for xf in xflist: xft = Xform() xft.multiply(cxfinv) xft.multiply(xf) xft.multiply(cxf) xftlist.append(xft) return xftlist
def addDihedralBond(a1, a2, length, angleInfo, dihedInfo): """Make bond between two models. The models will be combined and the originals closed. The new model will be opened in the same id/subid as the non-moving model. a1/a2 are atoms in different models. a2 and atoms in its model will be moved to form the bond. 'length' is the bond length. 'angleInfo' is a two-tuple of sequence of three atoms and an angle that the three atoms should form. 'dihedInfo' is like 'angleInfo', but 4 atoms. angleInfo/dihedInfo can be None if insufficient atoms """ if a1.molecule == a2.molecule: raise ValueError("Atoms to be bonded must be in different models") # first, get the distance correct from chimera import Xform, cross, angle, Point dvector = a1.xformCoord() - a2.xformCoord() dvector.length = dvector.length + length openState = a2.molecule.openState openState.globalXform(Xform.translation(dvector)) # then angle if angleInfo: atoms, angleVal = angleInfo p1, p2, p3 = [a.xformCoord() for a in atoms] axis = cross(p1-p2, p2-p3) curAngle = angle(p1, p2, p3) delta = angleVal - curAngle v2 = p2 - Point(0.0, 0.0, 0.0) trans1 = Xform.translation(v2) v2.negate() trans2 = Xform.translation(v2) trans1.multiply(Xform.rotation(axis, delta)) trans1.multiply(trans2) openState.globalXform(trans1)
def addDihedralBond(a1, a2, length, angleInfo, dihedInfo): """Make bond between two models. The models will be combined and the originals closed. The new model will be opened in the same id/subid as the non-moving model. a1/a2 are atoms in different models. a2 and atoms in its model will be moved to form the bond. 'length' is the bond length. 'angleInfo' is a two-tuple of sequence of three atoms and an angle that the three atoms should form. 'dihedInfo' is like 'angleInfo', but 4 atoms. angleInfo/dihedInfo can be None if insufficient atoms """ if a1.molecule == a2.molecule: raise ValueError("Atoms to be bonded must be in different models") # first, get the distance correct from chimera import Xform, cross, angle, Point dvector = a1.xformCoord() - a2.xformCoord() dvector.length = dvector.length + length openState = a2.molecule.openState openState.globalXform(Xform.translation(dvector)) # then angle if angleInfo: atoms, angleVal = angleInfo p1, p2, p3 = [a.xformCoord() for a in atoms] axis = cross(p1 - p2, p2 - p3) curAngle = angle(p1, p2, p3) delta = angleVal - curAngle v2 = p2 - Point(0.0, 0.0, 0.0) trans1 = Xform.translation(v2) v2.negate() trans2 = Xform.translation(v2) trans1.multiply(Xform.rotation(axis, delta)) trans1.multiply(trans2) openState.globalXform(trans1)
def anglePos(atomPos, bondPos, bondLength, degrees, coplanar=None): if coplanar: # may have one or two coplanar positions specified, # if two, compute both resultant positions and average # (the up vector has to be negated for the second one) xforms = [] if len(coplanar) > 2: raise ValueError, \ "More than 2 coplanar positions specified!" for cpos in coplanar: up = cpos - atomPos if xforms: up.negate() xform = Xform.lookAt(atomPos, bondPos, up) # lookAt puts ref point opposite that of zAlign, so # rotate 180 degrees around y axis xform.premultiply(Xform.yRotation(180)) xforms.append(xform) else: xforms = [Xform.zAlign(atomPos, bondPos)] points = [] for xform in xforms: radians = pi * degrees / 180.0 angle = Point(0.0, bondLength * sin(radians), bondLength * cos(radians)) xform.invert() points.append(xform.apply(angle)) if len(points) > 1: midpoint = points[0] + (points[1] - points[0]) / 2.0 v = midpoint - atomPos v.length = bondLength return atomPos + v return points[0]
def update(self, trigName, myData, changes): # print >> __stdout__, "update", trigName, myData, dir(changes), changes.modified # coordSet = list(changes.modified)[0] # print >> __stdout__, len(coordSet.coords()) # print >> __stdout__, dir(coordSet) # print >> __stdout__, "update" # atoms = [] # for selection in xla.get_gui().Subunits.getMovableAtomSpecs(): # atoms.extend(evalSpec(selection).atoms()) for serie in self.series: serie['new'] = [] for chainId in serie['chainIds']: atoms = evalSpec(':.{0}'.format(chainId)).atoms() serie['new'].append(numpyArrayFromAtoms(atoms)) # if self.was_changed(): i = 0 changed_c = None for old_c, new_c in zip(serie['old'], serie['new']): if not (old_c == new_c).all(): changed_c = i i = i + 1 if changed_c is not None: other = set(range(len(serie['chainIds']))) other.remove(changed_c) t3d, rmsd = matchPositions(serie['new'][changed_c], serie['old'][changed_c]) for o in other: newT = Xform.identity() newT.premultiply(serie['t3ds'][o][changed_c]) newT.premultiply(t3d) newT.premultiply(serie['t3ds'][changed_c][o]) atoms = evalSpec(':.{0}'.format( serie['chainIds'][o])).atoms() for a in atoms: a.setCoord(newT.apply(a.coord())) serie['old'] = [] for chainId in serie['chainIds']: atoms = evalSpec(':.{0}'.format(chainId)).atoms() serie['old'].append(numpyArrayFromAtoms(atoms))
def update(self, trigName, myData, changes): # print >> __stdout__, "update", trigName, myData, dir(changes), changes.modified # coordSet = list(changes.modified)[0] # print >> __stdout__, len(coordSet.coords()) # print >> __stdout__, dir(coordSet) # print >> __stdout__, "update" # atoms = [] # for selection in xla.get_gui().Subunits.getMovableAtomSpecs(): # atoms.extend(evalSpec(selection).atoms()) for serie in self.series: serie['new'] = [] for chainId in serie['chainIds']: atoms = evalSpec(':.{0}'.format(chainId)).atoms() serie['new'].append(numpyArrayFromAtoms(atoms)) # if self.was_changed(): i = 0 changed_c = None for old_c, new_c in zip(serie['old'], serie['new']): if not (old_c == new_c).all(): changed_c = i i = i + 1 if changed_c is not None: other = set(range(len(serie['chainIds']))) other.remove(changed_c) t3d, rmsd = matchPositions(serie['new'][changed_c], serie['old'][changed_c]) for o in other: newT = Xform.identity() newT.premultiply(serie['t3ds'][o][changed_c]) newT.premultiply(t3d) newT.premultiply(serie['t3ds'][changed_c][o]) atoms = evalSpec(':.{0}'.format(serie['chainIds'][o])).atoms() for a in atoms: a.setCoord(newT.apply(a.coord())) serie['old'] = [] for chainId in serie['chainIds']: atoms = evalSpec(':.{0}'.format(chainId)).atoms() serie['old'].append(numpyArrayFromAtoms(atoms))
def orthogonalize(r): from chimera import Xform xf = Xform.xform(r[0][0], r[0][1], r[0][2], 0, r[1][0], r[1][1], r[1][2], 0, r[2][0], r[2][1], r[2][2], 0, orthogonalize=True) ro = xform_matrix(xf) ro33 = tuple([row[:3] for row in ro]) return ro33
def position_orthoviews(tv): # Put all 3 planes in xy plane. vx, vy, vz = tv from chimera import Xform vx.openState.localXform(Xform.xRotation(-90)) vx.openState.localXform(Xform.zRotation(-90)) vy.openState.localXform(Xform.xRotation(-90)) vy.openState.localXform(Xform.zRotation(180)) # Horz/vert axes vx:(y,z), vy:(x,z), vz:(x,y) sizes = [] for v in tv: (x0, y0, z0), (x1, y1, z1) = v.xyz_bounds(step=1, subregion='all') sizes.append((x1 - x0, y1 - y0, z1 - z0)) # Align lower left corners vy.openState.localXform(Xform.translation(-sizes[1][0])) # Center vertically and spread out horizontally. vx.openState.localXform(Xform.translation(0, 0, -0.5 * sizes[0][2])) offset = 1.05 * sizes[0][1] vy.openState.localXform(Xform.translation(offset, 0, -0.5 * sizes[1][2])) offset += .05 * sizes[0][1] + sizes[1][0] vz.openState.localXform(Xform.translation(offset, -0.5 * sizes[2][1], 0)) # Hide all other models. from chimera import openModels mset = set(tv + [v.solid_model() for v in tv]) for m in openModels.list(): if not m in mset: m.display = False # Standard orientation, fit in window. from Midas import reset reset() from chimera import viewer viewer.viewAll() viewer.scaleFactor *= 0.95 viewer.depthCue = False
def translate_xy_mouse_drag_cb(self, viewer, event): px, py = self.previous_xy dx = event.x - px dy = event.y - py self.previous_xy = (event.x, event.y) psize = pixel_size_at_rotation_center(self.rotation_center) if event.state & 0x1: psize *= 0.1 # Slow motion when shift key held from chimera import Xform xf = Xform.translation(psize * dx, -psize * dy, 0) self.move_objects(xf) # Translate fixed rotation center. from chimera import openModels if openModels.cofrMethod == openModels.Fixed: openModels.cofr = xf.apply(openModels.cofr)
def accSynAnti(donor, donorHyds, acceptor, synAtom, planeAtom, synR2, synPhi, synTheta, antiR2, antiPhi, antiTheta): """'planeAtom' (in conjunction with acceptor, and with 'synAtom' defining the 'up' direction) defines a plane. If donor is on the same side as 'synAtom', use syn params, otherwise anti params. """ if base.verbose: print "accSynAnti" dc = donor.xformCoord() dp = dc ac = acceptor.xformCoord() ap = ac pp = planeAtom.xformCoord() sp = synAtom.xformCoord() synXform = Xform.lookAt(ap, pp, sp - pp) xdp = synXform.apply(dp) phiBasePos = pp phiPlane = [ap, pp, sp] if xdp.y > 0.0: if base.verbose: print "Syn" if donor.element.name == "S": # increase distance cutoff to allow for larger # vdw radius of sulphur (which isn't considered # considered as a donor in original paper) synR2 = sulphurCompensate(synR2) return testPhiPsi(dp, donorHyds, ap, phiBasePos, phiPlane, synR2, synPhi, synTheta) if base.verbose: print "Anti" if donor.element.name == "S": # increase distance to compensate for sulphur radius antiR2 = sulphurCompensate(antiR2) return testPhiPsi(dp, donorHyds, ap, phiBasePos, phiPlane, antiR2, antiPhi, antiTheta)
def map_points_and_weights(v, above_threshold, metric = 'sum product'): from chimera import Xform m, tf_inv = v.matrix_and_transform(Xform(), subregion = None, step = None) from Matrix import invert_matrix tf = invert_matrix(tf_inv) size = list(m.shape) size.reverse() from VolumeData import grid_indices from numpy import single as floatc, ravel, nonzero, take points = grid_indices(size, floatc) # i,j,k indices import _contour _contour.affine_transform_vertices(points, tf) weights = ravel(m).astype(floatc) if above_threshold: # Keep only points where density is above lowest displayed threshold threshold = min(v.surface_levels) from numpy import greater_equal, compress ge = greater_equal(weights, threshold) points = compress(ge, points, 0) weights = compress(ge, weights) if metric == 'correlation about mean': wm = weights.sum() / len(weights) weights -= wm else: # Eliminate points with zero weight. nz = nonzero(weights)[0] if len(nz) < len(weights): points = take(points, nz, axis=0) weights = take(weights, nz, axis=0) return points, weights
def findPt(n1, n2, n3, dist, angle, dihed): # cribbed from Midas addgrp command v12 = n2 - n1 v13 = n3 - n1 v12.normalize() x = cross(v13, v12) x.normalize() y = cross(v12, x) y.normalize() mat = [0.0] * 12 for i in range(3): mat[i * 4] = x[i] mat[1 + i * 4] = y[i] mat[2 + i * 4] = v12[i] mat[3 + i * 4] = n1[i] xform = Xform.xform(*mat) radAngle = pi * angle / 180.0 tmp = dist * sin(radAngle) radDihed = pi * dihed / 180.0 pt = Point(tmp * sin(radDihed), tmp * cos(radDihed), dist * cos(radAngle)) return xform.apply(pt)
def findPt(n1, n2, n3, dist, angle, dihed): # cribbed from Midas addgrp command v12 = n2 - n1 v13 = n3 - n1 v12.normalize() x = cross(v13, v12) x.normalize() y = cross(v12, x) y.normalize() mat = [0.0] * 12 for i in range(3): mat[i*4] = x[i] mat[1 + i*4] = y[i] mat[2 + i*4] = v12[i] mat[3 + i*4] = n1[i] xform = Xform.xform(*mat) radAngle = pi * angle / 180.0 tmp = dist * sin(radAngle) radDihed = pi * dihed / 180.0 pt = Point(tmp*sin(radDihed), tmp*cos(radDihed), dist*cos(radAngle)) return xform.apply(pt)
def __init__(self): self.m = chimera.openModels.list()[0] # Matchmaker yRvb12.hexamer.pdb, chain C (#1) with yRvb12.hexamer.pdb, chain A (#0), sequence alignment score = 1986.2 # with these parameters: # chain pairing: bb # Needleman-Wunsch using BLOSUM-62 # ss fraction: 0.3 # gap open (HH/SS/other) 18/18/6, extend 1 # ss matrix: # (H, O): -6 # (S, S): 6 # (H, H): 6 # (O, S): -6 # (O, O): 4 # (H, S): -9 # iteration cutoff: 2 # RMSD between 393 atom pairs is 0.001 angstroms # Position of yRvb12.hexamer.pdb (#0) relative to yRvb12.hexamer.pdb (#1) coordinates: # Matrix rotation and translation # -0.50000042 0.86602516 0.00000116 -103.53997515 # -0.86602516 -0.50000042 0.00000058 179.33655802 # 0.00000108 -0.00000072 1.00000000 0.00005125 # Axis -0.00000075 0.00000005 -1.00000000 # Axis point -0.00001174 119.55767842 0.00000000 # Rotation angle (degrees) 120.00002798 # Shift along axis 0.00003425 self.series = [ { 'tr3d': Xform.xform(-0.50000042, 0.86602516, 0.00000116, -103.53997515, -0.86602516, -0.50000042, 0.00000058, 179.33655802, 0.00000108, -0.00000072, 1.00000000, 0.00005125, orthogonalize=True), 'chainIds': ['A', 'C', 'E'], 'old': [], 'new': [] } ] # for a in evalSpec(':.A').atoms(): # a.setCoord(self.symTr3d.apply(a.coord())) for serie in self.series: serie['t3ds'] = [[None for i in range(len(serie['chainIds']))] for j in range(len(serie['chainIds']))] for i in range(len(serie['chainIds'])): # self.t3ds.append([]) for j in range(len(serie['chainIds'])): count = abs(j-i) symTr3d = Xform.identity() for c in range(count): symTr3d.multiply(serie['tr3d']) newT = Xform.identity() if i < j: newT = symTr3d elif i > j: newT = symTr3d.inverse() serie['t3ds'][i][j] = newT for chainId in serie['chainIds']: atoms = evalSpec(':.{0}'.format(chainId)).atoms() serie['old'].append(numpyArrayFromAtoms(atoms))
def check_space_navigator(self, trigger_name, d1, d2): e = self.device.last_event() if e is None: return rot, trans, buttons = e from math import sqrt, pow from chimera import Vector, Xform, viewer # Rotation rx, ry, rz = rot # 10 bits, signed, +/-512 rmag = sqrt(rx * rx + ry * ry + rz * rz) # Translation tx, ty, tz = trans # 10 bits, signed, +/-512 if self.zoom and not self.fly_mode: zm = tz tz = 0 else: zm = 0 tmag = sqrt(tx * tx + ty * ty + tz * tz) zmag = abs(zm) if self.dominant: if tmag < rmag or tmag < zmag: tmag = 0 if rmag < tmag or rmag < zmag: rmag = 0 if zmag < tmag or zmag < rmag: zmag = 0 if self.fly_mode: rt = 50 if abs(ry) > abs(rx) + rt and abs(ry) > abs(rz) + rt: rx = rz = 0 else: ry = 0 rmag = sqrt(rx * rx + ry * ry + rz * rz) if rmag > 0: axis = Vector(rx / rmag, ry / rmag, rz / rmag) if self.fly_mode: f = 3 else: f = 30 angle = self.speed * (f * rmag / 512) xf = Xform.rotation(axis, angle) self.apply_transform(xf) if tmag > 0: axis = Vector(tx / tmag, ty / tmag, tz / tmag) shift = axis * 0.15 * self.speed * viewer.viewSize * tmag / 512 xf = Xform.translation(shift) self.apply_transform(xf) if zmag != 0: f = pow(1.1, self.speed * float(zm) / 512) import Midas Midas.updateZoomDepth(viewer) try: viewer.scaleFactor *= f except ValueError: import chimera raise chimera.LimitationError("refocus to continue scaling") if 'N1' in buttons or 31 in buttons: self.view_all() if 'N2' in buttons: self.toggle_dominant_mode()
def check_space_navigator(self, trigger_name, d1, d2): e = self.device.last_event() if e is None: return rot, trans, buttons = e from math import sqrt, pow from chimera import Vector, Xform, viewer # Rotation rx, ry, rz = rot # 10 bits, signed, +/-512 rmag = sqrt(rx*rx + ry*ry + rz*rz) # Translation tx, ty, tz = trans # 10 bits, signed, +/-512 if self.zoom and not self.fly_mode: zm = tz tz = 0 else: zm = 0 tmag = sqrt(tx*tx + ty*ty + tz*tz) zmag = abs(zm) if self.dominant: if tmag < rmag or tmag < zmag: tmag = 0 if rmag < tmag or rmag < zmag: rmag = 0 if zmag < tmag or zmag < rmag: zmag = 0 if self.fly_mode: rt = 50 if abs(ry) > abs(rx)+rt and abs(ry) > abs(rz)+rt: rx = rz = 0 else: ry = 0 rmag = sqrt(rx*rx + ry*ry + rz*rz) if rmag > 0: axis = Vector(rx/rmag, ry/rmag, rz/rmag) if self.fly_mode: f = 3 else: f = 30 angle = self.speed*(f*rmag/512) xf = Xform.rotation(axis, angle) self.apply_transform(xf) if tmag > 0: axis = Vector(tx/tmag, ty/tmag, tz/tmag) shift = axis * 0.15 * self.speed * viewer.viewSize * tmag/512 xf = Xform.translation(shift) self.apply_transform(xf) if zmag != 0: f = pow(1.1, self.speed*float(zm)/512) import Midas Midas.updateZoomDepth(viewer) try: viewer.scaleFactor *= f except ValueError: import chimera raise chimera.LimitationError("refocus to continue scaling") if 'N1' in buttons or 31 in buttons: self.view_all() if 'N2' in buttons: self.toggle_dominant_mode()
def euler_xform(euler_angles, translation): xf = euler_rotation(*euler_angles) from chimera import Xform xf.premultiply(Xform.translation(*translation)) return xf
def __init__(self): self.m = chimera.openModels.list()[0] # Matchmaker yRvb12.hexamer.pdb, chain C (#1) with yRvb12.hexamer.pdb, chain A (#0), sequence alignment score = 1986.2 # with these parameters: # chain pairing: bb # Needleman-Wunsch using BLOSUM-62 # ss fraction: 0.3 # gap open (HH/SS/other) 18/18/6, extend 1 # ss matrix: # (H, O): -6 # (S, S): 6 # (H, H): 6 # (O, S): -6 # (O, O): 4 # (H, S): -9 # iteration cutoff: 2 # RMSD between 393 atom pairs is 0.001 angstroms # Position of yRvb12.hexamer.pdb (#0) relative to yRvb12.hexamer.pdb (#1) coordinates: # Matrix rotation and translation # -0.50000042 0.86602516 0.00000116 -103.53997515 # -0.86602516 -0.50000042 0.00000058 179.33655802 # 0.00000108 -0.00000072 1.00000000 0.00005125 # Axis -0.00000075 0.00000005 -1.00000000 # Axis point -0.00001174 119.55767842 0.00000000 # Rotation angle (degrees) 120.00002798 # Shift along axis 0.00003425 self.series = [{ 'tr3d': Xform.xform(-0.50000042, 0.86602516, 0.00000116, -103.53997515, -0.86602516, -0.50000042, 0.00000058, 179.33655802, 0.00000108, -0.00000072, 1.00000000, 0.00005125, orthogonalize=True), 'chainIds': ['A', 'C', 'E'], 'old': [], 'new': [] }] # for a in evalSpec(':.A').atoms(): # a.setCoord(self.symTr3d.apply(a.coord())) for serie in self.series: serie['t3ds'] = [[None for i in range(len(serie['chainIds']))] for j in range(len(serie['chainIds']))] for i in range(len(serie['chainIds'])): # self.t3ds.append([]) for j in range(len(serie['chainIds'])): count = abs(j - i) symTr3d = Xform.identity() for c in range(count): symTr3d.multiply(serie['tr3d']) newT = Xform.identity() if i < j: newT = symTr3d elif i > j: newT = symTr3d.inverse() serie['t3ds'][i][j] = newT for chainId in serie['chainIds']: atoms = evalSpec(':.{0}'.format(chainId)).atoms() serie['old'].append(numpyArrayFromAtoms(atoms))
import chimera from chimera import Plane, Xform, cross, Vector, Point m = chimera.openModels.list()[0] b = chimera.selection.currentBonds()[0] bondVec = b.atoms[0].coord() - b.atoms[1].coord() bondVec.normalize() axis = Vector(1.0, 0.0, 0.0) crossProd = cross(axis, bondVec) if crossProd.sqlength() > 0: from math import acos, degrees xform = Xform.rotation(crossProd, degrees(acos(axis * bondVec))) xform.invert() else: xform = Xform.identity() m.openState.xform = xform # okay, that puts the bond parallel to the X axis, now swing the plane of # the rest of the molecule into the xy plane... molPlane = Plane([a.xformCoord() for a in m.atoms[:3]]) angle = chimera.angle(molPlane.normal, Vector(0, 0, -1)) xform2 = Xform.rotation(b.atoms[0].xformCoord() - b.atoms[1].xformCoord(), angle) xform2.multiply(xform) m.openState.xform = xform2
import chimera from chimera import Plane, Xform, cross, Vector, Point m = chimera.openModels.list()[0] b = chimera.selection.currentBonds()[0] bondVec = b.atoms[0].coord() - b.atoms[1].coord() bondVec.normalize() axis = Vector(1.0, 0.0, 0.0) crossProd = cross(axis, bondVec) if crossProd.sqlength() > 0: from math import acos, degrees xform = Xform.rotation(crossProd, degrees(acos(axis * bondVec))) xform.invert() else: xform = Xform.identity() m.openState.xform = xform # okay, that puts the bond parallel to the X axis, now swing the plane of # the rest of the molecule into the xy plane... molPlane = Plane([a.xformCoord() for a in m.atoms[:3]]) angle = chimera.angle(molPlane.normal, Vector(0, 0, -1)) xform2 = Xform.rotation(b.atoms[0].xformCoord()-b.atoms[1].xformCoord(), angle) xform2.multiply(xform) m.openState.xform = xform2