module Biobase.SubstMatrix.Embedded where

import Control.Monad.Except
import Data.ByteString (ByteString)
import Data.FileEmbed
import Control.Arrow (second)
import GHC.Real(Ratio(..))

import Numeric.Discretized
import Statistics.Odds

import Biobase.SubstMatrix.Import
import Biobase.SubstMatrix.Types



embeddedPamBlosumFiles  [(FilePath,ByteString)]
embeddedPamBlosumFiles :: [(FilePath, ByteString)]
embeddedPamBlosumFiles = $(makeRelativeToProject "sources/PamBlosum" >>= embedDir)

embeddedPamBlosum  [(FilePath,AASubstMat t (DiscLogOdds (1:%1)) a b)]
embeddedPamBlosum :: [(FilePath, AASubstMat t (DiscLogOdds (1 ':% 1)) a b)]
embeddedPamBlosum = (FilePath
 -> [(FilePath, AASubstMat t (DiscLogOdds (1 ':% 1)) a b)])
-> ([(FilePath, AASubstMat t (DiscLogOdds (1 ':% 1)) a b)]
    -> [(FilePath, AASubstMat t (DiscLogOdds (1 ':% 1)) a b)])
-> Either
     FilePath [(FilePath, AASubstMat t (DiscLogOdds (1 ':% 1)) a b)]
-> [(FilePath, AASubstMat t (DiscLogOdds (1 ':% 1)) a b)]
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either FilePath -> [(FilePath, AASubstMat t (DiscLogOdds (1 ':% 1)) a b)]
forall a. HasCallStack => FilePath -> a
error [(FilePath, AASubstMat t (DiscLogOdds (1 ':% 1)) a b)]
-> [(FilePath, AASubstMat t (DiscLogOdds (1 ':% 1)) a b)]
forall a. a -> a
id (Either
   FilePath [(FilePath, AASubstMat t (DiscLogOdds (1 ':% 1)) a b)]
 -> [(FilePath, AASubstMat t (DiscLogOdds (1 ':% 1)) a b)])
-> ([(FilePath, ByteString)]
    -> Either
         FilePath [(FilePath, AASubstMat t (DiscLogOdds (1 ':% 1)) a b)])
-> [(FilePath, ByteString)]
-> [(FilePath, AASubstMat t (DiscLogOdds (1 ':% 1)) a b)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Except
  FilePath [(FilePath, AASubstMat t (DiscLogOdds (1 ':% 1)) a b)]
-> Either
     FilePath [(FilePath, AASubstMat t (DiscLogOdds (1 ':% 1)) a b)]
forall e a. Except e a -> Either e a
runExcept
                  (Except
   FilePath [(FilePath, AASubstMat t (DiscLogOdds (1 ':% 1)) a b)]
 -> Either
      FilePath [(FilePath, AASubstMat t (DiscLogOdds (1 ':% 1)) a b)])
-> ([(FilePath, ByteString)]
    -> Except
         FilePath [(FilePath, AASubstMat t (DiscLogOdds (1 ':% 1)) a b)])
-> [(FilePath, ByteString)]
-> Either
     FilePath [(FilePath, AASubstMat t (DiscLogOdds (1 ':% 1)) a b)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((FilePath, ByteString)
 -> ExceptT
      FilePath
      Identity
      (FilePath, AASubstMat t (DiscLogOdds (1 ':% 1)) a b))
-> [(FilePath, ByteString)]
-> Except
     FilePath [(FilePath, AASubstMat t (DiscLogOdds (1 ':% 1)) a b)]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (\(FilePath
k,ByteString
v)  ByteString
-> ExceptT
     FilePath Identity (AASubstMat t (DiscLogOdds (1 ':% 1)) a b)
forall k1 k2 k3 k4 (m :: * -> *) (k5 :: k1) (t :: k2) (a :: k3)
       (b :: k4).
(MonadError FilePath m, Real (Discretized k5)) =>
ByteString -> m (AASubstMat t (DiscLogOdds k5) a b)
fromByteString ByteString
v ExceptT
  FilePath Identity (AASubstMat t (DiscLogOdds (1 ':% 1)) a b)
-> (AASubstMat t (DiscLogOdds (1 ':% 1)) a b
    -> ExceptT
         FilePath
         Identity
         (FilePath, AASubstMat t (DiscLogOdds (1 ':% 1)) a b))
-> ExceptT
     FilePath
     Identity
     (FilePath, AASubstMat t (DiscLogOdds (1 ':% 1)) a b)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \AASubstMat t (DiscLogOdds (1 ':% 1)) a b
mv  (FilePath, AASubstMat t (DiscLogOdds (1 ':% 1)) a b)
-> ExceptT
     FilePath
     Identity
     (FilePath, AASubstMat t (DiscLogOdds (1 ':% 1)) a b)
forall (m :: * -> *) a. Monad m => a -> m a
return (FilePath
k,AASubstMat t (DiscLogOdds (1 ':% 1)) a b
mv))
                  ([(FilePath, ByteString)]
 -> [(FilePath, AASubstMat t (DiscLogOdds (1 ':% 1)) a b)])
-> [(FilePath, ByteString)]
-> [(FilePath, AASubstMat t (DiscLogOdds (1 ':% 1)) a b)]
forall a b. (a -> b) -> a -> b
$ [(FilePath, ByteString)]
embeddedPamBlosumFiles
{-# NoInline embeddedPamBlosum #-}