Skip to main content

Cython bindings and Python interface to FastANI.

Project description

🐍⏩🧬 pyFastANI Stars

Cython bindings and Python interface to FastANI, a method for fast whole-genome similarity estimation.

Actions Coverage License PyPI Wheel Python Versions Python Implementations Source GitHub issues Changelog Downloads DOI

🗺️ Overview

FastANI is a method published in 2018 by Jain et al. for high-throughput computATION of whole-genome Average Nucleotide Identity (ANI). It uses MashMap to compute orthologous mappings without the need for expensive alignments.

pyfastani is a Python module, implemented using the Cython language, that provides bindings to FastANI. It directly interacts with the FastANI internals, which has the following advantages over CLI wrappers:

  • simpler compilation: FastANI requires several additional libraries, which make compilation of the original binary non-trivial. In pyFastANI, libraries that were needed for threading or I/O are provided as stubs, so you only need to have boost::math to build. Or even better, just install from one of the provided wheels!
  • single dependency: If your software or your analysis pipeline is distributed as a Python package, you can add pyfastani as a dependency to your project, and stop worrying about the FastANI 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 FastANI without needing 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 run one-to-one computations.

🔧 Installing

pyFastANI 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 Cython:

$ pip install pyfastani

Note that in the event you compile from source, you will need to have the headers and libraries for boost::math available.

💡 Example

The following snippets show how to compute the ANI between two genomes, with the reference being a draft genome. For one-to-many or many-to-many searches, simply add additional references with m.add_draft before indexing. Note that any name can be given to the reference sequences, this will just affect the name attribute of the hits returned for a query.

🔬 Biopython

Biopython does not let us access to the sequence directly, so we need to convert it to bytes first with the bytes builtin function. For older versions of Biopython (earlier than 1.79), use record.seq.encode() instead of bytes(record.seq).

import pyfastani
import Bio.SeqIO

m = pyfastani.Mapper()

# add a single draft genome to the mapper, and index it
ref = list(Bio.SeqIO.parse("vendor/FastANI/data/Shigella_flexneri_2a_01.fna", "fasta"))
m.add_draft("Shigella_flexneri_2a_01", (bytes(record.seq) for record in ref))
m.index()

# read the query and query the mapper
query = Bio.SeqIO.read("vendor/FastANI/data/Escherichia_coli_str_K12_MG1655.fna", "fasta")
hits = m.query_sequence(bytes(query.seq))

for hit in hits:
    print("Escherichia_coli_str_K12_MG1655", hit.name, hit.identity, hit.matches, hit.fragments)

🧪 Scikit-bio

Scikit-bio lets us access to the sequence directly as a numpy array, but shows the values as byte strings by default. To make them readable as char (for compatibility with the C code), they must be cast with seq.values.view('B').

import pyfastani
import skbio.io

m = pyfastani.Mapper()

ref = list(skbio.io.read("vendor/FastANI/data/Shigella_flexneri_2a_01.fna", "fasta"))
m.add_draft("Shigella_flexneri_2a_01", (seq.values.view('B') for seq in ref))
m.index()

# read the query and query the mapper
query = next(skbio.io.read("vendor/FastANI/data/Escherichia_coli_str_K12_MG1655.fna", "fasta"))
hits = m.query_genome(query.values.view('B'))

for hit in hits:
    print("Escherichia_coli_str_K12_MG1655", hit.name, hit.identity, hit.matches, hit.fragments)

💭 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 FastANI code was written by Chirag Jain and is distributed under the terms of the Apache License 2.0 license, unless otherwise specified in vendored sources. See vendor/FastANI/LICENSE for more information.

This project is in no way not affiliated, sponsored, or otherwise endorsed by the original FastANI 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

pyfastani-0.1.2.tar.gz (97.6 kB view details)

Uploaded Source

Built Distributions

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

pyfastani-0.1.2-pp37-pypy37_pp73-manylinux_2_24_x86_64.whl (200.2 kB view details)

Uploaded PyPymanylinux: glibc 2.24+ x86-64

pyfastani-0.1.2-pp37-pypy37_pp73-macosx_10_7_x86_64.whl (180.3 kB view details)

Uploaded PyPymacOS 10.7+ x86-64

pyfastani-0.1.2-cp39-cp39-manylinux_2_24_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.24+ x86-64

