def align_com(reference, probe, **kwargs): ref_com = np.average([a.xformCoord() for a in reference.atoms], axis=0) probe_com = np.average([a.xformCoord() for a in probe.atoms], axis=0) translation_v = chimera.Point(*ref_com) - chimera.Point(*probe_com) xform = probe.openState.xform.translation(translation_v) _transform_molecule(probe, xform) return 1000.
def CylMesh (r1, r2, Length, div, color, xf) : v = None vi = [] # print "CylinderMesh:", div at = 0 for psi_i in range(div) : psi = float(psi_i) * 360.0/float(div) #print "%.0f(%d)(%d)" % (psi, at, at-l), x1 = r1 * numpy.sin(psi * numpy.pi/180) y1 = r1 * numpy.cos(psi * numpy.pi/180) x2 = r2 * numpy.sin(psi * numpy.pi/180) y2 = r2 * numpy.cos(psi * numpy.pi/180) p = chimera.Point ( x1,y1,0 ); if xf : p = xf.apply ( p ) if psi_i == 0 : v = numpy.array( [ [p[0], p[1], p[2]], ], numpy.float32 ) else : pt1 = numpy.array( [ [p[0], p[1], p[2]], ], numpy.float32 ) v = numpy.concatenate ( [v, pt1] ) p = chimera.Point ( x2,y2,Length ); if xf : p = xf.apply ( p ) pt2 = numpy.array( [ [p[0], p[1], p[2]], ], numpy.float32 ) v = numpy.concatenate ( [v, pt2] ) at = at + 2 if psi_i == 0 : pass else : tris = Quad2Tri ( [at-3, at-1, at-2, at-4] ) vi.extend(tris) if psi_i == div-1 : tris = Quad2Tri ( [at-1, 1, 0, at-2] ) vi.extend(tris) p = chimera.Point ( 0,0,0 ); if xf : p = xf.apply ( p ) pt1 = numpy.array( [ [p[0], p[1], p[2]], ], numpy.float32 ) v = numpy.concatenate ( [v, pt1] ) p = chimera.Point ( 0,0,Length ); if xf : p = xf.apply ( p ) pt1 = numpy.array( [ [p[0], p[1], p[2]], ], numpy.float32 ) v = numpy.concatenate ( [v, pt1] ) return v, vi
def orientPlanarRing(atoms, ringIndices=[], convex=True): r = atoms[0].residue if not r.fillDisplay or r.fillMode != chimera.Residue.Thick: # can't show orientation of thin nor aromatic ring return [] pts = [a.coord() for a in atoms] bonds = bondsBetween(atoms) if chimera.Bond.Wire in [b.drawMode for b in bonds]: radius = 0 else: radius = min([b.radius for b in bonds]) radius *= atoms[0].molecule.stickScale color_kwds = _atom_color(atoms[0]) if radius == 0: # can't show orientation of thin ring return [] # non-zero radius planeEq = chimera.Plane(pts) offset = planeEq.normal * radius result = [] for r in ringIndices: center = chimera.Point([pts[i] for i in r]) + offset t = vrml.Transform() t.translation = center.data() s = vrml.Sphere(radius=radius, **color_kwds) t.addChild(s) result.append(t) return result
def find_coordinating_residues(tree, site, within=(3.5, 7), criteria='restype', strict_atom='CB', backbone=True): """ Given a protein, search for potential coordinating residues within `radius` A from `site` coordinates. This is, residues featuring a beta-carbon within r and 2*r from site. """ residues = set() within_top, within_bottom = max(within), min(within) nearby_atoms = tree.searchTree(site, within_bottom) site_point = chimera.Point(*site) for atom in nearby_atoms: if backbone and atom.name == 'O' and any( [a.name == 'C' for a in atom.neighbors]): residues.add(atom.residue) elif atom.residue.type in COORDINATING_RESIDUES: if strict_atom: try: cb_atom = atom.residue.atomsMap[strict_atom][0] except KeyError: continue if within_top >= cb_atom.coord().distance( site_point) >= within_bottom: residues.add(atom.residue) else: residues.add(atom.residue) return residues
def set_metal_contacts(self, radius): """ For the metals given, sets the contacts of this atom that are within a "radius" distance from that metal """ contacts = [] # If a metal in "all_metals" is a direct neighbor of this residue, # then it's definitely a contact, regardless of radius, and doesn't # need to be considered further metals_temp = self.all_metals metals = [] this_residue_label = self.residue_1_letter + str(self.number) for metal_potential in metals_temp: if this_residue_label in metal_potential.nearby_residues: contacts.append(metal_potential) else: metals.append(metal_potential) for metal in metals: metal_coords = [float(x) for x in metal.location.split(",")] distance = chimera.distance( self.atom.xformCoord(), chimera.Point(metal_coords[0], metal_coords[1], metal_coords[2]), ) if distance - ionicRadiusDict.get(metal.type, None) <= radius: contacts.append(metal) self.metal_contacts = contacts
def mol_translate(mol, p): for a in mol.atoms: x = a.coord().x + p[0] y = a.coord().y + p[1] z = a.coord().z + p[2] new_coord=chimera.Point(x,y,z) a.setCoord(new_coord)
def cvtMolecule(m): print '.comment', m.name mrad = m.DefaultBondRadius for a in m.atoms: # save color in singleton color = a.color if color is None: color = m.color _emit_color(color) coord = a.xformCoord() radius = a.radius * mrad print '.sphere %g %g %g %g' % (coord[0], coord[1], coord[2], radius) for b in m.bonds: # save color in singleton a0, a1 = b.atoms p0 = a0.xformCoord() p1 = a1.xformCoord() c0 = a0.color if c0 is None: c0 = m.color c1 = a1.color if c1 is None: c1 = m.color if c0 == c1: _emit_color(c0) print '.cylinder %g %g %g %g %g %g %g open' % ( p0[0], p0[1], p0[2], p1[0], p1[1], p1[2], mrad) else: mid = chimera.Point([p0, p1]) _emit_color(c0) print '.cylinder %g %g %g %g %g %g %g open' % ( p0[0], p0[1], p0[2], mid[0], mid[1], mid[2], mrad) _emit_color(c1) print '.cylinder %g %g %g %g %g %g %g open' % ( p1[0], p1[1], p1[2], mid[0], mid[1], mid[2], mrad)
def restore_state(self, model): model.name = self.name model.display = self.display model.openState.xform = self.xform.create_object() model.openState.active = self.active # # Record how model id number has been remapped. # if self.version >= 2: import SimpleSession if hasattr(SimpleSession, 'modelMap'): mid = (self.id, self.subid) SimpleSession.modelMap.setdefault(mid, []).append(model) else: from SimpleSession import updateOSLmap updateOSLmap(self.osl_identifier, model.oslIdent()) if self.version >= 3: p = model.clipPlane import chimera p.origin = chimera.Point(*self.clip_plane_origin) n = chimera.Vector(*self.clip_plane_normal) if n.length == 0: n = chimera.Vector(0, 0, -1) p.normal = n model.clipPlane = p model.clipThickness = self.clip_thickness model.useClipPlane = self.use_clip_plane if self.version >= 4: model.useClipThickness = self.use_clip_thickness
def unexpress(self): """ Set the original coordinates (stored at mol.coordSets[0]) as the active ones. """ for a, xyz in zip(self.molecule.compound.mol.atoms, self._original_xyz): a.setCoord(chimera.Point(*xyz))
def screen_center_at_near_clip_plane(): import chimera c = chimera.viewer.camera cx, cy, cz = c.center n, f = c.nearFar center = chimera.Point(cx, cy, n) return center
def chimera_coords_btn_cb(self, *args, **kwargs): molecules = self.bk_selected_molecules() if not molecules: return for bk_mol in molecules: chi_mol = self._new_chimera_molecule() for atom in bk_mol.atoms: a = chi_mol.addAtom(atom.name) a.setCoord(chimera.Point(atom.coords[:2]))
def express(self): """ Apply new coords as provided by current normal mode """ c2p = self._chimera2prody for atom in self.molecule.atoms: index = c2p[atom.serialNumber] new_coords = self.allele[index] atom.setCoord(chimera.Point(*new_coords))
def center_of_points(points): import chimera plist = map(lambda xyz: chimera.Point(*xyz), points) valid, sphere = chimera.find_bounding_sphere(plist) if not valid: return None c = sphere.center.data() return c
def restoreModelClip(clipInfo): for modelID, info in clipInfo.items(): model = idLookup(modelID) originData, normalData = info cp = model.clipPlane cp.origin = chimera.Point(*originData) cp.normal = chimera.Vector(*normalData) model.clipPlane = cp model.useClipPlane = True
def express(self): """ Load the frame requested by the current allele into a new CoordSet object (always at index 1) and set that as the active one. """ traj = self.load_frame(self.allele) coords = traj.xyz[0] * 10 for a, xyz in zip(self.molecule.compound.mol.atoms, coords): a.setCoord(chimera.Point(*xyz))
def sugarTube(residue, anchor=SUGAR, showGly=False): if anchor is SUGAR: showGly = False if anchor is SUGAR or showGly: aname = "C1'" else: try: t = residue.type if t in ('PSU', 'P'): n = 'P' elif t in ('NOS', 'I'): n = 'I' else: n = nucleic3to1[t] type = standard_bases[n]['type'] except KeyError: return [] aname = _BaseAnchors[type] if not aname: return [] a = residue.findAtom(aname) if not a or not a.display: return [] ep0 = a.coord() radius = a.molecule.stickScale * chimera.Molecule.DefaultBondRadius color_kwds = _atom_color(a) # calculate position between C3' and C4' on ribbon hasRibbon = residue.ribbonDisplay and residue.hasRibbon() if hasRibbon: rrc = residue.ribbonResidueClass found, o3pPos = rrc.position("O3'") if not found: return [] found, c5pPos = rrc.position("C5'") if not found: return [] s = chimera.Spline(chimera.Spline.BSpline, residue.ribbonCenters()) ep1 = s.coordinate((o3pPos + c5pPos) / 2) else: c3p = residue.findAtom("C3'") if not c3p: return [] c4p = residue.findAtom("C4'") if not c4p: return [] ep1 = chimera.Point([c3p.coord(), c4p.coord()]) node = drawCylinder(radius, ep0, ep1, **color_kwds) setHideAtoms(True, SugarAtomsRE, SugarExceptRE, [residue]) return [node]
def drawCylinder(radius, ep0, ep1, **kw): t = vrml.Transform() t.translation = chimera.Point([ep0, ep1]).data() delta = ep1 - ep0 height = delta.length axis = chimera.cross(cylAxis, delta) cos = (cylAxis * delta) / height angle = math.acos(cos) t.rotation = (axis[0], axis[1], axis[2], angle) c = vrml.Cylinder(radius=radius, height=height, **kw) t.addChild(c) return t
def update_rotamers(protein, xyz, atomnum): """ Apply new coordinates `xyz` to selected atom with serialNumber `atomnum` in `protein`. """ try: atom = next(a for a in protein.atoms if a.serialNumber == int(atomnum)) except StopIteration: pass else: atom.setCoord(chimera.Point(*map(float, xyz))) return atom
def BoxMesh (w, h, l, color, xf, mol) : if mol == None : import _surface mol = _surface.SurfaceModel() chimera.openModels.add ( [mol] ) # , sameAs = alignTo) mol.name = "Box" v = numpy.zeros ( [8,3] ) # print "BoxMesh:", div at = 0 w = w / 2.0 h = h / 2.0 l = l / 2.0 if xf == None : xf = chimera.Xform() v[0] = xf.apply ( chimera.Point ( -w,-h,-l ) ) v[1] = xf.apply ( chimera.Point ( w,-h,-l ) ) v[2] = xf.apply ( chimera.Point ( w,h,-l ) ) v[3] = xf.apply ( chimera.Point ( -w,h,-l ) ) v[4] = xf.apply ( chimera.Point ( -w,-h,l ) ) v[5] = xf.apply ( chimera.Point ( w,-h,l ) ) v[6] = xf.apply ( chimera.Point ( w,h,l ) ) v[7] = xf.apply ( chimera.Point ( -w,h,l ) ) vi = [] vi.extend( Quad2Tri ( [0,3,2,1] ) ) vi.extend( Quad2Tri ( [1,5,6,2] ) ) vi.extend( Quad2Tri ( [2,6,7,3] ) ) vi.extend( Quad2Tri ( [0,4,5,1] ) ) vi.extend( Quad2Tri ( [0,4,7,3] ) ) vi.extend( Quad2Tri ( [5,4,7,6] ) ) sph = mol.addPiece ( v, vi, color ) return sph
def convert_gaussian_molecule_to_chimera(path_or_parser): if isinstance(path_or_parser, basestring): parsed = Gaussian(path_or_parser).parse() else: parsed = path_or_parser elements = parsed.atomnos coords = parsed.atomcoords[-1] m = chimera.Molecule() r = m.newResidue("UNK", " ", 1, " ") for i, (element, xyz) in enumerate(zip(elements, coords)): element = chimera.Element(element) a = m.newAtom('{}{}'.format(element, i), element) r.addAtom(a) a.setCoord(chimera.Point(*xyz)) a.serialNumber = i chimera.connectMolecule(m) return m
def front_of_volume_at_screen_center(): v = active_volume() if v == None: return None import chimera wx_size, wy_size = chimera.viewer.windowSize from VolumeViewer.slice import volume_segment xyz_in, xyz_out, shown = volume_segment(v, wx_size/2, wy_size/2) if xyz_in == None: return None xf = v.model_transform() eye_xyz_in = xf.apply(chimera.Point(*xyz_in)) return eye_xyz_in
def PlaneMesh ( w, h, d, color, xf, mol ) : if mol == None : import _surface mol = _surface.SurfaceModel() chimera.openModels.add ( [mol] ) # , sameAs = alignTo) mol.name = "Box" atX = -w/2 atY = -h/2 if xf == None : xf = chimera.Xform() numx = int ( max ( numpy.ceil ( w / d ), 2 ) ) numy = int ( max ( numpy.ceil ( h / d ), 2 ) ) dx = w / float(numx-1) dy = h / float(numx-1) print " - plane - w %.2f, h %.2f, %d/%d" % (w, h, numx, numy) v = numpy.zeros ( [numx*numy,3] ) vi = [] for j in range ( numy ) : for i in range ( numx ) : v[j*numx+i] = xf.apply ( chimera.Point ( atX + dx*i, atY + dy*j, 0 ) ) #vs.append ( p.data() ) if i > 0 and j > 0 : p1 = j*numx+i p2 = j*numx+i-1 p3 = (j-1)*numx+i-1 p4 = (j-1)*numx+i vi.extend( Quad2Tri ( [p1,p2,p3,p4] ) ) sph = mol.addPiece ( v, vi, color ) return sph
def set_metal_contacts(self, radius): """ Set contacts between this residue and metals at a given radius """ contacts = [] for metal in self.all_metals: for atom in self.atoms: # Set the coordinates of this metal in a way that Point() # can accept metal_coords = [float(x) for x in metal.location.split(",")] # Get the distance between this atom and this metal distance = chimera.distance( atom.xformCoord(), chimera.Point(metal_coords[0], metal_coords[1], metal_coords[2]), ) # If we're within the distance expected, add this metal # to the list and move to the next if distance - ionicRadiusDict.get(metal.type, None) <= radius: contacts.append(metal) break self.metal_contacts = contacts
def evaluate_distances(self, ind): """ Measure the distance """ distances = [] if isinstance(self._target[0], basestring): # AtomSpec like 'Molecule/1' target = ind.find_molecule(self._target.molecule ).find_atom(self._target.atom).xformCoord() else: # coordinates target = chimera.Point(*self._target) for a in self.atoms(ind, *self._probes): d = self._distance(a, target) if self.threshold == 'covalent': threshold = chimera.Element.bondLength(a.element, target.element) else: threshold = self.threshold d = d - threshold if self.tolerance is not None and d < self.tolerance: distances.append(-1000 * self.weight) else: distances.append(d) return numpy.mean(numpy.absolute(distances))
from conftest import create_metal_class import pytest import chimera from chimera import runCommand as rc Model = Model() def test_temp_directory(Model=Model): path = Model.temp_directory() assert (os.path.isdir(path)) @pytest.mark.parametrize("element, file, charge, geom, dummies_xyz", [ ('zn', 'zinc.pdb', 2, 'tetrahedral', [ chimera.Point(28.448, 41.088, 28.914), chimera.Point(28.879, 40.185, 29.990), chimera.Point(29.612, 41.434, 29.741), chimera.Point(28.261, 41.477, 30.319) ]), ('zn', 'zinc.pdb', 2, 'square planar', [ chimera.Point(29.643, 41.073, 29.428), chimera.Point(27.957, 41.019, 30.054), chimera.Point(29.057, 40.470, 30.383), chimera.Point(28.543, 41.622, 29.099) ]), ('zn', 'zinc.pdb', 2, 'octahedron', [ chimera.Point(29.549, 41.526, 29.876), chimera.Point(28.376, 41.530, 30.370), chimera.Point(29.224, 40.562, 29.112), chimera.Point(29.063, 40.459, 30.370),
from numpy import around as numpy_around import math import numpy as np # Chimera import chimera from chimera import Xform as X import Matrix as M from FitMap.search import random_rotation from Molecule import atom_positions # GAUDI from gaudi.genes import GeneProvider from gaudi import parse ZERO = chimera.Point(0.0, 0.0, 0.0) IDENTITY = ((1.0, 0.0, 0.0, 0.0), (0.0, 1.0, 0.0, 0.0), (0.0, 0.0, 1.0, 0.0)) logger = logging.getLogger(__name__) def enable(**kwargs): kwargs = Search.validate(kwargs) return Search(**kwargs) class Search(GeneProvider): """ Parameters ---------- target : namedtuple or Name of gaudi.genes.molecule Can be either:
def unexpress(self): """ Undo coordinates change """ for i, atom in enumerate(self.molecule.atoms): atom.setCoord(chimera.Point(*self._original_coords[i]))
def showTurn(turn, color, width, thickness): pt = [] for r in turn: a = r.findAtom('CA') if not a: continue pt.append(a.coord()) size = max(width, thickness) try: c, d, n, b = ssMap[turn[0]] cv = chimera.Point(c[0], c[1], c[2]) dv = chimera.Vector(d[0], d[1], d[2]) nv = chimera.Vector(n[0], n[1], n[2]) bv = chimera.Vector(b[0], b[1], b[2]) startDir = dv startNormals = (nv, bv) pt.insert(0, cv) except KeyError: startDir = None startNormals = None try: c, d, n, b = ssMap[turn[-1]] cv = chimera.Point(c[0], c[1], c[2]) dv = chimera.Vector(d[0], d[1], d[2]) nv = chimera.Vector(n[0], n[1], n[2]) bv = chimera.Vector(b[0], b[1], b[2]) endDir = -dv endNormals = (nv, bv) pt.append(cv) except KeyError: endDir = None endNormals = None if len(pt) < 3: return [] if len(pt) == 3: # need at least 4 points for vrml.Extrustion if startDir: pt.insert(1, chimera.Point(pt[:2])) if endDir: pt.insert(-1, chimera.Point(pt[-2:])) dir = [] if startDir is None: dir.append(pt[1] - pt[0]) else: dir.append(startDir) for i in range(1, len(pt) - 1): dir.append(pt[i + 1] - pt[i - 1]) if endDir is None: dir.append(pt[-1] - pt[-2]) else: dir.append(endDir) offsets = [[0.0, thickness], [width, 0.0], [0.0, -thickness], [-width, 0.0]] edges = [] for i in offsets: edges.append([]) if startNormals is not None: normal, binormal = startNormals else: normal, binormal = getEndNormals(pt[0], pt[1], pt[2]) addEdges(edges, offsets, pt[0], normal, binormal) for i in range(1, len(pt) - 1): try: n, b = getInteriorNormals(pt[i], pt[i - 1], pt[i + 1]) normal, binormal = minimizeTwist(dir[i], n, b, normal, binormal) except ValueError: # This can happen if the three points are linear # We just inherit the normals from the previous triple pass addEdges(edges, offsets, pt[i], normal, binormal) if endNormals is not None: n, b = endNormals else: n, b = getEndNormals(pt[-1], pt[-3], pt[-2]) normal, binormal = minimizeTwist(dir[-1], n, b, normal, binormal) addEdges(edges, offsets, pt[-1], normal, binormal) rgba = color.get().rgba() ext = vrml.Extrusion(color=rgba[:3], edges=edges) if rgba[3] < 1.0: ext.transparency = 1.0 - rgba[3] return [ext]
def interpolate(mol, molXform, segments, equivAtoms, method, rMethod, frames, cartesian, cb): # mol molecule where new coordinate sets are added # should already have first frame in place # molXform transform to convert atoms from their own # local coordinate system into "mol" local coordinates # (usually [inverse transform of trajectory model] x # [transform of target model]) # segments list of 2-tuples of matching residue lists # equivAtoms dictionary of equivalent atoms # key is atom from first frame # value is 2-tuple of atoms from last frame and "mol" # method interpolation method name # rMethod rate profile, e.g., "linear" # frames number of frames to generate in trajectory # cartesian use cartesian coordinate interpolation? # cb function called for every frame generated import InterpResidue from util import getAtomList, findBestMatch import chimera from chimera import match method = findBestMatch(method, InterpolationMap.iterkeys()) interpolateFunction = InterpolationMap[method] rMethod = findBestMatch(rMethod, RateMap.iterkeys()) rateFunction = RateMap[rMethod] if cartesian: planFunction = InterpResidue.planCartesian else: planFunction = InterpResidue.planInternal rate = rateFunction(frames) numFrames = len(rate) + 1 activeCS = mol.activeCoordSet csSize = len(mol.activeCoordSet.coords()) baseCS = max(mol.coordSets.keys()) + 1 segMap = {} plan = {} for seg in segments: rList0, rList1 = seg aList0 = getAtomList(rList0) aList1 = [ equivAtoms[a0] for a0 in aList0 ] c1 = chimera.Point([ a.coord() for a in aList1 ]) segMap[seg] = (aList0, aList1, molXform.apply(c1)) for r in rList0: plan[r] = planFunction(r) import numpy def coordsToPosition(atoms): return numpy.array([a.coord().data() for a in atoms]) def xformCoordsToPosition(atoms): return numpy.array([molXform.apply(a.coord()).data() for a in atoms]) lo = 0.0 interval = 1.0 for i in range(len(rate)): f = (rate[i] - lo) / interval lo = rate[i] interval = 1.0 - lo cs = mol.newCoordSet(baseCS + i, csSize) for seg in segments: aList0, aList1, c1 = segMap[seg] c = chimera.Point([ a.coord() for a in aList0 ]) cList0 = coordsToPosition(aList0) cList1 = xformCoordsToPosition(aList1) xform, rmsd = match.matchPositions(cList1, cList0) xf, xf1 = interpolateFunction(xform, c, c1, f) xf1.multiply(molXform) rList0, rList1 = seg for r in rList0: InterpResidue.applyPlan(plan[r], r, cs, f, equivAtoms, xf, xf1) mol.activeCoordSet = cs if cb: cb(mol) cs = mol.newCoordSet(baseCS + len(rate), csSize) for a0, a1 in equivAtoms.iteritems(): a0.setCoord(molXform.apply(a1.coord()), cs) mol.activeCoordSet = cs
def ReadMol ( fpath, log=False ) : from random import random cif, loops = ReadCif ( fpath, log ) # descriptions by chain id: descrByEntityId = GetEntityDescr ( cif, loops ) try : atoms = loops['_atom_site']['data'] print " - %d atom records" % len(atoms) except : print " - no atoms in cif?" return None labels = loops['_atom_site']['labels'] if 0 : print "Labels:" for l in labels : print " : ", l import time start = time.time() rmap = {} nmol = chimera.Molecule() from os import path #nmol.name = path.splitext ( path.split (fpath)[1] )[0] nmol.name = path.split (fpath) [1] nmol.openedAs = [ fpath, [] ] nmol.cif = cif nmol.cifLoops = loops nmol.chainColors = {} nmol.chainDescr = {} numQ = 0 first = True for at in atoms : mp = at['asMap'] if log and first : #for label, val in mp.iteritems () : for li, label in enumerate ( labels ) : print " %d : %s : %s" % (li+1, label, mp[label]) first = False atType = mp['type_symbol'] atName = mp['label_atom_id'] rtype = mp['label_comp_id'] chainId = mp['label_asym_id'] chainEId = mp['label_entity_id'] px = mp['Cartn_x'] py = mp['Cartn_y'] pz = mp['Cartn_z'] occ = mp['occupancy'] bfactor = mp['B_iso_or_equiv'] altLoc = mp['label_alt_id'] if altLoc == "." : altLoc = '' if chainEId in descrByEntityId : nmol.chainDescr [chainId] = descrByEntityId [chainEId] resId = ResId ( mp ) if resId == None : continue ris = "%s%d" % (chainId, resId) res = None if not ris in rmap : res = nmol.newResidue ( rtype, chimera.MolResId(chainId, resId) ) rmap[ris] = res else : res = rmap[ris] clr = None if not chainId in nmol.chainColors : clr = chimera.MaterialColor ( random(), random(), random(), 1.0 ) nmol.chainColors[chainId] = clr if 0 and log : print " - chain %s" % chainId else : clr = nmol.chainColors [chainId] nat = nmol.newAtom ( atName, chimera.Element(atType) ) drawRib = rtype in protein3to1 or rtype in nucleic3to1 #aMap[at] = nat res.addAtom( nat ) nat.setCoord ( chimera.Point( float(px), float(py), float(pz) ) ) nat.altLoc = altLoc nat.occupancy = float(occ) nat.bfactor = float(bfactor) if 'Q-score' in mp : try : Q = float ( mp['Q-score'] ) nat.Q = Q numQ += 1 except : #print " - q score is", mp['Q-score'] pass end = time.time() print " - created %d atoms, %.1fs, %d q-scores" % ( len(nmol.atoms), end-start, numQ ) return nmol