Datasets:
SSP: protein secondary structure (TAPE training data + CASP12-16 test sets, rcsb/casp/tape versions)
1c12c1a verified Download scripts/compare_ss_tools_helpers.py from hazemessam/SSP: direct link, hf CLI and curl.
- Browser
- Download file 660 Bytes
-
https://huggingface.co/datasets/hazemessam/SSP/resolve/main/scripts/compare_ss_tools_helpers.py
- Command line
-
hf download hf://datasets/hazemessam/SSP/scripts/compare_ss_tools_helpers.py
-
curl -L -o compare_ss_tools_helpers.py https://huggingface.co/datasets/hazemessam/SSP/resolve/main/scripts/compare_ss_tools_helpers.py
660 Bytes
| from Bio import Align | |
| aligner = Align.PairwiseAligner(mode="global", match_score=2, mismatch_score=-1, open_gap_score=-5, extend_gap_score=-0.5) | |
| def project(ref_seq, seqres, labels): | |
| """Map labels on `seqres` onto positions of `ref_seq` (identity if equal, else via global alignment).""" | |
| if ref_seq == seqres: | |
| return labels, "identical" | |
| aln = aligner.align(ref_seq, seqres)[0] | |
| out = [None] * len(ref_seq) | |
| for (a0, a1), (b0, b1) in zip(*aln.aligned): | |
| for k in range(a1 - a0): | |
| out[a0 + k] = labels[b0 + k] | |
| return out, f"aligned ({sum(a1 - a0 for (a0, a1), _ in zip(*aln.aligned))}/{len(ref_seq)} positions)" | |