program derive(xyin, derivep, dxyin, output); (* derive: compute the derivative curve for a xyin Dr. Thomas D. Schneider National Institutes of Health National Cancer Institute Center for Cancer Research Nanobiology Program Molecular Information Theory Group Frederick, Maryland 21702-1201 toms@ncifcrf.gov permanent email: toms@alum.mit.edu (use only if first address fails) http://www.ccrnp.ncifcrf.gov/~toms/ *) label 1; (* end of program *) const (* begin module version *) version = 1.02; (* of derive.p 2007 Mar 13 2007 Mar 13, 1.02: upgrade documentation 2007 Jan 20, 1.01: mostly ready 2007 Jan 20, 1.00: origin *) updateversion = 1.00; (* defines lowest acceptable current parameter file *) (* end module version *) (* begin module describe.derive *) (* name derive: compute the derivative curve for a xyin synopsis derive(xyin: in, derivep: in, dxyin: out, output: out) files xyin: input file for the xyplo program dxyin: derivative of log of values from the xyin derivep: parameters to control the program. The file must contain the following parameters, one per line: parameterversion: The version number of the program. This allows the user to be warned if an old parameter file is used. (Missing parameters to determine columns, defaults to 1 and 2 for x and y.) output: messages to the user description Compute the derivative of the curve by finding the differences of the y values divided by the differences of the x values. examples documentation see also {program for plotting xyin} xyplo.p author Thomas Dana Schneider bugs Only columns 1 and 2 can be used for now. The code for chosing arbitrary columns has not been written. technical notes *) (* end module describe.derive *) var xyin, (* file used by this program *) derivep, (* file used by this program *) dxyin: text; (* file used by this program *) (* 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 = 5.31; (@ of prgmod.p 2006 Oct 10 *) (* 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 = 5.31; (@ of prgmod.p 2006 Oct 10 *) (* begin module getcolumns *) procedure getcolumns(var xyin: text; column1, column2: integer; var x, y: real); (* get the x and y values from the two designated columns. *) begin if (column1 <> 1) and (column2 <> 2) then begin writeln(output,'COLUMNS NOT BEING READ PROPERLY YET'); halt; end; readln(xyin, x, y); end; (* end module getcolumns *) (* begin module derive.themain *) procedure themain(var xyin, derivep, dxyin: text); (* the main procedure of the program *) var parameterversion: real; (* parameter version number *) columnx, columny: integer; (* columns to be read *) x0, y0: real; (* previous values of the computation *) x1, y1: real; (* current values of the computation *) slope: real; (* computed slope *) initializing: boolean; (* when to start computing *) xwidth, xdecimal: integer; (* characters for output *) ywidth, ydecimal: integer; (* characters for output *) swidth, sdecimal: integer; (* characters for output *) begin writeln(output,'derive ',version:4:2); reset(derivep); readln(derivep, parameterversion); if round(100*parameterversion) < round(100*updateversion) then begin writeln(output, 'You have an old parameter file!'); halt end; columnx := 1; columny := 2; xwidth := 15; xdecimal := 13; ywidth := 15; ydecimal := 13; swidth := 15; sdecimal := 13; reset(xyin); rewrite(dxyin); writeln(dxyin,'* derive ',version:4:2); initializing := true; while not eof(xyin) do begin if eoln(xyin) then begin readln(xyin); writeln(dxyin); end else begin if xyin^ = '*' then begin copyaline(xyin, dxyin); end else begin if initializing then begin getcolumns(xyin, columnx, columny, x0, y0); {writeln(output,'INITIALIZING');} { writeln(output, x0:xwidth:xdecimal, ' ', y0:ywidth:ydecimal ); } initializing := false; writeln(dxyin); writeln(dxyin, '* dxyin columns: x, y, slope'); end else begin {writeln(output,'STEPPING');} getcolumns(xyin, columnx, columny, x1, y1); if x1 - x0 = 0 then begin writeln(output, 'x1 = x0 = ', x1:5:2); halt; end; { slope := (y1 - y0)/(x1 - x0); } slope := (ln(y1) - ln(y0))/(ln(x1) - ln(x0)); writeln(dxyin, x0:xwidth:xdecimal, ' ', y0:ywidth:ydecimal, ' ', slope:swidth:sdecimal); (* step the variables forward for next time *) x0 := x1; y0 := y1; end end end end; end; (* end module derive.themain *) begin themain(xyin, derivep, dxyin); 1: end.