MyNixOS website logo
Description

Interval map.

Interval map with support for overlapping intervals

IntervalIntMap

An interval map structure that is optimized for low memory (each interval is represented by about 3 words + whatever the cargo is) and has semantics that are appropriate for genomic intervals (namely, intervals can overlap and queries will return all matches together). It also designed to be used in two phases: a construction phase + query phase).

This is not a general purpose package, it serves mostly as support for NGLess and is used there.

Do get in touch if you want to use it more generally, but the plans for this repo is to develop it only in so far as it helps with NGLess' goals.

Example Usage

Step 1: construction

In the first phase, an IntervalIntMapAccumulator accumulator is used. This is a mutable object and it must be used inside a PrimMonad (typically either IO or ST s). Elements can be inserted into this object.

import qualified Data.IntervalIntMap as IM

insertMany :: [(Int, Int)] -> IO (IM.IntervalIntMap Int)
insertMany elems = do
    acc <- IM.new
    forM_ (zip elems [0..]) $ \((s,p), ix) ->
        IM.insert (IM.Interval s p) ix
    IM.unsafeFreeze acc

The final step in construction is freezing the accumulator to produce a IntervalIntMap. If the original accumulator is not to be used again, then unsafeFreeze can be used.

Step 2: usage

The IntervalIntMap object is a pure object, with the typical container functions: map, lookup, elems,...

Do note that the signature for lookup is

lookup ::  Storable a => Int -> IntervalIntMap a -> [a]

Thus, a list is always returned: [] if nothing is found, but multiple intervals can independently overlap with the query.

Citation

If you do use this repository, please cite the main NGLess paper:

NG-meta-profiler: fast processing of metagenomes using NGLess, a domain-specific language by Luis Pedro Coelho, Renato Alves, Paulo Monteiro, Jaime Huerta-Cepas, Ana Teresa Freitas, Peer Bork, Microbiome (2019) https://doi.org/10.1186/s40168-019-0684-8

LICENSE: MIT.

Metadata

Version

0.0.1.0

License

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows