🔗🐍⏭️ pyfgs 
Python bindings to FragGeneScanRs for fast, error-tolerant bacterial ORF prediction
For full usage, see the docs
Why pyfgs?
Built for noisy data
Standard ab initio predictors are fantastic for pristine, fully assembled contigs.
However, they struggle with raw metagenomic reads or error-prone assemblies because they immediately break the open
reading frame at the first sign of an indel. pyfgs uses an error-tolerant Hidden Markov Model trained on specific
sequencing profiles (Illumina, 454, Sanger) to power through these sequencing errors, dynamically correct the reading
frame, and salvage the translated protein.
Native frameshift tracking
Instead of just silently stitching broken genes together, pyfgs exposes the exact coordinates of every hallucinated or
skipped base directly to Python. This allows you to rigorously track structural variants, correctly annotate
INSDC-compliant pseudogenes, or export exact frameshift coordinates for downstream quality control.
No subprocess I/O tax
Running standard CLI bioinformatics tools from Python usually requires a heavy I/O penalty: dumping sequences to a
temporary FASTA file, firing a subprocess, and parsing the text outputs back into memory. pyfgs binds directly to the
underlying Rust engine. The HMM runs entirely in memory and yields native Python objects ready for immediate analysis.
True multithreading and zero-copy memory
pyfgs is designed to process massive datasets efficiently:
-
GIL-Free Inference: The Rust backend completely releases the Python Global Interpreter Lock (GIL) during the heavy HMM math. You can drop the predictor into a standard ThreadPoolExecutor and achieve true parallel processing across all your CPU cores.
-
Zero-Copy Bytes: The engine borrows raw byte slices
(&[u8])directly from Python's memory, bypassing the overhead of copying strings between languages. -
Lazy Translation: Translating DNA to amino acids is computationally expensive.
pyfgsevaluates sequence strings lazily, meaning you only pay the CPU and memory cost of string allocation if you explicitly request the sequence data.
A Pythonic API
Bioinformatics coordinates are notoriously messy. pyfgs outputs standard 0-based, half-open intervals ([start, end)),
allowing you to slice sequence arrays immediately without wrestling with 1-based GFF3 coordinate math. When you do need
standardized files, it includes heavily optimized, native-Rust context managers to stream perfectly compliant VCF, BED,
GFF3, and FASTA files directly to disk without bloating your RAM.
Blazing Fast
Thanks to the memory-safe zero-copy architecture and multi-threading through Rayon, pyfgs can outperform even the fastest SIMD-optimized Gene Finders (e.g. pyrodigal) in Whole Genome mode—especially on highly fragmented assemblies and metagenomes.
🚀 Usage
1. Vectorized Batch Prediction
If you are a power user integrating gene prediction into a larger Python pipeline, pyfgs offers a vectorized, zero-copy NumPy API that sidesteps Python object overhead completely.
import pyfgs
# 1. Initialize the gene finder
# By default, this loads the Illumina HMM model (error-tolerant).
finder = pyfgs.GeneFinder()
# 2. Extract byte strings of sequence
# Notice we pass bytes (b""), not strings, to avoid encoding overhead.
sequences = [
b"ATGCCCGGGAAATTTTGACCC",
b"ATGAAAAAA",
]
# 3. Predict genes across all sequences in parallel (releasing the GIL)
batch = finder.find_genes_batch(sequences)
# 4. Access predictions as flat, 1-dimensional NumPy arrays (Structure-of-Arrays)
print(batch.starts) # array([0, ...])
print(batch.ends) # array([18, ...])
print(batch.strands) # array([1, ...])
print(batch.scores) # array([12.34, ...])
# 5. Fields with variable counts per gene (e.g. insertions/deletions)
# are exposed as flat arrays alongside parallel "offsets" arrays
# defining the slice boundaries (i.e. ragged arrays).
print(batch.insertions_offsets)
print(batch.insertions_flat)
2. High-Performance I/O Pipeline
If your goal is just to read a FASTA file and output standard format files (GFF3, BED, etc), pyfgs provides a pure-Rust IO pipeline that bypasses Python entirely. This is what the pyfgs CLI uses under the hood.
import pyfgs
finder = pyfgs.GeneFinder()
# Stream directly from disk to disk using Rust native threading
finder.run_file(
input_path="input.fasta",
is_fastq=False,
outputs={
"gff3": "output.gff3",
"faa": "output.faa",
},
)
🔧 Installing
This project is supported on Python 3.10 and later.
pyfgs can be installed directly from PyPI:
pip install pyfgs
⚡️ Power users ⚡️ can force your local machine to compile the Rust engine specifically for your own CPU by running:
RUSTFLAGS="-C target-cpu=native" pip install --no-binary pyfgs pyfgs
💭 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.
📋 Changelog
This project adheres to Semantic Versioning and provides a changelog in the Keep a Changelog format.
⚖️ License
This library is provided under the GNU General Public License v3.0.
The FragGeneScanRs code was written by Peter Dawyndt,
Bart Mesuere and
Felix Van der Jeugt and is distributed under the
terms of the GPLv3 as well. See https://github.com/FragGeneScanRs/LICENSE for more information.
This project is in no way affiliated, sponsored, or otherwise endorsed by the original FragGeneScanRs authors Peter Dawyndt, Bart Mesuere and Felix Van der Jeugt. It was developed by Tom Stanton during his Post-doc project at Monash University in the Wryes Lab.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyfgs-0.0.3.tar.gz.
File metadata
- Download URL: pyfgs-0.0.3.tar.gz
- Upload date:
- Size: 124.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
68516f012fa4199ec6873a1584de252239444d39dd56dca41570771d256980b7
|
|
| MD5 |
86c7ecf45dca8fda22fc88f0ae385b92
|
|
| BLAKE2b-256 |
38e84e163ea3a5a9948190ddca8a197f808cd4fb4292f1b3e48d80af3d426391
|
Provenance
The following attestation bundles were made for pyfgs-0.0.3.tar.gz:
Publisher:
publish.yml on tomdstanton/pyfgs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyfgs-0.0.3.tar.gz -
Subject digest:
68516f012fa4199ec6873a1584de252239444d39dd56dca41570771d256980b7 - Sigstore transparency entry: 2452311470
- Sigstore integration time:
-
Permalink:
tomdstanton/pyfgs@68da61be2db42a4c449190d45eaaa42cb7f06537 -
Branch / Tag:
refs/tags/v0.0.3 - Owner: https://github.com/tomdstanton
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@68da61be2db42a4c449190d45eaaa42cb7f06537 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pyfgs-0.0.3-cp314-cp314-macosx_11_0_arm64.whl.
File metadata
- Download URL: pyfgs-0.0.3-cp314-cp314-macosx_11_0_arm64.whl
- Upload date:
- Size: 2.1 MB
- Tags: CPython 3.14, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1fecbc19fadabde0e6347c1a9b934ff4de155330277d0a8553736fccbfce8cd2
|
|
| MD5 |
49658bf9c8ec6f93e55ebd06e198aac0
|
|
| BLAKE2b-256 |
ef238f6db1ee22e63e9b26c14efa2856194da89d1080e5219c30f8dae99c8fbd
|
Provenance
The following attestation bundles were made for pyfgs-0.0.3-cp314-cp314-macosx_11_0_arm64.whl:
Publisher:
publish.yml on tomdstanton/pyfgs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyfgs-0.0.3-cp314-cp314-macosx_11_0_arm64.whl -
Subject digest:
1fecbc19fadabde0e6347c1a9b934ff4de155330277d0a8553736fccbfce8cd2 - Sigstore transparency entry: 2452311638
- Sigstore integration time:
-
Permalink:
tomdstanton/pyfgs@68da61be2db42a4c449190d45eaaa42cb7f06537 -
Branch / Tag:
refs/tags/v0.0.3 - Owner: https://github.com/tomdstanton
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@68da61be2db42a4c449190d45eaaa42cb7f06537 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pyfgs-0.0.3-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: pyfgs-0.0.3-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 2.0 MB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
89de1ce70cab252d5a88667e5aed64371211edf19ee228020e0c28bd24b2c79f
|
|
| MD5 |
8daff83514bf3f6a4215adacefa73ec4
|
|
| BLAKE2b-256 |
89df6ebfc99b4e21380c067bec50b51d1ecbf3991e9b5c0af2da7881d43a0abe
|
Provenance
The following attestation bundles were made for pyfgs-0.0.3-cp312-cp312-win_amd64.whl:
Publisher:
publish.yml on tomdstanton/pyfgs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyfgs-0.0.3-cp312-cp312-win_amd64.whl -
Subject digest:
89de1ce70cab252d5a88667e5aed64371211edf19ee228020e0c28bd24b2c79f - Sigstore transparency entry: 2452311743
- Sigstore integration time:
-
Permalink:
tomdstanton/pyfgs@68da61be2db42a4c449190d45eaaa42cb7f06537 -
Branch / Tag:
refs/tags/v0.0.3 - Owner: https://github.com/tomdstanton
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@68da61be2db42a4c449190d45eaaa42cb7f06537 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pyfgs-0.0.3-cp312-cp312-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: pyfgs-0.0.3-cp312-cp312-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 2.1 MB
- Tags: CPython 3.12, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eb4d014a3aead38e1b185a0858a0e010764dbd7000e5c8bd225a92f6b5bbc54a
|
|
| MD5 |
c6c150f3ad749e8300448f88e4071dc3
|
|
| BLAKE2b-256 |
b4714d234d3c82e8492c24cbf848f34912b5c372321a8f9a8038c93c40214618
|
Provenance
The following attestation bundles were made for pyfgs-0.0.3-cp312-cp312-manylinux_2_34_x86_64.whl:
Publisher:
publish.yml on tomdstanton/pyfgs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyfgs-0.0.3-cp312-cp312-manylinux_2_34_x86_64.whl -
Subject digest:
eb4d014a3aead38e1b185a0858a0e010764dbd7000e5c8bd225a92f6b5bbc54a - Sigstore transparency entry: 2452311555
- Sigstore integration time:
-
Permalink:
tomdstanton/pyfgs@68da61be2db42a4c449190d45eaaa42cb7f06537 -
Branch / Tag:
refs/tags/v0.0.3 - Owner: https://github.com/tomdstanton
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@68da61be2db42a4c449190d45eaaa42cb7f06537 -
Trigger Event:
release
-
Statement type: