2010-04-14 05:32:54 -04:00
|
|
|
USING: ascii kernel io io.files splitting strings
|
|
|
|
io.encodings.ascii hashtables sequences assocs math
|
|
|
|
math.statistics namespaces prettyprint math.parser combinators
|
|
|
|
arrays sorting formatting grouping fry ;
|
2007-11-24 19:55:48 -05:00
|
|
|
IN: benchmark.knucleotide
|
|
|
|
|
|
|
|
: discard-lines ( -- )
|
|
|
|
readln
|
2007-11-25 00:50:12 -05:00
|
|
|
[ ">THREE" head? [ discard-lines ] unless ] when* ;
|
2007-11-24 19:55:48 -05:00
|
|
|
|
|
|
|
: read-input ( -- input )
|
|
|
|
discard-lines
|
|
|
|
">" read-until drop
|
2007-11-25 00:50:12 -05:00
|
|
|
CHAR: \n swap remove >upper ;
|
2007-11-24 19:55:48 -05:00
|
|
|
|
|
|
|
: handle-table ( inputs n -- )
|
2010-04-15 00:50:00 -04:00
|
|
|
<clumps>
|
2010-04-14 05:32:54 -04:00
|
|
|
[ histogram >alist sort-values reverse ] [ length ] bi
|
|
|
|
'[
|
|
|
|
[ first write bl ]
|
|
|
|
[ second 100 * _ /f "%.3f" printf nl ] bi
|
|
|
|
] each ;
|
2007-11-24 19:55:48 -05:00
|
|
|
|
2010-04-14 05:32:54 -04:00
|
|
|
: handle-n ( input x -- )
|
2010-04-15 00:50:00 -04:00
|
|
|
[ nip ] [ length <clumps> histogram ] 2bi at 0 or "%d\t" printf ;
|
2007-11-24 19:55:48 -05:00
|
|
|
|
|
|
|
: process-input ( input -- )
|
2010-04-14 05:32:54 -04:00
|
|
|
[ 1 handle-table nl ]
|
|
|
|
[ 2 handle-table nl ]
|
|
|
|
[
|
|
|
|
{ "GGT" "GGTA" "GGTATT" "GGTATTTTAATT" "GGTATTTTAATTTATAGT" }
|
|
|
|
[ [ handle-n ] keep print ] with each
|
|
|
|
]
|
|
|
|
tri ;
|
2007-11-24 19:55:48 -05:00
|
|
|
|
|
|
|
: knucleotide ( -- )
|
2008-05-06 13:37:11 -04:00
|
|
|
"resource:extra/benchmark/knucleotide/knucleotide-input.txt"
|
2008-02-16 23:17:41 -05:00
|
|
|
ascii [ read-input ] with-file-reader
|
2007-11-25 00:50:12 -05:00
|
|
|
process-input ;
|
2007-11-24 19:55:48 -05:00
|
|
|
|
|
|
|
MAIN: knucleotide
|