module ELynx.Export.Sequence.Fasta
( sequenceToFasta,
sequencesToFasta,
)
where
import qualified Data.ByteString.Lazy.Char8 as BL
import ELynx.Data.Sequence.Sequence
fastaHeader :: BL.ByteString -> BL.ByteString -> BL.ByteString
ByteString
n ByteString
d =
Char -> ByteString
BL.singleton Char
'>' ByteString -> ByteString -> ByteString
forall a. Semigroup a => a -> a -> a
<> ByteString
n ByteString -> ByteString -> ByteString
forall a. Semigroup a => a -> a -> a
<> if ByteString -> Bool
BL.null ByteString
d then ByteString
BL.empty else [Char] -> ByteString
BL.pack [Char]
" " ByteString -> ByteString -> ByteString
forall a. Semigroup a => a -> a -> a
<> ByteString
d
sequenceToFasta :: Sequence -> BL.ByteString
sequenceToFasta :: Sequence -> ByteString
sequenceToFasta Sequence
s =
[ByteString] -> ByteString
BL.unlines [ByteString -> ByteString -> ByteString
fastaHeader (Sequence -> ByteString
name Sequence
s) (Sequence -> ByteString
description Sequence
s), Characters -> ByteString
toByteString (Characters -> ByteString) -> Characters -> ByteString
forall a b. (a -> b) -> a -> b
$ Sequence -> Characters
characters Sequence
s]
sequencesToFasta :: [Sequence] -> BL.ByteString
sequencesToFasta :: [Sequence] -> ByteString
sequencesToFasta [Sequence]
ss = [ByteString] -> ByteString
BL.concat ([ByteString] -> ByteString) -> [ByteString] -> ByteString
forall a b. (a -> b) -> a -> b
$ (Sequence -> ByteString) -> [Sequence] -> [ByteString]
forall a b. (a -> b) -> [a] -> [b]
map Sequence -> ByteString
sequenceToFasta [Sequence]
ss