← Files Biological Sequence & Alignment ViewerARCHIVED FILE

src/sequence/translation.test.ts

809 Bytes · Sep 30, 2026 · 23:01 UTC

↓ Download file

import { describe, expect, it } from "vitest";

import { reverseComplement, translateSixFrames } from "./translation";

describe("sequence translation", () => {
  it("translates all forward and reverse frames with the standard code", () => {
    const frames = translateSixFrames("ATGAAATAG");

    expect(frames.find(({ frame }) => frame === 1)?.aminoAcids).toBe("MK*");
    expect(frames.map(({ frame }) => frame)).toEqual([1, -1, 2, -2, 3, -3]);
  });

  it("reverse-complements IUPAC nucleotide symbols", () => {
    expect(reverseComplement("ATGCRYNN")).toBe("NNRYGCAT");
  });

  it("normalizes RNA and marks ambiguous codons without inventing residues", () => {
    const frames = translateSixFrames("AUGNNNUAA");

    expect(frames.find(({ frame }) => frame === 1)?.aminoAcids).toBe("MX*");
  });
});

SHA-256: b4f61f3609271a749a48847f9e7676012f4eb8374963130905e4ed4d91ba27a3