Skip to main content

PyO3 bindings and Python interface to skani, a method for fast fast genomic identity calculation using sparse chaining.

Project description

🐍⛓️🧬 Pyskani Stars

PyO3 bindings and Python interface to skani, a method for fast fast genomic identity calculation using sparse chaining.

Actions Coverage License PyPI Bioconda AUR Wheel Python Versions Python Implementations Source Mirror Issues Docs Changelog Downloads

🗺️ Overview

skani is a method developed by Jim Shaw and Yun William Yu for fast and robust metagenomic sequence comparison through sparse chaining. It improves on FastANI by being more accurate and much faster, while requiring less memory.

pyskani is a Python module, implemented using the PyO3 framework, that provides bindings to skani. It directly links to the skani code, which has the following advantages over CLI wrappers:

  • pre-built wheels: pyskani is distributed on PyPI and features pre-built wheels for common platforms, including x86-64 and Arm64 UNIX.
  • single dependency: If your software or your analysis pipeline is distributed as a Python package, you can add pyskani as a dependency to your project, and stop worrying about the skani binary being present on the end-user machine.
  • sans I/O: Everything happens in memory, in Python objects you control, making it easier to pass your sequences to skani without having to write them to a temporary file.

This library is still a work-in-progress, and in an experimental stage, but it should already pack enough features to be used in a standard pipeline.

🔧 Installing

Pyskani can be installed directly from PyPI, which hosts some pre-built CPython wheels for x86-64 Unix platforms, as well as the code required to compile from source with Rust:

$ pip install pyskani

In the event you have to compile the package from source, all the required Rust libraries are vendored in the source distribution, and a Rust compiler will be setup automatically if there is none on the host machine.

💡 Examples

📝 Creating a database

A database can be created either in memory or using a folder on the machine filesystem to store the sketches. Independently of the storage, a database can be used immediately for querying, or saved to a different location.

Here is how to create a database into memory, using Biopython to load the record:

database = pyskani.Database()
record = Bio.SeqIO.read("vendor/skani/test_files/e.coli-EC590.fasta", "fasta")
database.sketch("E. coli EC590", bytes(record.seq))

For draft genomes, simply pass more arguments to the sketch method, for which you can use the splat operator:

database = pyskani.Database()
records = Bio.SeqIO.parse("vendor/skani/test_files/e.coli-o157.fasta", "fasta")
sequences = (bytes(record.seq) for record in records)
database.sketch("E. coli O157", *sequences)

🗒️ Loading a database

To load a database, either created from skani or pyskani, you can either load all sketches into memory, for fast querying:

database = pyskani.Database.load("path/to/sketches")

Or load the files lazily to save memory, at the cost of slower querying:

database = pyskani.Database.open("path/to/sketches")

🔎 Querying a database

Once a database has been created or loaded, use the Database.query method to compute ANI for some query genomes:

record = Bio.SeqIO.read("vendor/skani/test_files/e.coli-K12.fasta", "fasta")
hits = database.query("E. coli K12", bytes(record.seq))

🔎 See Also

Computing ANI for closed genomes? You may also be interested in pyfastani, a Python package for computing ANI using the FastANI method developed by Chirag Jain et al.

💭 Feedback

⚠️ Issue Tracker

Found a bug ? Have an enhancement request ? Head over to the GitHub issue tracker if you need to report or ask something. If you are filing in on a bug, please include as much information as you can about the issue, and try to recreate the same bug in a simple, easily reproducible situation.

🏗️ Contributing

Contributions are more than welcome! See CONTRIBUTING.md for more details.

⚖️ License

This library is provided under the MIT License.

The skani code was written by Jim Shaw and is distributed under the terms of the MIT License as well. See vendor/skani/LICENSE for more information. Source distributions of pyskani vendors additional sources under their own terms using the cargo vendor command.

This project is in no way not affiliated, sponsored, or otherwise endorsed by the original skani authors. It was developed by Martin Larralde during his PhD project at the European Molecular Biology Laboratory in the Zeller team.

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

pyskani-0.1.0.tar.gz (2.9 MB view hashes)

Uploaded Source

Built Distributions

