[][src]Trait fastobo::ext::OboSemantics

pub trait OboSemantics {
    fn assign_namespaces(&mut self) -> Result<(), CardinalityError>;
fn treat_xrefs(&mut self); }

Additional methods for OboDoc that can be used to edit the syntax tree.

The OBO 1.4 semantics are used to process header macros or to add the default OBO namespace to all the frames of the document.

Required methods

fn assign_namespaces(&mut self) -> Result<(), CardinalityError>

Assign the ontology default namespace to all frames without one.

This function will not check the cardinality of namespace clauses in entity frames: it will only add a single namespace clause to all frames that have none.

Errors

  • CardinalityError::MissingClause: if the header frame does not contain any default namespace definition.
  • CardinalityError::DuplicateClauses if the header frame does contain more than one default namespace definition.

Example

let mut doc = OboDoc::from_str(
"default-namespace: TST

[Term]
id: TST:01

[Term]
id: PATO:0000001
namespace: quality
").unwrap();

doc.assign_namespaces().unwrap();

assert_eq!(doc.to_string(),
"default-namespace: TST

[Term]
id: TST:01
namespace: TST

[Term]
id: PATO:0000001
namespace: quality
");

fn treat_xrefs(&mut self)

Process macros in the header frame, adding clauses to relevant entities.

Header macros are used to expand an ontology by overloading the actual semantics of xref clauses contained in several entity frames. In case the translated clauses are already present in the document, they won't be added a second time.

The following implicit macros will be processed even if they are not part of the document:

  • treat-xrefs-as-equivalent: RO
  • treat-xrefs-as-equivalent: BFO

Note

After processing the document, neither the original frame xrefs nor the treat-xrefs header clauses will be removed from the AST.

See also

Loading content...

Implementors

impl OboSemantics for OboDoc[src]

Additional methods for OboDoc that can be used to edit the syntax tree.

fn assign_namespaces(&mut self) -> Result<(), CardinalityError>[src]

Assign the ontology default namespace to all frames without one.

fn treat_xrefs(&mut self)[src]

Process macros in the header frame, adding clauses to relevant entities.

Loading content...