1 ! Copyright (C) 2008, 2010 Slava Pestov.
2 ! See https://factorcode.org/license.txt for BSD license.
3 USING: ascii assocs formatting grouping io io.encodings.ascii
4 io.files kernel math math.statistics sequences ;
5 IN: benchmark.knucleotide
7 CONSTANT: knucleotide-in "vocab:benchmark/knucleotide/knucleotide-input.txt"
11 [ ">THREE" head? [ discard-lines ] unless ] when* ;
13 : read-input ( -- input )
16 CHAR: \n swap remove >upper ;
18 : handle-table ( inputs n -- )
20 [ sorted-histogram reverse ] [ length ] bi
23 [ second 100 * _ /f "%.3f" printf nl ] bi
26 : handle-n ( input x -- )
27 [ nip ] [ length clump histogram ] 2bi at 0 or "%d\t" printf ;
29 : process-input ( input -- )
33 { "GGT" "GGTA" "GGTATT" "GGTATTTTAATT" "GGTATTTTAATTTATAGT" }
34 [ [ handle-n ] keep print ] with each
38 : knucleotide-benchmark ( -- )
40 ascii [ read-input ] with-file-reader
43 MAIN: knucleotide-benchmark