← Files Biological Sequence & Alignment ViewerARCHIVED FILE

src/sequence/feature-tracks.test.ts

1.02 KB · Sep 30, 2026 · 23:01 UTC

↓ Download file

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

import {
  getMaxFeatureLaneCount,
  getVisibleFeatureLanes,
} from "./feature-tracks";
import type { SequenceFeature } from "./types";

const OVERLAPPING_FEATURES: Array<SequenceFeature> = [
  {
    end: 12,
    id: "gene-1",
    qualifiers: {},
    start: 1,
    strand: "+",
    type: "gene",
  },
  {
    end: 9,
    id: "cds-1",
    qualifiers: {},
    start: 4,
    strand: "-",
    type: "CDS",
  },
  {
    end: 18,
    id: "misc-1",
    qualifiers: {},
    start: 13,
    strand: ".",
    type: "misc_feature",
  },
];

describe("feature track lanes", () => {
  it("stacks overlapping features and reuses lanes after spans end", () => {
    expect(getMaxFeatureLaneCount(OVERLAPPING_FEATURES)).toBe(2);
    expect(
      getVisibleFeatureLanes({
        features: OVERLAPPING_FEATURES,
        lineEnd: 20,
        lineStart: 1,
      }).map(({ feature, laneIndex }) => [feature.id, laneIndex]),
    ).toEqual([
      ["gene-1", 0],
      ["cds-1", 1],
      ["misc-1", 0],
    ]);
  });
});

SHA-256: 5334f978ae1467f3ea21e313b6c30527a9fa98c99f8ad83e2b5381a9ef0e532a