Expand description
Rust support for the Synthetic Biology Open Language (SBOL) 3.1.0 specification.
The crate keeps RDF parsing and serialization behind a small adapter while exposing SBOL documents, typed builders, owned typed client objects, and structured validation diagnostics.
use sbol::constants::SBO_DNA;
use sbol::prelude::*;
let component = Component::builder("https://example.org/lab", "my_component")?
.types([SBO_DNA])
.name("My component")
.build()?;
let document = Document::from_objects(vec![SbolObject::Component(component)])?;
document.check()?;
assert_eq!(document.components().count(), 1);§Mental model
SBOL describes designed biology as a graph of typed objects. Every object
has a stable Iri identity, a displayId, and a namespace. Objects
split into two layers:
- Top-level objects live directly in a
Document:Component(the central design unit — DNA, RNA, protein, complexes, functional descriptions),Sequence,Collection,CombinatorialDerivation,Implementation,ExperimentalData,Experiment,Model,Attachment, plus PROV-O activities (Activity,Plan,Agent) and OM unit definitions (Unitand friends). - Owned children belong to a top-level parent and live nested inside
it:
SubComponent/LocalSubComponent/ExternallyDefined/SequenceFeature/ComponentReferencehang offComponent;Range/Cut/EntireSequencehang off features;Interactions containParticipations;Constraints relate features.
References between objects are typed: a SubComponent names the
Component it instantiates, an ExternallyDefined points to a term in
an external ontology, and so on. Reference traversal lives on the typed
structs and takes anything implementing ObjectGraph — a Document
for single-file work, a DocumentSet when references cross document
boundaries.
§Document lifecycle
A typical flow:
- Read.
Document::read_pathinfers the format from the file extension;Document::readtakes an explicitRdfFormatfor in-memory input. - Validate.
Document::validatereturns a fullValidationReportwith errors, warnings, and per-rule coverage — use it when you want to inspect or render the report regardless of pass/fail state.Document::checkis the?-friendly convenience that maps errors toErr(warnings ignored), andDocument::check_completeadditionally fails on partial-application diagnostics for strict CI gates. - Traverse / mutate. Typed accessors on
Documentiterate each top-level class (document.components(),document.sequences(),document.activities(), …). Builders (Component::builder, etc.) construct new objects without invalidating existing IRIs. - Write.
Document::writetakes anRdfFormat;write_turtle,write_rdf_xml,write_jsonld, andwrite_ntriplesare shortcut methods. Round-trip preserves unknown extension triples.
§Error model
Errors are surfaced through four distinct types so callers can branch on the failure mode without parsing strings:
ReadError— I/O or parse failure when ingesting RDF.BuildError— invariant violation at builder time (invaliddisplayId, malformed namespace, missing required field).WriteError— serialization failure.ValidationReport— structured diagnostics from validation (multiple issues per call, each with itssbol3-*rule identifier).
§Where to go next
- Crate guide — architectural tour and where each subsystem lives.
- Validation system overview —
what the validator covers,
checkvscheck_complete, CI wiring, trust boundaries. - RDF I/O — format inference, round-trip guarantees, cross-implementation conformance.
- Conformance grid — generated per-rule status for every SBOL 3.1.0 rule.
prelude— re-exports the symbols you’ll need for most code;use sbol::prelude::*;is the conventional import. It includes theSbolIdentifiedandSbolTopLevelaccessor traits so methods likecomponent.name(),component.display_id(), andcomponent.namespace()are available on every typed object.constants— IRIs for SBO / SO / EDAM / SBOL terms that show up as builder arguments (SBO_DNA,SO_PROMOTER, etc.).
Re-exports§
pub use identity::DisplayId;pub use identity::HashAlgorithm;pub use identity::Namespace;pub use identity::SbolIdentity;pub use identity::SequenceElements;
Modules§
- constants
- Common ontology IRIs for building SBOL documents.
- identity
- Validated identity helpers used by the typed builder surface.
- prelude
- Convenient re-exports for typical SBOL construction and inspection workflows.
- schema
- Public schema descriptors for SBOL classes and properties.
Structs§
- Activity
- Activity
Builder - Builder for
Activity. - Agent
- Agent
Builder - Builder for
Agent. - Applied
Options - A summary of options that were active for this run. Round-trips through the JSON output schema so downstream readers know what coverage they’re looking at.
- Association
- Association
Builder - Builder for
Association. - Attachment
- Attachment
Builder - Builder for
Attachment. - Binary
Prefix - Binary
Prefix Builder - Builder for
BinaryPrefix. - Caching
Http Resolver - Decorator that caches
HttpResolverresults on disk. - Collection
- Collection
Builder - Builder for
Collection. - Combinatorial
Derivation - Combinatorial
Derivation Builder - Builder for
CombinatorialDerivation. - Component
- Component
Builder - Builder for
Component. - Component
Reference - Component
Reference Builder - Builder for
ComponentReference. - Compound
Unit - Compound
Unit Builder - Builder for
CompoundUnit. - Constraint
- Constraint
Builder - Builder for
Constraint. - Cut
- CutBuilder
- Builder for
Cut. - Document
- An SBOL document parsed from RDF.
- Document
Set - A set of in-memory SBOL documents indexed by object identity.
- Document
SetError - Entire
Sequence - Entire
Sequence Builder - Builder for
EntireSequence. - Experiment
- Experiment
Builder - Builder for
Experiment. - Experimental
Data - Experimental
Data Builder - Builder for
ExperimentalData. - Extension
Triple - A non-SBOL annotation triple attached to a typed object.
- Externally
Defined - Externally
Defined Builder - Builder for
ExternallyDefined. - Feature
Data - Shared owned fields for SBOL Feature objects.
- Feature
Trace - The result of walking a
ComponentReferencechain to its leaf feature. - File
Resolver - File-backed resolver for opt-in local validation.
- Http
Resolver - HTTP(S) resolver for opt-in external validation.
- Identified
- Shared fields on SBOL Identified objects.
- Identified
Data - Shared owned fields for SBOL Identified objects.
- Identified
Extension - An RDF subject preserved through the typed model when no concrete
SBOL class variant matched its
rdf:typeset. The Identified shared fields (displayId, name, …, derived_from, generated_by, measures, extensions) are populated as usual; when the subject also carriedsbol:TopLevelsemantics,top_levelisSome. Therdf_typesvector preserves every originalrdf:typeIRI so re-serialization emits exactly what the parser saw. - Identified
Extension Builder - Builder for
IdentifiedExtension. - Implementation
- Implementation
Builder - Builder for
Implementation. - Interaction
- Interaction
Builder - Builder for
Interaction. - Interface
- Interface
Builder - Builder for
Interface. - Iri
- An RDF IRI.
- Literal
- RDF literal lexical data.
- Local
SubComponent - Local
SubComponent Builder - Builder for
LocalSubComponent. - Location
Data - Shared owned fields for SBOL Location objects.
- Measure
- Measure
Builder - Builder for
Measure. - Model
- Model
Builder - Builder for
Model. - NotApplied
- Per-rule not-applied record.
- Object
- An SBOL or SBOL extension object.
- Ontology
- Offline ontology query surface used by SBOL validation.
- Ontology
Registry - A read-only view that layers zero-or-more extension snapshots on top of
the bundled
Ontology. - Partial
Application - Per-rule partial-application record.
- Participation
- Participation
Builder - Builder for
Participation. - Plan
- Plan
Builder - Builder for
Plan. - Policy
Options - Policy decisions that affect rule semantics. Conservative defaults match current behavior bit-for-bit; opting into Strict or Lenient changes the outcome of specific Policy-blocked rules.
- Prefix
- Prefix
Builder - Builder for
Prefix. - Prefix
Data - Shared OM Prefix fields. Carried by every concrete Prefix subclass so the label/symbol/factor serializers can be reused.
- Prefixed
Unit - Prefixed
Unit Builder - Builder for
PrefixedUnit. - Range
- Range
Builder - Builder for
Range. - RdfGraph
- Backend-opaque in-memory RDF graph.
- Resolution
Error - A resolver failure with a stable kind and human-readable context.
- Resolved
Content - Resolved byte content for an Attachment or Model source.
- Rule
Coverage - Per-rule outcome for a single validation run.
- SIPrefix
- SIPrefix
Builder - Builder for
SIPrefix. - Sequence
- Sequence
Builder - Builder for
Sequence. - Sequence
Feature - Sequence
Feature Builder - Builder for
SequenceFeature. - Singular
Unit - Singular
Unit Builder - Builder for
SingularUnit. - SubComponent
- SubComponent
Builder - Builder for
SubComponent. - TopLevel
- Shared fields on SBOL TopLevel objects.
- TopLevel
Data - Shared owned fields for SBOL TopLevel objects.
- Triple
- An RDF triple in the default graph.
- Unit
- Unit
Builder - Builder for
Unit. - Unit
Data - Shared OM Unit fields. Carried by every concrete Unit subclass so the label/symbol/comment serializers can be reused.
- Unit
Division - Unit
Division Builder - Builder for
UnitDivision. - Unit
Exponentiation - Unit
Exponentiation Builder - Builder for
UnitExponentiation. - Unit
Multiplication - Unit
Multiplication Builder - Builder for
UnitMultiplication. - Unknown
Rule - Returned when a per-rule override targets a rule that is not in the catalog — almost always a typo at the call site.
- Usage
- Usage
Builder - Builder for
Usage. - Validation
Context - Resolver-aware validation inputs.
- Validation
Issue - A single SBOL validation issue.
- Validation
Options - Options for local SBOL validation.
- Validation
Report - Structured validation result for a document.
- Validation
Rule Status - Variable
Feature - Variable
Feature Builder - Builder for
VariableFeature. - Variant
Set - The expanded variant Components for a
CombinatorialDerivation.
Enums§
- Blocker
- Classification of why a
PartialorDeferredvalidation rule is not yet fully implemented. - Build
Error - Errors produced while building an SBOL document from owned typed objects.
- Coverage
Kind - What a Partial rule’s local subset actually covered for this validation run. Stable, machine-grep-able tags so downstream tooling can filter rather than parse prose.
- External
Validation Mode - Controls whether validation may inspect resources outside the primary document.
- Feature
Ref - A child feature resolved from a Component’s
hasFeaturelist. - Hash
Algorithm Registry - How
sbol:hashAlgorithmvalues are validated. - Hint
- Actionable hint surfaced alongside a diagnostic. Closed enum so renderers can pick a representation rather than scraping prose.
- Location
Ref - A child location resolved from a SequenceFeature’s
hasLocationlist. - Normative
Severity - RFC2119-style normative force of a spec rule. Distinguishes “Partial-but-MUST” rules (gaps that block strict-mode compliance) from “Partial-but-SHOULD” rules (gaps in recommended-but-optional behavior).
- NotApplied
Reason - Why a rule did not run for this validation run.
- RdfFormat
- RDF serialization format.
- Read
Error - Errors produced while reading an SBOL document.
- Reference
Error - Failure mode when resolving a typed SBOL reference.
- Resolution
Error Kind - Coarse class of a resolution failure.
- Resource
- RDF subject resource.
- Rule
Override - Per-rule override applied at issue-emit time.
- Rule
Status - Per-rule classification. Five categories, each capturing one meaningful axis: algorithm complete with Error severity, algorithm complete with Warning severity, configurable (behavior depends on resolver / ontology snapshot / policy / external context), spec-▲ (not to be machine-reported), or unimplemented.
- Sbol
Class - SBOL RDF classes handled by this crate.
- Sbol
Object - Owned SBOL object variants supported by the client API.
- Severity
- Validation severity.
- Term
- RDF object term.
- Topology
Completeness - Controls whether validators assume missing nucleic-acid topology is knowable.
- Write
Error - Errors produced while writing an SBOL document.
Constants§
- SPECIFICATION_
URL - Canonical URL for the targeted SBOL specification.
- SPEC_
VERSION - The SBOL specification version targeted by this crate.
- VALIDATION_
OUTPUT_ SCHEMA_ VERSION - JSON schema version emitted by
to_json. Bumps on any breaking rename/removal of fields. - VALIDATION_
RULE_ SPEC_ CANONICAL_ URL - VALIDATION_
RULE_ SPEC_ PATH - VALIDATION_
RULE_ SPEC_ PDF_ SHA256 - VALIDATION_
RULE_ SPEC_ VERSION
Traits§
- Content
Resolver - Resolves an Attachment or Model source into bytes.
- Document
Resolver - Resolves an external resource into an SBOL document.
- Object
Graph - In-memory scope of SBOL objects keyed by identity.
- Sbol
Identified - Read-only access to the shared metadata every SBOL
Identifiedobject carries:displayId,name,description, the PROVwasDerivedFrom/wasGeneratedByresource sets, OM measures, and round-tripped non-SBOL extension triples. - Sbol
TopLevel - Read-only access to the metadata SBOL
TopLevelobjects carry on top ofSbolIdentified: the document namespace and any attachedsbol:Attachmentresources. - ToRdf
- Converts an owned typed SBOL value into RDF triples.
- TryFrom
Object - Converts an RDF-collected object into an owned typed SBOL value.
Functions§
- render_
conformance_ report - Renders the conformance report markdown for the supplied rule
catalog. Pass
validation_rule_statuses()to render the canonical committed report. - to_json
- Serialize a
ValidationReportto JSON v1. - validation_
rule_ statuses