bio-0.5.2: A bioinformatics library

Safe Haskell | Safe-Inferred

Bio.Location.Position

Contents

- Sequence positions
- Manipulating positions
- Extracting sequences
- Displaying positions

Description

Data type for a sequence position.

Zero-based `Offset` / `Int64` indices are used throughout, to facilitate direct use of indexing functions on `SeqData`.

Synopsis

- data Pos = Pos {
  - offset :: !Offset
  - strand :: !Strand
  }
- slide :: Pos -> Offset -> Pos
- seqNt :: (Error e, MonadError e m) => SeqData -> Pos -> m Char
- seqNtPadded :: SeqData -> Pos -> Char
- display :: Pos -> String

# Sequence positions

data Pos

Position in a sequence

Constructors

Pos |

Fields

offset :: !Offset

  0-based index of the position

strand :: !Strand

  Strand of the position

Instances

Eq Pos |
Ord Pos |
Read Pos |
Show Pos |
Ix Pos |
Stranded Pos |

# Manipulating positions

slide :: Pos -> Offset -> Pos

Returns a position resulting from sliding the original position along the sequence by a specified offset. A positive offset will move the position away from the 5' end of the forward stand of the sequence regardless of the strand of the position itself. Thus,

     slide (revCompl pos) off == revCompl (slide pos off)

# Extracting sequences

seqNt :: (Error e, MonadError e m) => SeqData -> Pos -> m Char

Extract the nucleotide at a specific sequence position. If the position lies outside the bounds of the sequence, an error results.

seqNtPadded :: SeqData -> Pos -> Char

As `seqNt`, extract the nucleotide at a specific sequence position, but return `N` when the position lies outside the bounds of the sequence.

     seqNtPadded sequ pos == (either 'N' id . seqNt sequ) pos

# Displaying positions

display :: Pos -> String

Display a human-friendly, zero-based representation of a sequence position.