elynx-tree-0.6.0.0: Handle phylogenetic trees
Copyright(c) Dominik Schrempf 2021
LicenseGPL-3.0-or-later
Maintainerdominik.schrempf@gmail.com
Stabilityunstable
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

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

Non-negative length

data Length Source #

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

Instances details
Enum Length Source # 
Instance details

Defined in ELynx.Tree.Length

Eq Length Source # 
Instance details

Defined in ELynx.Tree.Length

Methods

(==) :: Length -> Length -> Bool #

(/=) :: Length -> Length -> Bool #

Floating Length Source # 
Instance details

Defined in ELynx.Tree.Length

Fractional Length Source # 
Instance details

Defined in ELynx.Tree.Length

Num Length Source # 
Instance details

Defined in ELynx.Tree.Length

Ord Length Source # 
Instance details

Defined in ELynx.Tree.Length

Read Length Source # 
Instance details

Defined in ELynx.Tree.Length

Real Length Source # 
Instance details

Defined in ELynx.Tree.Length

RealFloat Length Source # 
Instance details

Defined in ELynx.Tree.Length

RealFrac Length Source # 
Instance details

Defined in ELynx.Tree.Length

Methods

properFraction :: Integral b => Length -> (b, Length) #

truncate :: Integral b => Length -> b #

round :: Integral b => Length -> b #

ceiling :: Integral b => Length -> b #

floor :: Integral b => Length -> b #

Show Length Source # 
Instance details

Defined in ELynx.Tree.Length

Generic Length Source # 
Instance details

Defined in ELynx.Tree.Length

Associated Types

type Rep Length :: Type -> Type #

Methods

from :: Length -> Rep Length x #

to :: Rep Length x -> Length #

Semigroup Length Source # 
Instance details

Defined in ELynx.Tree.Length

Monoid Length Source # 
Instance details

Defined in ELynx.Tree.Length

NFData Length Source # 
Instance details

Defined in ELynx.Tree.Length

Methods

rnf :: Length -> () #

ToJSON Length Source # 
Instance details

Defined in ELynx.Tree.Length

FromJSON Length Source # 
Instance details

Defined in ELynx.Tree.Length

Default Length Source # 
Instance details

Defined in ELynx.Tree.Length

Methods

def :: Length #

Splittable Length Source # 
Instance details

Defined in ELynx.Tree.Length

Methods

split :: Length -> Length Source #

HasLength Length Source # 
Instance details

Defined in ELynx.Tree.Length

HasMaybeLength Length Source # 
Instance details

Defined in ELynx.Tree.Length

HasMaybeSupport Length Source # 
Instance details

Defined in ELynx.Tree.Export.Newick

type Rep Length Source # 
Instance details

Defined in ELynx.Tree.Length

type Rep Length = D1 ('MetaData "Length" "ELynx.Tree.Length" "elynx-tree-0.6.0.0-FQkEU9t6m33732ommPyIXg" 'True) (C1 ('MetaCons "Length" 'PrefixI 'True) (S1 ('MetaSel ('Just "fromLength") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Double)))

toLength :: Double -> Either String Length Source #

Return Left if negative.

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.

Instances

Instances details
HasMaybeLength () Source # 
Instance details

Defined in ELynx.Tree.Length

HasMaybeLength Length Source # 
Instance details

Defined in ELynx.Tree.Length

HasMaybeLength Support Source # 
Instance details

Defined in ELynx.Tree.Export.Newick

HasMaybeLength PhyloExplicit Source # 
Instance details

Defined in ELynx.Tree.Phylogeny

HasMaybeLength Phylo Source # 
Instance details

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 #

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.

totalBranchLength :: HasLength e => Tree e a -> Length Source #

Total branch length of a tree.

normalizeBranchLengths :: HasLength e => Tree e a -> Tree e a Source #

Normalize branch lengths so that the sum is 1.0.

normalizeHeight :: HasLength e => Tree e a -> Tree e a Source #

Normalize height of tree to 1.0.

ultrametric :: HasLength e => Tree e a -> Bool Source #

Check if a tree is ultrametric.

makeUltrametric :: HasLength e => Tree e a -> Tree e a Source #

Elongate terminal branches such that the tree becomes ultrametric.