2 -- lecture 3

Rotation and translation Superposition, structure comparison Structure classification

Rotation is angular addition

y atom starts at (x=|r|cosα, y=|r|sinα) axis of (x’,y’) rotation = Cartesian β (x,y) origin r α x ..rotates to... (x'=|r|cos(α+β), y'=|r|sin(α+β))

Convention: angles are measured counter-clockwise.

1 Sum of angles formula

cos (α+β) = cos α cos β − sin α sin β

sin (α+β) = sin α cos β + sin β cos α

A rotation matrix

y α x = |r|cos (x’,y’) y = |r|sin α β (x,y) r α x x' = |r| cos (α+β) y' = |r| sin (α+β) = |r|(cos α cos β − sin α sin β) = |r|(sin α cos β + sin β cos α) = (|r| cos α) cos β − (|r| sin α)sin β = (|r| sin α) cos β + (|r| cos α) sin β = x cos β − y sin β = y cos β + x sin β

 x' cosββ− sin r cosα cosββ− sin  x   =    =     y'  sinββ cos  rsinα   sinββ cos  y

rotation matrix is the same for any r, any α.

2 A rotation around a principle axis The Z coordinate stays the same. X and Y change. cosββ− sin 0 R = sinββ cos 0 z    001 The Y coordinate stays the same. X and Z change.  cosγγ0 sin  R = 010 y   −sinγγ0 cos  The X coordinate stays the same. Y and Z change. 10 0 0 cosαα− sin  Rx =  0 sinαα cos 

A 3D rotation matrix

Is the product of 2D rotation matrices.

cosββ− sin 0cosγγ0 − sin  cosβγ cos− sin β cos β  sinββ cos 0 01 0 =  sinβγ cos cos β− sin βγ sin        001 sinγγ00 cos   sinγγ cos 

Rotatio 3D rotati n around z n around y- on

-axis axis

3 What happens when you move the mouse:

1. Mouse sends mouse coordinates (∆x,∆y) to the running program y 2. Rotation angles are calculated: x θ ∆ θ ∆ x = x*scale, y = y*scale 3. Rotation matrices are calculated: 10 0  θθ−  cosyy0 sin =− θθ   R 0 cosxx sin = 01 0 x   Ry   0 sinθθ cos   θθ xx  sinyy0 cos 

