[−][src]Struct fastobo::ast::OboDoc
A complete OBO document in format version 1.4.
Implementations
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 = fastobo::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 = fastobo::from_reader(&mut r).unwrap(); // FIXME: threaded parser may not maintain ordering YET // 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.
impl OboDoc
[src]
Shared and mutable getters.
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.
pub fn is_empty(&self) -> bool
[src]
Check whether or not the document is empty.
An empty document has no header clauses and no entity frames.
impl OboDoc
[src]
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.
pub fn assign_namespaces(&mut self) -> Result<(), CardinalityError>
[src]
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 ");
pub fn treat_xrefs(&mut self)
[src]
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
- Header Macro Translation section of the syntax and semantics guide.
pub fn is_fully_labeled(&self) -> bool
[src]
Check if the OBO document is fully labeled.
An OBO ontology is fully labeled if every frame has exactly one name
clause. This is equivalent to the definition in the OBO specification
if we suppose an invalid OBO document is never fully labeled.
Trait Implementations
impl AsMut<Vec<EntityFrame>> for OboDoc
[src]
fn as_mut(&mut self) -> &mut Vec<EntityFrame>
[src]
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 Clone for OboDoc
[src]
impl Debug for OboDoc
[src]
impl Default for OboDoc
[src]
impl Display for OboDoc
[src]
impl Eq for OboDoc
[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>,
impl<'i> FromPair<'i> for OboDoc
[src]
const RULE: Rule
[src]
unsafe fn from_pair_unchecked(pair: Pair<'i, Rule>) -> Result<Self, SyntaxError>
[src]
fn from_pair(pair: Pair<'i, Rule>) -> Result<Self, SyntaxError>
[src]
impl FromStr for OboDoc
[src]
type Err = SyntaxError
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<Self, Self::Err>
[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,
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 PartialEq<OboDoc> for OboDoc
[src]
impl StructuralEq for OboDoc
[src]
impl StructuralPartialEq for OboDoc
[src]
impl<'_, B: BufRead> TryFrom<&'_ mut SequentialReader<B>> for OboDoc
[src]
type Error = Error
The type returned in the event of a conversion error.
fn try_from(reader: &mut SequentialReader<B>) -> Result<Self, Self::Error>
[src]
impl<'_, B: BufRead> TryFrom<&'_ mut ThreadedReader<B>> for OboDoc
[src]
type Error = Error
The type returned in the event of a conversion error.
fn try_from(reader: &mut ThreadedReader<B>) -> Result<Self, Self::Error>
[src]
impl<B: BufRead> TryFrom<SequentialReader<B>> for OboDoc
[src]
type Error = Error
The type returned in the event of a conversion error.
fn try_from(reader: SequentialReader<B>) -> Result<Self, Self::Error>
[src]
impl<B: BufRead> TryFrom<ThreadedReader<B>> for OboDoc
[src]
Auto Trait Implementations
impl RefUnwindSafe for OboDoc
impl Send for OboDoc
impl Sync for OboDoc
impl Unpin for OboDoc
impl UnwindSafe for OboDoc
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
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> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
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>,