<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://dynamo.iro.umontreal.ca/wiki/skins/common/feed.css?270"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://dynamo.iro.umontreal.ca/wiki/index.php?title=Programming_language_shootout:_k-nucleotide&amp;feed=atom&amp;action=history</id>
		<title>Programming language shootout: k-nucleotide - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://dynamo.iro.umontreal.ca/wiki/index.php?title=Programming_language_shootout:_k-nucleotide&amp;feed=atom&amp;action=history"/>
		<link rel="alternate" type="text/html" href="http://dynamo.iro.umontreal.ca/wiki/index.php?title=Programming_language_shootout:_k-nucleotide&amp;action=history"/>
		<updated>2013-05-19T18:27:53Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.16.4</generator>

	<entry>
		<id>http://dynamo.iro.umontreal.ca/wiki/index.php?title=Programming_language_shootout:_k-nucleotide&amp;diff=83&amp;oldid=prev</id>
		<title>Bjlucier: disabling interrupts is bad form and doesn't improve performance.</title>
		<link rel="alternate" type="text/html" href="http://dynamo.iro.umontreal.ca/wiki/index.php?title=Programming_language_shootout:_k-nucleotide&amp;diff=83&amp;oldid=prev"/>
				<updated>2008-02-26T14:08:42Z</updated>
		
		<summary type="html">&lt;p&gt;disabling interrupts is bad form and doesn&amp;#39;t improve performance.&lt;/p&gt;
