Sylphy 🧬
Sylphy is a Python toolkit for turning protein sequences into machine-learning-ready representations.
It covers three main workflows:
- Classical sequence encoders: one-hot, ordinal, frequency, k-mers, physicochemical, FFT
- Embedding extraction from pretrained protein models: ESM2, ProtT5, ProtBERT, Ankh2, Mistral-Prot, ESM-C
- Dimensionality reduction for downstream analysis and visualization
Installation
pip install sylphy
Install optional extras as needed:
embeddingsfor PyTorch and Transformers-based embedding extractionreductionsfor UMAP and related optional reducersallfor all optional runtime dependencies
The reductions extra may require a C++ compiler and Python development headers because of optional native dependencies such as ClustPy.
pip install 'sylphy[embeddings]'
pip install 'sylphy[all]'
On Debian or Ubuntu systems, install the build prerequisites with:
sudo apt-get install build-essential python3-dev
On Fedora or RHEL systems:
sudo dnf install gcc gcc-c++ python3-devel
Quick Start
Classical sequence encoding:
import polars as pl
from sylphy.sequence_encoder import create_encoder
df = pl.DataFrame({"id": ["p1", "p2", "p3"], "sequence": ["MKTAYIAKQR", "GAVLIMPFWK", "PEPTIDE"]})
encoder = create_encoder(
"one_hot", # or: ordinal, kmers, frequency, physicochemical, fft
dataset=df,
sequence_column="sequence",
)
encoder.run_process()
encoded = encoder.coded_dataset
encoder.export_encoder("encoded.parquet") # same format as the CLI
Embedding extraction:
import polars as pl
from sylphy.embedding_extractor import create_embedding
df = pl.DataFrame({"id": ["p1", "p2", "p3"], "sequence": ["MKTAYIAKQR", "GAVLIMPFWK", "PEPTIDE"]})
embedder = create_embedding(
model_name="facebook/esm2_t6_8M_UR50D",
dataset=df,
column_seq="sequence",
name_device="cuda",
precision="fp16", # fp32, fp16, or bf16
)
embedder.run_process(batch_size=8, pool="mean") # mean, cls, or eos
embeddings = embedder.coded_dataset
embedder.export_encoder("embeddings.parquet") # id_col="id" by default
export_encoder(path, file_format, *, id_col="id") writes the same files as the CLI (see Inputs and outputs), keyed by the id_col column of the input dataset.
A missing, empty or duplicated id raises sylphy.exceptions.DataError.
For fft, pass the id along with the physicochemical matrix: phys.coded_dataset.with_columns(phys.dataset["id"]).
Dimensionality reduction:
from sylphy.reductions import reduce_dimensionality
model, reduced = reduce_dimensionality(
method="pca", # pca, truncated_svd, umap, tsne, isomap, etc.
dataset=embeddings,
n_components=2,
random_state=42,
)
CLI
sylphy --help
# Extract embeddings (ESM2, GPU, fp16)
sylphy embed \
-i sequences.csv -o embeddings.parquet \
-m facebook/esm2_t6_8M_UR50D -d cuda -p fp16 -b 16
# Extract embeddings (ProtT5, last 4 layers averaged)
sylphy embed \
-i sequences.csv -o embeddings.npy \
-m Rostlab/prot_t5_xl_uniref50 -d cuda -p bf16 --layers last4 --layer-agg mean
# Classical encoding — one-hot
sylphy encode --method one_hot -i sequences.csv -o encoded.parquet
# Classical encoding — physicochemical (AAIndex)
sylphy encode --method physicochemical \
-i sequences.csv -o phys.parquet --name-property ARGP820101
# Classical encoding — k-mers TF-IDF
sylphy encode --method kmers -i sequences.csv -o kmers.csv -k 4
# Options from a YAML/JSON file (keys are option names, e.g. max_length); flags override the file
sylphy encode -i sequences.csv -o encoded.parquet --config encode.yaml
sylphy validate-config encode encode.yaml --json
# Cache management
sylphy cache stats
sylphy cache ls --recursive
sylphy cache prune --max-size 10GB --apply
Validate a config from Python
from sylphy import ConfigIssue, validate_config
issues = validate_config("encode.yaml", "encode") # or a mapping; target is "encode" or "embed"
for issue in issues:
print(issue.path or "<root>", issue.message)
An empty list means the config is valid; a missing or unparsable file is one issue with path "".
Inputs and outputs
- Input: FASTA (
.fa,.fasta,.faa; the id is the first token of the header), or CSV/TSV/Parquet with an id column (--id-col, defaultid) and a sequence column (--seq-col). Ids must be present, non-empty and unique. - Output tables (
.csv,.parquet): a stringidcolumn followed by the feature columns; the sequence is not written. .npz:values,columnsandids..npy: the numeric matrix only, plus<stem>.ids.txtwith one id per line.- Each run also writes
<output>.provenance.json(parameters, input/output hashes, package versions; forembed, the model revision, device and batch size actually used). sylphy embed --revisionpins the model revision (branch, tag or commit).
Exit codes
0success;2usage or config error;3runtime or data error (sylphy errors, I/O, model loading, unparsable input);4unexpected error (traceback on stderr).
Configuration
By default Sylphy stores cache data in the platform cache directory:
- Linux:
~/.cache/sylphy - macOS:
~/Library/Caches/sylphy - Windows:
%LOCALAPPDATA%\\sylphy\\Cache
Useful environment variables:
SYLPHY_CACHE_ROOTto override the cache locationSYLPHY_DEVICEto forcecpuorcudaSYLPHY_MODEL_<NAME>to override a registered model path
Learn More
- DEVELOPMENT.md for local setup, tests, architecture, and contribution notes
- examples/README.md for the examples index and runnable scripts/notebooks
Citation
If you use Sylphy in your research, please cite:
Medina-Ortiz, D.; Álvarez Saravia, D.; García-Vinuesa, J. Sylphy: Protein Sequence Representation: Encoders, Embeddings, and Reductions. Version 1.2.0, 2026. Zenodo. https://doi.org/10.5281/zenodo.21819735
@software{sylphy2026,
author = {Medina-Ortiz, David and Álvarez Saravia, Diego and García-Vinuesa, Julián},
title = {{Sylphy}: Protein Sequence Representation: Encoders, Embeddings, and Reductions},
year = {2026},
version = {1.2.0},
publisher = {Zenodo},
doi = {10.5281/zenodo.21819735},
url = {https://doi.org/10.5281/zenodo.21819735}
}
To cite this exact release, use the version DOI 10.5281/zenodo.21819736. Machine-readable metadata lives in CITATION.cff.
License
MIT. See LICENSE.
Acknowledgements
Built with the Hugging Face Transformers ecosystem, the Meta ESM-C SDK, and the broader scientific Python stack including scikit-learn, PyTorch, UMAP, and ClustPy.
Developed by KREN AI Lab at Universidad de Magallanes, Chile.
Metadata
Release files for sylphy 1.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sylphy-1.2.0.tar.gz | 60.1 kB | With provenance | Details for sylphy-1.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sylphy-1.2.0-py3-none-any.whl | Python 3 | none | any | Details for sylphy-1.2.0-py3-none-any.whl |
Total release size: 150.4 kB
Release files / sylphy-1.2.0.tar.gz
| Download URL | sylphy-1.2.0.tar.gz |
|---|---|
| Size | 60.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1c819e4a259fde08fff1830e109653dc9fbdf50145ce9498212dfed1ad1ab453
|
|
BLAKE2b-256 checksum How to use checksums |
2f7450949740b885703e353a9fac0ff14e18cccfb8d3569d5c40f31673232ee0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.
Transparency logRelease files / sylphy-1.2.0-py3-none-any.whl
| Download URL | sylphy-1.2.0-py3-none-any.whl |
|---|---|
| Size | 90.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b3334e2240a54d2ab6fc00cab96a22424590f819e263254779bdb6b9f8f36015
|
|
BLAKE2b-256 checksum How to use checksums |
a1109485f2f8e925481ce2de98b7ff68def0e6aac7fc312063c9f1efcc2aa1f3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.
Transparency logSecurity for sylphy 1.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for sylphy-1.2.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.