Python implementation of the Amino Acid Annotation (A3) format
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rtemis_a3-0.1.0.tar.gz.
File metadata
- Download URL: rtemis_a3-0.1.0.tar.gz
- Upload date:
- Size: 13.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
799923c6f7016c9963d6c9581d1ab1b3dce4d06d080dc6da71c4a66ea11bda97
|
|
| MD5 |
7527db9b7af5eb8ee56cf65137f2de1a
|
|
| BLAKE2b-256 |
4238a7bddcbcd2036a720ad67516552b6a24a3807cd79f600548bf47ba612aa4
|
File details
Details for the file rtemis_a3-0.1.0-py3-none-any.whl.
File metadata
- Download URL: rtemis_a3-0.1.0-py3-none-any.whl
- Upload date:
- Size: 16.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
93809fea07a3adaf7bc224b6acb619600d069d95a2d3914af76c44ae79a85d4a
|
|
| MD5 |
72350bb3ba35e9873828ff8cde81502a
|
|
| BLAKE2b-256 |
a7bed09c35072846201bd4c75cb48bd3a3d10acfaf0ac848b8231368caf6b3fe
|