cobot-io-0.1.5.3: Biological data file formats and IO
Safe HaskellSafe-Inferred
LanguageHaskell2010

Bio.Sequence.Functions.Weight

Synopsis

Documentation

mean :: ContainsWeight s => s -> Double Source #

Calculate mean weight for given s.

sequWeighted = Sequence ['a', 'a', 'b', 'a'] someMarking [0.1, 0.2, 0.3, 0.4]

mean sequWeighted == 0.45

meanInRange :: ContainsWeight s => s -> RangeInclusive -> Double Source #

Calculate mean weight for given s in range RangeInclusive.

sequWeighted = Sequence ['a', 'a', 'b', 'a'] someMarkings [0.1, 0.2, 0.3, 0.4]
meanInRange sequWeighted (1, 2) == 0.25

getWeight :: (ContainsWeight s, MonadError Text m) => s -> Int -> m (Weight s) Source #

Get weight of element of s at given position.

getWeights :: ContainsWeight s => s -> [Weight s] Source #

Get Weights of all elements in s.

toWeighted :: (IsBareSequence s, IsWeightedSequence s', Weight s' ~ w, Element s ~ Element s', MonadError Text m) => s -> [w] -> m s' Source #

Converts IsBareSequence s to IsWeightedSequence s' that is weighted using provided list of Weights. If length of Weights list is different from length of s, an error is thrown.

sequBare = Sequence ['a', 'a', 'b', 'a'] mempty mempty :: BareSequence Char
toMarked sequ [0.1, 0.2, 0.3, 0.4] :: WeightedSequence Double Char

unsafeToWeighted :: (IsBareSequence s, IsWeightedSequence s', Weight s' ~ w, Element s ~ Element s') => s -> [w] -> s' Source #