program dangles(input,output); (* dangles: DNA angles *) const (* begin module version *) version = 1.07; (* of dangles.p 1996 March 18 updated 1995 Aug 30 origin 1986 Dec 2 *) (* end module version *) (* begin module describe.dangles *) (* name dangles: dangles: DNA angles synopsis dangles(input: in, output: out); files input: a set of integers, one per line output: angles corresponding to the positions. describe DNA angles of a list of positions. author Thomas Dana Schneider bugs none known *) (* end module describe.dangles *) bppt = 10.6; (* basepairs per turn *) pi = 3.14159265354; (* circumference divided by diameter of circle *) var angle: real; (* angle relative to coordinate zero *) first: boolean; (* are we at the first data point? *) position : integer; (* postions from the input file *) turns: real; (* number of DNA turns from coordinate zero *) x,y: real; (* coordinates for the angle and the radius *) (* begin module pic.polrec *) procedure polrec(r,theta: real; var x,y: real); (* convert polar to rectangular coordinates, theta is in radians *) begin x := r*cos(theta); y := r*sin(theta) end; (* end module pic.polrec *) (* begin module pic.degtorad *) function degtorad(angle: real):real; (* convert angle in degrees to radians *) begin degtorad := (angle / 360) * 2 * pi end; (* end module pic.degtorad *) begin first := true; while not eof(input) do begin if input^='*' (* copy lines beginning with '*' to output *) then while not eoln(input) do begin write(output,input^); get(input) end else begin if first then begin writeln(output,'* columns:'); writeln(output,'* 1. position'); writeln(output,'* 2. turns'); writeln(output,'* 3. angle'); writeln(output,'* 4. x'); writeln(output,'* 5. y'); first := false; end; read(input,position); turns := position/bppt; angle := 360 * (turns - trunc(turns)); polrec(1.0, degtorad(angle), x,y); write(output,position:6, ' ',turns:11:1, ' ',angle:11:1, ' ',x:11:8, ' ',y:11:8); end; readln(input); writeln(output); end end.