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

Bio.Sequence.Functions.Sequence

Synopsis

Documentation

drop :: ContainsNoMarking s => Int -> s -> s Source #

Unsafe drop: * if n < 0, an error is thrown; * if n >= length s, an error is thrown.

sequWeighted = Sequence ['a', 'a', 'b', 'a'] mempty [0.1, 0.2, 0.3, 0.4]
drop 2 sequWeighted == Sequence [b', 'a'] mempty [0.3, 0.4]
drop (-1) sequWeighted == error
drop 4 sequWeighted == error

getRange :: (IsSequence s, MonadError Text m, Complementary (Element s)) => s -> Range -> m [Element s] Source #

Get elements from sequence that belong to given Range. If the range is a Span, then both lower and upper bounds are included. If given Range is out of bounds, an error will be thrown.

sequ = Sequence ['a', 'a', 'b', 'a'] [("Letter A", (0, 2)), ("Letter A", (3, 4)), ("Letter B", (2, 3))] mempty
getRange sequ (0, 3) == Just ['a', 'a', 'b']

length :: IsSequence s => s -> Int Source #

Calculates length of s.

null :: IsSequence s => s -> Bool Source #

Returns True if s is empty. Returns False otherwise.

reverse :: IsSequence s => s -> s Source #

Reverses given IsSequence s. Markings and Weights are reversed, too.

sequ = Sequence ['a', 'a', 'b', 'a'] [("Letter A", (0, 2)), ("Letter A", (3, 4)), ("Letter B", (2, 3))] [1, 2, 3, 4]
reverse sequ == Sequence ['a', 'b', 'a', 'a'] [("Letter A", (2, 4)), ("Letter A", (0, 1)), ("Letter B", (1, 2))] [4, 3, 2, 1]

tail :: ContainsNoMarking s => s -> s Source #

Unsafe tail: * length s == 0, an error is thrown; * length s == 1, an error is thrown.

sequWeighted = Sequence ['a', 'a', 'b', 'a'] mempty [0.1, 0.2, 0.3, 0.4]
tail sequWeighted == Sequence [a', 'b', 'a'] mempty [0.2, 0.3, 0.4]
tail (tail (tail (tail (tail sequWeighted)))) == error

take :: ContainsNoMarking s => Int -> s -> s Source #

Unsafe take: * if n < 0, an error is thrown; * if n == 0, an error is thrown.

sequWeighted = Sequence ['a', 'a', 'b', 'a'] mempty [0.1, 0.2, 0.3, 0.4]
take 2 sequWeighted == Sequence ['a', 'a'] mempty [0.1, 0.2]
take -1 sequWeighted == error
take 0 sequWeighted == error

toList :: IsSequence s => s -> [Element s] Source #

List all elemnts of s.

(!) :: IsSequence s => s -> Int -> Element s infixl 9 Source #

Unsafe operator to get elemnt at given position in s.

(!?) :: IsSequence s => s -> Int -> Maybe (Element s) infixl 9 Source #

Safe operator to get element at given position in s.