bio-0.5.2: A bioinformatics library

Safe Haskell | Safe-Inferred

Bio.Location.OnSeq

Contents

- Data types
- Utility functions
- Sequence collections indexed by name

Description

Data types for functorially lifting sequence positions and locations onto named sequences. These are useful for taking functions that work with sequence positions and locations and associating them specific, named sequences.

Synopsis

- type SeqName = SeqData
- data OnSeq a = OnSeq {
  - onSeqName :: !SeqName
  - onSeqObj :: !a
  }
- withSeqData :: Monad m => (SeqData -> a -> m b) -> (SeqName -> m SeqData) -> OnSeq a -> m b
- andSameSeq :: (a -> b -> Bool) -> OnSeq a -> OnSeq b -> Bool
- onSameSeq :: (Error e, MonadError e m) => (a -> b -> m c) -> OnSeq a -> OnSeq b -> m c
- type OnSeqs a = Map SeqName a
- perSeq :: Monoid b => (a -> b -> c) -> OnSeq a -> OnSeqs b -> c
- perSeqUpdate :: Monoid b => (a -> b -> b) -> OnSeq a -> OnSeqs b -> OnSeqs b
- withNameAndSeq :: Monad m => (SeqName -> a -> b -> m c) -> OnSeq a -> OnSeqs b -> m c

# Data types

type SeqName = SeqData

Sequence name, as in a `Sequence`

data OnSeq a

Data type for an object associated with a specific, named sequence

Constructors

OnSeq |

Fields

onSeqName :: !SeqName
onSeqObj :: !a

Instances

Functor OnSeq |
Eq a => Eq (OnSeq a) |
Ord a => Ord (OnSeq a) |
Show a => Show (OnSeq a) |

# Utility functions

withSeqData

Arguments

:: Monad m |
=> (SeqData -> a -> m b) | Function using sequence data
-> (SeqName -> m SeqData) | Lookup sequence by name
-> OnSeq a | Object with named sequence
-> m b |

Looks up a sequence by name and applies a function to it

andSameSeq :: (a -> b -> Bool) -> OnSeq a -> OnSeq b -> Bool

Tests a predicate when two objects are on the same sequence, returning `False` if they are on different sequences.

onSameSeq :: (Error e, MonadError e m) => (a -> b -> m c) -> OnSeq a -> OnSeq b -> m c

Performs an action when two objects are on the same sequence and produces an error otherwise.

# Sequence collections indexed by name

type OnSeqs a = Map SeqName a

Data type for a collection of objects indexed by sequence name

perSeq :: Monoid b => (a -> b -> c) -> OnSeq a -> OnSeqs b -> c

Lifts a function on an underlying object to look up the sequence name in a name-indexed collection.

perSeqUpdate :: Monoid b => (a -> b -> b) -> OnSeq a -> OnSeqs b -> OnSeqs b

Lifts a function that updates an underlying object to look up the named sequence and update a named-index collection.

withNameAndSeq :: Monad m => (SeqName -> a -> b -> m c) -> OnSeq a -> OnSeqs b -> m c

Lifts a function on underlying objects to look up a sequence in a name-indexed collection