[][src]Struct fastobo::ast::OboDoc

pub struct OboDoc { /* fields omitted */ }

A complete OBO document in format version 1.4.

Methods

impl OboDoc[src]

Constructors and builder methods.

Parser

Use from_file to parse a file on the local filesystem, or from_stream to parse a BufRead implementor (BufRead is needed instead of Read as the parser is line-based):

let doc1 = OboDoc::from_file("tests/data/ms.obo").unwrap();

// This is equivalent to (but with the file path set in eventual errors):
let mut r = BufReader::new(File::open("tests/data/ms.obo").unwrap());
let doc2 = OboDoc::from_stream(&mut r).unwrap();

assert_eq!(doc1, doc2);

Builder Pattern

The builder pattern makes it easy to create an OboDoc from an interator of EntityFrame, in order to add an HeaderFrame after all the entities where collected:

use std::iter::FromIterator;

let entities = vec![TermFrame::new(ClassIdent::from(PrefixedIdent::new("TEST", "001")))];
let doc = OboDoc::from_iter(entities.into_iter())
    .and_header(HeaderFrame::from(HeaderClause::FormatVersion("1.4".into())));

pub fn new() -> Self[src]

Create a new empty OBO document.

pub fn with_header(header: HeaderFrame) -> Self[src]

Create a new OBO document with the provided frame.

pub fn and_header(self, header: HeaderFrame) -> Self[src]

Use the provided frame as the header of the OBO document.

pub fn with_entities(entities: Vec<EntityFrame>) -> Self[src]

Create a new OBO document with the provided entity frames.

pub fn and_entities(self, entities: Vec<EntityFrame>) -> Self[src]

Use the provided entity frames as the content of the OBO document.

pub fn from_stream<B>(stream: &mut B) -> Result<Self> where
    B: BufRead
[src]

Consume a buffered stream containing an OBO document into an AST.

pub fn from_file<P>(path: P) -> Result<Self> where
    P: AsRef<Path>, 
[src]

Read an OBO file located somwhere in the filesystem.

impl OboDoc[src]

pub fn header(&self) -> &HeaderFrame[src]

Get a reference to the header of the OBO document.

pub fn header_mut(&mut self) -> &mut HeaderFrame[src]

Get a mutable reference to the header of the OBO document.

pub fn entities(&self) -> &Vec<EntityFrame>[src]

Get a reference to the entities of the OBO document.

pub fn entities_mut(&mut self) -> &mut Vec<EntityFrame>[src]

Get a reference to the entities of the OBO document.

Trait Implementations

impl<'i> FromPair<'i> for OboDoc[src]

fn from_pair(pair: Pair<'i, Rule>) -> Result<Self, Error>[src]

Create a new instance from a Pair.

impl Orderable for OboDoc[src]

fn sort(&mut self)[src]

Sort the document in the right serialization order.

fn is_sorted(&self) -> bool[src]

Check if the document is sorted in the right serialization order.

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.

impl AsRef<[EntityFrame]> for OboDoc[src]

impl AsRef<Vec<EntityFrame>> for OboDoc[src]

impl AsMut<Vec<EntityFrame>> for OboDoc[src]

impl PartialEq<OboDoc> for OboDoc[src]

impl Eq for OboDoc[src]

impl Clone for OboDoc[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Default for OboDoc[src]

impl Hash for OboDoc[src]

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0[src]

Feeds a slice of this type into the given [Hasher]. Read more

impl Debug for OboDoc[src]

impl Display for OboDoc[src]

impl FromStr for OboDoc[src]

type Err = Error

The associated error which can be returned from parsing.

impl<E> FromIterator<E> for OboDoc where
    E: Into<EntityFrame>, 
[src]

Auto Trait Implementations

impl Send for OboDoc

impl Sync for OboDoc

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]