Skip to content

update-to-minimap2-2.29 #122

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
### 0.1.24 minimap2 2.29
+ Update minimap2-sys to 2.29
+ Rust 2024 edition
+ Remove best_n setting to 1, it should be determined by minimap2
+ Helper functions for read_junction, read_pass1, read_splice_scores

### 0.1.23 minimap2 2.28
+ Functions to set flag opts for MapOpt and IdxOpt @dwpeng
+ Fixed memory leak when not dropping mm_idx_t properly. This is done by adding in syntactic sugar in minimap2-sys @jguhlin
Expand Down
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "minimap2"
version = "0.1.23+minimap2.2.28"
edition = "2021"
version = "0.1.24+minimap2.2.29"
edition = "2024"
authors = ["Joseph Guhlin <[email protected]>"]
license = "MIT OR Apache-2.0"
description = "Bindings to libminimap2"
Expand Down Expand Up @@ -29,7 +29,7 @@ exclude = ["minimappers2", "fakeminimap2", "minimap2-sys"]
libc = "0.2"
needletail = { version = "0.6", optional = true, default-features = false}

minimap2-sys = { path = "./minimap2-sys" , version = "0.1.21+minimap2.2.28" }
minimap2-sys = { path = "./minimap2-sys", version = "0.1.22+minimap2.2.29" }
rust-htslib = { version = "0.49", default-features = false, optional = true }