What happens when you move the mouse (cont'd): 4. New atomvv coordinates are calculated rr' = RRyx

5. The scene is rendered using the new coordinates.

4 When multiplying matrices, the order matters.

 θθ−  10 0 cosyy0 sin     = 01 0 0 cosθθ− sin RRyx   xx  θθ  θθ  sinyy0 cos  0 sinxx cos

 θθθθθ−− cosyxyyx sin sin sin cos =  θθ−   0 cosxx sin   θθθθθ  sinyxyxy sin cos cos cos 

This is the matrix if the X-rotation is first, then the Y-rotation.

Rotating in opposite order gives a different matrix

  θθ−  10 0 cosyy0 sin   =−0 cosθθ sin  01 0 RRxy xx   θθ θθ 0 sinxx cos  sinyy0 cos 

 θθ−  cosyy0 sin = −−θθ θ θ θ  sinxy sin cos x sin x cos y  θθ θ θθ  sinyx cos sin x cos xy cos 

5 Reversing the rotation For the opposite rotation, flip the matrix.  AB T  AC This is the “transpose”   =   CD  BD

 x'  cosββ sin  x   =     y' −sinββ cos  y

The inverse matrix = The transposed matrix.

 cosββ sin cosββ− sin  10    =   −sinββ cos  sinββ cos  01

NOTE: cosβ cosβ + sinβ sinβ = 1

Example: rotation in 2 steps Rotate the vector v=(1.,2.,3.) around Z by 60°, then around Y by -60°

°− ° −+− cos60 sin 60 01 1(.) 0 5 2 (. 0 866 ) 3 () 0   1. 232  °°  =  ++ =   sin60 cos 60 0 2 1(. 0 866 ) 2 (.) 0 5 3 () 0 1. 866         001 3  0031++()   3 

cos60°−° 0 sin 60 −1. 232 −+−1.(.).()(.) 232 0 5 1 866 0 3 0 866  −3. 214  01 0 1. 866  =  −++1.().()() 232 0 1 866 1 3 0  =  1. 866          sin60°° 0 cos 60  3  −++1.(.).()(.) 232 0 866 1 866 0 3 0 5   0. 433 

6 Right-handed 90° rotations: z 90° rotation around 10 0 00− 1 X   y   01 0 x x  001  010 Y   z −  100 y

010−  y Z 100   x 001 z Helpful hint: For a R-handed rotation, the -sine is up and to the right of the +sine.

In class exercise: rotate a point

(x,y,z) = (1., 4., 7.) Rotate this point by 90° around the Z-axis Then... Rotate the new point by 90° around the Y-axis. What are the new coordinates?

7 3D rotation conventions: α β γ axis of Euler angles, z’’ x’ z rotation: cosγγ− sin 010 0cosαα− sin 0  sinγγ cos00 cos ββ− sin  sinαα cos 0       ββ  Order of 0010 sin cos 001 rotations: 3 2 1 Each rotation is around a principle axis. Polar angles, φψκ z’’’’ y’’’ z’’-y’ -z cosφφ− sin 0cosϕϕ0 − sin cosκκ− sin 0 cosϕϕ0 sin  cosφφ sin 0  sinφφ cos 0 01 0 sinκκ cos 0 010−sinφφ cos 0        001 sinϕϕ0 cos  001−sinϕϕ0 cos  001 5 4 3 2 1 Net rotation = κ, around an axis axis defined by φ and ψ

Polar angles

z = north pole

ψ κ

y

φ x = prime meridean @ equator

Rotation of κ degrees around an axis axis located at φ degrees longitude and ψ degrees latitude

8 Special properties of rotation matrices

•They are square, 2x2 or 3x3(higher dimensions in principle) •The product of any two rotation matrices is a rotation matrix. •The inverse equals the transpose, R-1 = RT •Every row/column is a unit vector. •Any two rows/columns are orthogonal vectors. •The cross-product of any two rows equals the third. •|x| = |Rx|, where R is a rotation matrix. Read more about rotation matrices at: http://mathworld.wolfram.com/RotationMatrix.html

RMSD

Root Mean Square Deviation in superimposed coordinates is the standard measure of structural difference. Similar to “standard deviation” which is the square-root of the variance. Orengo p.88 r r ()− 2 ∑ xyii iN=1, N

Where xi are the coordinates from molecule 1 and

yi are the equivalent* coordinates from molecule 2.

*Which atoms are equivalent is based on an alignment.

9 pseudo-pseudocode program for computing rmsd sum = 0 N = 0 while { /** Read coordinates for two aligned positions.

read (x1,y1,z1) , (x2,y2,z2) /** Compute the distance2

2 2 2 d =(x1-x2) +(y1-y2) +(z1-z2)

/** sum it. sum = sum + d /** keep track of how many pairs there are. N = N + 1 } /** Average and take square root. rmsd = sqrt(sum/N)

Least squares superposition

Problem: find the rotation matrix, M, and a vector, v, that minimize the following quantity: +−2 ∑ Mxii v y i

Where xi are the coordinates from one molecule and yi are the equivalent* coordinates from another molecule.

*equivalent based on alignment

10 Mapping structural equivalence = aligning the sequence Any position that is aligned is included in the sum of squares.

4DFR:A ISLIAALAVDRVIGMENAMPWNLPADLAWFKRNTLDKPVIMGRHTWESIG-RPLPGRKNI 1DFR:_ TAFLWAQNRNGLIGKDGHLPWHLPDDLHYFRAQTVGKIMVVGRRTYESFPKRPLPERTNV

4DFR:A ILSSQ-PGTDDRVTWVKSVDEAIAAC--GDVPEIMVIGGGRVYEQFLPKAQKLYLTHIDA 1DFR:_ VLTHQEDYQAQGAVVVHDVAAVFAYAKQHLDQELVIAGGAQIFTAFKDDVDTLLVTRLAG

4DFR:A EVEGDTHFPDYEPDDWESVFSEFHDADAQNS--HSYCFKILERR 1DFR:_ SFEGDTKMIPLNWDDFTKVSSRTVEDT---NPALTHTYEVWQKK

Unaligned positions are not.

Least squares

At the position of best superposition, +≅ we have an approximate equality: Mxii v y First we eliminate v by translating the center of mass of both molecules to the origin.Now Mx''≅ y we have: ii We have one equation (i) for each atom, M has 9 unknowns.

If there are more equations than unknowns, there is a unique solution. What is it? See the next two slides.

11 Least squares Least squares solves a set of a linear equations in the form :

x11a1+x12a2+ … x1NaN = y1 M x x21a1+x22a2+ … x2NaN = y2

• • • xM1a1+xM2a2+ … xMNaN = yM s (M > N)

known coefficientsknown N value This is 'shorthand' unknowns (N) notation for the a equations. x = y

matrix vector vector

Least squares, continued

a Green elements are known. x = y Orange are unknown. Fat Rectangles are matrices. Thin rectangles are vectors.

Multiply both sides by xT a = xT x y transpose of x. "Squaring"

"Squared" matrix is now, uh,

T y square. Which means we can x x a T = x invert it. (We can use the "LU decomposition" method.)

Multiplying both sides by the y

T -1 T a = (x x) x inverse of "squared" matrix solves for a. Summary: a = (xTx)-1 xTy

12 least-squares superimposed molecules

In class exercise: Superimpose 2 molecules by hand •Open insightII •Open two PDB files: 3shd.pdb, 1jzm.pdb •Display first chain ("A" usually) as "trace only" •Choose a better color if necessary. •Adjust the depth queuing if necessary.

•Superimpose the two molecules Use the reference pages that follow.

Do these pairs: 3sdh.pdb 1jzm.pdb (hard) 3sdh.pdb 1h97.pdb (harder) 3sdh.pdb 1phn.pdb (hardest)

13 InsightII reference: getting a molecule: Molecule-->Get--> Getfile type=PDB Filename=

Trace of chain A only: Molecule-->Display--> Display operation=Only Molec. attrib.=Atoms Atom set=Trace Molec. Spec= :A*

left-click on a molecule to see the object name chain ID=A atom spec. Look for chain ID, if any.

InsightII reference: invis. dark change depth queuing: slab hit F12 bright click here slab thick invis. viewer

Color molecule: Molecule-->Color--> Attribute=Atoms Molec. Spec= Atom set=specified Color=