[−][src]Struct fastobo::ast::OboDoc
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]
B: BufRead,
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]
P: AsRef<Path>,
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]
const RULE: Rule
[src]
unsafe fn from_pair_unchecked(pair: Pair<'i, Rule>) -> Result<Self>
[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]
fn as_ref(&self) -> &[EntityFrame]
[src]
impl AsRef<Vec<EntityFrame>> for OboDoc
[src]
fn as_ref(&self) -> &Vec<EntityFrame>
[src]
impl AsMut<Vec<EntityFrame>> for OboDoc
[src]
fn as_mut(&mut self) -> &mut Vec<EntityFrame>
[src]
impl PartialEq<OboDoc> for OboDoc
[src]
impl Eq for OboDoc
[src]
impl Clone for OboDoc
[src]
fn clone(&self) -> 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<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
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.
fn from_str(s: &str) -> Result<Self>
[src]
impl<E> FromIterator<E> for OboDoc where
E: Into<EntityFrame>,
[src]
E: Into<EntityFrame>,
fn from_iter<T>(iter: T) -> Self where
T: IntoIterator<Item = E>,
[src]
T: IntoIterator<Item = E>,
Auto Trait Implementations
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,