Skip to content

marpaia/sbol-rs

Repository files navigation

sbol-rs: a Rust implementation of SBOL

sbol-rs is a Rust implementation of the Synthetic Biology Open Language (SBOL 3.1.0). SBOL is the community standard for the exchange of synthetic biology designs across registries, design-automation tools, and laboratory automation pipelines. sbol-rs exposes a typed API for reading, building, and rewriting SBOL documents, plus a validator that covers the 109 machine-checkable rules from SBOL 3.1.0 Appendix B.

New to the codebase? Start with the crate guide.

Installation

Add the library to your Cargo.toml:

[dependencies]
sbol = "0.1"

Or with cargo add:

cargo add sbol

The CLI ships as a separate crate. cargo install sbol-cli installs a binary named sbol:

cargo install sbol-cli
sbol validate design.ttl

Example

use sbol::constants::{EDAM_IUPAC_DNA, SBO_DNA, SO_PROMOTER};
use sbol::prelude::*;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let namespace = "https://example.org/lab";

    let sequence = Sequence::builder(namespace, "j23119_seq")?
        .elements("ttgacagctagctcagtcctaggtataatgctagc")
        .encoding(EDAM_IUPAC_DNA)
        .build()?;

    let component = Component::builder(namespace, "j23119")?
        .types([SBO_DNA])
        .add_component_role(SO_PROMOTER)
        .add_sequence(sequence.identity.clone())
        .name("J23119 constitutive promoter")
        .build()?;

    let document = Document::from_objects(vec![
        SbolObject::Component(component),
        SbolObject::Sequence(sequence),
    ])?;

    document.check()?;
    println!("{}", document.write_turtle()?);
    Ok(())
}

Reading documents, traversing references across documents, expanding combinatorial derivations, and inspecting validation reports are covered in crates/sbol/examples/. Run any of them with cargo run -p sbol --example <name>.

Validation

SBOL 3.1.0 Appendix B defines 149 validation rules; 40 are marked as not-to-be-machine-reported. sbol implements an algorithm for each of the remaining 109, with configurable scope (offline by default, or resolver-backed for cross-document references), per-rule severity overrides, and text / JSON / SARIF output. docs/validation.md covers what's checked and the trust boundaries; docs/conformance.md carries the per-rule status grid.

Ontology Extensions

EDAM, SBO, SO, GO, ChEBI, and Cell Ontology ship bundled. NCIT and lab-specific ontologies install on demand into a local cache; see docs/ontology-extensions.md.

Performance

Round-trip cost (parse → serialize in the same format) on toggle_switch_v2.ttl (~30 KB), median microseconds across 100 measured iterations (20 warmup); lower is better. Every implementation runs in its own pinned Docker image so the rows are apples-to-apples. Rows sorted by rdfxml p50 ascending; fastest first:

Impl turtle rdfxml jsonld ntriples
sbol-rs 352 368 750 393
libSBOLj3 1.0.5.2 1,976 2,264 4,418 2,096
sboljs 3.0.2 n/a 2,543 n/a n/a
pySBOL3 1.2 7,566 9,864 6,489 7,234

Apple M4 Max (16 cores), 128 GB RAM, macOS 26.3.1, Docker Desktop 29.0.1. sboljs's underlying rdfoo only emits RDF/XML and its parser stack is too fragile to reach the other format rows on real SBOL 3 fixtures; the bench README documents the specific failure modes. The crates/sbol-bench crate runs the comparison end-to-end; see benches/cross-impl/README.md for results across smaller fixtures, full methodology, and per-row caveats.

About

Rust implementation of the Synthetic Biology Open Language (SBOL 3.1.0)

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Contributors

Languages