Skip to main content

Sylphy 🧬

PyPI PyVersions Tests License DOI

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:

  • embeddings for PyTorch and Transformers-based embedding extraction
  • reductions for UMAP and related optional reducers
  • all for 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({"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

Embedding extraction:

import polars as pl
from sylphy.embedding_extractor import create_embedding

df = pl.DataFrame({"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")

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

# Cache management
sylphy cache stats
sylphy cache ls --recursive
sylphy cache prune --max-size 10GB --apply

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_ROOT to override the cache location
  • SYLPHY_DEVICE to force cpu or cuda
  • SYLPHY_MODEL_<NAME> to override a registered model path

Learn More

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.0.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.0.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.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sylphy 1.1.0
File Size Uploaded Provenance Actions
sylphy-1.1.0.tar.gz 52.3 kB With provenance Details for sylphy-1.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sylphy 1.1.0
File Interpreter ABI Platform Actions
sylphy-1.1.0-py3-none-any.whl Python 3 none any Details for sylphy-1.1.0-py3-none-any.whl

Total release size: 131.3 kB

Release files / sylphy-1.1.0.tar.gz

Download URL sylphy-1.1.0.tar.gz
Size 52.3 kB
Tags Source
SHA-256 checksum
How to use checksums
e2bf7b90d74d5af7bcb0676ea36a9f400de331b1a444eb145f432d227bcabab8
BLAKE2b-256 checksum
How to use checksums
a0a6e1f199f79b3a3c0bf0a4d3c60297f370641742e5b899c484068cb0477912
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 23, 2026.

Transparency log

Release files / sylphy-1.1.0-py3-none-any.whl

Download URL sylphy-1.1.0-py3-none-any.whl
Size 79.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3da525d893317d06aae7bf28a05d2bda8c472781acb8de49e7c4cfe06739d484
BLAKE2b-256 checksum
How to use checksums
3a601450341df0ae9641a6d947a23734c5e17ffdf0a50542b10ce67a8f7aff13
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 23, 2026.

Transparency log

Security for sylphy 1.1.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.

Select from 2 files

Attestation for sylphy-1.1.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 Sep 23, 2026.

Transparency log

A 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page