&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
		&lt;tr valign='top'&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;← Older revision&lt;/td&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 14:08, 26 February 2008&lt;/td&gt;
		&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 14:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 14:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;(define (substring-copy! dest dest-start source source-start source-end)&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;(define (substring-copy! dest dest-start source source-start source-end)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;nbsp; (declare (not interrupts-enabled))&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; (do ((i source-start (+ i 1))&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; (do ((i source-start (+ i 1))&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;  (j dest-start&amp;nbsp;  (+ j 1)))&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;  (j dest-start&amp;nbsp;  (+ j 1)))&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Bjlucier</name></author>	</entry>

	<entry>
		<id>http://dynamo.iro.umontreal.ca/wiki/index.php?title=Programming_language_shootout:_k-nucleotide&amp;diff=78&amp;oldid=prev</id>
		<title>Bjlucier: Add note about 20MB structure</title>
		<link rel="alternate" type="text/html" href="http://dynamo.iro.umontreal.ca/wiki/index.php?title=Programming_language_shootout:_k-nucleotide&amp;diff=78&amp;oldid=prev"/>
				<updated>2008-02-22T23:29:51Z</updated>
		
		<summary type="html">&lt;p&gt;Add note about 20MB structure&lt;/p&gt;
&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
		&lt;tr valign='top'&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;← Older revision&lt;/td&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 23:29, 22 February 2008&lt;/td&gt;
		&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 142:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 142:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The file knucleotide-input1000000.txt is generated by [[Programming language shootout: fasta| fasta]].&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The file knucleotide-input1000000.txt is generated by [[Programming language shootout: fasta| fasta]].&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;Note: Running the program with the largest data set creates a string of length 5,000,000.&amp;nbsp; With four-byte characters (Gambit's default) this is 20,000,000 byte object, and the largest object that can be created in a 32-bit system is a bit less than 16MB.&amp;nbsp; So, either configure Gambit with --enable-char-size=1 (or 2) or use a 64-bit version of Gambit.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Bjlucier</name></author>	</entry>

	<entry>
		<id>http://dynamo.iro.umontreal.ca/wiki/index.php?title=Programming_language_shootout:_k-nucleotide&amp;diff=65&amp;oldid=prev</id>
		<title>Bjlucier: correct link to alioth</title>
		<link rel="alternate" type="text/html" href="http://dynamo.iro.umontreal.ca/wiki/index.php?title=Programming_language_shootout:_k-nucleotide&amp;diff=65&amp;oldid=prev"/>
				<updated>2008-02-22T21:57:40Z</updated>
		
		<summary type="html">&lt;p&gt;correct link to alioth&lt;/p&gt;
&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
		&lt;tr valign='top'&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;← Older revision&lt;/td&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 21:57, 22 February 2008&lt;/td&gt;
		&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;This is a Gambit implementation of the [http://shootout.alioth.debian.org/&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;gp4&lt;/del&gt;/benchmark.php?test=&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;k-nucleotide&lt;/del&gt;&amp;amp;lang=all k-nucleotide] benchmark of the [[Programming language shootout|Computer Language Benchmarks Game]].&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;This is a Gambit implementation of the [http://shootout.alioth.debian.org/&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;gp4sandbox&lt;/ins&gt;/benchmark.php?test=&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;knucleotide&lt;/ins&gt;&amp;amp;lang=all k-nucleotide] benchmark of the [[Programming language shootout|Computer Language Benchmarks Game]].&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;This implementation is quite slow; nearly all the time is spent in all-counts.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;This implementation is quite slow; nearly all the time is spent in all-counts.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Bjlucier</name></author>	</entry>

	<entry>
		<id>http://dynamo.iro.umontreal.ca/wiki/index.php?title=Programming_language_shootout:_k-nucleotide&amp;diff=48&amp;oldid=prev</id>
		<title>Bjlucier: Add k-nuncleotide benchmark program page</title>
		<link rel="alternate" type="text/html" href="http://dynamo.iro.umontreal.ca/wiki/index.php?title=Programming_language_shootout:_k-nucleotide&amp;diff=48&amp;oldid=prev"/>
				<updated>2008-02-22T20:25:27Z</updated>
		
		<summary type="html">&lt;p&gt;Add k-nuncleotide benchmark program page&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;This is a Gambit implementation of the [http://shootout.alioth.debian.org/gp4/benchmark.php?test=k-nucleotide&amp;amp;lang=all k-nucleotide] benchmark of the [[Programming language shootout|Computer Language Benchmarks Game]].&lt;br /&gt;
&lt;br /&gt;
This implementation is quite slow; nearly all the time is spent in all-counts.&lt;br /&gt;
&lt;br /&gt;
==The program==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
;; The Computer Language Benchmarks Game&lt;br /&gt;
;; http://shootout.alioth.debian.org/&lt;br /&gt;
&lt;br /&gt;
;; Derived by Bradley Lucier from the Ikarus variant&lt;br /&gt;
;; derived by Michael D. Adams from the MzScheme variant&lt;br /&gt;
&lt;br /&gt;
(declare (standard-bindings)(extended-bindings)(block)(fixnum)(not safe))&lt;br /&gt;
&lt;br /&gt;
(define (substring-copy! dest dest-start source source-start source-end)&lt;br /&gt;
  (declare (not interrupts-enabled))&lt;br /&gt;
  (do ((i source-start (+ i 1))&lt;br /&gt;
       (j dest-start   (+ j 1)))&lt;br /&gt;
      ((= i source-end))&lt;br /&gt;
    (string-set! dest j (string-ref source i))))&lt;br /&gt;
&lt;br /&gt;
(define (strings-&amp;gt;string strings)&lt;br /&gt;
  (let* ((total-length&lt;br /&gt;
	  (do ((i 0 (+ i (string-length (car strings))))&lt;br /&gt;
	       (strings strings (cdr strings)))&lt;br /&gt;
	      ((null? strings) i)))&lt;br /&gt;
	 (result&lt;br /&gt;
	  (make-string total-length)))&lt;br /&gt;
    (let loop ((strings strings)&lt;br /&gt;
	       (i 0))&lt;br /&gt;
      (if (null? strings)&lt;br /&gt;
	  result&lt;br /&gt;
	  (let* ((string (car strings))&lt;br /&gt;
		 (n (string-length string)))&lt;br /&gt;
	    (substring-copy! result i string 0 n)&lt;br /&gt;
	    (loop (cdr strings)&lt;br /&gt;
		  (+ i n)))))))&lt;br /&gt;
&lt;br /&gt;
(define (insertion-sort lst &amp;lt;)&lt;br /&gt;
&lt;br /&gt;
  (define (insert item lst)&lt;br /&gt;
    (if (or (null? lst)&lt;br /&gt;
	    (&amp;lt; item (car lst)))&lt;br /&gt;
	(cons item lst)&lt;br /&gt;
	(cons (car lst)&lt;br /&gt;
	      (insert item (cdr lst)))))&lt;br /&gt;
&lt;br /&gt;
  (if (null? lst)&lt;br /&gt;
      lst&lt;br /&gt;
      (insert (car lst) (insertion-sort (cdr lst) &amp;lt;))))&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;&lt;br /&gt;
&lt;br /&gt;
;;;  Boiler-plate for formatting floating point values&lt;br /&gt;
&lt;br /&gt;
(define (roundto digits n)&lt;br /&gt;
  (declare (generic))&lt;br /&gt;
  (let* ((e (expt 10 digits))&lt;br /&gt;
         (num (round (abs (* e (inexact-&amp;gt;exact n)))))&lt;br /&gt;
         (str (number-&amp;gt;string (remainder num e))))&lt;br /&gt;
    (string-append&lt;br /&gt;
     (if (negative? n) &amp;quot;-&amp;quot; &amp;quot;&amp;quot;)&lt;br /&gt;
     (number-&amp;gt;string (quotient num e))&lt;br /&gt;
     &amp;quot;.&amp;quot;&lt;br /&gt;
     (make-string (- digits (string-length str)) #\0)&lt;br /&gt;
     str)))&lt;br /&gt;
&lt;br /&gt;
(define (upcase! str)&lt;br /&gt;
  (let ((n (string-length str)))&lt;br /&gt;
    (do ((i 0 (+ i 1)))&lt;br /&gt;
	((= i n) str)&lt;br /&gt;
      (string-set! str i (char-upcase (string-ref str i))))))&lt;br /&gt;
&lt;br /&gt;
(define (all-counts len dna)&lt;br /&gt;
  (let ((table (make-table test: string=?&lt;br /&gt;
			   size: (let ()&lt;br /&gt;
				   (declare (generic))&lt;br /&gt;
				   (min (expt 4 len) (string-length dna))))))&lt;br /&gt;
    (let loop ((s (- (string-length dna) len))&lt;br /&gt;
	       (seq (make-string len)))&lt;br /&gt;
      (if (&amp;lt; s 0)&lt;br /&gt;
	  table&lt;br /&gt;
	  (begin&lt;br /&gt;
	    (substring-copy! seq 0 dna s (+ s len))&lt;br /&gt;
	    (let* ((cnt (table-ref table seq 0)))&lt;br /&gt;
	      (table-set! table seq (+ 1 cnt))&lt;br /&gt;
	      (loop (- s 1)&lt;br /&gt;
		    (if (zero? cnt)&lt;br /&gt;
			(make-string len)&lt;br /&gt;
			seq))))))))&lt;br /&gt;
&lt;br /&gt;
(define (write-freqs table)&lt;br /&gt;
  (declare (generic))&lt;br /&gt;
  (let* ((keys+values (table-&amp;gt;list table))&lt;br /&gt;
	 (total  (apply + (map cdr keys+values))))&lt;br /&gt;
    (for-each (lambda (a)&lt;br /&gt;
		(display (car a)) (display &amp;quot; &amp;quot;)&lt;br /&gt;
		(display (roundto 3 (* 100 (/ (cdr a) total)))) (newline))&lt;br /&gt;
	      (insertion-sort keys+values (lambda (x y) (&amp;lt; (cdr y) (cdr x)))))))&lt;br /&gt;
&lt;br /&gt;
(define (write-one-freq table key)&lt;br /&gt;
  (let ((cnt (table-ref table key 0)))&lt;br /&gt;
    (display cnt) (display &amp;quot;\t&amp;quot;)&lt;br /&gt;
    (display key) (display &amp;quot;\n&amp;quot;)))&lt;br /&gt;
&lt;br /&gt;
(define dna&lt;br /&gt;
  (let ((port (current-input-port))&lt;br /&gt;
        (start &amp;quot;&amp;gt;THREE Homo sapiens frequency&amp;quot;))&lt;br /&gt;
    (let skip ((x (read-line port)))&lt;br /&gt;
      (if (not (string=? x start))&lt;br /&gt;
	  (skip (read-line port))&lt;br /&gt;
	  (let loop ((x (read-line port))&lt;br /&gt;
		     (s '()))&lt;br /&gt;
	    (if (eof-object? x)&lt;br /&gt;
		(strings-&amp;gt;string (reverse s))&lt;br /&gt;
		(loop (read-line port)&lt;br /&gt;
		      (cons (upcase! x) s))))))))&lt;br /&gt;
&lt;br /&gt;
;; 1-nucleotide counts:&lt;br /&gt;
(write-freqs (all-counts 1 dna))&lt;br /&gt;
(newline)&lt;br /&gt;
&lt;br /&gt;
;; 2-nucleotide counts:&lt;br /&gt;
(write-freqs (all-counts 2 dna))&lt;br /&gt;
(newline)&lt;br /&gt;
&lt;br /&gt;
;; Specific sequences:&lt;br /&gt;
(for-each (lambda (seq)&lt;br /&gt;
            (write-one-freq (all-counts (string-length seq) dna)&lt;br /&gt;
                            seq))&lt;br /&gt;
          '(&amp;quot;GGT&amp;quot; &amp;quot;GGTA&amp;quot; &amp;quot;GGTATT&amp;quot; &amp;quot;GGTATTTTAATT&amp;quot; &amp;quot;GGTATTTTAATTTATAGT&amp;quot;))&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
==Compiling==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
gsc k-nucleotide&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
==Running==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
gsi k-nucleotide &amp;lt; knucleotide-input1000000.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The file knucleotide-input1000000.txt is generated by [[Programming language shootout: fasta| fasta]].&lt;/div&gt;</summary>
		<author><name>Bjlucier</name></author>	</entry>

	</feed>