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 |
|---|---|---|---|
|
| required | Wire-format object-kind discriminator (see betula’s versioning policy). |
| 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¶
[
{ "identifier": "seq1", "sequence": "ACGT--ACGT" },
{ "identifier": "seq2", "sequence": "ACGTACAC--" },
{ "identifier": "seq3", "sequence": "AC-TAC--GT" }
]
{
"type": "alignment",
"sequences": [
{ "identifier": "seq1", "sequence": "ACGT--ACGT" },
{ "identifier": "seq2", "sequence": "ACGTACAC--" }
]
}
Invalid examples¶
[]
[
{ "header": "seq1", "sequence": "ACGT" },
{ "identifier": "seq2", "sequence": "ACGT" }
]
{
"type": "alignment"
}
{
"type": "tree",
"sequences": [
{ "identifier": "seq1", "sequence": "ACGT" }
]
}
Schema source
{
"$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.
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)
import { readFileSync } from "node:fs";
import { parseJson, type Alignment } from "betula-schema";
const alignment: Alignment = parseJson("Alignment", readFileSync("alignment.json", "utf8"));
// Alignment is a union type: WrappedAlignment | UnwrappedAlignment
console.log(alignment);
fn main() -> Result<(), Box<dyn std::error::Error>> {
let text = std::fs::read_to_string("alignment.json")?;
let alignment: betula_schema::Alignment = betula_schema::parse_str(&text)?;
// Alignment is an enum with one variant per alternative, e.g. Alignment::WrappedAlignment(_)
println!("{alignment:?}");
Ok(())
}