RDF
-
class omexmeta::RDF : public omexmeta::IRDF
Public Functions
-
explicit RDF(const std::string &storage_type =
"memory", const std::string &storage_name ="OmexMetaStore", const char *storage_options = nullptr, const char *model_options = nullptr) constructor for RDF class
- Parameters
storage_type. – Defaults to memory. Other options include: “hashes”, “file”, “mysql”, “postgresql”, “sqlite”, “uri”,
storage_name – name used for storage. When storage is not internally held in memory, this becomes the name of the file or database.
storage_options – options that get passed on to storage. Please study http://librdf.org/docs/api/redland-storage-modules.html for more information. @model_options options that get passed to the model. Please see http://librdf.org/docs/api/index.html for more details.
-
RDF(const RDF &rdf) = delete
copy constructor for RDF class
RDF instances are not copyable due to restrictions within the redland libraries. You must instead move RDF objects.
-
RDF &operator=(const RDF &rdf) = delete
copy assignment constructor for RDF ojects
Copy assignment functionality is prohibited for RDF objects. Use move semantics insead.
-
virtual int size() const override
returns the number of triples currently present in the RDF graph.
-
virtual bool empty() const override
indicator for whether the RDF graph is empty
- Returns
true if RDF graph has no triples, false otherwise.
-
virtual void addFromString(const std::string &str, const std::string &syntax =
"guess") override non-static variant of RDF::fromString(). Reads rdf into an RDF instance. See RDF::fromString() for argument requirements.
-
virtual void addFromUri(const std::string &uri_string, const std::string &syntax =
"guess") override non-static counterpart of RDF::fromUri. Downloads and parses rdf from a URI.
See RDF::fromUri for details.
-
virtual void addFromFile(const std::string &filename, const std::string &syntax) override
non-static counter part of RDF::fromFile. Reads rdf from annotations in a file
Uses LibrdfParser::fromFile under the hood
-
virtual std::string toString(const std::string &syntax =
"turtle", const char *mime_type = nullptr, const char *type_uri = nullptr) override serialize RDF graph to string
- Parameters
syntax – the expected output syntax. Options include: “ntriples”, “turtle”, “rdfxml-xmp”, “rdfxml-abbrev”, “rdfxml”, “dot”, “json-triples”, “json”, “nquads”, “html”.
-
virtual void toFile(const std::string &filename, const std::string &syntax =
"turtle", const char *mime_type = nullptr, const char *type_uri = nullptr) override Write annotations to file.
- Parameters
syntax – the expected output syntax. Options include: “ntriples”, “turtle”, “rdfxml-xmp”, “rdfxml-abbrev”, “rdfxml”, “dot”, “json-triples”, “json”, “nquads”, “html”.
filename – full path of file to write
mime_type – optional valid mime
type_uri – optional type uri
-
virtual Editor toEditor(const std::string &xml, bool generate_new_metaids = false, bool sbml_semantic_extraction = true) override
instantiate an Editor object.
- Parameters
xml – the xml you want to open for editing. This can be any type of xml document, but SBML and CellML are most common.
generate_new_metaids – When true, will add metaids onto a copy of the xml source code for annotation. Default = false.
OmexMetaXmlType – an indicator enum specifying whether the xml is sbml, cellml or unknown. Default is “OMEXMETA_TYPE_NOTSET”
-
virtual Editor *toEditorPtr(const std::string &xml, bool generate_new_metaids = false, bool sbml_semantic_extraction = true) override
instantiate an Editor object and return a new pointer to it. Memory returned is owned by the caller and needs deleting.
- Parameters
xml – the xml you want to open for editing. This can be any type of xml document, but SBML and CellML are most common.
generate_new_metaids – When true, will add metaids onto a copy of the xml source code for annotation. Default = false.
OmexMetaXmlType – an indicator enum specifying whether the xml is sbml, cellml or unknown. Default is “OMEXMETA_TYPE_NOTSET”
-
virtual LibrdfModel getModel() const override
-
virtual LibrdfStorage getStorage() const override
-
virtual int commitTransaction() const override
-
virtual int startTransaction() const override
-
virtual void *getTransactionHandle() const override
-
virtual int startTransactionWithHandle(void *handle) const override
-
virtual int getTransactionRollback() const override
-
virtual std::string queryResultsAsString(const std::string &query_str, const std::string &results_syntax) override
-
virtual ResultsMap queryResultsAsMap(const std::string &query_str) override
-
virtual std::unordered_map<std::string, std::string> propagateNamespacesFromParser(const std::vector<std::string> &seen_namespaces) override
compared namespaces seen with namespaces known and ensures models that use a known namespace use that namespace.
- Parameters
seen_namespaces – a vector of strings of namespaces the parser has seen before.
-
virtual OmexMetaXmlType getXmlType() const override
getter for xmlType attribue.
when the rdf graph is sbml, it will return OMEXMETA_TYPE_SBML. When cellML it will return OMEXMETA_TYPE_CELLML. Otherwise it is OMEXMETA_TYPE_UNKNOWN.
-
virtual void setXmlType(OmexMetaXmlType xmlType) override
set the xml type for the current graph.
If you have been reading from an SBML you cannot then read from another syntax (such as cellml).
-
virtual const std::string &getRepositoryUri() const override
getter for repository uri which defaults to “http://omex-library.org/”
-
virtual void setRepositoryUri(const std::string &repositoryName) override
setter for the repository uri which defaults to “http://omex-library.org/”.
- Parameters
repositoryName – the repository uri.
-
virtual const std::string &getArchiveUri() const override
getter for archiveUri attribute.
default to http://omex-library.org/NewOmex.omex/
-
virtual void setArchiveUri(const std::string &archiveName) override
setter for archiveUri attribute.
default to http://omex-library.org/NewOmex.omex/
- Parameters
archiveName – the new name for archive uri attribute
-
virtual const std::string &getModelUri() const override
getter for model uri.
defaults to http://omex-library.org/NewOmex.omex/NewModel.xml
-
virtual void setModelUri(std::string modelName) override
setter for model uri.
defaults to http://omex-library.org/NewOmex.omex/NewModel.xml
- Parameters
modelName – string for new model uri.
-
virtual const std::string &getModelMetaid() override
gets the uri fragment used for model level annotations. This must be a valid metaid in your model and should be attached to a “model” element
-
virtual void setModelMetaid(const std::string &modelMetaid) override
sets the uri fragment used for model level annotations. This must be a valid metaid in your model and should be attached to a “model” element
-
virtual std::string getModelLevelAnnotationUri() override
get the full uri for model level annotations.
the modelUri concatonated with the model metaid fragment
-
virtual const std::string &getLocalUri() const override
getter for local uri attribute.
defaults to http://omex-library.org/NewOmex.omex/NewModel.rdf#
-
virtual UriHandler &getUriHandler() override
-
void purgeRDFBag()
remove rdf:Bag constructs from the current rdf graph
-
void translateVcard()
Translate VCARD into foaf
Public Members
-
NamespaceMap namespaces_
Storage for namespaces and prefixes
-
std::vector<std::string> seen_namespaces_
Part of the mechanism that propogates namespaces through to serializer.
todo observer pattern might make for more elegant design.
-
const std::string OMEXlib_ =
"http://OMEXlibrary.org/" Default repository uri
Public Static Functions
-
static RDF fromString(const std::string &str, const std::string &syntax =
"guess") instantiate an RDF instance and read annotations from a string. This is a static method.
- Parameters
str – a reference to the string containing annotations
syntax – which syntax str is in. Default=”guess” : try to guess.
-
static RDF fromUri(const std::string &uri_string, const std::string &syntax =
"guess") parse RDF directly from a uri
downloads uri from the internet and creates an RDF graph. See Librdf::parseUri() for more details.
-
static RDF fromFile(const std::string &filename, const std::string &syntax)
read rdf from annotations in a file
Uses LibrdfParser::fromFile under the hood
-
static std::ostringstream listOptions()
-
static bool equals(RDF *actual, const std::string &expected, const std::string &syntax =
"turtle", bool verbose = false) test for equality between
- Parameters
actual – and
expected –
-
static bool equals(const Triple &actual, const std::string &expected, const std::string &syntax =
"turtle", bool verbose = false) test for equality between
- Parameters
actual – and
expected –
-
static bool equals(Triples &actual, const std::string &expected, const std::string &syntax =
"turtle", bool verbose = false) test for equality between
- Parameters
actual – and
expected –
-
static bool equals(RDF *actual, RDF *expected, const std::string &syntax =
"turtle", bool verbose = false) test for equality between
- Parameters
actual – and
expected –
-
static bool equals(const std::string &first, const std::string &second, const std::string &first_syntax =
"turtle", const std::string &second_syntax ="turtle", bool verbose = false) test for equality between
- Parameters
first – and
second –
Private Functions
-
void classifyXmlType(const std::string &xml, const std::string &input_syntax)
autoset the xmlType variable based on xml content.
-
void classifyXmlTypeFromFile(const std::string &xml_file, const std::string &input_syntax)
reads xml from file before calling classifyXmlType
-
void extractSemanticInformationFromSBML(const std::string &sbml)
pull semantic information out of the sbml int the RDF graph
-
void freeRDF()
release memory consumed by RDF.
Memory consumed by RDF is destructed using RAII so users normally do not need this function.
-
void setLogHandlers()
set custom handler functions for librdf, raptor and rasqal
-
explicit RDF(const std::string &storage_type =