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.
In a fresh conda or other virutal environment, run:
pip install defense_predictor
defense_predictor_downloadThe 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.
Requires python >= 3.10
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.csvdefense_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.
Input files can be downloaded from the ftp webpage for any gemone of interest, which is linked on its assembly page. Input files can be generated from an unannotated nuceotide assembly using NCBI's Prokaryotic Genome Annotation Pipeline.