Spaces:
Sleeping
Sleeping
Download tests/test_rederive.py from opsmind-tech/syntheogenesis: direct link, hf CLI and curl.
- Browser
- Download file 1.6 kB
-
https://huggingface.co/spaces/opsmind-tech/syntheogenesis/resolve/main/tests/test_rederive.py
- Command line
-
hf download hf://spaces/opsmind-tech/syntheogenesis/tests/test_rederive.py
-
curl -L -o test_rederive.py https://huggingface.co/spaces/opsmind-tech/syntheogenesis/resolve/main/tests/test_rederive.py
1.6 kB
| """Tests for the DE-engine variant DNA re-derive (_rederive_variant_row). | |
| Audit fix: a premature stop is a legitimate nonsense/truncation mutation and | |
| must be ALLOWED (it used to hard-reject the save with a false "vendors will | |
| reject this" claim — the "can't do a single-nucleotide mutation" bug). Frame | |
| breaks and non-ACGT are still rejected.""" | |
| import pytest | |
| from dee import server | |
| WT_DNA = "ATG" + "GCT" * 10 + "TAA" # M + 10×A | |
| WT_PROT = "M" + "A" * 10 | |
| ROW = {"Variant_ID": "V1", "Predicted_Fitness_Score": 0.5} | |
| def _rederive(dna): | |
| return server._rederive_variant_row( | |
| variant_id="V1", edited_dna=dna, wt_protein=WT_PROT, original_row=ROW) | |
| def test_premature_stop_is_allowed_and_truncates(): | |
| # SNP/edit that installs a stop at codon 6 → protein truncates, NO raise. | |
| edited = "ATG" + "GCT" * 4 + "TAA" + "GCT" * 5 + "TAA" # M AAAA *(stop) ... | |
| row = _rederive(edited) | |
| assert row["Mutant_AA_Seq"] == "MAAAA" # truncated at the stop | |
| assert row["Optimized_DNA_Seq"] == edited # DNA kept as-is | |
| assert row["Edited"] is True | |
| def test_point_substitution_changes_one_residue(): | |
| # change codon 2 GCT(A) → GAT(D): a clean single-residue missense | |
| edited = "ATG" + "GAT" + "GCT" * 9 + "TAA" | |
| row = _rederive(edited) | |
| assert row["Mutant_AA_Seq"] == "MD" + "A" * 9 | |
| def test_frame_break_still_rejected(): | |
| with pytest.raises(ValueError): | |
| _rederive("ATGGC") # 5 bp, not a multiple of 3 | |
| def test_non_acgt_still_rejected(): | |
| with pytest.raises(ValueError): | |
| _rederive("ATGGCNGCTTAA") # contains N | |