Scripts: angles.py

File angles.py, 1.8 KB (added by goddard, 10 years ago)
Line 
1# Chimera Python script to compute angles between dynactin axis and microtuble axes
2# projected to the 2d planes containing the microtubule axis and dynactin centroid
3# and the plane contining the microtubule axis that is perpendicular to that plane.
4
5cm = (0,0,0) # Microtubule axis point
6am = (0,0,1) # Microtubule axis vector
7
8cd = (7.5,10.8,-5.6) # Dynactin centroid in dynactin map coordinate system (Angstroms)
9ad = (.8,.7,.2) # Dynactin long axis vector in dynactin map coord system.
10
11# Convert dynactin coordinates to microtubule coordinates
12from chimera import openModels
13mmodel, dmodel = openModels.list() # Assuming microtubule model #0, dynactin model #1
14print "Using microtubule model", mmodel.name, "dynactin model", dmodel.name
15
16# Find transformation from dynactin model coordinates to camera coordinates
17# then camera coordinates to microtuble coordinates.
18import Matrix as M
19tf = M.multiply_matrices(M.xform_matrix(mmodel.openState.xform.inverse()),
20 M.xform_matrix(dmodel.openState.xform))
21cdm = M.apply_matrix(tf, cd) # Dynactin centroid in microtubule map coordinate system
22adm = M.apply_matrix_without_translation(tf, ad) # Dynactin axis in microtubule map coordinate system
23adm = M.normalize_vector(adm) # Make sure axis is unit length vector
24
25# Make coordinate system for microtubule with z-axis along cylinder axis,
26# and yz plane containing dynactin center
27from numpy import subtract
28mx,my,mz = M.orthonormal_frame(zaxis = am, ydir = subtract(cdm, cm))
29
30# Now measure dynactin axis angle in microtubule yz plane and xz planes.
31from math import atan2, pi
32ayz = atan2(M.inner_product(my, adm), M.inner_product(mz, adm))
33axz = atan2(M.inner_product(mx, adm), M.inner_product(mz, adm))
34
35print('Dynactin axis orientation: %.1f degrees from microtubule axis, %.1f degrees transverse to microtuble axis'
36 % (ayz * 180/pi, axz * 180/pi))