bio-0.5.2: A bioinformatics library

Safe Haskell | Safe-Infered

Bio.Location.LocMap

Contents

- Constructing location lookup maps
- Searching for target locations
- Modifying location lookup maps
- Utilities

Description

Efficient lookup of sequence positions and locations in a large map of target locations. For example, target locations might represent a collection of genes annotated on a chromosome. The `LocMap` would efficiently find which gene(s) overlapped a sequence position on that chromosome.

Target locations are assigned to one or more zones based on `bounds`. Query locations are then tested only against the target locations in the relevant zones.

Synopsis

- data LocMap a
- fromList :: Offset -> [(Loc, a)] -> LocMap a
- lookupWithin :: Pos -> LocMap a -> [(Loc, a)]
- lookupOverlaps :: Loc -> LocMap a -> [(Loc, a)]
- delete :: Eq a => (Loc, a) -> LocMap a -> LocMap a
- deleteBy :: ((Loc, a) -> Bool) -> LocMap a -> LocMap a
- insert :: Loc -> a -> LocMap a -> LocMap a
- checkInvariants :: LocMap a -> [String]

# Constructing location lookup maps

data LocMap a

Data structure allowing efficient lookup of target sequence locations that overlap a query location. Target locations can be paired with an arbitrary object.

Instances

Monoid (LocMap a) |

fromList :: Offset -> [(Loc, a)] -> LocMap a

Create a `LocMap` from an association list of target locations.

# Searching for target locations

lookupWithin :: Pos -> LocMap a -> [(Loc, a)]

Find the (possibly empty) list of target locations and associated objects that contain a sequence position, in the sense of `isWithin`

lookupOverlaps :: Loc -> LocMap a -> [(Loc, a)]

Find the (possibly empty) list of target locations and associated objects that overlap a sequence location, in the sense of `overlaps`

# Modifying location lookup maps

delete :: Eq a => (Loc, a) -> LocMap a -> LocMap a

Remove a target location and object association from the map, if it is present. If it is present multiple times, only the first occurrence will be deleted.

deleteBy :: ((Loc, a) -> Bool) -> LocMap a -> LocMap a

Generalized version of `delete` that removes the first target location / object association that satisfies a predicate function.

insert :: Loc -> a -> LocMap a -> LocMap a

Insert a new target association into a target location map.

# Utilities

checkInvariants :: LocMap a -> [String]