| Copyright | (c) Dominik Schrempf 2021 |
|---|---|
| License | GPL-3.0-or-later |
| Maintainer | dominik.schrempf@gmail.com |
| Stability | unstable |
| Portability | portable |
| Safe Haskell | None |
| Language | Haskell2010 |
ELynx.Tree.Length
Description
Creation date: Thu Jan 17 14:16:34 2019.
Non-negativity of lengths is not completely ensured. See the documentation of
Length.
Synopsis
- data Length
- toLength :: Double -> Either String Length
- toLengthUnsafe :: Double -> Length
- class HasMaybeLength e where
- getMaybeLength :: e -> Maybe Length
- class HasMaybeLength e => HasLength e where
- height :: HasLength e => Tree e a -> Length
- rootHeight :: HasLength e => Tree e a -> Length
- distancesOriginLeaves :: HasLength e => Tree e a -> [Length]
- totalBranchLength :: HasLength e => Tree e a -> Length
- normalizeBranchLengths :: HasLength e => Tree e a -> Tree e a
- normalizeHeight :: HasLength e => Tree e a -> Tree e a
- ultrametric :: HasLength e => Tree e a -> Bool
- makeUltrametric :: HasLength e => Tree e a -> Tree e a
Non-negative length
Non-negative length.
However, non-negativity is only checked with toLength, and negative values
can be obtained using the Num and related instances.
Safe conversion is roughly 50 percent slower.
benchmarking length/length sum foldl' with safe conversion
time 110.4 ms (109.8 ms .. 111.0 ms)
1.000 R² (1.000 R² .. 1.000 R²)
mean 110.2 ms (110.0 ms .. 110.6 ms)
std dev 501.8 μs (359.1 μs .. 730.0 μs)
benchmarking length/length sum foldl' num instance
time 89.37 ms (85.13 ms .. 94.27 ms)
0.996 R² (0.992 R² .. 1.000 R²)
mean 86.53 ms (85.63 ms .. 88.52 ms)
std dev 2.239 ms (1.069 ms .. 3.421 ms)
benchmarking length/double sum foldl'
time 85.47 ms (84.88 ms .. 86.42 ms)
1.000 R² (0.999 R² .. 1.000 R²)
mean 85.56 ms (85.26 ms .. 86.02 ms)
std dev 611.9 μs (101.5 μs .. 851.7 μs)
Instances
toLengthUnsafe :: Double -> Length Source #
Do not check if value is negative.
class HasMaybeLength e where Source #
Class of data types that may have a length.
Methods
getMaybeLength :: e -> Maybe Length Source #
Instances
| HasMaybeLength () Source # | |
Defined in ELynx.Tree.Length Methods getMaybeLength :: () -> Maybe Length Source # | |
| HasMaybeLength Length Source # | |
Defined in ELynx.Tree.Length | |
| HasMaybeLength Support Source # | |
Defined in ELynx.Tree.Export.Newick | |
| HasMaybeLength PhyloExplicit Source # | |
Defined in ELynx.Tree.Phylogeny Methods | |
| HasMaybeLength Phylo Source # | |
Defined in ELynx.Tree.Phylogeny | |
class HasMaybeLength e => HasLength e where Source #
Class of data types with measurable and modifiable length.
Methods
getLength :: e -> Length Source #
setLength :: Length -> e -> e Source #
modifyLength :: (Length -> Length) -> e -> e Source #
Instances
| HasLength Length Source # | |
| HasLength PhyloExplicit Source # | |
Defined in ELynx.Tree.Phylogeny Methods getLength :: PhyloExplicit -> Length Source # setLength :: Length -> PhyloExplicit -> PhyloExplicit Source # modifyLength :: (Length -> Length) -> PhyloExplicit -> PhyloExplicit Source # | |
height :: HasLength e => Tree e a -> Length Source #
The maximum distance between origin and leaves.
The height includes the branch length of the stem.
rootHeight :: HasLength e => Tree e a -> Length Source #
The maximum distance between root node and leaves.
Functions on trees
distancesOriginLeaves :: HasLength e => Tree e a -> [Length] Source #
Distances from the origin of a tree to the leaves.
The distances include the branch length of the stem.