Scripts: angle.py

File angle.py, 860 bytes (added by goddard, 16 years ago)
Line 
1# Measure the angle between two axes, each axis specified by two atoms.
2#
3# This was written to measure angles between axes determined by the
4# "measure rotation" command which creates axis models containing two atoms
5# connected by a bond defining the axis. If models #2 and #3 are two such
6# axis models this script can be run using Chimera command
7#
8# runscript angle.py #2 #3
9#
10a1, a2 = arguments
11
12from Midas.midas_text import _parseAtomBondAxis as parseAxis
13# Axis vector and base point given in model coordinate system
14lv1, p1, os1 = parseAxis(a1)
15lv2, p2, os2 = parseAxis(a2)
16
17# Get axis vectors in global coordinate system.
18v1 = os1.xform.apply(lv1)
19v2 = os2.xform.apply(lv2)
20
21# Calculate angle
22a = chimera.angle(v1,v2)
23
24from chimera.replyobj import status, info
25msg = 'Angle %s to %s is %.4g degrees' % (a1, a2, a)
26status(msg)
27info(msg + '\n')