[dev-dependencies]
Expand Down
31 changes: 20 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,19 @@ minimap2-sys is the raw FFI bindings to minimap2. minimap2 is the more opinionat
# How to use
## Requirements
```toml
minimap2 = "0.1.23+minimap2.2.28"
minimap2 = "0.1.24+minimap2.2.29"
```
Also see [Features](#features)

Tested with rustc 1.82.0 and nightly. So probably a good idea to upgrade before running. But let me know if you run into pain points with older versions and will try to fix.

## Minimap2 Version Table
| minimap2-rs | minimap2 |
|-------------|----------|
| 0.1.23 | 2.28 |
| 0.1.22 | 2.28 |
| 0.1.21 | 2.28 |
| 0.1.20 | 2.28 |
| 0.1.19 | 2.28 |
| 0.1.18 | 2.28 |
| 0.1.17 | 2.27 |
| 0.1.16 | 2.26 |
| minimap2-rs | minimap2 |
|-----------------|----------|
| 0.1.24 | 2.29 |
| 0.1.18 - 0.1.23 | 2.28 |
| 0.1.17 | 2.27 |
| 0.1.16 | 2.26 |

## Usage
Create an Aligner
Expand Down Expand Up @@ -184,6 +180,19 @@ Minimap2 is tested on x86_64 and aarch64 (arm64). Other platforms may work, plea
- [STRdust](https://github.com/wdecoster/STRdust) - Tandem repeat genotyper for long reads
- [oarfish](https://github.com/COMBINE-lab/oarfish) - transcript quantification from long-read RNA-seq data
- [lrge](https://github.com/mbhall88/lrge) - Long Read-based Genome size Estimation from overlaps
- [mmr](https://github.com/arcInstitute/mmr) - A minimap2-based aligner with BINSEQ file format support

# Notes
## Memory management
Minimap2 sets cap_kalloc to ~500Mb, so for 32 threads this can be ~16Gb. You can set this manually with `aligner.mapopt.cap_kalloc`. This is a good idea if you are using a lot of threads, or have very long running jobs.

```
let per_thread_cap_kalloc = (1_000_000_000_f64 / (args.threads as f64)).ceil() as i64;
aligner.mapopt.cap_kalloc = per_thread_cap_kalloc;
```

## best_n
* Minimap2 outputs and results are sensitive to the best_n parameter. Set it manually or be prepared for it to be changed upstream (potentially!)

# Next things todo
* Iterator interface for map_file
Expand Down
11 changes: 5 additions & 6 deletions examples/channels.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crossbeam::queue::ArrayQueue;
use minimap2::*;
use needletail::{parse_fastx_file, FastxReader};
use needletail::{FastxReader, parse_fastx_file};

use std::path::PathBuf;
use std::{error::Error, path::Path, sync::Arc, time::Duration};
Expand Down Expand Up @@ -99,16 +99,16 @@ fn map(

let handle = std::thread::spawn(move || {
// Now that the threads are running, read the input file and push the work to the queue
let mut reader: Box<dyn FastxReader> =
parse_fastx_file(query_file).unwrap_or_else(|_| panic!("Can't find query FASTA file"));
let mut reader: Box<dyn FastxReader> = parse_fastx_file(query_file)
.unwrap_or_else(|_| panic!("Can't find query FASTA file"));

// I just do this in the main thread, but you can split threads
let backoff = crossbeam::utils::Backoff::new();
while let Some(Ok(record)) = reader.next() {
let mut work = WorkQueue::Work((record.id().to_vec(), record.seq().to_vec()));
while let Err(work_packet) = work_queue.push(work) {
work = work_packet; // Simple way to maintain ownership
// If we have an error, it's 99% because the queue is full
// If we have an error, it's 99% because the queue is full
backoff.snooze();
}
}
Expand All @@ -128,7 +128,6 @@ fn map(
// This is where we processs mapping results as they come in...
Some(WorkQueue::Result((record, alignments))) => {
num_alignments += alignments.len();

}
Some(_) => unimplemented!("Unexpected result type"),
None => {
Expand Down Expand Up @@ -178,7 +177,7 @@ fn worker(
let mut result = WorkQueue::Result((sequence, alignment));
while let Err(result_packet) = results_queue.push(result) {
result = result_packet; // Simple way to maintain ownership
// If we have an error, it's 99% because the queue is full
// If we have an error, it's 99% because the queue is full
backoff.snooze();
}
}
Expand Down
4 changes: 2 additions & 2 deletions examples/rayon.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use clap::Parser;
use minimap2::*;
use needletail::{parse_fastx_file, FastxReader};
use needletail::{FastxReader, parse_fastx_file};
use rayon::prelude::*;
use clap::Parser;

use std::path::PathBuf;
use std::{error::Error, path::Path};
Expand Down
50 changes: 25 additions & 25 deletions minimap2-sys/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions minimap2-sys/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "minimap2-sys"
version = "0.1.21+minimap2.2.28"
edition = "2021"
version = "0.1.22+minimap2.2.29"
edition = "2024"
links = "libminimap2"
authors = ["Joseph Guhlin <[email protected]>"]
license = "MIT OR Apache-2.0"
Expand All @@ -26,7 +26,6 @@ exclude = [
"/mm2-fast/test",
"/minimap2/test",
"/mm2-fast/test_bench/",

]

[lib]
Expand Down
10 changes: 10 additions & 0 deletions minimap2-sys/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ Use this if you need lower-level bindings for minimap2.
Minimap2 2.28

## Breaking Changes
### 0.1.29
Potentially an issue, derive(copy) is no longer valid for structs where we have implemented a Drop trait. So I've added some newtypes where appropriate. Hopefully it's an invisible change.
This is primarily for mm_idx_t. If you use it directly (instead of MmIdx newtype), you need to call mm_idx_destroy() manually.

### 0.1.18
mm2-fast and minimap2 have diverged. At this point mm2-fast is no longer supported. Please use a previous crate version.

Expand All @@ -19,6 +23,12 @@ mm2-fast and minimap2 have diverged. At this point mm2-fast is no longer support
* Can we decouple from pthread? This would allow Windows and (possibly) WASM compilation.

## Changelog
### 0.1.29 minimap2.2.29
* Update to minimap2 2.29
* Update to 2024 edition
* Remove some noise from the build system
* Remove Drop impl for mm_idx_t. If you use it directly (instead of MmIdx newtype), you need to call mm_idx_destroy() manually.

### 0.1.21 minimap2.2.28
* Flag functions for IdxOpt and MapOpt @dwpeng
* Syntactic sugar for mm_idx_t to support Drop, Deref, and DerefMut
Expand Down
7 changes: 6 additions & 1 deletion minimap2-sys/build.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

use std::env;
use std::path::{Path, PathBuf};

Expand Down Expand Up @@ -124,6 +125,8 @@ fn simde(cc: &mut cc::Build) {

fn compile() {
let mut cc = cc::Build::new();
cc.warnings(false);
cc.flag_if_supported("-Wno-unused-result");

let out_path = PathBuf::from(env::var_os("OUT_DIR").unwrap());

Expand All @@ -148,7 +151,8 @@ fn compile() {
cc.flag("-lz");

let mut cc = cc::Build::new();


cc.flag_if_supported("-Wno-unused-result");
cc.warnings(false);
cc.flag("-Wc++-compat");
cc.out_dir(&out_path);
Expand Down Expand Up @@ -206,6 +210,7 @@ fn gen_bindings() {
let out_path = PathBuf::from(env::var_os("OUT_DIR").unwrap());

let mut bindgen = bindgen::Builder::default()
.derive_debug(true)
.parse_callbacks(Box::new(bindgen::CargoCallbacks::new()))
.rustfmt_bindings(true);

Expand Down
2 changes: 1 addition & 1 deletion minimap2-sys/minimap2
Loading