pyskani-0.1.0-pp39-pypy39_pp73-win_amd64.whl (3.3 MB view hashes)

Uploaded PyPy Windows x86-64

pyskani-0.1.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.4 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

pyskani-0.1.0-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.4 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARM64

pyskani-0.1.0-pp39-pypy39_pp73-macosx_10_9_x86_64.whl (3.4 MB view hashes)

Uploaded PyPy macOS 10.9+ x86-64

pyskani-0.1.0-pp38-pypy38_pp73-win_amd64.whl (3.3 MB view hashes)

Uploaded PyPy Windows x86-64

pyskani-0.1.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.4 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

pyskani-0.1.0-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.4 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARM64

pyskani-0.1.0-pp38-pypy38_pp73-macosx_10_9_x86_64.whl (3.4 MB view hashes)

Uploaded PyPy macOS 10.9+ x86-64

pyskani-0.1.0-pp37-pypy37_pp73-win_amd64.whl (3.3 MB view hashes)

Uploaded PyPy Windows x86-64

pyskani-0.1.0-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.4 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

pyskani-0.1.0-pp37-pypy37_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.4 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARM64

pyskani-0.1.0-pp37-pypy37_pp73-macosx_10_9_x86_64.whl (3.4 MB view hashes)

Uploaded PyPy macOS 10.9+ x86-64

pyskani-0.1.0-cp311-cp311-win_amd64.whl (3.3 MB view hashes)

Uploaded CPython 3.11 Windows x86-64

pyskani-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.4 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

pyskani-0.1.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.4 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

pyskani-0.1.0-cp311-cp311-macosx_11_0_arm64.whl (3.3 MB view hashes)

Uploaded CPython 3.11 macOS 11.0+ ARM64

pyskani-0.1.0-cp311-cp311-macosx_10_9_x86_64.whl (3.4 MB view hashes)

Uploaded CPython 3.11 macOS 10.9+ x86-64

pyskani-0.1.0-cp310-cp310-win_amd64.whl (3.3 MB view hashes)

Uploaded CPython 3.10 Windows x86-64

pyskani-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.4 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

pyskani-0.1.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.4 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

pyskani-0.1.0-cp310-cp310-macosx_11_0_arm64.whl (3.3 MB view hashes)

Uploaded CPython 3.10 macOS 11.0+ ARM64

pyskani-0.1.0-cp310-cp310-macosx_10_9_x86_64.whl (3.4 MB view hashes)

Uploaded CPython 3.10 macOS 10.9+ x86-64

pyskani-0.1.0-cp39-cp39-win_amd64.whl (3.3 MB view hashes)

Uploaded CPython 3.9 Windows x86-64

pyskani-0.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.4 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

pyskani-0.1.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.4 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

pyskani-0.1.0-cp39-cp39-macosx_11_0_arm64.whl (3.3 MB view hashes)

Uploaded CPython 3.9 macOS 11.0+ ARM64

pyskani-0.1.0-cp39-cp39-macosx_10_9_x86_64.whl (3.4 MB view hashes)

Uploaded CPython 3.9 macOS 10.9+ x86-64

pyskani-0.1.0-cp38-cp38-win_amd64.whl (3.3 MB view hashes)

Uploaded CPython 3.8 Windows x86-64

pyskani-0.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.4 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

pyskani-0.1.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.4 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARM64

pyskani-0.1.0-cp38-cp38-macosx_11_0_arm64.whl (3.3 MB view hashes)

Uploaded CPython 3.8 macOS 11.0+ ARM64

pyskani-0.1.0-cp38-cp38-macosx_10_9_x86_64.whl (3.4 MB view hashes)

Uploaded CPython 3.8 macOS 10.9+ x86-64

pyskani-0.1.0-cp37-cp37m-win_amd64.whl (3.3 MB view hashes)

Uploaded CPython 3.7m Windows x86-64

pyskani-0.1.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.4 MB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

pyskani-0.1.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.4 MB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ ARM64

pyskani-0.1.0-cp37-cp37m-macosx_10_9_x86_64.whl (3.4 MB view hashes)

Uploaded CPython 3.7m macOS 10.9+ x86-64

Supported by

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