program dirty(dirtyp, distribution, xyin, output); (* dirty: calculate probabilities for dirty DNA synthesis tom schneider *) label 1; (* end of program *) const (* begin module version *) version = 2.39; (* of dirty, 1994 sep 5 origin: 1987 may 28 *) (* end module version *) (* begin module describe.dirty *) (* name dirty: calculate probabilities for dirty DNA synthesis synopsis dirty(dirtyp: in, distribition: out, xyin: out, output: out) files dirtyp: parameter file. one line giving the number of random bases that will be used (r). one line giving the average number of changes desired (n) distribution: the distribution of numbers of changes at the peak for n xyin: Graphics output of the program. The input to xyplo for plotting. The graph gives three curves against the independent variable p, which is the probability of getting the correct base and randoms is the number of random bases: o = probability of only one base changed, as randoms (1-p)p^(randoms-1) m = probability of one or more bases changed: 1 - p^randoms n = probability of n bases changed I have not found this output to be too useful; I concentrate on the distribution file. output: messages to the user description If one is designing a randomized ("dirty") DNA synthesis, how heavily should it be randomized? To use this program, pick the size of the region you want to randomize, r. Then make a guess at the average number of changes you want over the region, n. Put r and n into dirtyp and run the program. Look at the distribution file. the line for n=0 is the frequency that you will get back the original sequence. You must chose whether this is tolerable. For example, when I synthesized the T7 promoters, I knew that I could find at least 1 promoter in 100 clones by toothpicking, and I was willing to toothpick thousands. This way I was sure to get some positives, even if they were the original sequence. (As it turned out, the frequency of functional promoters was much higher than 1%.) If you have a strong selection, you could make this a small number, by increasing the number of changes per clone. With more changes per clone you will get more data from the randomization, so make it as high as you can tolerate. The program calculates the ratio of bases to random bases. In the experiment described in the NAR paper, the technician put 4 drops of the appropriate base with 1 drop of the equiprobable mix. This made the dirty bottle. example This is the analysis used in the NAR paper. With the dirtyp file containing: 27 the number of random bases that will be used. 4 the number of changes desired (n) the distribution file is: * dirty 2.38 * distribution of number of changes calculated from binomial * 27 random positions * 4 average number of bases changed * p = probability of correct base = 0.85185185 * fraction of [base] : 0.80246914 * fraction of [random n] : 0.19753086 * * ratio of [base] to [random N]: 4.06250000 * * TO DO THE SYNTHESIS, * add one part of an equimolar mixture of the 4 bases * to 4.06250000 parts of the "wild type" base * * In the following table, * n = number of changes * f = frequency of n changes * s = running sum of frequencies f (should approach 1.0) * In the first row, where n=0, f is the frequency of wild type sequences * n = 0 f = 0.01317741 s = 0.01317741 n = 1 f = 0.06187652 s = 0.07505392 n = 2 f = 0.13989473 s = 0.21494866 n = 3 f = 0.20274599 s = 0.41769465 n = 4 f = 0.21156103 s = 0.62925568 n = 5 f = 0.16924883 s = 0.79850451 n = 6 f = 0.10792679 s = 0.90643130 n = 7 f = 0.05630963 s = 0.96274093 n = 8 f = 0.02448245 s = 0.98722338 n = 9 f = 0.00898872 s = 0.99621210 n =10 f = 0.00281386 s = 0.99902596 n =11 f = 0.00075629 s = 0.99978226 n =12 f = 0.00017537 s = 0.99995763 n =13 f = 0.00003519 s = 0.99999282 n =14 f = 0.00000612 s = 0.99999894 n =15 f = 0.00000092 s = 0.99999986 n =16 f = 0.00000012 s = 0.99999999 n =17 f = 0.00000001 s = 1.00000000 n =18 f = 0.00000000 s = 1.00000000 n =19 f = 0.00000000 s = 1.00000000 n =20 f = 0.00000000 s = 1.00000000 n =21 f = 0.00000000 s = 1.00000000 n =22 f = 0.00000000 s = 1.00000000 n =23 f = 0.00000000 s = 1.00000000 n =24 f = 0.00000000 s = 1.00000000 n =25 f = 0.00000000 s = 1.00000000 n =26 f = 0.00000000 s = 1.00000000 n =27 f = 0.00000000 s = 1.00000000 see also xyplo.p documentation @article{Schneider1989, author = "T. D. Schneider and G. D. Stormo", title = "Excess Information at Bacteriophage {T7} Genomic Promoters Detected by a Random Cloning Technique", year = "1989", journal = "Nucleic Acids Research", volume = "17", pages = "659-674"} author Tom Schneider National Cancer Institute Laboratory of Mathematical Biology Frederick, Maryland toms@ncifcrf.gov bugs n must be an integer *) (* end module describe.dirty *) var b: real; (* fraction of one base in total dirty mix *) dirtyp: text; (* parameter file from which to read randoms *) distribution: text; (* number of changes *) g: real; (* probability of having n changes *) o: real; (* probability of having exactly one change *) m: real; (* probability of having one or more change *) n: integer; (* average number of given changes *) p: real; (* the probability of having a correct base in one position *) r: real; (* fraction of one base to mix with N base *) randoms: integer; (* number of random positions to calculate for *) sum: real; (* running sum of g *) xyin: text; (* the input to the xyplo program for plotting, output of this program *) x: real; (* ratio of the random base (N) in total dirty mix *) (* 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'; *) function raise(tothe: integer):real; (* raise p to the tothe *) begin raise := exp(tothe*ln(p)) end; function calcgiven(p: real): real; (* calculate the frequency of n given changes, warning: n is global! *) var i: integer; (* index *) m: real; (* multiplicative parameter *) begin m:=1.0; for i := randoms-n+1 to randoms do m := m * i; for i := 2 to n do m := m/i; calcgiven := m * raise(randoms-n) * exp( n * ln(1-p)); end; procedure header(var f: text); (* give information about what the run is about *) begin rewrite(f); writeln(f,'* dirty ',version:4:2); writeln(f,'* ',randoms:1,' random positions'); writeln(f,'* independent variable, p = probability of correct base'); writeln(f,'* dependendent variables: o, m'); writeln(f,'* o = probability of only one base changed, as ', randoms:1, '(1-p)p^', (randoms-1):1); writeln(f,'* m = probability of one or more bases changed, 1 - p^', randoms:1); writeln(f,'* n = probability of n (=',n:1,') bases changed', ' calculated from binomial'); end; begin writeln(output,'dirty ',version:4:2); reset(dirtyp); if eof(dirtyp) then begin writeln(output,'empty parameter file'); halt end; readln(dirtyp,randoms); if randoms < 1 then begin writeln(output,'there must be at least 1 random position'); halt end; writeln(output,randoms:1,' random positions'); readln(dirtyp,n); if n <= 0 then begin writeln(output,'n must be positive'); halt end; if n > randoms then begin writeln(output,'n must less than or equal to the', ' number of random positions'); halt end; header(xyin); p := 0.01; while p < 1.0 do begin o := randoms * raise(randoms-1) * (1-p); m := 1-raise(randoms); g := calcgiven(p); (* based on n *) writeln(xyin,'o ',p:10:8, ' ',o:10:8); writeln(xyin,'n ',p:10:8, ' ',g:10:8); writeln(xyin,'m ',p:10:8, ' ',m:10:8, ' o/m ratio: ', o/m:10:8); p := p + 0.01 end; p := 1 - n/randoms; r := (1-p)*4/3; b := 1 - r; x := b / r; rewrite(distribution); writeln(distribution,'* dirty ',version:4:2); writeln(distribution,'* distribution of number of changes', ' calculated from binomial'); writeln(distribution,'* ',randoms:1,' random positions'); writeln(distribution,'* ',n:2,' average number of bases changed'); if r < 1.0 then begin writeln(distribution,'* p = probability of correct base = ',p:10:8); writeln(distribution,'* fraction of [base] : ',b:10:8); writeln(distribution,'* fraction of [random n] : ',r:10:8); writeln(distribution,'*'); writeln(distribution,'* ratio of [base] to [random N]: ',x:10:8); writeln(distribution,'*'); writeln(distribution,'* TO DO THE SYNTHESIS, '); writeln(distribution,'* add one part of an equimolar mixture', ' of the 4 bases'); writeln(distribution,'* to ',x:10:8,' parts of the "wild type" base'); writeln(distribution,'*'); writeln(distribution,'* In the following table,'); writeln(distribution,'* n = number of changes'); writeln(distribution,'* f = frequency of n changes'); writeln(distribution,'* s = running sum of frequencies f', ' (should approach 1.0)'); writeln(distribution,'* In the first row, where n=0,', ' f is the frequency of wild type sequences'); writeln(distribution,'*'); sum := 0; for n := 0 to randoms do begin g := calcgiven(p); (* based on n *) sum := sum + g; writeln(distribution,'n =',n:2, ' f = ',g:10:8, ' s = ',sum:10:8) end; end else begin writeln(distribution, '* USE PURE EQUIPROBABLY RANDOM BASES FOR THE SYNTHESIS.'); end; 1: end.