Where a community format is well specified, betula follows it. Where it isn’t, betula decides and documents the decision here.
Coordinates¶
Intervals are 1-based and inclusive, following GFF3 (columns 4 and 5): a feature covering the
first ten bases of a sequence has start: 1 and end: 10, and its length is end - start + 1.
This applies to annotation and to the location primitive.
Differences from other formats¶
| Format | Convention | Convert to betula |
|---|---|---|
| GFF3, GTF, VCF | 1-based, inclusive | start, end unchanged |
| BED | 0-based, half-open | start + 1, end unchanged |
| Python / Rust ranges, slicing | 0-based, half-open | start + 1, end unchanged |
Converting from betula to BED or to a slice is the reverse: start - 1, end unchanged. The usual
mistake is forgetting the shift on start only, which silently moves every feature one base.
Zero-length intervals¶
betula does not represent zero-length intervals (a point between two bases, such as an insertion
site or a cut site): every interval covers at least one base. GFF3 writes such a site as
start equal to end, meaning the point to the right of that base. betula reads the same numbers
as a one-base feature, so copying them changes their meaning. None of the current consumers need
zero-length intervals; supporting them would be a schema change.
BLAST coordinates¶
blast-result follows BLAST’s XML2 output (-outfmt 16), with keys in camelCase, for blastn, blastp,
blastx, tblastn and tblastx. Coordinates are 1-based and inclusive, in nucleotides for a nucleotide
sequence (also when translated) and amino acids for a protein. The start <= end rule does not
apply. Checked against BLAST+ 2.16.0:
| Program | Strand fields | Minus strand |
|---|---|---|
| blastn | queryStrand, hitStrand (Plus or Minus) | hitStrand: "Minus", and hitFrom > hitTo |
| blastp | none | |
| blastx | queryFrame | queryFrame is negative; queryFrom <= queryTo |
| tblastn | hitFrame | hitFrame is negative; hitFrom <= hitTo |
| tblastx | queryFrame, hitFrame | the frame is negative; from <= to on both |
The fields in the second column are required for that program, and a required frame can’t be 0. Other programs have no strand rule. When converting from other output formats:
-outfmt 5(XML) has the same coordinates, but writes both frames for every program. For blastn, turn frames 1 and -1 intoPlusandMinus; drop frames of 0.-outfmt 6(tabular) swaps from and to on the minus strand for translated searches too. Sort each translated pair and keep its frame (request theqframeandsframecolumns); for blastn, usesstrand. Its frames for blastp are 1; drop them.
When there are no hits, XML2 gives a message (“No hits found”) and hits is absent or empty. stat and params
are XML2’s Statistics and Parameters elements, without the wrapper. XML holds only text, so a
parser must convert numbers.
Tree branch lengths¶
length is optional, as in Newick. Leave it out when it is unknown or doesn’t apply, such as at the
root or in a topology-only tree; don’t write 0, which means a branch of zero length. Negative
lengths are allowed, because neighbor-joining can produce them.
Absent values¶
No betula schema allows null. Leave an optional field out instead.
Extra data¶
Unknown fields are rejected. Put application-specific data in the optional metadata field, whose
values are strings or lists of strings:
sequence,distance-matrix,blast-result: on the top-level object.alignment: on the wrapped form. A bare array has nowhere to put it, so wrap it.tree: on every node.annotation: useattributes(GFF3 column 9), on every node.
Keys that turn out to be common can become fields of the schema.
Conformance¶
A document conforms to betula if it passes its JSON Schema and the rules below, which JSON Schema can’t express. The bindings check both. If you validate with the schema alone, in any language, you must also implement the rules.
| Schemas | Rule |
|---|---|
annotation (every node, including children), core/location | start <= end |
blast-result (every HSP) | the strand fields its program requires are present, and required frames are not 0 |
To test an implementation, run the fixtures in examples/<name>/:
| Directory | Schema alone | Conforming implementation |
|---|---|---|
valid | accepts | accepts |
invalid | rejects | rejects |
invalid-rules | accepts | rejects |