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
Note: The
embeddingsextra requires Python 3.11 or 3.12.torchtext(a dependency of ESM-C) doesn't providee support for Python 3.13+.
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_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
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.
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 sylphy-1.0.0.tar.gz.
File metadata
- Download URL: sylphy-1.0.0.tar.gz
- Upload date:
- Size: 51.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6bf5e3b0c3a17b88964c60982bb5d9464a9558145696031dee73dcffb952b107
|
|
| MD5 |
a4b94c7469b37bb457d52aa0ee87067e
|
|
| BLAKE2b-256 |
2fc169ad380879bd5820b242cb6bef97c3f83f1fc09c1281a27550e994f0e8d5
|
Provenance
The following attestation bundles were made for sylphy-1.0.0.tar.gz:
Publisher:
publish-pypi.yml on kren-ai-lab/sylphy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sylphy-1.0.0.tar.gz -
Subject digest:
6bf5e3b0c3a17b88964c60982bb5d9464a9558145696031dee73dcffb952b107 - Sigstore transparency entry: 2357185948
- Sigstore integration time:
-
Permalink:
kren-ai-lab/sylphy@2533fa5fee85129f9db3a2e7a0c8640980365450 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/kren-ai-lab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@2533fa5fee85129f9db3a2e7a0c8640980365450 -
Trigger Event:
push
-
Statement type:
File details
Details for the file sylphy-1.0.0-py3-none-any.whl.
File metadata
- Download URL: sylphy-1.0.0-py3-none-any.whl
- Upload date:
- Size: 78.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0898799478e6a28fbb5391d8d4533501b2ff31fdf77e5e576ead1e6ee363bf4f
|
|
| MD5 |
d30d0fe525e1a0763c51c702e971f26f
|
|
| BLAKE2b-256 |
03452d6d8ef8ae39ff0d0bd787a3be83ff0325de300455e4ad8cb5731e8764f6
|
Provenance
The following attestation bundles were made for sylphy-1.0.0-py3-none-any.whl:
Publisher:
publish-pypi.yml on kren-ai-lab/sylphy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sylphy-1.0.0-py3-none-any.whl -
Subject digest:
0898799478e6a28fbb5391d8d4533501b2ff31fdf77e5e576ead1e6ee363bf4f - Sigstore transparency entry: 2357186438
- Sigstore integration time:
-
Permalink:
kren-ai-lab/sylphy@2533fa5fee85129f9db3a2e7a0c8640980365450 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/kren-ai-lab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@2533fa5fee85129f9db3a2e7a0c8640980365450 -
Trigger Event:
push
-
Statement type: