use fastobo::ast::HeaderClause;
use fastobo::ast::HeaderFrame;
use fastobo::ast::EntityFrame;
use fastobo::ast::Ident;
use fastobo::ast::QuotedString;
use fastobo::ast::Synonym;
use fastobo::ast::OboDoc;
use fastobo::ast::SynonymScope;
use fastobo::ast::TermClause;
use fastobo::ast::TypedefClause;
use fastobo::ast::InstanceClause;
use fastobo::ast::TermFrame;
use fastobo::ast::IsoDateTime;
use fastobo::ast::InstanceFrame;
use fastobo::ast::TypedefFrame;
use fastobo::ast::Line;
use fastobo::ast::UnquotedString;
use fastobo::ast::Xref;
use fastobo::ast::XrefList;
use fastobo::ast::RelationIdent;
use fastobo::ast::PrefixedIdent;
use fastobo::ast::SubsetIdent;
use fastobo::ast::InstanceIdent;
use fastobo::ast::PropertyValue;
use fastobo::ast::Url;
use fastobo::semantics::Identified;
use fastobo::semantics::Orderable;
use crate::constants::property::dc;
use crate::constants::property::iao;
use crate::constants::property::obo_in_owl;
use crate::constants::property::rdfs;
use crate::error::Result;
use crate::model::Graph;
use crate::model::Meta;
use crate::model::Node;
use crate::model::NodeType;
use crate::model::BasicPropertyValue;
use crate::model::DefinitionPropertyValue;
use crate::model::SynonymPropertyValue;
use crate::model::XrefPropertyValue;
use super::Context;
use super::IntoGraphCtx;
impl IntoGraphCtx<Meta> for HeaderFrame {
fn into_graph_ctx(self, ctx: &mut Context) -> Result<Meta> {
use fastobo::ast::HeaderClause::*;
let mut definition = None;
let mut comments = Vec::new();
let mut subsets = Vec::new();
let mut xrefs = Vec::new();
let mut synonyms = Vec::new();
let mut basic_property_values = Vec::new();
let mut version = None;
let mut deprecated = false;
for clause in self.into_iter() {
match clause {
FormatVersion(v) => {
basic_property_values.push(
BasicPropertyValue::new(
obo_in_owl::HAS_OBO_FORMAT_VERSION.to_string(),
v.into_string(),
)
);
},
DataVersion(v) => {
version = Some(v.into_string());
},
Date(dt) => {
basic_property_values.push(
BasicPropertyValue::new(
obo_in_owl::HAS_DATE.to_string(),
dt.to_string(),
)
);
},
SavedBy(name) => {
basic_property_values.push(
BasicPropertyValue::new(
obo_in_owl::SAVED_BY.to_string(),
name.into_string(),
)
);
},
AutoGeneratedBy(name) => {
basic_property_values.push(
BasicPropertyValue::new(
obo_in_owl::AUTO_GENERATED_BY.to_string(),
name.into_string(),
)
);
},
Import(import) => (),
Subsetdef(id, def) => {
subsets.push(id.to_string());
},
SynonymTypedef(ty, def, optscope) => (),
DefaultNamespace(ns) => {
basic_property_values.push(
BasicPropertyValue::new(
obo_in_owl::HAS_DEFAULT_NAMESPACE.to_string(),
ns.to_string(),
)
);
},
NamespaceIdRule(idrule) => {
basic_property_values.push(
BasicPropertyValue::new(
obo_in_owl::NAMESPACE_ID_RULE.to_string(),
idrule.into_string(),
)
);
},
Idspace(prefix, url, optdef) => (),
TreatXrefsAsEquivalent(prefix) => (),
TreatXrefsAsGenusDifferentia(prefix, rid, cid) => (),
TreatXrefsAsReverseGenusDifferentia(prefix, rid, cid) => (),
TreatXrefsAsRelationship(prefix, rid) => (),
TreatXrefsAsIsA(prefix) => (),
TreatXrefsAsHasSubclass(prefix) => (),
PropertyValue(pv) => {
basic_property_values.push(pv.into_graph_ctx(ctx)?);
},
Remark(remark) => {
comments.push(remark.into_string());
},
Ontology(ontology) => (),
OwlAxioms(axioms) => (),
Unreserved(key, value) => (),
}
}
Ok(Meta {
definition,
comments,
subsets,
xrefs,
synonyms,
basic_property_values,
version,
deprecated,
})
}
}