Python interface to Prodigal, an ORF finder for genomes, progenomes and metagenomes.
Project description
🔥 Pyrodigal ![Stars](https://pypi-camo.freetls.fastly.net/010b6b31c61988425f670531a065d5b3cbafffc8/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f616c74686f6e6f732f7079726f646967616c2e7376673f7374796c653d736f6369616c266d61784167653d33363030266c6162656c3d53746172)
Python interface to Prodigal, an ORF finder for genomes, progenomes and metagenomes.
🗺️ 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 single or metagenomic mode. It is still missing some features of the CLI:
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for pyrodigal-0.4.0-cp39-cp39-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 379f3fa0f589021487c07b90abf622e5de3d6b56a56141525a474b745f7ec8b2 |
|
MD5 | 99b27effc774d2a92372ef513a76722a |
|
BLAKE2b-256 | dd04742f023acef3d425c83ce15bbfb2b3884876d921867cd4df3658e17759d6 |
Hashes for pyrodigal-0.4.0-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c6ce0c91ed2e73cd46d6c6ba5c96044375a7902895c65827a4cb3080db5d6a75 |
|
MD5 | 6bc092abbe024972e0d608b37e33ef68 |
|
BLAKE2b-256 | d7cadd065c72d0f85a8d84f3150f1fdb3e5a325c4b548b5d821ca935b2989f74 |
Hashes for pyrodigal-0.4.0-cp38-cp38-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a9b8837dcab3400fbf177305f0eeec6ddef530d78bfd6281042450131e6746eb |
|
MD5 | 2bf6a842d9697529eafe6d2f65896570 |
|
BLAKE2b-256 | b5b2a2b01a9e169aab76232a87e869adaeb2e2cb71e608c187f0ba1187d8c813 |
Hashes for pyrodigal-0.4.0-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 467bbcbeeb35eabd129032a21767a205faea9c14855873d2da0a820ab74bdabe |
|
MD5 | 4a5013f05b6ede5888091546fdc03a21 |
|
BLAKE2b-256 | 696765e73e3e8164a905b92c0d10d787f41d01cd6eef26aa7cffb2f286caf617 |
Hashes for pyrodigal-0.4.0-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0e6068dea8311ec66a622d57e01738d583c6a0c9efccd2fad974a513e288d2e5 |
|
MD5 | 07323f9f0298939979ddaf3be877cbd0 |
|
BLAKE2b-256 | 8ebf7165534e1c8849dd47144708889902e925d2b7c117d09f29b02972869970 |
Hashes for pyrodigal-0.4.0-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e7ae430cdbe6e1afc94b12a78551b31cbcc61d9392265edd039dcbd1cb9c0fb1 |
|
MD5 | cecc302bffd9e99a48a12661fcf76414 |
|
BLAKE2b-256 | f542551e527a9267fa006cbdea59304b70c71a1f7b592de18f7a4b72e51d837c |
Hashes for pyrodigal-0.4.0-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e88b7dd1a6eb09388a1b2a30c0e98db4cea957ff3c1a95de031b2820825618a7 |
|
MD5 | 2dcecb0ed20f1fb6d042e85749a8427f |
|
BLAKE2b-256 | 0faa74c8832ea81fdc23c5c0143baea7d5f5eb62a51269fa60ddab2f5e4642e4 |
Hashes for pyrodigal-0.4.0-cp35-cp35m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4b2c9853c190caaaff76654d12dfaf68e6f2d3a90e338587bde5df9564d23dde |
|
MD5 | b304b27231549120a65b58da04580666 |
|
BLAKE2b-256 | 9b8b168aae6259383b7f0da80b1829034072faee08007a9d688bebce0d87da54 |