-- |
-- Module      :  ELynx.Data.MarkovProcess.PhyloModel
-- Description :  Phylogenetic model
-- Copyright   :  (c) Dominik Schrempf 2021
-- License     :  GPL-3.0-or-later
--
-- Maintainer  :  dominik.schrempf@gmail.com
-- Stability   :  unstable
-- Portability :  portable
--
-- Creation date: Fri Feb  1 12:43:06 2019.
--
-- A phylogenetic model is a complete description of the evolutionary process. At
-- the moment, it is either a mixture model or a plain substitution model, but more
-- complicated models may be added in the future.
--
-- To be imported qualified.
module ELynx.Data.MarkovProcess.PhyloModel
  ( PhyloModel (..),
    getAlphabet,
  )
where

import ELynx.Data.Alphabet.Alphabet
import qualified ELynx.Data.MarkovProcess.MixtureModel as M
import qualified ELynx.Data.MarkovProcess.SubstitutionModel as S

-- | A phylogenetic model is a mixture model or a substitution model. More
-- complicated models may be added.
data PhyloModel = MixtureModel M.MixtureModel | SubstitutionModel S.SubstitutionModel
  deriving (Int -> PhyloModel -> ShowS
[PhyloModel] -> ShowS
PhyloModel -> String
(Int -> PhyloModel -> ShowS)
-> (PhyloModel -> String)
-> ([PhyloModel] -> ShowS)
-> Show PhyloModel
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PhyloModel] -> ShowS
$cshowList :: [PhyloModel] -> ShowS
show :: PhyloModel -> String
$cshow :: PhyloModel -> String
showsPrec :: Int -> PhyloModel -> ShowS
$cshowsPrec :: Int -> PhyloModel -> ShowS
Show, ReadPrec [PhyloModel]
ReadPrec PhyloModel
Int -> ReadS PhyloModel
ReadS [PhyloModel]
(Int -> ReadS PhyloModel)
-> ReadS [PhyloModel]
-> ReadPrec PhyloModel
-> ReadPrec [PhyloModel]
-> Read PhyloModel
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PhyloModel]
$creadListPrec :: ReadPrec [PhyloModel]
readPrec :: ReadPrec PhyloModel
$creadPrec :: ReadPrec PhyloModel
readList :: ReadS [PhyloModel]
$creadList :: ReadS [PhyloModel]
readsPrec :: Int -> ReadS PhyloModel
$creadsPrec :: Int -> ReadS PhyloModel
Read)

-- | Extract code from phylogenetic model.
getAlphabet :: PhyloModel -> Alphabet
getAlphabet :: PhyloModel -> Alphabet
getAlphabet (MixtureModel MixtureModel
mm) = MixtureModel -> Alphabet
M.alphabet MixtureModel
mm
getAlphabet (SubstitutionModel SubstitutionModel
sm) = SubstitutionModel -> Alphabet
S.alphabet SubstitutionModel
sm