Download scripts/utils/constants.py from OneScience-Group/SaProt: direct link, hf CLI and curl.
- Browser
- Download file 825 Bytes
-
https://huggingface.co/OneScience-Group/SaProt/resolve/main/scripts/utils/constants.py
- Command line
-
hf download hf://OneScience-Group/SaProt/scripts/utils/constants.py
-
curl -L -o constants.py https://huggingface.co/OneScience-Group/SaProt/resolve/main/scripts/utils/constants.py
825 Bytes
| import itertools | |
| aa_set = {"A", "C", "D", "E", "F", "G", "H", "I", "K", "L", "M", "N", "P", "Q", "R", "S", "T", "V", "W", "Y"} | |
| aa_list = ["A", "C", "D", "E", "F", "G", "H", "I", "K", "L", "M", "N", "P", "Q", "R", "S", "T", "V", "W", "Y"] | |
| foldseek_seq_vocab = "ACDEFGHIKLMNPQRSTVWY#" | |
| foldseek_struc_vocab = "pynwrqhgdlvtmfsaeikc#" | |
| struc_unit = "abcdefghijklmnopqrstuvwxyz" | |
| def create_vocab(size: int) -> dict: | |
| """ | |
| Args: | |
| size: Size of the vocabulary | |
| Returns: | |
| vocab: Vocabulary | |
| """ | |
| token_len = 1 | |
| while size > len(struc_unit) ** token_len: | |
| token_len += 1 | |
| vocab = {} | |
| for i, token in enumerate(itertools.product(struc_unit, repeat=token_len)): | |
| vocab[i] = "".join(token) | |
| if len(vocab) == size: | |
| vocab[i+1] = "#" | |
| return vocab |