2 <!-- MOZ_INSERT_CONTENT_HOOK -->
3 <script src = runner.js
></script>
5 var onlyName
= 'Homo sapiens frequenc', onlyNum
= 4;
8 // The Great Computer Language Shootout
9 // http://shootout.alioth.debian.org
11 // Contributed by Ian Osgood
13 var last
= 42, A
= 3877, C
= 29573, M
= 139968;
16 last
= (last
* A
+ C
) % M
;
17 return max
* last
/ M
;
21 "GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGG" +
22 "GAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGA" +
23 "CCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAAT" +
24 "ACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCA" +
25 "GCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGG" +
26 "AGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCC" +
27 "AGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAA";
30 a
:0.27, c
:0.12, g
:0.12, t
:0.27,
31 B
:0.02, D
:0.02, H
:0.02, K
:0.02,
32 M
:0.02, N
:0.02, R
:0.02, S
:0.02,
33 V
:0.02, W
:0.02, Y
:0.02
43 function makeCumulative(table
) {
45 for (var c
in table
) {
46 if (last
) table
[c
] += table
[last
];
51 function fastaRepeat(n
, seq
) {
52 var seqi
= 0, lenOut
= 60;
54 if (n
<lenOut
) lenOut
= n
;
55 if (seqi
+ lenOut
< seq
.length
) {
56 ret
= seq
.substring(seqi
, seqi
+lenOut
);
59 var s
= seq
.substring(seqi
);
60 seqi
= lenOut
- s
.length
;
61 ret
= s
+ seq
.substring(0, seqi
);
67 function fastaRandom(n
, table
) {
68 var line
= new Array(60);
69 makeCumulative(table
);
71 if (n
<line
.length
) line
= new Array(n
);
72 for (var i
=0; i
<line
.length
; i
++) {
74 for (var c
in table
) {
86 startTest("real-fasta");
90 for ( var n
= 2; n
<= 16; n
*= 2 ) (function(n
){
91 test( "Homo sapiens alu", n
, function(){
92 ret
= fastaRepeat(2*n
*100000, ALU
);
95 test( "IUB ambiguity codes", n
, function(){
96 ret
= fastaRandom(3*n
*1000, IUB
);
99 test( "Homo sapiens frequenc", n
, function(){
100 ret
= fastaRandom(5*n
*1000, HomoSap
);
107 <body onload=
"thisTest()"></body></html>