Skip to main content

Cython bindings and Python interface to Prodigal, an ORF finder for genomes and metagenomes.

Project description

🔥 Pyrodigal Stars

Cython bindings and Python interface to Prodigal, an ORF finder for genomes and metagenomes. Now with SIMD!

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

🗺️ Overview

Pyrodigal is a Python module that provides bindings to Prodigal using Cython. It directly interacts with the Prodigal internals, which has the following advantages:

  • single dependency: Pyrodigal is distributed as a Python package, so you can add it as a dependency to your project, and stop worrying about the Prodigal binary being present on the end-user machine.
  • no intermediate files: Everything happens in memory, in a Python object you fully control, so you don't have to invoke the Prodigal CLI using a sub-process and temporary files. Sequences can be passed directly as strings or bytes, which avoids the overhead of formatting your input to FASTA for Prodigal.
  • lower memory usage: Pyrodigal is slightly more conservative when it comes to using memory, which can help process very large sequences. It also lets you save some more memory when running several meta-mode analyses
  • better performance: Pyrodigal uses SIMD instructions to compute which dynamic programming nodes can be ignored when scoring connections. This can save from a third to half the runtime depending on the sequence.

📋 Features

The library now features everything needed to run Prodigal in single or metagenomic mode. It is still missing some features of the CLI:

Roadmap:

  • ✔️ Metagenomic mode
  • ✔️ Single mode
  • ✔️ Region masking (-m flag)
  • ❌ External training file support (-t flag)

🐏 Memory

Pyrodigal makes two changes compared to the original Prodigal command line:

  • Sequences are stored as raw bytes instead of compressed bitmaps. This means that the sequence itself takes 3/8th more space, but since the memory used for storing the sequence is often negligible compared to the memory used to store dynamic programming nodes, this is an acceptable trade-off for better performance when finding the start and stop nodes.
  • Node arrays are dynamically allocated and grow exponentially instead of being pre-allocated with a large size. On small sequences, this leads to Pyrodigal using about 30% less memory.

🧶 Thread-safety

pyrodigal.OrfFinder instances are thread-safe. In addition, the find_genes method is re-entrant. This means you can train an OrfFinder instance once, and then use a pool to process sequences in parallel:

import pyrodigal

orf_finder = pyrodigal.OrfFinder()
orf_finder.train(training_sequence)

with multiprocessing.pool.ThreadPool() as pool:
    predictions = pool.map(orf_finder.find_genes, sequences)

🔧 Installing

Pyrodigal can be installed directly from PyPI, which hosts some pre-built wheels for the x86-64 architecture (Linux/OSX/Windows) and the Aarch64 architecture (Linux only), as well as the code required to compile from source with Cython:

$ pip install pyrodigal

Otherwise, Pyrodigal is also available as a Bioconda package:

$ conda install -c bioconda pyrodigal

💡 Example

Let's load a sequence from a GenBank file, use an OrfFinder to find all the genes it contains, and print the proteins in two-line FASTA format.

🔬 Biopython

To use the OrfFinder in single mode, you must explicitly call the train method with the sequence you want to use for training before trying to find genes, or you will get a RuntimeError:

orf_finder = pyrodigal.OrfFinder()
orf_finder.train(bytes(record.seq))
genes = orf_finder.find_genes(bytes(record.seq))

However, in meta mode, you can find genes directly:

record = Bio.SeqIO.read("sequence.gbk", "genbank")
orf_finder = pyrodigal.OrfFinder(meta=True)

for i, pred in enumerate(orf_finder.find_genes(bytes(record.seq))):
    print(f">{record.id}_{i+1}")
    print(pred.translate())

On older versions of Biopython (before 1.79) you will need to use record.seq.encode() instead of bytes(record.seq).

🧪 Scikit-bio

seq = next(skbio.io.read("sequence.gbk", "genbank"))
orf_finder = pyrodigal.OrfFinder(meta=True)

for i, pred in enumerate(orf_finder.find_genes(seq.values.view('B'))):
    print(f">{record.id}_{i+1}")
    print(pred.translate())

We need to use the view method to get the sequence viewable by Cython as an array of unsigned char.

💭 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 GNU General Public License v3.0. The Prodigal code was written by Doug Hyatt and is distributed under the terms of the GPLv3 as well. See vendor/Prodigal/LICENSE for more information. The cpu_features library was written by Guillaume Chatelet and is licensed under the terms of the Apache License 2.0. See vendor/cpu_features/LICENSE for more information.

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

pyrodigal-0.6.3.tar.gz (1.7 MB view hashes)

Uploaded Source

Built Distributions

pyrodigal-0.6.3-pp37-pypy37_pp73-win_amd64.whl (1.9 MB view hashes)

Uploaded PyPy Windows x86-64

pyrodigal-0.6.3-pp37-pypy37_pp73-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (1.9 MB view hashes)

Uploaded PyPy manylinux: glibc 2.12+ x86-64

pyrodigal-0.6.3-pp37-pypy37_pp73-macosx_10_7_x86_64.whl (1.9 MB view hashes)

Uploaded PyPy macOS 10.7+ x86-64

pyrodigal-0.6.3-pp36-pypy36_pp73-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (1.9 MB view hashes)

Uploaded PyPy manylinux: glibc 2.12+ x86-64

pyrodigal-0.6.3-cp39-cp39-win_amd64.whl (1.9 MB view hashes)

Uploaded CPython 3.9 Windows x86-64

pyrodigal-0.6.3-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.0 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

pyrodigal-0.6.3-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (3.0 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.12+ x86-64

pyrodigal-0.6.3-cp39-cp39-macosx_10_14_x86_64.whl (2.0 MB view hashes)

Uploaded CPython 3.9 macOS 10.14+ x86-64

pyrodigal-0.6.3-cp38-cp38-win_amd64.whl (1.9 MB view hashes)

Uploaded CPython 3.8 Windows x86-64

pyrodigal-0.6.3-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.0 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARM64

pyrodigal-0.6.3-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (3.0 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.12+ x86-64

pyrodigal-0.6.3-cp38-cp38-macosx_10_14_x86_64.whl (2.0 MB view hashes)

Uploaded CPython 3.8 macOS 10.14+ x86-64

pyrodigal-0.6.3-cp37-cp37m-win_amd64.whl (1.9 MB view hashes)

Uploaded CPython 3.7m Windows x86-64

pyrodigal-0.6.3-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.0 MB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ ARM64

pyrodigal-0.6.3-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (2.9 MB view hashes)

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

pyrodigal-0.6.3-cp37-cp37m-macosx_10_14_x86_64.whl (2.0 MB view hashes)

Uploaded CPython 3.7m macOS 10.14+ x86-64

pyrodigal-0.6.3-cp36-cp36m-win_amd64.whl (1.9 MB view hashes)

Uploaded CPython 3.6m Windows x86-64

pyrodigal-0.6.3-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.0 MB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.17+ ARM64

pyrodigal-0.6.3-cp36-cp36m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (2.9 MB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.12+ x86-64

pyrodigal-0.6.3-cp36-cp36m-macosx_10_14_x86_64.whl (2.0 MB view hashes)

Uploaded CPython 3.6m macOS 10.14+ x86-64

pyrodigal-0.6.3-cp35-cp35m-win_amd64.whl (1.9 MB view hashes)

Uploaded CPython 3.5m Windows x86-64

pyrodigal-0.6.3-cp35-cp35m-manylinux2010_x86_64.whl (2.9 MB view hashes)

Uploaded CPython 3.5m manylinux: glibc 2.12+ x86-64

pyrodigal-0.6.3-cp35-cp35m-macosx_10_14_x86_64.whl (2.0 MB view hashes)

Uploaded CPython 3.5m macOS 10.14+ 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