minimap2-cr
minimap2-cr
Crystal >= 1.19.1 bindings for minimap2. Build/load reference indexes and map sequences with coordinates, MAPQ and CIGAR.
Installation
Requires a C compiler, make, curl, tar, bzip2 and zlib development headers. On Ubuntu: sudo apt-get install build-essential curl bzip2 zlib1g-dev. On macOS, install Xcode Command Line Tools. Windows requires MSYS2 UCRT64 with MAKE=mingw32-make; see CI setup for packages.
dependencies:
minimap2:
github: kojix2/minimap2-cr
Run shards install. The postinstall hook builds the minimap2 version pinned in ext/build.cr. Crystal links ext/libminimap2.a statically; setting a shared-library search path is not required.
Map
require "minimap2"
aligner = Minimap2::Aligner.new("reference.fa", preset: "map-ont", cigar: true)
hits = aligner.map("ACGTACGTACGT", cs: true, md: true)
hits.each { |hit| puts "#{hit.target_name}:#{hit.target_start} MAPQ=#{hit.mapq}" }
Supply your own FASTA or minimap2 index. Coordinates are zero-based and half-open. cs:, md: and ds: request alignment tags and enable CIGAR generation for that call. CIGAR and tags require an index containing reference sequences. Mapping#nm is the edit distance when base-level alignment is performed (with_cigar, cigar: true, or a tag request). Otherwise it is nil, rather than zero. Code that uses nm must handle this missing value. aligner.seq(name, start, stop) retrieves reference sequence, returning nil for invalid ranges, missing contigs, or indexes built with --idx-no-seq. Minimap2.revcomp(sequence) reverse-complements a sequence. For presets and detailed options, use AlignerBuilder.
See examples for command-line examples and their validation.
Development
shards install
crystal spec
ameba src spec examples
crystal tool format --check src spec examples
To rebuild native code in a local checkout: crystal run ext/build.cr. License: MIT.
minimap2-cr
- 1
- 0
- 1
- 1
- 1
- 12 days ago
- February 11, 2026
MIT License
Wed, 18 Nov 2026 02:28:07 GMT