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

18 lines
621 B
Factor
Raw Normal View History

2020-11-29 08:22:10 +01:00
! Copyright (C) 2020 Bubbler.
! See http://factorcode.org/license.txt for BSD license.
USING: arrays assocs fry grouping io io.encodings.utf8 io.files
kernel math.parser rosalind.common sequences ;
IN: rosalind.revp
: reverse-palindrome? ( dna -- ? )
dup "ACGT" "TGCA" zip substitute reverse = ;
: revp ( dna -- pairs )
{ 4 6 8 10 12 } swap
'[ _ over clump [ reverse-palindrome? ] map t swap indices [ 1 + ] map
swap '[ _ 2array ] map ] map concat ;
: revp-main ( -- ) "datasets/rosalind/revp.txt" utf8 file-contents
fasta>assoc first second revp [ [ 10 >base ] map " " join print ] each ;
MAIN: revp-main