pyfastani-0.1.2-cp39-cp39-macosx_10_14_x86_64.whl (221.0 kB view details)

Uploaded CPython 3.9macOS 10.14+ x86-64

pyfastani-0.1.2-cp38-cp38-manylinux_2_24_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.24+ x86-64

pyfastani-0.1.2-cp38-cp38-macosx_10_14_x86_64.whl (218.5 kB view details)

Uploaded CPython 3.8macOS 10.14+ x86-64

pyfastani-0.1.2-cp37-cp37m-manylinux_2_24_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.24+ x86-64

pyfastani-0.1.2-cp37-cp37m-macosx_10_14_x86_64.whl (217.4 kB view details)

Uploaded CPython 3.7mmacOS 10.14+ x86-64

pyfastani-0.1.2-cp36-cp36m-manylinux_2_24_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.6mmanylinux: glibc 2.24+ x86-64

pyfastani-0.1.2-cp36-cp36m-macosx_10_14_x86_64.whl (217.4 kB view details)

Uploaded CPython 3.6mmacOS 10.14+ x86-64

File details

Details for the file pyfastani-0.1.2.tar.gz.

File metadata

  • Download URL: pyfastani-0.1.2.tar.gz
  • Upload date:
  • Size: 97.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5

File hashes

Hashes for pyfastani-0.1.2.tar.gz
Algorithm Hash digest
SHA256 9920c89b00a3c3dfe5496c0824b374ea4fae489bfb758fec2c452549cbbcc1ae
MD5 073d37f0590b60ffa7e60707e0d2f666
BLAKE2b-256 f15548b109d4a474e7b1fd551971130e4f36bd6552040c831540bb62c680da18

See more details on using hashes here.

File details

Details for the file pyfastani-0.1.2-pp37-pypy37_pp73-manylinux_2_24_x86_64.whl.

File metadata

  • Download URL: pyfastani-0.1.2-pp37-pypy37_pp73-manylinux_2_24_x86_64.whl
  • Upload date:
  • Size: 200.2 kB
  • Tags: PyPy, manylinux: glibc 2.24+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5

File hashes

Hashes for pyfastani-0.1.2-pp37-pypy37_pp73-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 a93a764dc73ec2d88dee811ada26db13d648a34c281ff5f949ccaa688a6763ff
MD5 92c5b500a6c95283f0c0e2e3804580ca
BLAKE2b-256 901e6cb5c74c2f3bad362b8db0450999012cc9eb932f601b2abb84f80eb257de

See more details on using hashes here.

File details

Details for the file pyfastani-0.1.2-pp37-pypy37_pp73-macosx_10_7_x86_64.whl.

File metadata

  • Download URL: pyfastani-0.1.2-pp37-pypy37_pp73-macosx_10_7_x86_64.whl
  • Upload date:
  • Size: 180.3 kB
  • Tags: PyPy, macOS 10.7+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5

File hashes

Hashes for pyfastani-0.1.2-pp37-pypy37_pp73-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 91ee6abee634dd942bc27eb54afdbbdda8a6287abfd636928d99f06095aeca7a
MD5 6a1e9d458e2b3efc84dab924a7296c15
BLAKE2b-256 9fd7412b87b2e89f715e920aeb94eb4872a63ca6482da56315c45599ed77faf5

See more details on using hashes here.

File details

Details for the file pyfastani-0.1.2-cp39-cp39-manylinux_2_24_x86_64.whl.

File metadata

  • Download URL: pyfastani-0.1.2-cp39-cp39-manylinux_2_24_x86_64.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: CPython 3.9, manylinux: glibc 2.24+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5

File hashes

Hashes for pyfastani-0.1.2-cp39-cp39-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 fad22f07325ca656493d37b38cdb41bc7fabeefff2914ab8aa7c04bf58a746e6
MD5 1e0baae365737d00169392a6f23705fc
BLAKE2b-256 376173d50ae7584768739273f5ad599b647af54d5406c218039e5f76492e91ce

See more details on using hashes here.

File details

Details for the file pyfastani-0.1.2-cp39-cp39-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: pyfastani-0.1.2-cp39-cp39-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 221.0 kB
  • Tags: CPython 3.9, macOS 10.14+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5

File hashes

