#bioinformatics #phenotype #ontology #phenopackets

phenopackets-dev

Rust bindings for Phenopacket Schema

4 releases

0.2.2 Jan 7, 2025
0.2.1 Jan 7, 2025
0.2.0 Jan 7, 2025
0.1.0 Jan 7, 2025

#459 in Biology

Download history 252/week @ 2025-01-06 10/week @ 2025-01-13 4/week @ 2025-02-17 3/week @ 2025-02-24

76 downloads per month

Custom license

135KB
2K SLoC

Rust bindings for Phenopacket Schema.

The crate contains Rust structs and enums generated from Phenopacket Schema protobuf descriptors. Phenopacket Schema versions v1 and v2 are supported.

Examples

Create a Phenopacket Schema element programatically

Any struct or enums of the schema can be created by invoking its initializer. For instance, an schema::v2::core::OntologyClass:

use phenopackets_dev::schema::v2::core::OntologyClass;

let seizure = OntologyClass {
  id: "HP:0001250".into(),
  label: "Seizure".into(),
};

assert_eq!(&seizure.id, "HP:0001250");
assert_eq!(&seizure.label, "Seizure");

Encode/decode into protobuf binary format

The schema elements can be encoded or decoded into bytes:

use phenopackets_dev::schema::v2::core::OntologyClass;
use prost::Message;

let seizure = OntologyClass {
  id: "HP:0001250".into(),
  label: "Seizure".into(),
};

// Dump to bytes ...
let bytes: Vec<u8> = seizure.encode_to_vec();

// ... and read back.
let other = OntologyClass::decode(&bytes[..]).unwrap();

assert_eq!(seizure, other);

Note, only the protobuf binary format is implemented (no JSON, YAML, ...).


Continuous Integration Documentation Crate

Rust bindings for Phenopacket Schema

See the documentation on docs.rs for usage examples and more info.

Dependencies

~0.4–2.2MB
~32K SLoC