rtemis-a3
Python implementation of the Amino Acid Annotation (A3) format — a structured JSON format for amino acid sequences with site, region, PTM, processing, and variant annotations.
Part of the rtemis-org/a3 monorepo, which provides A3 implementations in Python, TypeScript, R, Julia, and Rust.
Installation
pip install rtemis-a3
# or with uv
uv add rtemis-a3
Quick Start
from rtemis.a3 import create_a3
a3 = create_a3(
"MKTAYIAKQR",
site={
"Active site": {"index": [3, 5], "type": "activeSite"},
},
region={
"Repeat 1": {"index": [[1, 4]], "type": ""},
},
ptm={
"Phosphorylation": {"index": [7], "type": ""},
},
variant=[{"position": 3, "from": "K", "to": "R"}],
metadata={
"uniprot_id": "P12345",
"description": "Example protein",
"organism": "Homo sapiens",
},
)
len(a3.sequence) # 10
Parsing JSON
from rtemis.a3 import a3_from_json, A3ValidationError, A3ParseError
try:
a3 = a3_from_json(json_string)
except A3ValidationError as e:
print(e.errors) # list of Pydantic error dicts with field paths
except A3ParseError as e:
print(e) # malformed JSON
File I/O
from rtemis.a3 import read_a3json, write_a3json
a3 = read_a3json("protein.json")
write_a3json(a3, "output.json", indent=2)
Serialization
from rtemis.a3 import a3_to_json
json_string = a3_to_json(a3) # compact
json_string = a3_to_json(a3, indent=2) # pretty-printed
Wire Format
{
"$schema": "https://schema.rtemis.org/a3/v1/schema.json",
"a3_version": "1.0.0",
"sequence": "MKTAYIAKQR",
"annotations": {
"site": { "Active site": { "index": [3, 5], "type": "activeSite" } },
"region": { "Repeat 1": { "index": [[1, 4]], "type": "" } },
"ptm": { "Phospho": { "index": [7], "type": "" } },
"processing": {},
"variant": [{ "position": 3, "from": "K", "to": "R" }]
},
"metadata": {
"uniprot_id": "P12345",
"description": "Example protein",
"reference": "",
"organism": "Homo sapiens"
}
}
All five annotation families are always present in output. Each annotation
entry is { index, type } — bare arrays are rejected. Positions are
1-based, sorted, and deduplicated. Ranges are [start, end] pairs
(start < end), sorted by start; overlapping ranges are rejected.
API
Construction
| Function | Description |
|---|---|
create_a3(sequence, *, site, region, ptm, processing, variant, metadata) |
Build and validate an A3 object |
Queries
| Function | Description |
|---|---|
residue_at(a3, position) |
Residue at a 1-based position; raises ValueError if out of bounds |
variants_at(a3, position) |
All variant records at a 1-based position |
Serialization / I/O
| Function | Description |
|---|---|
a3_from_json(text) |
Parse a JSON string into an A3 object |
a3_to_json(a3, *, indent) |
Serialize an A3 object to a JSON string |
read_a3json(path) |
Read an A3 JSON file from disk |
write_a3json(a3, path, *, indent) |
Write an A3 object to a JSON file |
Pydantic Model Hierarchy
A3
├── sequence: str
├── annotations: A3Annotations
│ ├── site: dict[str, SiteEntry] (position index)
│ ├── region: dict[str, RegionEntry] (range index)
│ ├── ptm: dict[str, FlexEntry] (position or range index)
│ ├── processing: dict[str, FlexEntry] (position or range index)
│ └── variant: list[VariantRecord]
└── metadata: A3Metadata
├── uniprot_id, description, reference, organism
All models are immutable (frozen=True). Users never construct them directly —
use create_a3 or a3_from_json instead.
Canonical Schema
See specs/a3.md for the language-agnostic specification and specs/A3_Pydantic.md for Pydantic-specific design notes.
License
Metadata
Release files for rtemis-a3 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| rtemis_a3-0.2.0.tar.gz | 23.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| rtemis_a3-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 50.3 kB
Release files / rtemis_a3-0.2.0.tar.gz
| Download URL | rtemis_a3-0.2.0.tar.gz |
|---|---|
| Size | 23.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6c601c60e5ffa53f51f7b563d1a50815b4560b58897308609a460cea81a1ab7c
|
|
BLAKE2b-256 checksum How to use checksums |
2e2ecd29850e82fdf7784b1d6201e0d57502ac1ecd8e84d66f0fc26bb2919128
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.2 {"installer":{"name":"uv","version":"0.12.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / rtemis_a3-0.2.0-py3-none-any.whl
| Download URL | rtemis_a3-0.2.0-py3-none-any.whl |
|---|---|
| Size | 27.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e4574ed604ecc3ec7fe37226437abe7d498cdbae9c11a67962040a7f843ad578
|
|
BLAKE2b-256 checksum How to use checksums |
1cf5e23aebdeb9051f551d5bc6535b6c117bb3c4fb1d0c13585959be2d2aa9a1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.2 {"installer":{"name":"uv","version":"0.12.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|