Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Alignment

https://schemas.wur.nl/betula/alignment/0.6.0/schema.json

A multiple sequence alignment: a list of Sequence records. Conventionally all sequences have the same length once gaps are included, but that is a semantic constraint, not checked structurally by this schema. Accepts either the bare-array shape every current producer (react-bio-viz’s AlignedSequences, acacia’s MSAData) actually emits, or a wrapped object carrying the wire-format ‘type’ discriminator for producers that want one.

One of:

Definitions

WrappedAlignment

Field

Type

Required

Description

type

"alignment"

required

Wire-format object-kind discriminator (see betula’s versioning policy).

sequences

array of Sequence

required

No properties beyond those listed are allowed.

UnwrappedAlignment

The shape every current producer (react-bio-viz, acacia) actually emits: no wrapper, no discriminator.

Array of Sequence (minItems 1).

Valid examples

simple.json
[
  { "identifier": "seq1", "sequence": "ACGT--ACGT" },
  { "identifier": "seq2", "sequence": "ACGTACAC--" },
  { "identifier": "seq3", "sequence": "AC-TAC--GT" }
]
wrapped.json
{
  "type": "alignment",
  "sequences": [
    { "identifier": "seq1", "sequence": "ACGT--ACGT" },
    { "identifier": "seq2", "sequence": "ACGTACAC--" }
  ]
}

Invalid examples

empty.json
[]
legacy-header-field.json
[
  { "header": "seq1", "sequence": "ACGT" },
  { "identifier": "seq2", "sequence": "ACGT" }
]
wrapped-missing-sequences.json
{
  "type": "alignment"
}
wrong-type-const.json
{
  "type": "tree",
  "sequences": [
    { "identifier": "seq1", "sequence": "ACGT" }
  ]
}
Schema source
alignment.schema.json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://schemas.wur.nl/betula/alignment/0.6.0/schema.json",
  "title": "Alignment",
  "description": "A multiple sequence alignment: a list of Sequence records. Conventionally all sequences have the same length once gaps are included, but that is a semantic constraint, not checked structurally by this schema. Accepts either the bare-array shape every current producer (react-bio-viz's AlignedSequences, acacia's MSAData) actually emits, or a wrapped object carrying the wire-format 'type' discriminator for producers that want one.",
  "oneOf": [
    { "$ref": "#/$defs/WrappedAlignment" },
    { "$ref": "#/$defs/UnwrappedAlignment" }
  ],
  "$defs": {
    "WrappedAlignment": {
      "type": "object",
      "properties": {
        "type": {
          "const": "alignment",
          "description": "Wire-format object-kind discriminator (see betula's versioning policy)."
        },
        "sequences": {
          "type": "array",
          "items": { "$ref": "https://schemas.wur.nl/betula/sequence/0.6.0/schema.json" },
          "minItems": 1
        }
      },
      "required": ["type", "sequences"],
      "additionalProperties": false
    },
    "UnwrappedAlignment": {
      "description": "The shape every current producer (react-bio-viz, acacia) actually emits: no wrapper, no discriminator.",
      "type": "array",
      "items": { "$ref": "https://schemas.wur.nl/betula/sequence/0.6.0/schema.json" },
      "minItems": 1
    }
  }
}

Usage

Read a JSON document and parse it as a Alignment. CI runs this exact code against the first valid example above; see Getting started to install the bindings.

Python
TypeScript
Rust
alignment.py
from betula_schema import Alignment, parse_json

with open("alignment.json") as f:
    alignment = parse_json(Alignment, f.read())
# alignment.root is the matched variant: WrappedAlignment, or UnwrappedAlignment
print(alignment)