⛓️ Genomic Tokenizer
About
This is a tokenizer for DNA ⛓️ that aligns with the central dogma of molecular biology. The Genomic Tokenizer (GT) incorporates the biological process flow into a standard tokenizer interface within the HuggingFace transformer package. GT can be used to pre-train foundational transformer models on DNA sequences. [Read the preprint]
Please cite / contact me if you use it in your research.
🚀 Installation
pip install genomic-tokenizer
If you want to install the latest version from the repository, use the following command:
pip install git+https://github.com/dermatologist/genomic-tokenizer.git
🔧 Example usage
from genomic_tokenizer import GenomicTokenizer
# Fasta header if present is ignored.
fasta = """
AGGCGAGGCGCGGGCGGAGGCGGTGCGCGGGCGGAGGCGGGGCGCGGAGATGTGGCGGAGGTGGAGGCGG
AGGCGTAGCCGCCCCTGGGGACGTCATTGGTGGCGGAAGCAATCGCCGGCAACCAGCTGTAAGCGAGGTA
GGCTCACTCGGGCACGGAGGGTGCGGGTGAGAAAGGGAACGATTTGCTAGGAGTGTATGCGCCCGTGCTA
"""
model_max_length = 2048
tokenizer = GenomicTokenizer(model_max_length) # Use this in your model training pipeline
tokens = tokenizer(fasta)
print(tokens)
✨ Output
{'input_ids': [2, 7, 12, 17, 19, 16, 1, 7, 20, 6, 12, 21, 16, 12, 20, 12, 12, 8, 12, 1, 10, 20, 10, 20, 11, 7, 20, 21, 23, 8, 7, 20, 7, 6, 12, 21, 19, 10, 11, 16, 19, 7, 1, 22, 7, 1, 19, 21, 7, 16, 1, 21, 12, 23, 19, 12, 20, 6, 1],
'token_type_ids': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
'attention_mask': [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]}
🔧 Tokenization algorithm
- Identify the first occurrence of the start codon
ATG. - Split the sequence into codons of length 3 starting from the start codon.
- Convert synonymous codons to the same token.
- Convert stop codons to
[SEP]token.
📚 Cite
@misc{GT-Eapen2025,
title = {Genomic {{Tokenizer}}: {{Toward}} a Biology-Driven Tokenization in Transformer Models for {{DNA}} Sequences},
shorttitle = {Genomic {{Tokenizer}}},
author = {Eapen, Bell Raj},
year = {2025},
month = apr,
pages = {2025.04.02.646836},
publisher = {bioRxiv},
doi = {10.1101/2025.04.02.646836},
urldate = {2025-04-11},
}
Give us a star ⭐️
If you find this project useful, give us a star. It helps others discover the project.
Contributors
Metadata
Release files for genomic-tokenizer 0.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 |
|---|---|---|---|---|
| genomic_tokenizer-0.2.0.tar.gz | 74.2 kB | With provenance | Details for genomic_tokenizer-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| genomic_tokenizer-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for genomic_tokenizer-0.2.0-py3-none-any.whl |
Total release size: 88.5 kB
Release files / genomic_tokenizer-0.2.0.tar.gz
| Download URL | genomic_tokenizer-0.2.0.tar.gz |
|---|---|
| Size | 74.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4943558926e2ad322e6cdde7a376e0cf53c348a86a842c4b12b1e716540edcad
|
|
BLAKE2b-256 checksum How to use checksums |
21fb41993782e80e87cbd8b467dd06def3258538588440eb86bbf3ba07ba9eb7
|
| 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 Nov 13, 2026.
Transparency logRelease files / genomic_tokenizer-0.2.0-py3-none-any.whl
| Download URL | genomic_tokenizer-0.2.0-py3-none-any.whl |
|---|---|
| Size | 14.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d5a6ac12df82e61fe72ba0cd10344d825c0c181d8add001a738397137b0fa4e2
|
|
BLAKE2b-256 checksum How to use checksums |
7490a4af245b33313072b1bb3dfa784f1873c759ea912f0097649129449e99eb
|
| 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 Nov 13, 2026.
Transparency logSecurity for genomic-tokenizer 0.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
Both files in this release have been uploaded with provenance metadata.
Attestation for genomic_tokenizer-0.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 Nov 13, 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.