Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions python/rtemis_a3/docs/api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# API Reference

## Functional API

::: rtemis.a3.create_a3

::: rtemis.a3.a3_from_json

::: rtemis.a3.a3_to_json

::: rtemis.a3.residue_at

::: rtemis.a3.variants_at

## File I/O

::: rtemis.a3.read_a3json

::: rtemis.a3.write_a3json

## Types

::: rtemis.a3.A3

::: rtemis.a3.VariantRecord

## Errors

::: rtemis.a3.A3ValidationError

::: rtemis.a3.A3ParseError
105 changes: 105 additions & 0 deletions python/rtemis_a3/docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# 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](https://github.com/rtemis-org/a3) monorepo,
which provides A3 implementations in Python, TypeScript, R, Julia, and Rust.

## Installation

```bash
pip install rtemis-a3
# or with uv
uv add rtemis-a3
```

## Quick Start

```python
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

```python
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

```python
from rtemis.a3 import read_a3json, write_a3json

Comment on lines +3 to +62
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docs/index.md appears to duplicate the existing README.md content in this package (and also python/README.md). Keeping multiple copies of the same introductory text tends to drift over time; consider reusing a single source (e.g., include/redirect the README into MkDocs) so updates only need to be made in one place.

Suggested change
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](https://github.com/rtemis-org/a3) monorepo,
which provides A3 implementations in Python, TypeScript, R, Julia, and Rust.
## Installation
```bash
pip install rtemis-a3
# or with uv
uv add rtemis-a3
```
## Quick Start
```python
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
```python
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
```python
from rtemis.a3 import read_a3json, write_a3json
This is the 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](https://github.com/rtemis-org/a3) monorepo,
which provides A3 implementations in Python, TypeScript, R, Julia, and Rust.
## Documentation entry point
To avoid keeping multiple copies of the same introductory text in sync, the
canonical introduction, installation instructions, and quick-start examples
for the Python package are maintained in:
- The monorepo root [README](../../README.md)
- The Python package [README](../README.md)
Please refer to those documents for:
- Project overview and A3 format description
- Installation instructions (`pip`, `uv`, etc.)
- Quick-start examples for creating and parsing A3 JSON
- File I/O helpers and error handling
This `docs/index.md` file serves as the landing page for the generated
documentation site and intentionally links to a single canonical source for
the introductory material to prevent documentation drift.

Copilot uses AI. Check for mistakes.
a3 = read_a3json("protein.json")
write_a3json(a3, "output.json", indent=2)
```

## Serialization

```python
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

```json
{
"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.

## Canonical Schema

See the [A3 specification](https://github.com/rtemis-org/a3/blob/main/specs/A3.md)
for the language-agnostic schema definition.
13 changes: 13 additions & 0 deletions python/rtemis_a3/mkdocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
site_name: rtemis_a3
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

site_name here uses rtemis_a3 (underscore), but the project/package name and the docs content use rtemis-a3 (hyphen). This will make the rendered site header/title inconsistent; consider aligning the MkDocs site_name with the canonical project name used in pyproject.toml and docs/index.md.

Suggested change
site_name: rtemis_a3
site_name: rtemis-a3

Copilot uses AI. Check for mistakes.

Comment on lines +1 to +2
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The mkdocs.yml configuration is inconsistent with zensical.toml. Specifically, the site_name differs (rtemis_a3 vs rtemis-a3), and it lacks the nav, site_description, and site_author fields defined in the Zensical configuration. Keeping these in sync ensures a consistent documentation experience regardless of which tool is used for building. Additionally, rtemis-a3 matches the project name in pyproject.toml.

site_name: rtemis-a3
site_description: Python implementation of the A3 amino acid annotation format.
site_author: E.D. Gennatas

nav:
  - Home: index.md
  - API Reference: api.md

plugins:
- mkdocstrings:
handlers:
python:
paths: [src]
inventories:
- https://docs.python.org/3/objects.inv
options:
docstring_style: numpy
inherited_members: true
show_source: false
Comment on lines +3 to +13
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The repo’s Python CI workflow currently runs lint/typecheck/tests but does not build the documentation site. Since this PR adds MkDocs/Zensical configuration and mkdocstrings directives, consider adding a CI step to at least run a docs build (or a mkdocstrings render check) so doc generation failures are caught early.

Copilot uses AI. Check for mistakes.
2 changes: 2 additions & 0 deletions python/rtemis_a3/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ python = ".venv"
[dependency-groups]
dev = [
"ipykernel>=7.2.0",
"mkdocstrings-python>=2.0.3",
"pytest>=9.0.2",
"ruff>=0.15.8",
"ty>=0.0.26",
"zensical>=0.0.30",
]
Loading
Loading