Commit ·
b482fe2
1
Parent(s): 65ad73f
upload
Browse files
README.md
CHANGED
|
@@ -1 +1,25 @@
|
|
| 1 |
-
# ProtBERT
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ProtBERT
|
| 2 |
+
|
| 3 |
+
```python
|
| 4 |
+
from transformers import AutoTokenizer, AutoModel
|
| 5 |
+
import torch
|
| 6 |
+
|
| 7 |
+
tokenizer = AutoTokenizer.from_pretrained("Rostlab/prot_bert")
|
| 8 |
+
encoder = AutoModel.from_pretrained("Rostlab/prot_bert")
|
| 9 |
+
protenrich = AutoModel.from_pretrained("SaeedLab/ProtEnrich-ProtBERT", trust_remote_code=True)
|
| 10 |
+
|
| 11 |
+
seqs = ["MKTFFVLLL"]
|
| 12 |
+
seqs = [" ".join(i) for i in seqs]
|
| 13 |
+
inputs = tokenizer(seqs, return_tensors="pt", padding=True)
|
| 14 |
+
|
| 15 |
+
with torch.no_grad():
|
| 16 |
+
outputs = encoder(**inputs)
|
| 17 |
+
pooled = outputs.last_hidden_state[0, 1:-1].mean(axis=0)
|
| 18 |
+
enriched = protenrich(pooled)
|
| 19 |
+
|
| 20 |
+
print('H enrich:', enriched.h_enrich)
|
| 21 |
+
print('H anchor:', enriched.h_anchor)
|
| 22 |
+
print('H algn:', enriched.h_algn)
|
| 23 |
+
print('Structure:', enriched.struct)
|
| 24 |
+
print('Dynamics:', enriched.dyn)
|
| 25 |
+
```
|