Python wrapper for minimap2
Project description
pyminimap2: a Python wrapper for minimap2
pyminimap2 is a Python wrapper for minimap2 (developed by Heng Li). pyminimap2 generates exactly the same output as minimap2 as it simply pass the command-line arguments to the main function in main.c of minimap2.
Compared to invoking minimap2 through subprocess.run, using pyminimap2 incurs significantly lower overhead.
Speed comparison
In our benchmark, executing pyminimap2.main('--help') is approximately 20× faster than calling minimap2 --help via subprocess.run.
pyminimap2 is a good choice for applications requiring frequent or high-throughput invocations of minimap2 from within Python.
How to install
Option 1: Install via pip
Simply run:
pip install pyminimap2
Option 2: Clone the repository and install manually
git clone https://github.com/TheFangLab/pyminimap2.git
cd pyminimap2
pip install .
Note: both options require a C compiler.
How to use
Assuming your orignal command for executing minimap2 is
minimap2 -x map-ont ref.fa read.fq.gz
You can use pyminimap2 as follows:
import pyminimap2 as pymm2
out, err = pymm2.main("-x map-ont ref.fa read.fq.gz")
This would generate the exact same output as minimap2 -x map-ont ref.fa read.fq.gz.
If you want to save the output to a file, you can use the -o option (same as the -o option of minimap2):
out, err = pymm2.main("-x map-ont ref.fa read.fq.gz -o output.paf")
This would generate a output.paf file.
In summary, if you use -o to specify the output file, pyminimap2 will generate the same output file as minimap2. If -o is not specified, pymm2.main() returns a tuple (out, err) where out contains the stdout and err contains the stderr.
You can find explainations of the command-line arguments of minimap2 at
Difference from mappy
1. Access to the Full Command-Line Interface (CLI).
pyminimap2 accepts exactly the same command-line arguments as minimap2. Everything minimap2 can do via CLI is available.
2. Identical Output
pyminimap2 generates exact the same output as minimap2. If you are running existing pipelines that rely on parsing standard PAF or SAM files generated by the CLI tool, pyminimap2 creates strictly identical text output (stdout) or files.
mappy requires a deeper understanding of the Python API (such as mappy.Aligner and mappy.Alignment).
3. Low Migration Friction
If you have existing scripts using subprocess.run or os.system() to call minimap2, migrating to pyminimap2 is almost trivial. You just pass the specific string of arguments you were already using.
About version
You can use the following code to print the version number of minimap2 bound in pyminimap2:
import pyminimap2 as pymm2
print(pymm2.main('--version')[0])
License
pyminimap2 is released under the MIT license.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyminimap2-2.30.2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pyminimap2-2.30.2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 418.2 kB
- Tags: CPython 3.12, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e89785f5c1db34a645579b4e0755e72059ee9b1c145a193dd53f9af63a370d30
|
|
| MD5 |
2f72d9d4e1bfa29327874070d7880f5c
|
|
| BLAKE2b-256 |
a529d38685fb31336eb43b4574ddb868f46f7981c46b6ef8c1a8b3eaae0b36b0
|
File details
Details for the file pyminimap2-2.30.2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pyminimap2-2.30.2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 418.1 kB
- Tags: CPython 3.11, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b9510073d039ab4c2f73708b4e3c0fcea44eb40abb7d2076a07799b698a93352
|
|
| MD5 |
93ba1af5e3ded127792bc3a30f9626cc
|
|
| BLAKE2b-256 |
eff5485f4d60c7926c76aff4c2512f12c1ff933bab333950534e26a03a9e20f9
|
File details
Details for the file pyminimap2-2.30.2-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pyminimap2-2.30.2-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 418.1 kB
- Tags: CPython 3.10, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
715ab7bd03453fcef8eed518e9a07b70d96c866c9571e27d38c31b2bb0ecd25c
|
|
| MD5 |
be1e33c052fa476a870ef491ac50eb36
|
|
| BLAKE2b-256 |
8b307c6892577ac34b08a93ca136260660dd0ec9cac44c91856b10c8ea86ae03
|
File details
Details for the file pyminimap2-2.30.2-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pyminimap2-2.30.2-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 418.1 kB
- Tags: CPython 3.9, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
882bd374b9be4875dc9de8df3d24cbc662a8a5689ee2e98f6df2c3a734b7938f
|
|
| MD5 |
745af897e7398cc726e6d31647711e5b
|
|
| BLAKE2b-256 |
ae88e69dbd5c9cabbf88bb1bed9881acc57f5790ec9d5275aac06a0eca319335
|