minimap2-cr
minimap2-cr
Crystal bindings for minimap2 (long-read mapper).
This shard downloads/builds minimap2 during install (see shard.yml postinstall).
Installation
-
Add the dependency to your
shard.yml:dependencies: minimap2: github: kojix2/minimap2-cr -
Run
shards install
System requirements (Linux)
Building minimap2 requires a C toolchain and zlib headers.
sudo apt-get update
sudo apt-get install -y build-essential curl bzip2 zlib1g-dev
Usage
Quick Start
require "minimap2"
aligner = Minimap2::Aligner.new(
"reference.fasta",
preset: "map-ont",
cigar: true,
threads: 4
)
hits = aligner.map("ACGTACGTACGT", cs: true, md: true, ds: true)
pp hits.first?
Builder Style (recommended for explicit config)
require "minimap2"
aligner = Minimap2::Aligner.build
.map_hifi
.with_cigar
.with_index_threads(4)
.with_index("reference.fasta")
Available builder presets:
map_ontmap_hifimap_pbsplicesplice_hqsplice_srasm5asm10asm20sr
Practical Mapping Options
map supports these high-level toggles:
cs: true: emitcstag textmd: true: emitMDtag textds: true: emitdstag text (INDEL uncertainty extension)
Returned fields are available on Minimap2::Mapping as cs, md, and ds.
You can also pass minimap2 flags directly via extra_flags:
hits = aligner.map(
query,
extra_flags: [
Minimap2::LibMinimap2::OUT_MD.to_u64,
Minimap2::LibMinimap2::EQX.to_u64,
]
)
API Notes
Aligner.new(...)is a shortcut wrapper around the builder.Aligner.buildgives full control and is preferred for non-trivial setups.Aligner#seq(name, start, stop)reads reference subsequences from the loaded index.
Upstream minimap2 references
- Presets and command behavior: https://github.com/lh3/minimap2#readme
- CLI/manpage options (
--cs,--MD,--ds): https://github.com/lh3/minimap2/blob/master/minimap2.1 dstag background (release note): https://github.com/lh3/minimap2/blob/master/NEWS.md
Utilities
require "minimap2"
puts Minimap2.revcomp("ACGTN")
Development
- Build vendored minimap2:
shards install(runsext/build.crvia postinstall) - Run tests:
crystal spec
If you see runtime linker errors, try:
export LD_LIBRARY_PATH="$PWD/ext"
Repository
minimap2-cr
Owner
Statistic
- 1
- 0
- 1
- 0
- 0
- about 3 hours ago
- February 11, 2026
License
MIT License
Links
Synced at
Wed, 20 May 2026 01:39:28 GMT
Languages