Copyright | (c) Dominik Schrempf 2017 |
---|---|
License | GPLv3 |
Maintainer | dominik.schrempf@gmail.com |
Stability | unstable |
Portability | non-portable (not tested) |
Safe Haskell | None |
Language | Haskell2010 |
The boundary mutation model is a discrete-state, continuous-time Markov process that allows mutations only when the population is monomorphic.
- Changelog
TODO: BM states can not be read and written with a single letter, like characters. Check status of implementation.
Synopsis
- data Nucleotide
- type Allele = Nucleotide
- type PopulationSize = Int
- type AlleleCount = Int
- data State
- = Bnd {
- bndN :: PopulationSize
- bndA :: Allele
- | Ply {
- plyN :: PopulationSize
- plyI :: AlleleCount
- plyA :: Allele
- plyB :: Allele
- = Bnd {
- showCounts :: State -> ByteString
- nFixed :: Int
- setPopulationSize :: PopulationSize -> State -> Maybe State
- fromIndexWith :: PopulationSize -> Int -> State
- toIndex :: State -> Int
- stateSpace :: PopulationSize -> [State]
- stateSpaceSize :: PopulationSize -> Int
- neighbors :: State -> State -> Bool
Types
data Nucleotide Source #
Nucleotides.
Instances
type Allele = Nucleotide Source #
Alleles are just nucleotides at the moment. However, I want to keep the code such that it can be extended easily to codons or amino acids.
type PopulationSize = Int Source #
The population size has to be larger than one otherwise there be dragons.
type AlleleCount = Int Source #
The absolute frequency of an allele.
A boundary mutation model state is either a boundary state or a polymorphic state. The population size has to be larger than one; the allele count has to be larger than one and lower than the population size, otherwise there be dragons.
Another possibility would be:
data State = Bnd Allele | Ply AlleleCount Allele Allele
data StateComplete = StateComplete PopulationSize State
But then, I think it is more important that the information is kept in one,
at the cost of some overhead.
Bnd | |
| |
Ply | |
|
Instances
Bounded State Source # | A fixed population size |
Enum State Source # | Enumeration only works when the population size is |
Defined in ELynx.Data.Character.BoundaryMutation | |
Eq State Source # | |
Ord State Source # | A total order on the boundary mutation model states. In general, Bnd < Ply. Then, sorting happens according to the order population size, first allele, second allele, allele count. It may be beneficial to reverse the allele count order (i.e., make a polymorphic state with higher allele count show up before a polymorphic state with lower allele count, this would move some polymorphic states closer to their respective boundaries), |
Read State Source # | |
showCounts :: State -> ByteString Source #
L.ByteString representation of State
; without surrounding brackets.
Fixed population size when converting a State
to or from a number. In
this case, a fixed population size is necessary so that toEnum . fromEnum ==
id
. When converting from a number to State
, the population size has to be
given or assumed (see fromIndexWith
) anyways. Especially when performing IO,
the same number should always correspond to the same State
(bijection).
nFixed
has been set such that the size of the state space is 256.
Functions
setPopulationSize :: PopulationSize -> State -> Maybe State Source #
fromIndexWith :: PopulationSize -> Int -> State Source #
For a given population size PopulationSize
, convert a number Int
to State
.
toIndex :: State -> Int Source #
Convert State
to a number Int
for the given population size PopulationSize
.
Back conversion can be done with fromIndexWith
, with the same population size.
stateSpace :: PopulationSize -> [State] Source #
Sorted list of all possible PoMo states for a specific population size.
stateSpaceSize :: PopulationSize -> Int Source #
The state space of the boundary mutation model for four alleles and a population size N is 4 + 6*(N-1).