A fine-tuned DNABERT model for binary promoter sequence classification. Given a DNA sequence, the model predicts whether it belongs to a Promoter or Non-Promoter region.
Unlike conventional NLP models, DNABERT treats DNA as a language. During preprocessing, each DNA sequence is converted into overlapping 6-mers, enabling the Transformer to learn biologically meaningful sequence patterns.
This project demonstrates the application of Transformer-based deep learning for computational genomics and serves as part of my Bioinformatics and Machine Learning portfolio.
Promoters are regulatory DNA elements responsible for initiating gene transcription. Accurate promoter identification plays a critical role in:
This model fine-tunes DNABERT, a Transformer model pre-trained on genomic sequences represented as 6-mers.
| Property | Value |
|---|---|
| Base Model | DNABERT (DNA-BERT-6) |
| Task | Binary DNA Sequence Classification |
| Framework | Hugging Face Transformers |
| Backend | PyTorch |
| Precision | FP16 Mixed Precision |
| Training Platform | Google Colab GPU |
Before tokenization, every DNA sequence is converted into overlapping 6-mers, matching the representation used during DNABERT pretraining.
Example:
DNA sequence
ATGCGTACGA
6-mer representation
ATGCGT TGCGTA GCGTAC CGTACG GTACGA
The generated 6-mer sentence is then tokenized using the DNABERT tokenizer.
Important: The same preprocessing must be applied during inference. Raw DNA sequences should always be converted to 6-mers before being passed to the model.
Rahul Kumar Singh
M.Sc. Bioinformatics
Deen Dayal Upadhyaya Gorakhpur University
| Label | Class |
|---|---|
| 0 | Non-Promoter |
| 1 | Promoter |
The model was evaluated on the held-out test dataset.
| Metric | Score |
|---|---|
| Accuracy | 90.8% |
| Weighted Precision | 0.92 |
| Weighted Recall | 0.91 |
| Weighted F1-score | 0.91 |
| ROC-AUC | 0.958 |
| Average Precision (PR-AUC) | 0.973 |
| Class | Precision | Recall | F1-score |
|---|---|---|---|
| Non-Promoter | 0.85 | 0.98 | 0.91 |
| Promoter | 0.98 | 0.85 | 0.91 |
Overall Test Accuracy: 90.8%
ROC-AUC = 0.958
Average Precision = 0.973
| Parameter | Value |
|---|---|
| Learning Rate | 2e-5 |
| Batch Size | 8 |
| Epochs | 5 |
| Weight Decay | 0.01 |
| Optimizer | AdamW |
| Mixed Precision | FP16 |
| Evaluation Strategy | Every Epoch |
| k-mer Size | 6 |
| Maximum Sequence Length | 512 Tokens |
from transformers import AutoTokenizer
from transformers import AutoModelForSequenceClassification
import torch
def generate_kmers(sequence, k=6):
return " ".join(
sequence[i:i+k]
for i in range(len(sequence)-k+1)
)
model_name = "rahuls472/DNABERT-Promoter-Classifier"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
sequence = "ATCGGCTAGCTAGCTAGCTAGCTA"
sequence = generate_kmers(sequence)
inputs = tokenizer(
sequence,
return_tensors="pt",
truncation=True,
padding="max_length",
max_length=512
)
with torch.no_grad():
outputs = model(**inputs)
prediction = torch.argmax(outputs.logits, dim=1).item()
print("Promoter" if prediction == 1 else "Non-Promoter")
DNA Sequence
│
▼
Generate overlapping 6-mers
│
▼
DNABERT Tokenizer
│
▼
DNABERT Encoder
│
▼
Sequence Classification Head
│
▼
Promoter / Non-Promoter
This model is intended for research and educational purposes only.
It is not intended for:
This project was developed using:
Special thanks to the open-source bioinformatics and machine learning communities for providing the datasets, pretrained models, and tools that made this work possible.