Expand description
§rtemis-a3
Rust implementation of the A3 (Amino Acid Annotation) format.
A3 is a structured format for annotating amino acid sequences with site, region, post-translational modification, processing, and variant information.
§Quick start
use rtemis_a3::{a3_from_json, a3_to_json};
// `annotations` and `metadata` are optional; both default to empty.
let json = r#"{
"$schema": "https://schema.rtemis.org/a3/v1/schema.json",
"a3_version": "1.0.0",
"sequence": "MAEPRQ"
}"#;
let a3 = a3_from_json(json).unwrap();
assert_eq!(a3.sequence(), "MAEPRQ");§Error handling
Validation is collect-all: a document is checked in four stages, every issue in the earliest failing stage is reported at once, and each issue carries a stable code and an RFC 6901 JSON Pointer.
use rtemis_a3::a3_from_json;
let json = r#"{
"$schema": "https://schema.rtemis.org/a3/v1/schema.json",
"a3_version": "1.0.0",
"sequence": "MAEPRQ",
"annotations": { "site": { "active": { "index": [3, 99] } } }
}"#;
let err = a3_from_json(json).unwrap_err();
let issues = err.issues();
assert_eq!(issues.len(), 1);
assert_eq!(issues[0].code.code(), "A3E_POS_OUT_OF_BOUNDS");
assert_eq!(issues[0].path, "/annotations/site/active/index/1");
assert_eq!(err.stage(), Some(4));Codes and paths are contractual and identical across the R, Python, Julia,
TypeScript, and Rust implementations. Messages are not — they may be
reworded freely. See spec/error-codes.md and spec/error-paths.md.
§Module layout
error—A3Errorenumissue—A3Issue,A3IssueCode, JSON Pointer constructiontypes— data model structs and enumsnormalization— the three normalization rulesvalidation— four-stage validation over the raw parsed JSON
Re-exports§
pub use error::A3Error;pub use issue::A3Issue;pub use issue::A3IssueCode;pub use types::A3;pub use types::A3_SCHEMA_URI;pub use types::A3_VERSION;pub use types::A3Index;pub use types::Annotations;pub use types::FlexEntry;pub use types::Metadata;pub use types::RegionEntry;pub use types::SiteEntry;pub use types::VariantRecord;pub use validation::validate;
Modules§
- error
- Error types for the rtemis-a3 library.
- issue
- Validation issues: stable codes, RFC 6901 paths, and human messages.
- normalization
- Normalization — the three transformations A3 applies to a valid document.
- types
- Data model for the A3 format.
- validation
- Four-stage A3 validation over the raw parsed JSON.
Functions§
- a3_
from_ json - Parse and validate an A3 JSON string.
- a3_
to_ json - Serialize a validated
A3to a JSON string. - residue_
at - Return the amino acid character at a 1-based
position. - variants_
at - Return all variant records at a 1-based
position.