Views
No views yet
zhihan1996/DNA_bert_6 to detect
whether a DNA sequence contains the TATA box motif (TATAAA), a common promoter signal.⚠️ Learning/demo model. Trained on a small synthetic dataset to demonstrate the DNABERT fine-tuning pipeline — not validated for real genomic analysis.
TATAAA motif.1import torch
2from transformers import AutoTokenizer, AutoModelForSequenceClassification
3
4repo = "adipras1407/my-dnabert6-promoter"
5tok = AutoTokenizer.from_pretrained(repo)
6model = AutoModelForSequenceClassification.from_pretrained(repo).eval()
7
8def seq2kmer(seq, k=6):
9 return " ".join(seq[i:i+k] for i in range(len(seq) - k + 1))
10
11def predict(seq):
12 x = tok(seq2kmer(seq), return_tensors="pt", truncation=True, max_length=128)
13 with torch.no_grad():
14 prob = torch.softmax(model(**x).logits, -1)[0, 1].item()
15 return {"has_motif": int(prob > 0.5), "confidence": round(prob, 3)}
16
17print(predict("GGGCGCTATAAACGCGCGATCG"))
18