def test_ra(session): from chimerax.core.models import Model, Drawing m = Model('test', session) d = Drawing('ring') d.set_geometry(*ring_arrow_with_post(0.5, 0.05, 4, 6, 0.3, 0.1, 0.05, 1)) m.add_drawing(d) session.models.add([m])
def _exclamation_mark(self): v, n, t = exclamation_mark(radius=0.1, height=0.5, nc = 8) flip = rotation((1,0,0), 180) flip.transform_points(v, in_place=True) flip.transform_vectors(n, in_place=True) translation((0,1,0)).transform_points(v, in_place=True) d = Drawing('rotamer cb indicator') d.set_geometry(v, n, t) return d
def _prepare_drawings(self): if not hasattr(self, '_omega_drawing'): od = self._omega_drawing = Drawing('cis/twisted omegas') od.skip_bounds = True od.pickable = False self.add_drawing(od) if not hasattr(self, '_rama_drawing'): rd = self._rama_drawing = Drawing('Ramachandran score indicators') rd.skip_bounds = True rd.pickable = False from chimerax.surface.shapes import sphere_geometry2 rd.set_geometry(*sphere_geometry2(80)) self.add_drawing(rd)
def simple_arrow(radius=0.1, height=1, nc=20, color=[255, 0, 0, 255], caps=True, head_length_fraction=0.33, head_width_ratio=1.5, points_out=True): from chimerax.core.models import Drawing d = Drawing(name='Arrow') d.color = color d.set_geometry( *simple_arrow_geometry(radius, height, nc, caps, head_length_fraction, head_width_ratio, points_out)) return d
def draw_asu(xmap): from chimerax.geometry import Place, Places from chimerax.core.models import Drawing, Model from chimerax.surface.shapes import sphere_geometry d = Drawing('asu corners') m = Model('asu box', session) #d.vertices, d.normals, d.triangles = sphere_geometry(80) d.set_geometry(*sphere_geometry(80)) asu = xmap.grid_asu() grid = xmap.grid_sampling() cell = xmap.cell() minmax = [asu.min().coord_frac(grid).coord_orth(cell).xyz, asu.max().coord_frac(grid).coord_orth(cell).xyz] dp = [] for i in range(2): for j in range(2): for k in range(2): dp.append(Place(origin=[minmax[i][0],minmax[j][1],minmax[k][2]])) d.positions = Places(dp) m.add_drawing(d) session.models.add([m]) return d
def _rota_indicator(self): v1, n1, t1 = exclamation_mark(radius=0.1, height=0.5, nc = 8) v2, n2, t2 = spiral(major_radius=0.3, minor_radius = 0.05, height=0.4, turn_segments=6, circle_segments=3) translation((0,0,-0.15)).transform_points(v2, in_place=True) v = numpy.concatenate((v1, v2)) n = numpy.concatenate((n1, n2)) t = numpy.concatenate((t1, t2+len(v1))) r = rotation((1,0,0),180) r.transform_points(v, in_place=True) r.transform_vectors(n, in_place=True) translation((0,0.5,0.25)).transform_points(v, in_place=True) d = Drawing('rotamer indicator') d.skip_bounds = True d.pickable = False d.set_geometry(v, n, t) return d
def draw_box(min_corner, max_corner, name='box'): from chimerax.geometry import Place, Places from chimerax.core.models import Drawing, Model from chimerax.surface.shapes import sphere_geometry d = Drawing('corners') m = Model(name, session) #d.vertices, d.normals, d.triangles = sphere_geometry(80) d.set_geometry(*sphere_geometry(80)) minmax = [min_corner, max_corner] dp = [] base_color = numpy.array([255,255,255,255]) color_increment = numpy.array([0,-32,-32,0]) colors = [] for i in range(2): for j in range(2): for k in range(2): dp.append(Place(origin=[minmax[i][0],minmax[j][1],minmax[k][2]])) colors.append(base_color-color_increment*(i+j+k)); d.positions = Places(dp) d.colors = colors m.add_drawing(d) session.models.add([m]) return d
def _cb_annotation(self): from chimerax.surface.shapes import cylinder_geometry v, n, t = cylinder_geometry(radius=0.1, height=2, nc=8, caps=True) d = Drawing('rotamer cb indicator') d.set_geometry(v, n, t) return d