Skip to main content

Python wrapper for minimap2 with stdout/stderr capture

Project description

PyPI version

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 https://github.com/TheFangLab/pyminimap2.git
cd pyminimap2
pip install .

Choose this option if you are using Python 3.13 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

  1. https://github.com/lh3/minimap2
  2. https://lh3.github.io/minimap2/minimap2.html

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyminimap2-2.30.3.tar.gz (86.4 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pyminimap2-2.30.3-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (441.8 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

pyminimap2-2.30.3-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (441.7 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

pyminimap2-2.30.3-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (441.7 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

pyminimap2-2.30.3-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (440.8 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

pyminimap2-2.30.3-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (440.6 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

File details

Details for the file pyminimap2-2.30.3.tar.gz.

File metadata

  • Download URL: pyminimap2-2.30.3.tar.gz
  • Upload date:
  • Size: 86.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyminimap2-2.30.3.tar.gz
Algorithm Hash digest
SHA256 14cdab59fc89e9bdb3f3902e42d312c6279dc014fd88e903621fdd8c47c9a575
MD5 a92fd7fae53f42e9587f73c15f467294
BLAKE2b-256 5ba0aac27e5d6d0353d5aca751b58edcc1969ccbee8d1a39304735a5ab4bb399

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyminimap2-2.30.3.tar.gz:

Publisher: build_wheels.yml on TheFangLab/pyminimap2

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyminimap2-2.30.3-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyminimap2-2.30.3-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5ed047ed17873e6974881d74f18ee5dfcd3f5fd9821d3e27b1abcf4c65635c90
MD5 184e5bcf982c3c8c711a672b7588cfa7
BLAKE2b-256 f391528cb07f8b901647943043b6ebe3f60339b06979bfaf2f21cecef32152d2

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyminimap2-2.30.3-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: build_wheels.yml on TheFangLab/pyminimap2

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyminimap2-2.30.3-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyminimap2-2.30.3-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a47ebeef73e9238d656f50ed233f5d89729fa163d29c615fb6aa33207ab52439
MD5 9205a60a14b207ca3ad94fe72ca5c042
BLAKE2b-256 99ea2c1bc0b3c1baf86ef9ddb212a302143483d72ca46b48987f5bec41c0b396

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyminimap2-2.30.3-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: build_wheels.yml on TheFangLab/pyminimap2

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyminimap2-2.30.3-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyminimap2-2.30.3-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d06b4baa0cf8e7753289f15386a71914993df95060598f0da613fde092f84b09
MD5 7a29e449a483c758e994713fc7473db8
BLAKE2b-256 6de22f3f229ff034cd0680b3342e858ce5def48000a7d1ada5f85b29920fce81

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyminimap2-2.30.3-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: build_wheels.yml on TheFangLab/pyminimap2

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyminimap2-2.30.3-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyminimap2-2.30.3-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 929eaaa4bd97408b7bf2a8c040e8dd37cb89cd5382dcff01c52b698994cd438d
MD5 b1679edf630d7fc3a55ac55f9d44c609
BLAKE2b-256 0644bfb548de4b7086c403b3cf2ead7aede2117c3123e74091192dc9c1517378

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyminimap2-2.30.3-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: build_wheels.yml on TheFangLab/pyminimap2

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyminimap2-2.30.3-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyminimap2-2.30.3-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 70a6027ccee1933c4ae9a90f7f19055a971b78cc2f29239ec7f0b07ef6f58190
MD5 6210463b8b9f003d329fc7e11049cad7
BLAKE2b-256 0d301e8866e9a1abfddaf4af876ddd7a59ccfbeeae7ae8332adf4d310f9afd00

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyminimap2-2.30.3-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: build_wheels.yml on TheFangLab/pyminimap2

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page