Download libs/encoders/sequence_features.py from QPromaQ/Docking_project: direct link, hf CLI and curl.
- Browser
- Download file 826 Bytes
-
https://huggingface.co/datasets/QPromaQ/Docking_project/resolve/main/libs/encoders/sequence_features.py
- Command line
-
hf download hf://datasets/QPromaQ/Docking_project/libs/encoders/sequence_features.py
-
curl -L -o sequence_features.py https://huggingface.co/datasets/QPromaQ/Docking_project/resolve/main/libs/encoders/sequence_features.py
826 Bytes
| from __future__ import annotations | |
| from typing import Dict | |
| AA_ALPHABET = "ACDEFGHIKLMNPQRSTVWY" | |
| def compute_sequence_features(sequence: str) -> Dict[str, float]: | |
| """Compute simple amino-acid composition and coarse biochemical summaries.""" | |
| seq = sequence.strip().upper() | |
| length = max(len(seq), 1) | |
| features: Dict[str, float] = {f"aa_frac_{aa}": seq.count(aa) / length for aa in AA_ALPHABET} | |
| aromatic = set("FWY") | |
| polar = set("STNQ") | |
| charged = set("KRHDE") | |
| features.update( | |
| { | |
| "seq_length": float(len(seq)), | |
| "frac_aromatic": sum(1 for aa in seq if aa in aromatic) / length, | |
| "frac_polar": sum(1 for aa in seq if aa in polar) / length, | |
| "frac_charged": sum(1 for aa in seq if aa in charged) / length, | |
| } | |
| ) | |
| return features | |