BioSight/python/phi/test_phi.py
allaun 295130c078 feat(dna): align layer naming and integrate SilverSight receipt verification
- Aligned layer naming and numbering (1 to 4) with the formal Lean specifications in SilverSight.
- Implemented phi.silversight to verify rule ordering, N=8 necessity, and Lean compilation status.
- Integrated SilverSight validation checks into equation_dna_encoder.py and rigour_pipeline.py.

Build: 3307 jobs, 0 errors (lake build)
2026-06-27 22:51:03 -05:00

42 lines
1.2 KiB
Python

import sys
import os
# Add package directory to path so we can import from phi
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from phi.embed import encode_phi
from phi.output import to_fastq, design_filtering_protocol
def test():
equations = [
"x + y",
"(a * b) + (c / d)",
"x^2 + y^2 = z^2",
"sin(x) + cos(y)",
"sqrt(x + y) * 2",
"", # Empty case
]
print(f"{'Equation':<20} | {'DNA Sequence':<30} | {'Consistency Pass':<15}")
print("-" * 70)
for eq in equations:
record = encode_phi(eq)
if record:
dna = record["dna_sequence"]
pass_flag = "PASS" if record["consistency_pass"] else "FAIL"
print(f"{eq:<20} | {dna:<30} | {pass_flag:<15}")
else:
print(f"{eq:<20} | {'None':<30} | {'N/A':<15}")
# Test Output functions
sample_record = encode_phi("(a + b) * c")
if sample_record:
print("\n--- FASTQ Example ---")
print(to_fastq(sample_record))
print("--- PCR Protocol ---")
print(design_filtering_protocol([sample_record]))
if __name__ == "__main__":
test()