COPASI API  4.40.278
CRDFGraph Class Reference

#include <CRDFGraph.h>

Public Types

typedef std::set< CRDFTriplet >::const_iterator const_iterator
 
typedef std::set< CRDFTriplet >::iterator iterator
 
typedef std::multimap< CRDFNode *, CRDFTripletNode2Triplet
 
typedef std::pair< Node2Triplet::const_iterator, Node2Triplet::const_iterator > Node2TripletConstRange
 
typedef std::pair< Node2Triplet::iterator, Node2Triplet::iterator > Node2TripletRange
 
typedef std::multimap< CRDFPredicate, CRDFTripletPredicate2Triplet
 
typedef std::pair< Predicate2Triplet::const_iterator, Predicate2Triplet::const_iterator > Predicate2TripletConstRange
 
typedef std::pair< Predicate2Triplet::iterator, Predicate2Triplet::iterator > Predicate2TripletRange
 

Public Member Functions

bool addNameSpace (const std::string &prefix, const std::string &uri)
 
CRDFTriplet addTriplet (const CRDFSubject &subject, const CRDFPredicate &predicate, const CRDFObject &object)
 
void clean ()
 
 CRDFGraph ()
 
CRDFNodecreateAboutNode (const std::string &key)
 
bool destroyUnreferencedNode (CRDFNode *pNode)
 
bool empty () const
 
std::string generatedNodeId (const std::string &existingId="")
 
const CRDFNodegetAboutNode () const
 
const std::map< std::string, CRDFNode * > & getBlankNodeMap () const
 
std::set< CRDFTripletgetIncomingTriplets (const CRDFNode *pObject) const
 
const std::map< std::string, CRDFNode * > & getLocalResourceNodeMap () const
 
const std::map< std::string, std::string > & getNameSpaceMap () const
 
std::set< const CRDFNode * > getParentSubjects (const CRDFNode *pObject) const
 
CRDFPredicate::Path getPredicatePath (const CRDFNode *pNode)
 
const std::vector< CRDFNode * > & getRemoteResourceNodes () const
 
const std::set< CRDFTriplet > & getTriplets () const
 
std::set< CRDFTripletgetTriplets (const CRDFNode *pSubject) const
 
std::set< CRDFTripletgetTriplets (const CRDFNode *pSubject, const CRDFPredicate &predicate) const
 
std::set< CRDFTripletgetTriplets (const CRDFPredicate &predicate, const bool &expandBag=true) const
 
bool guessGraphRoot (const std::string &about=" ")
 
CRDFTriplet moveTriplet (CRDFNode *pNewSubject, const CRDFTriplet &triplet)
 
bool removeTriplet (CRDFNode *pSubject, const CRDFPredicate &predicate, CRDFNode *pObject)
 
void updateNamespaces ()
 
 ~CRDFGraph ()
 

Private Member Functions

bool addTriplet (const CRDFTriplet &triplet)
 
bool removeEmptyNodes ()
 
bool removeTriplet (const CRDFTriplet &triplet)
 

Private Attributes

std::map< std::string, CRDFNode * > mBlankNodeId2Node
 
std::set< unsigned int > mGeneratedIds
 
std::map< std::string, std::string > mIdMap
 
std::vector< CRDFNode * > mLiteralNodes
 
std::map< std::string, CRDFNode * > mLocalResource2Node
 
Node2Triplet mObject2Triplet
 
CRDFNodempAbout
 
Predicate2Triplet mPredicate2Triplet
 
std::map< std::string, std::string > mPrefix2Namespace
 
std::vector< CRDFNode * > mRemoteResourceNodes
 
Node2Triplet mSubject2Triplet
 
std::set< CRDFTripletmTriplets
 

Friends

bool CRDFNode::addTripletToGraph (const CRDFTriplet &triplet) const
 
bool CRDFNode::removeTripletFromGraph (const CRDFTriplet &triplet) const
 

Member Typedef Documentation

◆ const_iterator

◆ iterator

◆ Node2Triplet

typedef std::multimap< CRDFNode *, CRDFTriplet > CRDFGraph::Node2Triplet

◆ Node2TripletConstRange

typedef std::pair< Node2Triplet::const_iterator, Node2Triplet::const_iterator> CRDFGraph::Node2TripletConstRange

◆ Node2TripletRange

typedef std::pair< Node2Triplet::iterator, Node2Triplet::iterator> CRDFGraph::Node2TripletRange

◆ Predicate2Triplet

◆ Predicate2TripletConstRange

typedef std::pair< Predicate2Triplet::const_iterator, Predicate2Triplet::const_iterator> CRDFGraph::Predicate2TripletConstRange

◆ Predicate2TripletRange

typedef std::pair< Predicate2Triplet::iterator, Predicate2Triplet::iterator> CRDFGraph::Predicate2TripletRange

Constructor & Destructor Documentation

◆ CRDFGraph()

CRDFGraph::CRDFGraph ( )

Default Constructor

◆ ~CRDFGraph()

Member Function Documentation

◆ addNameSpace()

bool CRDFGraph::addNameSpace ( const std::string &  prefix,
const std::string &  uri 
)

Add a name space including prefix to the graph. It returns false if the prefix was already used with another namespace

Parameters
conststd::string & prefix
conststd::string & namespace
Returns
bool success;

References CCopasiMessage::ERROR, MCAnnotation, and mPrefix2Namespace.

Referenced by updateNamespaces().

◆ addTriplet() [1/2]

◆ addTriplet() [2/2]

bool CRDFGraph::addTriplet ( const CRDFTriplet triplet)
private

Add a triplet to the graph. This method should only be used by CRDFNode

Parameters
constCRDFTriplet & triplet
Returns
bool success

References mObject2Triplet, mPredicate2Triplet, mSubject2Triplet, mTriplets, CRDFTriplet::pObject, CRDFTriplet::Predicate, and CRDFTriplet::pSubject.

◆ clean()

void CRDFGraph::clean ( )

Removes empty blank nodes . This should be called before CRDFWriter::xmlFromGraph

References removeEmptyNodes().

Referenced by CMIRIAMInfo::save(), and CRDFGraphConverter::SBML2Copasi().

◆ createAboutNode()

CRDFNode * CRDFGraph::createAboutNode ( const std::string &  key)

If no about node exists a node is created with the attribute: rdf:about="#key

Parameters
conststd::string & key
Returns
CRDFNode * pAbout

References guessGraphRoot(), mLocalResource2Node, mpAbout, CRDFSubject::RESOURCE, CRDFSubject::setResource(), CRDFNode::setSubject(), and CRDFSubject::setType().

Referenced by CMIRIAMInfo::load().

◆ destroyUnreferencedNode()

◆ empty()

bool CRDFGraph::empty ( ) const

Check whether the graph is empty bool empty

References mTriplets.

Referenced by CMIRIAMInfo::empty(), and CRDFWriter::write().

◆ generatedNodeId()

std::string CRDFGraph::generatedNodeId ( const std::string &  existingId = "")

Generate a unique blank node id.

Parameters
conststd::string & existingId (default: "")
Returns
std::string blankNodeId

References mBlankNodeId2Node, mGeneratedIds, and mIdMap.

Referenced by CRDFGraphConverter::convert(), CMIRIAMInfo::createCreator(), CRDFNode::createMissingAncestors(), CMIRIAMInfo::createModification(), CMIRIAMInfo::createReference(), CMIRIAMInfo::setCreatedDT(), and CRDFNode::setFieldValue().

◆ getAboutNode()

const CRDFNode * CRDFGraph::getAboutNode ( ) const

Retrieve the about/top node of the graph.

Returns
const CRDFNode * pAboutNode

References mpAbout.

Referenced by CMIRIAMInfo::createBiologicalDescription(), CMIRIAMInfo::createCreator(), CMIRIAMInfo::createModification(), and CMIRIAMInfo::createReference().

◆ getBlankNodeMap()

const std::map< std::string, CRDFNode * > & CRDFGraph::getBlankNodeMap ( ) const

Retrieve the map of IDs to blank nodes

Returns
const std::map< std::string, CRDFNode * > & blankNodeMap

References mBlankNodeId2Node.

◆ getIncomingTriplets()

std::set< CRDFTriplet > CRDFGraph::getIncomingTriplets ( const CRDFNode pObject) const

Retrieve all triples pointing to the object

Parameters
constCRDFNode * pObject
Returns
std::set< CRDFTriplet > triplets

References mObject2Triplet.

Referenced by removeEmptyNodes().

◆ getLocalResourceNodeMap()

const std::map< std::string, CRDFNode * > & CRDFGraph::getLocalResourceNodeMap ( ) const

Retrieve the map of URIs to local resource nodes

Returns
const std::map< std::string, CRDFNode * > & localResourceNodeMap

References mLocalResource2Node.

◆ getNameSpaceMap()

const std::map< std::string, std::string > & CRDFGraph::getNameSpaceMap ( ) const

Retrieve the map of prefixes to namespaces

Returns
const std::map< std::string, std::string > & nameSpaceMap

References mPrefix2Namespace.

Referenced by CRDFWriter::initNamespaces().

◆ getParentSubjects()

std::set< const CRDFNode * > CRDFGraph::getParentSubjects ( const CRDFNode pObject) const

Retrieve all parent subjects of the object

Parameters
constCRDFNode * pObject
Returns
std::set< const CRDFNode * > nodes

References mObject2Triplet.

Referenced by CRDFNode::hasAncestor().

◆ getPredicatePath()

CRDFPredicate::Path CRDFGraph::getPredicatePath ( const CRDFNode pNode)

Retrieve the predicate path to the ginve node.

Parameters
constCRDFNode * pNode
Returns
CRDFPredicate::Path

References CRDFPredicate::about, mObject2Triplet, mpAbout, and CRDFPredicate::rdf_li.

Referenced by CRDFNode::getDescendantsWithPredicate(), CRDFNode::getPath(), and CRDFNode::isReadOnly().

◆ getRemoteResourceNodes()

const std::vector< CRDFNode * > & CRDFGraph::getRemoteResourceNodes ( ) const

Retrieve the vector of remote resource nodes

Returns
const std::vector< CRDFNode * > & remoteResourceNodes

References mRemoteResourceNodes.

◆ getTriplets() [1/4]

const std::set< CRDFTriplet > & CRDFGraph::getTriplets ( ) const

Retrieve all triplets.

Returns
const std::set< CRDFTriplet > & triplets

References mTriplets.

Referenced by CRDFNode::addEdge(), CRDFGraphConverter::convert(), CRDFNode::getDescendantsWithPredicate(), getTriplets(), CRDFNode::isBagNode(), CRDFNode::removeEdge(), and CRDFWriter::write().

◆ getTriplets() [2/4]

std::set< CRDFTriplet > CRDFGraph::getTriplets ( const CRDFNode pSubject) const

Retrieve all triplets with the specified subject

Parameters
constCRDFNode * pSubject
Returns
std::set< CRDFTriplet > triplets

References mSubject2Triplet.

◆ getTriplets() [3/4]

std::set< CRDFTriplet > CRDFGraph::getTriplets ( const CRDFNode pSubject,
const CRDFPredicate predicate 
) const

Retrieve all triplets with the specified subject and predicate

Parameters
constCRDFNode * pSubject
constCRDFPredicate & predicate
Returns
std::set< CRDFTriplet > triplets

References mPredicate2Triplet.

◆ getTriplets() [4/4]

std::set< CRDFTriplet > CRDFGraph::getTriplets ( const CRDFPredicate predicate,
const bool &  expandBag = true 
) const

Retrieve all triplets with the specified predicate, this will collapse predicate.rdf:li to predicate.

Parameters
constCRDFPredicate & predicate
constbool & expandBag (default: true)
Returns
std::set< CRDFTriplet > triplets

References getTriplets(), mPredicate2Triplet, and CRDFPredicate::rdf_li.

◆ guessGraphRoot()

bool CRDFGraph::guessGraphRoot ( const std::string &  about = " ")

Guess the graph root element. If a unique root element is found true is returned other wise falls

Parameters
conststd::string & about (default: <space>)
Returns
bool success

References CRDFSubject::getResource(), CRDFNode::getSubject(), CRDFSubject::getType(), CRDFSubject::isLocal(), CRDFNode::isSubjectNode(), mLocalResource2Node, mpAbout, and CRDFSubject::RESOURCE.

Referenced by createAboutNode(), and CRDFParser::parse().

◆ moveTriplet()

CRDFTriplet CRDFGraph::moveTriplet ( CRDFNode pNewSubject,
const CRDFTriplet triplet 
)

Move a edge from one node to another

Parameters
CRDFNode* pNewSubject
CRDFNode* const CRDFTriplet & triplet
Returns
CRDFGraph::CRDFTriplet triplet

References CRDFNode::addEdge(), CRDFTriplet::pObject, CRDFTriplet::Predicate, CRDFTriplet::pSubject, and CRDFNode::removeEdge().

Referenced by CRDFGraphConverter::convert().

◆ removeEmptyNodes()

bool CRDFGraph::removeEmptyNodes ( )
private

Removes all empty blank nodes. It returns true if a node was removed

Returns
bool haveRemoved

References destroyUnreferencedNode(), getIncomingTriplets(), CRDFNode::isBagNode(), mBlankNodeId2Node, mSubject2Triplet, and CCopasiMessage::WARNING_FILTERED.

Referenced by clean().

◆ removeTriplet() [1/2]

bool CRDFGraph::removeTriplet ( const CRDFTriplet triplet)
private

Remove triplet from the graph. This method should only be used by CRDFNode Please note, this will also remove all unreferenced local resources created by removing the edge.

Parameters
constCRDFTriplet & triplet
Returns
true, if an element was deleted, false otherwise

References destroyUnreferencedNode(), mObject2Triplet, mPredicate2Triplet, mSubject2Triplet, mTriplets, CRDFTriplet::pObject, CRDFTriplet::Predicate, and CRDFTriplet::pSubject.

◆ removeTriplet() [2/2]

bool CRDFGraph::removeTriplet ( CRDFNode pSubject,
const CRDFPredicate predicate,
CRDFNode pObject 
)

Remove triplet from the graph. Please note, this will also remove all unreferenced local resources created by removing the edge.

Parameters
CRDFNode* pSubject
constCRDFPredicate & predicate
CRDFNode* pObject
Returns
true, if an element was deleted, false otherwise

References CRDFNode::removeEdge().

Referenced by CRDFGraphConverter::convert(), CMIRIAMInfo::removeBiologicalDescription(), CMIRIAMInfo::removeCreator(), CMIRIAMInfo::removeModification(), CMIRIAMInfo::removeReference(), and CRDFNode::removeTripletFromGraph().

◆ updateNamespaces()

void CRDFGraph::updateNamespaces ( )

Removes all unused name spaces.

References addNameSpace(), mPrefix2Namespace, and mTriplets.

Referenced by CMIRIAMInfo::save(), and CRDFGraphConverter::SBML2Copasi().

Friends And Related Function Documentation

◆ CRDFNode::addTripletToGraph

bool CRDFNode::addTripletToGraph ( const CRDFTriplet triplet) const
friend

◆ CRDFNode::removeTripletFromGraph

bool CRDFNode::removeTripletFromGraph ( const CRDFTriplet triplet) const
friend

Member Data Documentation

◆ mBlankNodeId2Node

std::map< std::string, CRDFNode * > CRDFGraph::mBlankNodeId2Node
private

A map of blank node ids to nodes of the graph.

Referenced by addTriplet(), destroyUnreferencedNode(), generatedNodeId(), getBlankNodeMap(), removeEmptyNodes(), and ~CRDFGraph().

◆ mGeneratedIds

std::set< unsigned int > CRDFGraph::mGeneratedIds
private

Memory for generated Ids

Referenced by generatedNodeId().

◆ mIdMap

std::map< std::string, std::string > CRDFGraph::mIdMap
private

Mapping from existing Ids to newly created ones.

Referenced by generatedNodeId().

◆ mLiteralNodes

std::vector< CRDFNode * > CRDFGraph::mLiteralNodes
private

A vector of all literal nodes of the graph

Referenced by addTriplet(), destroyUnreferencedNode(), and ~CRDFGraph().

◆ mLocalResource2Node

std::map< std::string, CRDFNode * > CRDFGraph::mLocalResource2Node
private

A map of resource URIs to local resource nodes of the graph, i

Referenced by addTriplet(), createAboutNode(), destroyUnreferencedNode(), getLocalResourceNodeMap(), guessGraphRoot(), and ~CRDFGraph().

◆ mObject2Triplet

◆ mpAbout

CRDFNode* CRDFGraph::mpAbout
private

The subject node this RDF graph is about

Referenced by createAboutNode(), getAboutNode(), getPredicatePath(), and guessGraphRoot().

◆ mPredicate2Triplet

Predicate2Triplet CRDFGraph::mPredicate2Triplet
private

◆ mPrefix2Namespace

std::map< std::string, std::string > CRDFGraph::mPrefix2Namespace
private

A map of prefixes to namespaces

Referenced by addNameSpace(), getNameSpaceMap(), and updateNamespaces().

◆ mRemoteResourceNodes

std::vector< CRDFNode * > CRDFGraph::mRemoteResourceNodes
private

A vector of all remote resource nodes of the graph

Referenced by addTriplet(), destroyUnreferencedNode(), getRemoteResourceNodes(), and ~CRDFGraph().

◆ mSubject2Triplet

◆ mTriplets

std::set< CRDFTriplet > CRDFGraph::mTriplets
private

All the triplets of the graph

Referenced by addTriplet(), empty(), getTriplets(), removeTriplet(), updateNamespaces(), and ~CRDFGraph().


The documentation for this class was generated from the following files: