Skip to main content

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

Project description

🔥 Pyrodigal Stars

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

TravisCI AppVeyor Coverage License PyPI Bioconda Wheel Python Versions Python Implementations Source GitHub issues 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 manually import and export sequences to pass to the Prodigal CLI.
  • no input formatting: sequences are manipulated directly as strings, which leverages the issue 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.

📋 Features

The library now features everything needed to run Prodigal in metagenomic mode. It does not yet support single mode, which requires more configuration from the user but offers more flexibility.

Roadmap:

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

🐏 Memory

Contrary to the Prodigal command line, Pyrodigal attempts to be more conservative about memory usage. This means that most of the allocations will be lazy, and that some functions will reallocate their results to exact-sized arrays when it's possible. This leads to Pyrodigal using about 30% less memory, but with a little bit more overhead to compute the size of buffers in advance.

🧶 Thread-safety

pyrodigal.Pyrodigal instances are thread-safe, and use an internal lock to prevent parallel calls to their methods from overwriting the internal buffers. However, a better solution to process sequences in parallel is to use a consumer/worker pattern, and have on Pyrodigal instance in each worker. Using a pool spawning Pyrodigal instances on the fly is also fine, but prevents recycling memory:

with multiprocessing.pool.ThreadPool() as pool:
    pool.map(lambda s: Pyrodigal(meta=True).find_genes(s), sequences)

🔧 Installing

Pyrodigal can be installed directly from PyPI, which hosts some pre-built CPython wheels for x86-64 Unix and Windows platforms, 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

Using Biopython, load a sequence from a GenBank file, import Pyrodigal to find all genes it contains, and print the proteins in FASTA format:

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

for i, gene in enumerate(p.find_genes(str(record.seq))):
    print(f"> {record.id}_{i+1}")
    print(textwrap.fill(record.translate()))

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

p = pyrodigal.Pyrodigal()
p.train(str(record.seq))
genes = p.find_genes(str(record.seq))

📜 License

This library, like the original Prodigal software, is provided under the GNU General Public License v3.0.

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.3.1.tar.gz (742.3 kB view hashes)

Uploaded Source

Built Distributions

pyrodigal-0.3.1-cp39-cp39-manylinux2010_x86_64.whl (993.0 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.12+ x86-64

pyrodigal-0.3.1-cp38-cp38-win_amd64.whl (719.6 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

pyrodigal-0.3.1-cp38-cp38-manylinux2010_x86_64.whl (998.1 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.12+ x86-64

pyrodigal-0.3.1-cp37-cp37m-win_amd64.whl (717.9 kB view hashes)

Uploaded CPython 3.7m Windows x86-64

pyrodigal-0.3.1-cp37-cp37m-manylinux2010_x86_64.whl (968.7 kB view hashes)

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

pyrodigal-0.3.1-cp36-cp36m-win_amd64.whl (717.9 kB view hashes)

Uploaded CPython 3.6m Windows x86-64

pyrodigal-0.3.1-cp36-cp36m-manylinux2010_x86_64.whl (968.1 kB view hashes)

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

pyrodigal-0.3.1-cp35-cp35m-win_amd64.whl (717.3 kB view hashes)

Uploaded CPython 3.5m Windows x86-64

pyrodigal-0.3.1-cp35-cp35m-manylinux2010_x86_64.whl (966.0 kB view hashes)

Uploaded CPython 3.5m manylinux: glibc 2.12+ 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