Hashes for pyfastani-0.1.2-cp39-cp39-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 4f6380f6a34cc9f6c8085aebf3141a7408ea603df40cae03cbbdd7187bc6d09d
MD5 c48110e86fdee281499a5a9411a89a54
BLAKE2b-256 f3f6567156799d5cd489f427a247fcb1f00e4fb6db70e38a82ce0cbb86ec19a4

See more details on using hashes here.

File details

Details for the file pyfastani-0.1.2-cp38-cp38-manylinux_2_24_x86_64.whl.

File metadata

  • Download URL: pyfastani-0.1.2-cp38-cp38-manylinux_2_24_x86_64.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: CPython 3.8, manylinux: glibc 2.24+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5

File hashes

Hashes for pyfastani-0.1.2-cp38-cp38-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 58b06aa307ce631b061ac70b4f25ed83af631cc983658f99c798f59f80f7dcd4
MD5 ac9f840178581d24ca345b036824e951
BLAKE2b-256 c4ab8f302f5098a890e4e0d359b592e601259306f3b59f597b2d6bac2051354d

See more details on using hashes here.

File details

Details for the file pyfastani-0.1.2-cp38-cp38-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: pyfastani-0.1.2-cp38-cp38-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 218.5 kB
  • Tags: CPython 3.8, macOS 10.14+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5

File hashes

Hashes for pyfastani-0.1.2-cp38-cp38-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 359d637194bbcbc14e10a1e6b551dd7107b88d943c902db78c812ec97e1929d8
MD5 3edd28f6cdd233b64522e544874f581f
BLAKE2b-256 4c0eca2eb2d17f8d6df7f5138452a98a90e31efa2982bca0a851ad676439a288

See more details on using hashes here.

File details

Details for the file pyfastani-0.1.2-cp37-cp37m-manylinux_2_24_x86_64.whl.

File metadata

  • Download URL: pyfastani-0.1.2-cp37-cp37m-manylinux_2_24_x86_64.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: CPython 3.7m, manylinux: glibc 2.24+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5

File hashes

Hashes for pyfastani-0.1.2-cp37-cp37m-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 7e95f48e00bbfe949ee36748518eb80ce7c6b6c2a25ad9ca60fd14cbca7fbb5e
MD5 ee64decb5903196b18a0c238eaf12127
BLAKE2b-256 b5f9a3a7bac545e4c6d0a038cabc55602fac58b9afc4beb8cda0e923247ca127

See more details on using hashes here.

File details

Details for the file pyfastani-0.1.2-cp37-cp37m-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: pyfastani-0.1.2-cp37-cp37m-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 217.4 kB
  • Tags: CPython 3.7m, macOS 10.14+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5

File hashes

Hashes for pyfastani-0.1.2-cp37-cp37m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 0a0194c22c7c752122105453e766f18eb8bf8a4d1991c02610f2eca16460764b
MD5 e23d0462913914d663b03f78dd977945
BLAKE2b-256 b67fd9485309b0f201854b7e49ee9200d1b2df4cf80eef2bbebf7679bf7e8de1

See more details on using hashes here.

File details

Details for the file pyfastani-0.1.2-cp36-cp36m-manylinux_2_24_x86_64.whl.

File metadata

  • Download URL: pyfastani-0.1.2-cp36-cp36m-manylinux_2_24_x86_64.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: CPython 3.6m, manylinux: glibc 2.24+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5

File hashes

Hashes for pyfastani-0.1.2-cp36-cp36m-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 78f886840b9b886b78384549fa559b04336f02a1331891324d78918fbcaf6376
MD5 ac717c74ed0cdd127c0872a15ca11c74
BLAKE2b-256 2ace768ca2d25c107afb9f46bce03425dc46b6c26178465c3b4ab530e5960b84

See more details on using hashes here.

File details

Details for the file pyfastani-0.1.2-cp36-cp36m-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: pyfastani-0.1.2-cp36-cp36m-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 217.4 kB
  • Tags: CPython 3.6m, macOS 10.14+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5

File hashes

Hashes for pyfastani-0.1.2-cp36-cp36m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 607a0df43a68f7e0d558ffd60e9d1dc7663ed27c5c4fa1e560de4b1033808bc4
MD5 63c2bd2bf87b921c06e3f37b820691b0
BLAKE2b-256 a3e888818abf7ba0a0c7e779c303153d463356ea8649c30cf73b075437dd8422

See more details on using hashes here.

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