Spaces:
Sleeping
Sleeping
Tengo Gzirishvili
Claude Opus 4.8
CRISPR M0: validation test suite + fix KO cut-position copy-paste bug
36858f4 Download tests/test_cloning.py from opsmind-tech/syntheogenesis: direct link, hf CLI and curl.
- Browser
- Download file 3.53 kB
-
https://huggingface.co/spaces/opsmind-tech/syntheogenesis/resolve/main/tests/test_cloning.py
- Command line
-
hf download hf://spaces/opsmind-tech/syntheogenesis/tests/test_cloning.py
-
curl -L -o test_cloning.py https://huggingface.co/spaces/opsmind-tech/syntheogenesis/resolve/main/tests/test_cloning.py
3.53 kB
| """Cloning-oligo correctness — the HIGHEST-CONSEQUENCE output. | |
| If an overhang is wrong by a single base, a customer's annealed oligo | |
| will not ligate into the digested vector and their cloning silently | |
| fails after they've paid for synthesis and spent bench time. These | |
| tests pin the published Zhang-lab (Cas9) and Zetsche (Cas12a) cloning | |
| conventions exactly. | |
| References: | |
| Ran 2013 (Zhang lab Cas9 protocol) — CACCG / AAAC overhangs after BbsI. | |
| Sanjana 2014 (lentiCRISPRv2) — same convention, BsmBI. | |
| Zetsche 2017 (Cas12a / pY094) — AGAT / AAAA overhangs after BsmBI. | |
| """ | |
| import pytest | |
| from dee.core import crispr_cloning as CC | |
| def _rc(s: str) -> str: | |
| return s.translate(str.maketrans("ACGT", "TGCA"))[::-1] | |
| CAS9_VECTORS = ["px330", "px458", "px459_v2", "lenticrisprv2", "plentiguide_puro"] | |
| SPACER = "GACGCATCTTCCCGACAACG" # 20 nt, starts with G | |
| def test_cas9_oligos_match_zhang_convention(vid): | |
| o = CC.generate_cloning_oligos(SPACER, vid) | |
| # sense: 5'-CACCG[spacer]-3' | |
| # antisense: 5'-AAAC[revcomp(spacer)]C-3' | |
| assert o["sense_oligo"] == "CACCG" + SPACER | |
| assert o["antisense_oligo"] == "AAAC" + _rc(SPACER) + "C" | |
| def test_cas9_oligos_anneal_into_matching_4nt_overhangs(vid): | |
| """When the two oligos anneal, the duplex must present a 5'-CACC | |
| overhang on the sense side and a 5'-AAAC overhang on the antisense | |
| side — exactly the overhangs BbsI/BsmBI leaves in the vector.""" | |
| o = CC.generate_cloning_oligos(SPACER, vid) | |
| sense, anti = o["sense_oligo"], o["antisense_oligo"] | |
| # The shared, fully base-paired core is "G"+spacer. | |
| core = "G" + SPACER | |
| assert sense == "CACC" + core | |
| # revcomp(antisense) must end with that same core, leaving AAAC as | |
| # the antisense 5' overhang (revcomp ends in CGTT... → AAAC at 5'). | |
| assert _rc(anti) == core + _rc("AAAC") | |
| assert sense.startswith("CACC") # 4-nt sense overhang | |
| assert anti.startswith("AAAC") # 4-nt antisense overhang | |
| def test_cas12a_py094_matches_zetsche_convention(): | |
| spacer23 = "ATTACCGGTACCGGATCGATCGG" # 23 nt | |
| o = CC.generate_cloning_oligos(spacer23, "py094") | |
| assert o["sense_oligo"] == "AGAT" + spacer23 | |
| assert o["antisense_oligo"] == "AAAA" + _rc(spacer23) | |
| assert o["enzyme"] == "BsmBI" | |
| assert o["addgene_id"] == "84739" | |
| def test_unknown_vector_returns_empty_but_valid_keys(): | |
| o = CC.generate_cloning_oligos(SPACER, "not_a_vector") | |
| assert o["sense_oligo"] == "" | |
| assert o["antisense_oligo"] == "" | |
| # Keys still present so callers never KeyError. | |
| for k in ("vector_id", "vector_name", "enzyme", "addgene_id"): | |
| assert k in o | |
| def test_empty_spacer_returns_empty(): | |
| o = CC.generate_cloning_oligos("", "px459_v2") | |
| assert o["sense_oligo"] == "" and o["antisense_oligo"] == "" | |
| def test_list_vectors_filters_by_enzyme(): | |
| cas9 = CC.list_vectors("cas9") | |
| cas12a = CC.list_vectors("cas12a") | |
| assert {v.id for v in cas9} == set(CAS9_VECTORS) | |
| assert [v.id for v in cas12a] == ["py094"] | |
| assert len(CC.list_vectors()) == len(CAS9_VECTORS) + 1 | |
| def test_default_vector_for(): | |
| assert CC.default_vector_for("cas9") == "px459_v2" | |
| assert CC.default_vector_for("cas12a") == "py094" | |
| def test_every_vector_has_a_valid_addgene_id_and_enzyme(): | |
| for v in CC.list_vectors(): | |
| assert v.addgene_id.isdigit() | |
| assert v.enzyme in ("BbsI", "BsmBI") | |
| assert v.nuclease in ("cas9", "cas12a") | |