1
0
Fork 0
factor-puzzles/rosalind/eval/eval.factor

19 lines
611 B
Factor
Raw Normal View History

2020-11-29 08:22:10 +01:00
! Copyright (C) 2021 Bubbler.
! See http://factorcode.org/license.txt for BSD license.
USING: arrays assocs io io.encodings.utf8 io.files kernel math
math.parser sequences splitting ;
IN: rosalind.eval
: (eval) ( n str gc-content -- prob )
2 / 0.5 over - 2array dup append "CAGT" swap zip
[ dup >array ] dip substitute product
[ length - 1 + ] dip * ;
: eval ( n str gc-contents -- seq ) [ (eval) ] 2with map ;
: eval-main ( -- )
"datasets/rosalind/eval.txt" utf8 file-contents "\n" split first3
[ dec> ] [ ] [ " " split [ dec> ] map ] tri*
eval [ 10 >base ] map " " join print ;
MAIN: eval-main