Package: pyskani
🐍⛓️🧬 PyskaniPyO3bindings and Python interface toskani, a method for fast fast genomic identity calculation using sparse chaining.🗺️ Overviewskaniis a method developed byJim ShawandYun William Yufor fast and robust
metagenomic sequence comparison through sparse chaining. It improves on
FastANI by being more accurate and much faster, while requiring less memory.pyskaniis a Python module, implemented using thePyO3framework, that provides bindings toskani. It directly links to theskanicode, which has the following advantages over CLI wrappers:pre-built wheels:pyskaniis 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 addpyskanias a dependency to
your project, and stop worrying about theskanibinary 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 toskaniwithout 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.🔧 InstallingPyskani can be installed directly fromPyPI,
which hosts some pre-built CPython wheels for x86-64 Unix platforms, as well
as the code required to compile from source with Rust:$pipinstallpyskaniIn 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 databaseA 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,
usingBiopythonto 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 thesketchmethod, 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)forrecordinrecords)database.sketch("E. coli O157",*sequences)🗒️ Loading a databaseTo load a database, either created fromskaniorpyskani, 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 databaseOnce a database has been created or loaded, use theDatabase.querymethod
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 AlsoComputing ANI for closed genomes? You may also be interested inpyfastani, a Python package for computing ANIusing theFastANI methoddeveloped byChirag Jainet al.💭 Feedback⚠️ Issue TrackerFound a bug ? Have an enhancement request ? Head over to theGitHub issue trackerif 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.🏗️ ContributingContributions are more than welcome! SeeCONTRIBUTING.mdfor more details.⚖️ LicenseThis library is provided under theMIT License.Theskanicode was written byJim Shawand is distributed under the terms of theMIT Licenseas well. Seevendor/skani/LICENSEfor more information. Source distributions
ofpyskanivendors additional sources under their own terms using
thecargo vendorcommand.This project is in no way not affiliated, sponsored, or otherwise endorsed
by theoriginalskaniauthors.
It was developed byMartin Larraldeduring his
PhD project at theEuropean Molecular Biology Laboratoryin theZeller team.