Command-line tool for automated plasmid family classification using protein marker search and a ML model.
Project description
โ๐๐๐ค๐๐๐๐๐ช๐ก๐๐ฃ
Command-line tool for automated plasmid family classification using protein marker search and a machine learning model (pytorch).
๐ฃ
โ โถ
โญ โถ โ โถ
โฏ โญ โง
๊ง ๐๐ต๐ช๐ผ๐ถ๐ฒ๐ญ๐ฃ๐๐น๐ฎ๐ป ๊ง โ
โญ โง
โญ โญ โฒ
โ โถ โญ
๐ฃ
Documentation
Description
PlasmidTyper takes one or more plasmid sequences (fasta) and classifies them into plasmid families. It does so by searching into a curated database of family-specific protein markers using MMseqs2, then scoring each plasmid against all families using a machine learning model. The top-3 most likely families are reported for each plasmid, along with confidence scores in predictions_stats.tsv. A summary of the plasmid's predicted family is given in results.tsv.
Pipeline steps
- Translation (optional) โ Prodigal translates nucleotide FASTA to protein FASTA (results written in
Prodigal_res) - MMseqs2 search & filtering โ each plasmid is searched against the marker database then hits below per-marker thresholds (qcov, tcov, pident) are removed (results written to
MMseqs2_res.tsv) - Typing โ hits are scored using the the AI model (results written to
results.tsvandpredictions_stats.tsvfor more details on the scoring part.)
Why?
Plasmid typing is a key step in understanding the epidemiology of antimicrobial resistance (AMR). Existing tools often require exact sequence identity or are limited to specific incompatibility groups. PlasmidTyper uses protein-level homology search and core genomes, making it more robust to sequence divergence, and supports machine-learning-based classification strategies.
Installation & Usage
Setup
For plasmid_typer to work, you will need an environment with python and MMseqs2 installed. You will also need to install prodigal if your files aren't already translated in a fasta protein format. To install MMseqs2 and prodigal, we recommend that you create an environment first and then install them in it (you can use conda or pixi for that).
We will first explain how to create a new environment with conda and pixi then we'll explain how to install PlasmidTyper with Pipy. For dockers usage, see the next update.
Environment configs
Installation with conda
To create a new environment with python, mmseqs2 and prodigal, open a terminal and write :
conda create -n name_env python=3.10 mmseqs2 prodigal -c conda-forge -c bioconda
with name_env the name you want your environment to be named.
Then, activate your new environment :
conda activate name_env
And finally install plasmid_typer. In your new environment, launch this command :
pip install plasmid_typer
With pixi
To create a new environment with pixi, open your terminal and write in the folder you want your environment in :
pixi init name_env
with name_env the name you want your environment to be named.
Then go in your environment like you do for any folder :
cd name_env
Add python, pip, MMseqs2 and Prodigal to your environment:
pixi add python=3.10
pixi add pip
pixi add prodigal
pixi add mmseqs2
If you're having troubles adding mmseqs2 or prodigal, try opening the pixi.toml file and add bioconda in the channel section. Then try again.
If there is still an issue, you can try this command : pixi add bioconda::mmseqs2.
And finally install plasmid_typer with this command :
pixi run pip install plasmid_typer
Container configs
None (yet)
Usage
plasmid_typer query_path [options]
With pixi, simply add pixi run before the command as pixi run plasmid_typer query_path
Requirements
- Requires plasmid sequences as input in one of these 4 forms :
- one directory with proteic fasta files
- one directory with nucleotidic fasta files
- one file in proteic fasta (containing sequences from multiple plasmids)
- one file in proteic or nucleotidic (containing the sequence of only one plasmid)
- to use one file containing multiples sequences in nucleotidic fasta, it is required that each header look like this :
>PlasmidName_ProtNumber(Prodigal will use this format automatically if you use it to translate your sequences)
- Do not use headers with '_' in your files other than to separate the name of your plasmid and the protein number (it will not work and you could obtain wrong results)
- Plasmids with few or highly divergent markers may be classified as
UNKNOWN
Example
Single plasmid (protein sequences)
plasmid_typer my_plasmid.faa -o results
Folder of plasmids, will use 8 CPU to run and will run Prodigal first
plasmid_typer my_sequences/plasmids -o results -t 8 -n
One file with multiple sequences, will run with low MMseqs2 sensitivity, low sensitivity to core genomes, will not delete mmseqs2 file results and will use 6 CPU
plasmid_typer new_plasmids_database/merged.fasta -o new_plasmids_database/results --sensitivity 5 --mode permissive -rm -t 6
Arguments
| Flag | Default | Description |
|---|---|---|
query_path |
(Required) | Path to a .fasta file or a folder containing multiple .fasta files (also .fna, or .faa) |
-o, --output_path |
working_directory/PlasmidTyper_<timestamp> |
Path to the output folder where /PlasmidTyper_<timestamp> will be created |
-d, --database_path |
directory where is installed PlasmidTyper |
Path to the database directory |
--model, -m |
database/model.pt (after 1st time launching) |
Path to pre-trained classification model |
--prodigal_output_path |
output directory |
Path to the Prodigal output directory/file |
--mmseqs_output_path |
output directory |
Path to the MMseqs2 output directory/file |
--tmp_dir |
output directory |
Path to the template directory were to write template files Note that it will be deleted at the end of runtime. |
-t, --n_threads |
2 |
Number of threads used by mmseqs2 |
-s, --sensitivity |
7.5 |
MMseqs2 sensitivity, the lower, the faster [4;7.5] |
-f, --files |
False |
Disaggregate all MMseqs2 results in many files instead of one |
-n, --nucleotide |
False |
ranslate nucleotide input with Prodigal before search |
-v, --mmseqs_verbosity |
2 |
Verbosity level of mmseqs2 (0:quiet, 1:errors, 2:warnings, 3:infos) |
-q, --prodigal_quiet |
True |
Re-activate verbosity of prodigal |
-rm, --remove_mmseqs |
True |
If activated, will not delete the mmseqs file.s in the output directory |
-rp, --remove_prodigal |
False |
Will delete the prodigal file.s in the output directory |
--batch_size |
256 |
size of batch load in one go for the model reading |
--mode |
balanced |
choose between strict(family predicted are certain, probably more related_to/unknown results), balanced or permissive(will diminish unknown results, great for a first launch on a unknown database) mode |
Output
| File | Description |
|---|---|
results.tsv |
One row per plasmid - predicted family & all their characteristics |
predictions_stats.tsv |
One row per plasmid - predicted family, top-3 families and probabilities |
MMseqs2_res/ or MMseqs2_res.tsv |
Filtered MMseqs2 results (optional) |
Plasmids with a top-1 probability below the confidence threshold are reported as UNKNOWN.
Architecture
plasmid_typer/
โโโ plasmid_typer.py # Entry point โ argument parsing, call main module
โโโ scriptes/
โโโ main.py # Main pipeline: path management, call all functions
โโโ config.py # Parsing & parameter validation
โโโ mmseqs2.py # MMseqs2: run MMseqs2
โโโ mmseqs2_utils.py # MMseqs2: DB index creation & result filtering
โโโ translate.py # Prodigal for nucleotide โ protein translation
โโโ AI/
โโโ type_plasmids.py # High-level typing functions
โโโ utils.py # Regroups functions and Class def
database/
โโโ markers_cluster_specific_plasmids_atleast3.faa # Protein marker database
โโโ markers_thresholds_database.tsv # Per-marker qcov/tcov/pident thresholds
โโโ infos_cluster.tsv # cluster family database
after download
โโโ model_for_inference*.pt # Pre-trained model
Dependencies
| Python dependency | Version |
|---|---|
| Python | 3.10 |
| numpy | 1.24 |
| pandas | 2.0 |
| scipy | 1.10 |
| torch/pytorch | 2.0 |
| tqdm | 4.65 |
| non-python dependency | Version |
|---|---|
| mmseqs2 | 18.8cc5c |
Prodigal (only with -n) |
2.6.3 |
References
- Steinegger M and Soeding J. MMseqs2 enables sensitive protein sequence searching for the analysis of massive data sets. Nature Biotechnology (2017).
- Kallenborn F, Chacon A, Hundt C, Sirelkhatim H, Didi K, Cha S, Dallago C, Mirdita M, Schmidt B, Steinegger M. GPU-accelerated homology search with MMseqs2. Nature Methods (2025)
- Prodigal by Doug Hyatt, https://github.com/hyattpd/Prodigal 2016
- Ansel, J., Yang, E., He, H., Gimelshein, N., Jain, A., Voznesensky, M., Bao, B., Bell, P., Berard, D., Burovski, E., Chauhan, G., Chourdia, A., Constable, W., Desmaison, A., DeVito, Z., Ellison, E., Feng, W., Gong, J., Gschwind, M., Hirsh, B., Huang, S., Kalambarkar, K., Kirsch, L., Lazos, M., Lezcano, M., Liang, Y., Liang, J., Lu, Y., Luk, C., Maher, B., Pan, Y., Puhrsch, C., Reso, M., Saroufim, M., Siraichi, M. Y., Suk, H., Suo, M., Tillet, P., Wang, E., Wang, X., Wen, W., Zhang, S., Zhao, X., Zhou, K., Zou, R., Mathews, A., Chanan, G., Wu, P., & Chintala, S. (2024). PyTorch 2: Faster Machine Learning Through Dynamic Python Bytecode Transformation and Graph Compilation [Conference paper]. 29th ACM International Conference on Architectural Support for Programming Languages and Operating Systems, Volume 2 (ASPLOS '24). https://doi.org/10.1145/3620665.3640366
- Harris, C.R., Millman, K.J., van der Walt, S.J. et al. Array programming with NumPy. Nature 585, 357-362 (2020). DOI: 10.1038/s41586-020-2649-2.
- Pauli Virtanen, Ralf Gommers, Travis E. Oliphant, Matt Haberland, Tyler Reddy, David Cournapeau, Evgeni Burovski, Pearu Peterson, Warren Weckesser, Jonathan Bright, Stรฉfan J. van der Walt, Matthew Brett, Joshua Wilson, K. Jarrod Millman, Nikolay Mayorov, Andrew R. J. Nelson, Eric Jones, Robert Kern, Eric Larson, CJ Carey, ฤฐlhan Polat, Yu Feng, Eric W. Moore, Jake VanderPlas, Denis Laxalde, Josef Perktold, Robert Cimrman, Ian Henriksen, E.A. Quintero, Charles R Harris, Anne M. Archibald, Antรดnio H. Ribeiro, Fabian Pedregosa, Paul van Mulbregt, and SciPy 1.0 Contributors. (2020) SciPy 1.0: Fundamental Algorithms for Scientific Computing in Python. Nature Methods, 17(3), 261-272. DOI: 10.1038/s41592-019-0686-2.
- Wes Mc Kinney, Data Structures for Statistical Computing in Python Proceedings of the 9th Python in Science Conference , 56-61, 2010.
Authors
- Pierre Bouteyre - scripte creation (June 2025)
- Lou Planterose - modifications, optimization, publication and documentation (2026)
- Charles Coluzzi - Machine learning creation and supervisor (2025-2026)
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
Built Distribution
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 plasmid_typer-1.3.2.tar.gz.
File metadata
- Download URL: plasmid_typer-1.3.2.tar.gz
- Upload date:
- Size: 8.4 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3f67b85231708072fb21f0cf0cf2b3370b5684d50ec22df9e9a0a8e0f4b1f883
|
|
| MD5 |
99426f12ae7a495a91b2bcb9ec0a3797
|
|
| BLAKE2b-256 |
61edb4f1dcb7dfc7dd0c2c35cbefb2e5df87c8579ecf280cd3e34cecd0dad95b
|
File details
Details for the file plasmid_typer-1.3.2-py3-none-any.whl.
File metadata
- Download URL: plasmid_typer-1.3.2-py3-none-any.whl
- Upload date:
- Size: 8.4 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aef48946617f8481136c778532ca94b0ae87d1c1f1334405f600bf4c9cd570f3
|
|
| MD5 |
dc71f78d32750b8ee8e5280aa9bc5f8b
|
|
| BLAKE2b-256 |
468aefb95c103bbd7cce016131e1f5761c74ec7c14e36a6fb3bfa83d2ba097a3
|