DefensePredictor: A Machine Learning Model to Discover Novel Prokaryotic Immune Systems
Python package to run DefensePredictor, a machine-learning model that leverages embeddings from a protein language model, ESM2, to classify proteins as anti-phage defensive.
For additional details, read the paper here.
Installation
In a fresh conda or other virutal environment, run:
pip install defense_predictor
defense_predictor_download
The first command downloads the python package from PyPI and the second downloads the model weights. Once model weights are downloaded you do not need to run this command again.
Requirements
Requires python >= 3.10
Usage
defense_predictor can be run as python code
import defense_predictor as dfp
ncbi_feature_table = 'GCF_003333385.1_ASM333338v1_feature_table.txt'
ncbi_cds_from_genomic = 'GCF_003333385.1_ASM333338v1_cds_from_genomic.fna'
ncbi_protein_fasta = 'GCF_003333385.1_ASM333338v1_protein.faa'
output_df, feature_matrix = dfp.defense_predictor(ft_file=ncbi_feature_table, fna_file=ncbi_cds_from_genomic, faa_file=ncbi_protein_fasta)
output_df.head()
Or from the command line
defense_predictor \
--ncbi_feature_table GCF_003333385.1_ASM333338v1_feature_table.txt \
--ncbi_cds_from_genomic GCF_003333385.1_ASM333338v1_cds_from_genomic.fna \
--ncbi_protein_fasta GCF_003333385.1_ASM333338v1_protein.faa \
--output GCF_003333385_defense_predictor_output.csv
Alternatively, defense_predictor can take a single GFF3 file with embedded genomic FASTA:
output_df, feature_matrix = dfp.defense_predictor(gff='annot_with_genomic_fasta.gff')
defense_predictor \
--gff annot_with_genomic_fasta.gff \
--output defense_predictor_output.csv
When given a GFF, defense_predictor translates proteins from the embedded genomic sequence using the bacterial codon table (transl_table=11) and uses each CDS's locus_tag as its identifier.
defense_predictor outputs the predicted log-odds of defense for each input protein in the columns mean_log_odds. We reccomend using a stringent log-odds cutoff of 4 to call a protein predicted defensive.
To see an example you can run the defense_predictor_example.ipynb in colab:
We reccomend running defense_predictor on a computer with a cuda-enabled GPU, to maximize computational efficiency.
Inputs
The NCBI input files can be downloaded from the ftp webpage for any gemone of interest, which is linked on its assembly page.
For an unannotated nucleotide assembly, run NCBI's Prokaryotic Genome Annotation Pipeline (PGAP)
or prokka and pass its *.gff output directly via --gff.
Release files for defense-predictor 1.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| defense_predictor-1.1.2.tar.gz | 14.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| defense_predictor-1.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size:28.8 kB
Release files / defense_predictor-1.1.2.tar.gz
| Download URL | defense_predictor-1.1.2.tar.gz |
|---|---|
| Size | 14.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
60fd790fdf476d899bf0e68cb270d9b9a58cfd0342b1a04e147645dc72798592
|
|
BLAKE2b-256 checksum How to use checksums |
d1469972144cdb45f8ae500c7cea24e5808801af0a400d8fab175cc237c57a8c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.4 CPython/3.13.1 Darwin/25.2.0
|
Release files / defense_predictor-1.1.2-py3-none-any.whl
| Download URL | defense_predictor-1.1.2-py3-none-any.whl |
|---|---|
| Size | 14.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
722c5e8c2b324f5cf538a88e7290bcdb2dd9350de347e56659fe9ef57643faa9
|
|
BLAKE2b-256 checksum How to use checksums |
0c9659b373ccc850dcdb2633b5d4c57347dd465e927111a342f39c15f3480ac5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.4 CPython/3.13.1 Darwin/25.2.0
|