Editor

class omexmeta::Editor

Add or change annotations in xml.

Public Functions

explicit Editor(std::string xml_or_file, bool create_ids, LibrdfModel &model, NamespaceMap &ns_map, UriHandler &uriHandler, bool generate_new_metaids = false, bool sbml_semantic_extraction = true)

constructor for Editor.

The Editor is usually instantiated from the RDF::to_editor class which automatically takes care of the

Parameters
  • xml_or_file – The valid xml content for annotation OR the path to the file on disk containing this content

  • generate_new_metaids. – Autogenerate metaids for xml element that do not already have them

  • sbml_semantic_extraction. – When

  • xml_or_file – is determined to be sbml, automatically extract some information regarding species and reactions. This option is ignored when

  • xml_or_file – is not sbml. Default is true.

  • model – a reference to the current model (owned by RDF).

  • nm_map – a set of namespaces for current xml

  • model – and

  • ns_map – arguments. When instantiated, the editor class automatically reads the XML and adds metaids to some or all of the elements, depending on the XML type parameter. If the user specifies that they are annotating an SBML model, the elements returned by SBMLAssistant::getValidElements() are given metaids (if not exist), while if the user chooses cellml the elements returned by CellMLAssistant::getValidElements() are used. If the type is unknown, then all elements are given metaids.

~Editor() = default

We no longer required to free the triples_ used by Editor since they are created and freed inplace - i.e. locally, not at the class scope.

int size() const
const NamespaceMap &getNamespaces() const

returns a hashmap of namespaces to prefixes.

Returns

Map where keys are namespaces and values are prefixes

LibrdfModel &getModel() const

return the underlying librdf_model* pointer

Returns

the librdf_model pointer

void setNamespaces(const NamespaceMap &namespaces)

set the namespace map.

const std::string &getXml() const

return the xml

Returns

the xml string after metaids are added

const std::vector<std::string> &getMetaids() const

returns a list of metaids both that existed previously and that was added during instantiation.

Returns

vector of metaids used in the xml

void addNamespace(const std::string &ns, std::string prefix)

add a namespace

Parameters
  • ns – the namespace

  • prefix – the prefix used in serialized annotations to refer to the namespace

void addSingleAnnotation(LibrdfNode subject, const PredicatePtr &predicate_ptr, const LibrdfNode &resource)

Add a SingleAnnotation (aka a Triple) to the model.

Parameters
  • subject – the subject portion of the triple

  • pointer – to the predicate the predicate portion of the triple. Ths is a pointer to support polymorphic calls.

  • resource – the resource portion of the triple

void addSingleAnnotation(SingularAnnotation &singularAnnotation)

Add a SingleAnnotation (aka Triple) to the rdf graph.

Parameters

singularAnnotation – An instance of SingularAnnotation to add to the model

void removeSingleAnnotation(const SingularAnnotation &singularAnnotation) const

remove a singular annotation (aka Triple) from the rdf graph

Parameters

singularAnnotation – An instance of SingularAnnotation to remove from the model

void addCompositeAnnotation(PropertyBearer *phenomenonPtr)

add a composite annotation to the rdf graph.

Composite annotations currently supported are PhysicalEntity, PhysicalProcess and EnergyDiff. The PhysicalDependency type will be supported in future releases.

For developers. Consider removing this function in favour of using the add* functions.

Parameters

phenomenonPtr – A pointer to an object of type PhysicalPhenomenon, the superclass of the composite annotations.

void addPhysicalProperty(PhysicalProperty &physicalProperty)

add a physical process to the rdf graph

void addPhysicalEntity(PhysicalEntity &physicalEntity)

add a composite annotation of type PhysicalEntity to the rdf graph

Parameters

physicalEntity – An instance of a PhysicalEntity object to add to the rdf graph.

void removePhysicalEntity(PhysicalEntity &physicalEntity) const

remove triples associated with a a PhysicalEntity object from the rdf graph

Parameters

physicalEntity – the PhysicalEntityto remove

void removePersonalInformation(PersonalInformation *information) const

remove triples associated with a PersonalInformation object from the rdf graph

Parameters

information – the PersonalInformation object to remove.

void addPhysicalProcess(PhysicalProcess &physicalProcess)

add a composite annotation of type PhysicalProcess to the rdf graph

Parameters

physicalProcess – An instance of a PhysicalProcess object to add to the rdf graph.

void removePhysicalProcess(PhysicalProcess &physicalProcess) const

remove triples associated with a PhysicalProcess object from the rdf graph

Parameters

physicalProcess – the PhysicalProcessto remove

void addEnergyDiff(EnergyDiff &ediff)

add a composite annotation of type EnergyDiff to the rdf graph

Parameters

ediff – An instance of a EnergyDiff objec to add to the rdf graph.

void addPersonalInformation(PersonalInformation *personalInformation)

add a PersonalInformation class to the rdf model

Parameters

personalInformation – An instance of a PersonalInformation object to add to the rdf graph.

void removeEnergyDiff(EnergyDiff &physicalForce) const

remove triples associated with a a EnergyDiff object from the rdf graph

Parameters

physicalForce – the EnergyDiff to remove

void checkValidMetaid(const std::string &metaid)

check that a metaid is valid by comparing with the output from Editor::getMetaIds()

void addNamespaceFromAnnotation(const std::string &predicate_string)

extract namespace part of uri from @parameter predicate_string and add it to namespace_ if we know it.

const std::string &getMetaidBase() const

get the string that is being used for the metaid base (default is OmexMetaID)

this base will only be used when the generate_metaids boolean is set to true in the constructor.

Returns

std::string of metaid base

void setMetaidBase(const std::string &metaidBase)

set the base metaid string (default is OmexMetaId)

using editor.setMetaidBase(“MyNewMetaid”) will make metaids added by libomexmeta look like MyNewMetaid0001, MyNewMetaid0002, etc. It is assumed that it will not be necessary to have more than 9999 new metaids.

Parameters

metaidBase – the string you want to use for metaid base

Returns

void

OmexMetaXmlType getType() const

getter for the current xml type identification variable.

This should be set automatically in the Editor constructor

Returns

OmexMetaType

void setType(OmexMetaXmlType type)

setter for the current xml type identification variable.

This should be set automatically in the Editor constructor

Returns

void

PhysicalEntity newPhysicalEntity()

create a new PhysicalEntity object.

PhysicalEntity objects should only be instantiated via the Editor because this enables the passing of necessary information behind the scenes, rather than needing to be provided by the user.

EnergyDiff newEnergyDiff()

create a new EnergyDiff object.

EnergyDiff objects should only be instantiated via the Editor because this enables the passing of necessary information behind the scenes, rather than needing to be provided by the user.

PhysicalProcess newPhysicalProcess()

create a new PhysicalProcess object.

PhysicalProcess objects should only be instantiated via the Editor because this enables the passing of necessary information behind the scenes, rather than needing to be provided by the user.

PersonalInformation newPersonalInformation()

create a new PersonalInformation object.

PersonalInformation objects should only be instantiated via the Editor because this enables the passing of necessary information behind the scenes, rather than needing to be provided by the user.

void addSingleAnnotationNoValidation(SingularAnnotation &singularAnnotation)

like addSingleAnnotation

OMEXMETA_DEPRECATED void addCompositeAnnotation2 (PropertyBearer *phenomenonPtr)
void addTriples(Triples &triples)
void removePropertyBearer(PropertyBearer *physicalPhenomenon) const
std::string getArchiveUri() const

get the current value of archive_uri_

std::string getLocalUri() const

get the current value of local_uri_

std::string getModelUri() const

get the current value of model_uri_

std::string getModelLevelAnnotationUri() const

get the current value of the uri used to annotate model level annotations

std::string getRepositoryUri() const

get the current value of archive_uri_

LibrdfNode createNodeWithModelUri(const std::string &string) const

instantiate a LibrdfNode that is prefixed with the current local_uri

Editor &addCreator(std::string orcid_id)

add the “creator” model level annotation

Parameters

an – orcid_id as string

Editor &addContributor(std::string orcid_id)

add the “curator” model level annotation

Parameters

an – orcid_id as string

Editor &addTaxon(const std::string &taxon_id)

add the “taxon id” model level annotation

Parameters

an – taxon_id as string

Editor &addPubmed(const std::string &pubmedid)

add the “pubmed id” model level annotation

Parameters

a – pubmed id as string

Editor &addDescription(const std::string &date)

add the “description” model level annotation

Parameters

a – description of the model as string

Editor &addDateCreated(const std::string &date)

add the “date created” model level annotation

Parameters

The – date that the model was created

SingularAnnotation newSingularAnnotation(std::string metaid) const

create a new singular annotation object with metaid

Parameters

metaid – the string to use in the “rdf:about” field or subject

Returns

a new SingularAnnotation object

Editor &addParentModel(const std::string &biomod_id)

add the “parent model” model level annotation

Parameters

The – biomodels id for the model in which this model was derived from

SingularAnnotation newSingularAnnotation() const

create a new SingularAnnotation object

a SingularAnnotation is a typedefed Triple object.

Returns

A SingularAnnotation object

PhysicalProperty newPhysicalProperty()

instantiate a new PhysicalProperty instance and return

PhysicalProperty *newPhysicalPropertyPtr()

instantiate a pointer to a new PhysicalProperty instance and return

the caller is responsible for deleting the returned PhysicalProperty using deletePhysicalProperty

UriHandler &getUriHandler() const

get a reference to the current UriHandler

std::string stripAnnotations(const std::string &annotationElementName = "annotation")

remove all <annotation> elements from the xml associated with this Editor instance.

returns a copy of xml without any annotations (i.e. CellML) may not follow this convention and have the option of changing check element contains the annotations. Users should be warned that no verification is in place to prevent you from stripping away arbitrary elements with this method - all elements named

Parameters
  • annotationElementName – the name of the element that contains the annotations. The default is “annotation” since sbml embedded annotations are all contained within an <annotation> element. Other languages

  • annotationElementName – will be removed from this xml document, regardless of content.

Private Functions

void extractNamespacesFromTriplesVector(PropertyBearer *pp)

Private Members

std::string xml_
std::vector<std::string> metaids_
LibrdfModel &model_
bool create_ids_ = false
std::unordered_map<std::string, std::string> &namespaces_
bool generate_new_metaids_
bool sbml_semantic_extraction_
std::string metaid_base_ = "#OmexMetaId"
OmexMetaXmlType type_
OmexMetaXmlPtr omexMetaXmlPtr_
UriHandler &uriHandler_