program diffinst(insta, instb, data, output); (* diffinst: gives the difference between all coordinates in two inst files Ryan Shultzaberger and 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.08; (* of diffinst.p 2005 Sep 13 2005 Sep 13, 1.08: spelling: asterisk 2003 Aug 15, 1.07: funcational 2003 Aug 15, 1.06: now reads instructions even if the instruction line does not start with the word "get" 2000 Dec 5, 1.04: upgrade documentation origin 1999 July 9 *) updateversion = 1.00; (* defines lowest acceptable current parameter file *) (* end module version *) (* begin module describe.diffinst *) (* name diffinst: find the difference between all coordinates in two inst files synopsis diffinst(insta: in, instb: in, data: out, output: out) files insta: A delila instruction set containing instructions of the form: get from 100 -20 to same +20; instb: A delila instruction set containing instructions of the form: get from 200 -20 to same +20; data: a list of the numerical differences between the coordinates in insta and instb. output: messages to the user description The difference between all coordinates in two inst files is computed as: insta From coordinate - instb From coordinate. examples documentation see also nocom.p instshift.p author Ryan Kent Shultzaberger bugs The program cannot handle comments. It will use commented lines in only this instance comment start get ... ... comment stop where the get is on the left and the comment is on a separate line. technical notes Details about the implementation that may be relevant to a user. *) (* end module describe.diffinst *) var insta, (* delila instruction file in this program (insta - instb) *) instb, (* delila instruction file in this program (insta - instb) *) data: 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 = 'delmod 6.16 84 mar 12 tds/gds'; *) (* begin module skipblanks *) procedure skipblanks(var thefile: text); (* skip over blanks until a non-blank, or end of line, is found *) begin while (thefile^ = ' ') and not eoln(thefile) do get(thefile); end; procedure skipnonblanks(var thefile: text); (* skip over nonblanks until a blank, or end of line, is found *) begin while (thefile^ <> ' ') and not eoln(thefile) do get(thefile); end; procedure skipcolumn(var thefile: text); (* skip over a data column *) begin skipblanks(thefile); skipnonblanks(thefile) end; (* end module skipblanks version = 1.28; (@ of genhis, 1985 mar 9 *) (* begin module delilacomment *) procedure delilacomment(previous, current: char; var comparen, comcurly: boolean); (* Detect delila comments. Given the previous and current characters, determine if we are inside either a parenthesis comment or a curly comment. *) const asterisk = '*'; (* asterisk *) leftcurly = '{'; (* left curly parenthesis *) leftparen = '('; (* left parenthesis *) rightcurly = '}'; (* right curly parenthesis *) rightparen = ')'; (* right parenthesis *) begin if ((previous = leftparen) and (current = asterisk)) then comparen := true; if comparen and (not comcurly) and ((previous = asterisk) and (current = rightparen)) then comparen := false; if (not comparen) and (current = leftcurly) then comcurly := true; if comcurly and (not comparen) and (current = rightcurly) then comcurly := false; end; (* end module delilacomment *) (***************************************************************************) (***************************************************************************) (* begin module isitget *) procedure isitget(var thefile: text; var getbool: boolean); (* checks to see if the first word in the line is 'get' *) var c: char; (* generic character *) begin getbool := false; if eoln(thefile) then begin getbool := false; end else begin (* find "get" anywhere on the line *) while not eoln(thefile) and (getbool = false) do begin read(thefile,c); if c = 'g' then begin if eoln(thefile) then begin getbool := false; end else begin read(thefile,c); if c = 'e' then begin if eoln(thefile) then begin getbool := false; end else begin read(thefile,c); if c = 't' then begin getbool := true; end else begin getbool := false; end; end; end else begin getbool := false; end; end; end else begin getbool := false; end; end; end; end; (* module module isitget *) (* begin module finddiff *) procedure finddiff(coorda, coordb, orienta, orientb: integer); (* find the difference between two coordinates *) var difference: integer; (* the difference between the two coordinates *) begin if (orienta <= 0) and (orientb <= 0) then begin difference := coorda - coordb; end; if (orienta > 0) and (orientb > 0) then begin difference := coordb -coorda; end; if ((orienta <= 0) or (orientb <=0)) and ((orienta >0) or (orientb > 0)) then begin writeln(output,'Corresponding coordinates', ' need to have the same orientation'); halt; end; writeln(data,difference:1); end; (* end module finddiff *) (* begin module diffinstloop *) procedure diffinstloop; (* the main loop, that runs through the inst files *) var coorda: integer; (* the inst coordinate from insta *) coordb: integer; (* the inst coordinate from instb *) orienta: integer; (* the orrientation from insta *) orientb: integer; (* the orrientation from instb *) getboola: boolean; (* if true, then the first word in the line is get *) getboolb: boolean; (* if true, then the first word in the line is get *) comparen: boolean; (* if true, we are inside a standard comment *) comcurly: boolean; (* if true, we are inside a curly comment *) previous: char; (* the previous value of c *) begin getboola := false; getboolb := false; comcurly := false; comparen := false; previous := ' '; reset(insta); reset(instb); rewrite(data); while not eof(insta) and not eof(instb) do begin isitget(insta, getboola); while (getboola = false) and not eof(insta) do begin readln(insta); isitget(insta,getboola); end; isitget(instb, getboolb); while (getboolb = false) and not eof(instb) do begin readln(instb); isitget(instb,getboolb); end; if (getboola = true) and (getboolb = true) then begin skipcolumn(insta); (* skips from *) skipcolumn(instb); (* skips from *) read(insta, coorda); readln(insta, orienta); read(instb, coordb); readln(instb, orientb); finddiff(coorda, coordb, orienta, orientb); end; end; end; (* end module diffinstloop *) (* begin module diffinst.themain *) procedure themain; (* the main procedure of the program *) begin writeln(output,'diffinst ',version:4:2); diffinstloop; end; (* end module diffinst.themain *) begin themain; 1: end.