Nce plottng of protens II Fnal remark regardng effcency: It s possble to wrte the Newton representaton n a way that can be computed effcently, usng smlar bracketng that we made for the frst representaton of the polynomal ( ( )) ( ) = + ( ) + ( ) + ( ) polynomal x c x x c x x c x x 3 3... Is polynomal nterpolaton good for plottng proten curves? After the lengthy ntroducton to polynomals and nterpolaton t s about the tme to ask: Is the polynomal ft any good for proten chans? Can we use polynomal fts to get a much smoother and better vews of proten structures? Polynomal fts are sound f hgher order dervatves of the true functon (beyond the order of the polynomal) do not contrbute sgnfcantly to the descrpton of the functon. However, the reverse s also true If hgh order dervatves do make a sgnfcant contrbuton then the ft s not sound. Consder for example a typcal secondary structure element n proten - the beta pleated sheet. To a frst approxmaton a beta pleated sheet s a smple straght lne where the C α atoms are equally space on t. Snce the proten shape s compact the chan must come back on tself. At the end of a secondary structure element, there s usually a sharp turn modfyng consderably the drecton of the chan. Let us try to create a smple model of the above qualtatve descrpton and check what s the result of a polynomal ft that we may obtan. Our chan wll be embedded (for smplcty) n two dmensons. The chan s of length 0, the frst nne ponts are along the X-axs and the last two ponts represent a sharp turn backward. Here s a quck vew of the above n MATLAB >> x x = >> y y = 3 4 5 6 7 8 9 9 8 0 0 0 0 0 0 0 0 0 >> plot(x,y)
Now let us try to get a polynomal ft to the above proten model. Here s a MATLAB code that does t: >> t = :; >> cx = polyft(t,x,length(t)-); >> cy = polyft(t,y,length(t)-); >> t=:0.:; >> polyx = polyval(cx,t); >> polyy = polyval(cy,t); >> plot(polyx,polyy)
Well, t s qute clear that the over-shootng of the turn s not what we had n mnd about a smooth and more pleasng representaton of the proten chan. We need to fnd an alternatve way of generatng the smooth representaton of the proten path. The problem we have s that we ft a large number of ponts (amno acd postons) to a sngle polynomal. If the curve vares sgnfcantly and abruptly as the ndex of the amno acd (the t varable), then volent responses, whch do not concde wth our vew of proten shapes, may occur. The polynomal s smooth and dfferentable to all orders. However, for graphcal presentatons, ths may be unnecessary. We can hardly detect (by lookng at a curve) that a thrd dervatve of the curve s dscontnuous. We usually are able to detect a dscontnuous second dervatve. We therefore set a somewhat mlder threshold a ft that s locally contnuous up to a second dervatve. Ths leads to the noton of pecewse contnuous functon and to cubc splne nterpolaton. The problem can be formulated as follows: Gven a set of ponts (, ),(, ),...,(, ) t x t x tn x n we wsh to ft a pecewse contnuous curve to t. Ths means that we wll ft sequental subsets of ponts to cubc functons and
nsst that the functon, frst and second dervatves wll match at the boundary. The Hermte nterpolaton scheme s smple and therefore a good startng pont: Consder the edges of the nterval that we wsh to ft ( x L and x R - two ponts only of the complete data ponts). We wrte the polynomal q( x ) nterpolatng between the two ponts as: ( ) ( ) ( ) ( ) q( x) = a+ b x xl + c x xl + d xxl x xr The parameters a d are determned from the condtons that the functon and the frst dervatve wll be contnuous at the edges of the nterval (when we patch addtonal polynomals n between). There are four condtons that are suffcent to determne the four parameters (functon and frst dervatve of the functon at the two end ponts). The set of lnear equatons that we need to solve s a = yl b= y' L a+ b x+ c x = yr b+ c x+ d x = y' ( x = x x ) R L R The above procedure makes the frst dervatves contnuous at the matchng ponts. The second dervatves are not consdered. We therefore mmedately upgrade the level of our nterpolaton to cubc splne, addng a condton also on the second dervatve We wrte the cubc polynomal at two ndces and + buldng on the hermte polynomal results but addng a new parameter s y' s s + s y' q x y s x x x x x x x x + + ( ) ( ) x ( x ) ' ( ) ( ) ( ) ( ) ( ) = + + + + y s s + s y' q x y s x x x x x x x x ( ) ( ) + + + + + + ( ) = + + + + + + + + + x+ ( x+ ) y+ y where x = x+ x and y ' = x x + Note that regardless of the value of s, at the matchng pont x + the functon and the dervatve of the two cubcs are the same. For example, the functons are evaluated below n detals
y' s + + + x + ( ) = + ( ) + ( ) q x y s x x x x y+ y = y + s ( x x ) + s ( x x ) = y q x = y ( ) + + + + + + x+ x As an exercse you may wsh to show the contnuty of the frst dervatve We are therefore left wth the requrement of contnuous second dervatves and s that are used to obtan ths result. We have undetermned parameters { } ' q'' ( x+ ) = ( s+ + s 3y) x q '' x 3y s s ' ( ) = ( ) + + + + + x+ that must be the same. Fxng the value of s = a and sn = b we can solve a set of lnear equatons for the n- varables. These equatons provdes a pecewse contnuous representaton of the curve wth contnuous functon, and frst and second dervatves at each of the boundares. It s therefore expected to work a lot better n the nterpolaton of proten chans. Note however that the choce for s and s n s not unque and there are three dfferent ways of ntatng and termnatng a splne. The procedure we descrbed above () ( s = a and sn = b ) s called the complete splne. The other optons are: a = q'' x and b= q'' ( xn ). If both a and b are set to zero, the ft s called the natural splne. () Ensurng thrd dervatve contnuty at x and () set the values of the second dervatves at the edges to fxed numbers ( ) In Matlab all the machnery of determnng splne coeffcents s already bult n. The same beta turn can be ftted to a cubc splne (wth default parameters from Matlab) and plotted n 4 lnes: >> tt=:0.:; >> xx=splne(t,x,tt); >> yy=splne(t,y,tt); >> plot(xx,yy) The result s not truly optmal but clearly better than the polynomal ft. xn
Let us work on example for a real proten plot. We start by readng n the PDB entry par usng the functon pckca( flename ) (check the course web page for source code) coor = pckca( par.pdb ); x = coor(:,); y = coor(:,); z = coor(:,3); % straght forward plot, just connect CA plot3(x,y,z)
% here start the fancy staff t=:5; tt=:0.:5; xx=splne(t,x,tt); yy=splne(t,y,tt); zz=splne(t,z,tt); plot3(xx,yy,zz)