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 or os.system(), using pyminimap2 incurs significantly lower overhead.
In our benchmark, running pyminimap2.main('--version') is approximately 20–30 times faster than invoking minimap2 --version using subprocess.run, and about 40 times faster than calling it via os.system().
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 (Recommended)
We provide pre-compiled binaries for Linux and Python versions 3.9 to 3.13. Simply run the following command:
pip install pyminimap2
Option 2: Clone and compile from source
git clone --recursive https://github.com/TheFangLab/pyminimap2.git
cd pyminimap2
pip install .
Choose this option if you are using Python 3.14 or a later version. You need to have a C compiler (e.g. GCC).
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])
Maintainers
pyminimap2 is currently maintained by Li Fang at Sun Yat-sen University. For issues and feature requests, please open an issue here.
Acknowledgments
License
pyminimap2 is released under the MIT license.
Metadata
Release files for pyminimap2 2.31.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pyminimap2-2.31.1.tar.gz | 113.6 kB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| pyminimap2-2.31.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl | CPython 3.13 | CPython 3.13 | Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 | Details |
| pyminimap2-2.31.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl | CPython 3.12 | CPython 3.12 | Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 | Details |
| pyminimap2-2.31.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl | CPython 3.11 | CPython 3.11 | Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 | Details |
| pyminimap2-2.31.1-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl | CPython 3.10 | CPython 3.10 | Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 | Details |
| pyminimap2-2.31.1-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl | CPython 3.9 | CPython 3.9 | Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 | Details |
Total release size: 2.3 MB
Release files / pyminimap2-2.31.1.tar.gz
| Download URL | pyminimap2-2.31.1.tar.gz |
|---|---|
| Size | 113.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fa7f7293e6ed3dc60308c460496b326565f2793bdd0961d1df7010fd0724498c
|
|
BLAKE2b-256 checksum How to use checksums |
db9ede609ffd62e68b216c6949d623b28d333afb165c1351a70feb398bc67b14
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 8, 2026.
Transparency logRelease files / pyminimap2-2.31.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | pyminimap2-2.31.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 443.2 kB |
| Tags | CPython 3.13 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
10e22ba3431e086a323975117876149ca26561bbaa21b1f7a7669fdbb5811b55
|
|
BLAKE2b-256 checksum How to use checksums |
1645193d12e9f95ba1cdcd2cd8b00f84b8e31c0f4084bbe3f6a2906c2868d1f8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 8, 2026.
Transparency logRelease files / pyminimap2-2.31.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | pyminimap2-2.31.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 443.1 kB |
| Tags | CPython 3.12 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
f47e211a62f02fa48a3d557e9ddda3548fb15ef2f4a63a842537833861d6074b
|
|
BLAKE2b-256 checksum How to use checksums |
14d152d8a7e69429c21949d6cafbf85cb61294a815a84810e6b20665dafe2f61
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 8, 2026.
Transparency logRelease files / pyminimap2-2.31.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | pyminimap2-2.31.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 443.2 kB |
| Tags | CPython 3.11 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
b9a6f4e8fbf91211138e9020911c46142f3a9e4ef1784c9d9c279d0d98dd8e98
|
|
BLAKE2b-256 checksum How to use checksums |
7691115dfa9e4448aa8f1b8bf95db862e1727a7d83085026c5b1cecf06764818
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 8, 2026.
Transparency logRelease files / pyminimap2-2.31.1-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | pyminimap2-2.31.1-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 442.3 kB |
| Tags | CPython 3.10 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
c53efed21757f658ae6dbc8111d91c8c80f4b0826913d1a65c137db94b8a9a71
|
|
BLAKE2b-256 checksum How to use checksums |
4570cf977bd288df5e0a960363b19f067a1607c160c5047612b8aa5437fc6b16
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 8, 2026.
Transparency logRelease files / pyminimap2-2.31.1-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | pyminimap2-2.31.1-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 442.1 kB |
| Tags | CPython 3.9 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
4db12177485e709fcd0b6420fb50a5123864687ae57a46c5d9032d049dd84877
|
|
BLAKE2b-256 checksum How to use checksums |
544a4571e05a1faa26729bba3184fa9299ada7fcff53ea6f94d773c3ed26eae3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 8, 2026.
Transparency log