1 USING: ascii kernel io io.files splitting strings
2 io.encodings.ascii hashtables sequences assocs math
3 math.statistics namespaces prettyprint math.parser combinators
4 arrays sorting formatting grouping fry ;
5 IN: benchmark.knucleotide
9 [ ">THREE" head? [ discard-lines ] unless ] when* ;
11 : read-input ( -- input )
14 CHAR: \n swap remove >upper ;
16 : handle-table ( inputs n -- )
18 [ histogram >alist sort-values reverse ] [ length ] bi
21 [ second 100 * _ /f "%.3f" printf nl ] bi
24 : handle-n ( input x -- )
25 [ nip ] [ length clump histogram ] 2bi at 0 or "%d\t" printf ;
27 : process-input ( input -- )
31 { "GGT" "GGTA" "GGTATT" "GGTATTTTAATT" "GGTATTTTAATTTATAGT" }
32 [ [ handle-n ] keep print ] with each
37 "resource:extra/benchmark/knucleotide/knucleotide-input.txt"
38 ascii [ read-input ] with-file-reader