Views
No views yet

python -m pip install git+https://github.com/PickyBinders/tea.gittea_convert command takes protein sequences from a FASTA file and generates new tea-FASTA. It supports confidence-based sequence output where low-confidence positions are displayed in lowercase, and has options for saving logits and entropy. If --save_avg_entropy is set, the FASTA identifiers will contain the average entropy of the sequence in the format <key>|H=<avg_entropy>.1usage: tea_convert [-h] -f FASTA_FILE -o OUTPUT_FILE [-l] [-H] [-r] [-c] [-t ENTROPY_THRESHOLD]
2
3options:
4 -h, --help show this help message and exit
5 -f FASTA_FILE, --fasta_file FASTA_FILE
6 Input FASTA file containing protein amino acid sequences
7 -o OUTPUT_FILE, --output_file OUTPUT_FILE
8 Output FASTA file for generated tea sequences
9 -l, --save_logits Save per-residue logits to .pt file
10 -H, --save_avg_entropy
11 Save average entropy values in FASTA identifiers
12 -r, --save_residue_entropy
13 Save per-residue entropy values to .pt file
14 -c, --lowercase_entropy
15 Save residues with entropy > threshold in lowercase
16 -t ENTROPY_THRESHOLD, --entropy_threshold ENTROPY_THRESHOLD
17 Entropy threshold for lowercase conversion1from tea.model import Tea
2from transformers import AutoTokenizer, AutoModel
3from transformers import BitsAndBytesConfig
4import torch
5import re
6
7tea = Tea.from_pretrained("PickyBinders/tea")
8device = next(tea.parameters()).device
9tokenizer = AutoTokenizer.from_pretrained("facebook/esm2_t33_650M_UR50D")
10bnb_config = BitsAndBytesConfig(load_in_4bit=True) if torch.cuda.is_available() else None
11esm2 = AutoModel.from_pretrained(
12 "facebook/esm2_t33_650M_UR50D",
13 torch_dtype="auto",
14 quantization_config=bnb_config,
15 add_pooling_layer=False,
16 ).to(device)
17esm2.eval()
18sequence_examples = ["PRTEINO", "SEQWENCE"]
19sequence_examples = [" ".join(list(re.sub(r"[UZOBJ]", "X", sequence))) for sequence in sequence_examples]
20ids = tokenizer.batch_encode_plus(sequence_examples, add_special_tokens=True, padding="longest")
21input_ids = torch.tensor(ids['input_ids']).to(device)
22attention_mask = torch.tensor(ids['attention_mask']).to(device)
23with torch.no_grad():
24 x = esm2(
25 input_ids=input_ids, attention_mask=attention_mask
26 ).last_hidden_state.to(device)
27 results = tea.to_sequences(embeddings=x, input_ids=input_ids, return_avg_entropy=True, return_logits=False, return_residue_entropy=False)
28resultsmatcha.out substitution matrix is included with the tea package. You can get its path programmatically:1from tea import get_matrix_path
2matcha_path = get_matrix_path()
3print(f"Matrix path: {matcha_path}")1mmseqs easy-search tea_query.fasta tea_target.fasta results.m8 tmp/ \
2 --comp-bias-corr 0 \
3 --mask 0 \
4 --gap-open 18 \
5 --gap-extend 3 \
6 --sub-mat /path/to/matcha.out \
7 --seed-sub-mat /path/to/matcha.out \
8 --exact-kmer-matching 1