program winfo(data, winfop, xyin, output); (* winfo: window information curve Tom Schneider National Cancer Institute Laboratory of Mathematical Biology Frederick, Maryland 21701-1013 toms@ncifcrf.gov 1989 *) label 1; (* end of program *) const (* begin module version *) version = 1.08; (* of winfo.p 1989 November 28 origin 1989 November 28 *) (* end module version *) (* begin module describe.winfo *) (* name winfo: window information curve synopsis winfo(data: in, winfop:in, xyin: out, output: out) files data: output of rseq winfop: parameters to control the program First line: window size xyin: input to xyplop output: messages to the user description Make a sliding window average of an information curve examples documentation see also rseq.p xyplo.p author Thomas Dana Schneider bugs not yet! technical notes Constant maxwin is the largest window size allowed. *) (* end module describe.winfo *) (* begin module const.winfo *) maxwin = 1000; (*the largest window size allowed. *) (* end module const.winfo *) var data: text; (* input data from rseq *) winfop: text; (* parameters *) xyin: text; (* output of this program, input to xyplo *) (* begin module halt *) procedure halt; (* stop the program. the procedure performs a goto to the end of the program. you must have a label: label 1; declared, and also the end of the program must have this label: 1: end. examples are in the module libraries. this is the only goto in the delila system. *) begin writeln(output,' program halt.'); goto 1 end; (* end module halt version = 'delmod 6.57 88 mar 1 tds/gds' *) (* begin module copyaline *) procedure copyaline(var fin, fout: text); (* copy a line from file fin to file fout *) begin (* copyaline *) while not eoln(fin) do begin fout^ := fin^; put(fout); get(fin) end; readln(fin); writeln(fout); end; (* copyaline *) (* end module copyaline version = 'delmod 6.57 88 mar 1 tds/gds' *) (* begin module winfo.themain *) procedure themain(var data, winfop, xyin: text); (* the main procedure of the program *) var a,c,g,t: integer; (* numbers of bases *) currentR: integer; (* the current value of R read in *) howmany: integer; (* how many values we have read so far *) l: integer; (* location *) oldestR: integer; (* the oldest value of R read in *) R: real; (* an amount of information *) rvalues: array[1..maxwin] of real; (* record of the last set of R values *) total: real; (* current total of R in the window *) windowsize: integer; (* size of window requested *) begin writeln(output,'winfo ',version:4:2); reset(winfop); if eof(winfop) then begin writeln(output,'empty parameter file winfop'); halt end; readln(winfop,windowsize); if windowsize > maxwin then begin writeln(output,'windowsize (',windowsize:1,') is bigger than', ' maxwin (',maxwin:1,', increase constant maxwin.'); halt end; rewrite(xyin); writeln(xyin,'* winfo ',version:4:2); reset(data); while data^='*' do copyaline(data,xyin); total := 0.0; howmany := 0; while (not eof(data)) and (howmany < windowsize) do begin readln(data,l,a,c,g,t,R); (* get the data *) howmany := howmany + 1; rvalues[howmany] := R; total := total + R end; oldestR := 0; currentR := windowsize; writeln(xyin,'* window: ',windowsize:1); writeln(xyin,'* symbol |', ' l |', ' average R in window |', ' R |', ' current total'); while not eof(data) do begin if data^ <> '*' then begin if (l mod 10) = 0 then writeln(xyin,'c',l:5,' ', (total/windowsize):10:5, ' ',R:10:5, ' ',total:10:5); writeln(xyin,'d',l:5,' ', (total/windowsize):10:5, ' ',R:10:5, ' ',total:10:5); oldestR := oldestR + 1; if oldestR > windowsize then oldestR := 1; total := total - rvalues[oldestR]; readln(data,l,a,c,g,t,R); (* get the data *) currentR := currentR + 1; if currentR > windowsize then currentR := 1; rvalues[currentR] := R; total := total + R end else readln(data) end; end; (* end module winfo.themain *) begin themain(data, winfop, xyin); 1: end.