COPASI API
4.40.278
|
#include <CRDFGraph.h>
Public Types | |
typedef std::set< CRDFTriplet >::const_iterator | const_iterator |
typedef std::set< CRDFTriplet >::iterator | iterator |
typedef std::multimap< CRDFNode *, CRDFTriplet > | Node2Triplet |
typedef std::pair< Node2Triplet::const_iterator, Node2Triplet::const_iterator > | Node2TripletConstRange |
typedef std::pair< Node2Triplet::iterator, Node2Triplet::iterator > | Node2TripletRange |
typedef std::multimap< CRDFPredicate, CRDFTriplet > | Predicate2Triplet |
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 () | |
CRDFNode * | createAboutNode (const std::string &key) |
bool | destroyUnreferencedNode (CRDFNode *pNode) |
bool | empty () const |
std::string | generatedNodeId (const std::string &existingId="") |
const CRDFNode * | getAboutNode () const |
const std::map< std::string, CRDFNode * > & | getBlankNodeMap () const |
std::set< CRDFTriplet > | getIncomingTriplets (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< CRDFTriplet > | getTriplets (const CRDFNode *pSubject) const |
std::set< CRDFTriplet > | getTriplets (const CRDFNode *pSubject, const CRDFPredicate &predicate) const |
std::set< CRDFTriplet > | getTriplets (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 |
CRDFNode * | mpAbout |
Predicate2Triplet | mPredicate2Triplet |
std::map< std::string, std::string > | mPrefix2Namespace |
std::vector< CRDFNode * > | mRemoteResourceNodes |
Node2Triplet | mSubject2Triplet |
std::set< CRDFTriplet > | mTriplets |
Friends | |
bool | CRDFNode::addTripletToGraph (const CRDFTriplet &triplet) const |
bool | CRDFNode::removeTripletFromGraph (const CRDFTriplet &triplet) const |
typedef std::set< CRDFTriplet >::const_iterator CRDFGraph::const_iterator |
typedef std::set< CRDFTriplet >::iterator CRDFGraph::iterator |
typedef std::multimap< CRDFNode *, CRDFTriplet > CRDFGraph::Node2Triplet |
typedef std::pair< Node2Triplet::const_iterator, Node2Triplet::const_iterator> CRDFGraph::Node2TripletConstRange |
typedef std::pair< Node2Triplet::iterator, Node2Triplet::iterator> CRDFGraph::Node2TripletRange |
typedef std::multimap< CRDFPredicate, CRDFTriplet > CRDFGraph::Predicate2Triplet |
typedef std::pair< Predicate2Triplet::const_iterator, Predicate2Triplet::const_iterator> CRDFGraph::Predicate2TripletConstRange |
typedef std::pair< Predicate2Triplet::iterator, Predicate2Triplet::iterator> CRDFGraph::Predicate2TripletRange |
CRDFGraph::CRDFGraph | ( | ) |
Default Constructor
CRDFGraph::~CRDFGraph | ( | ) |
Destructor
References mBlankNodeId2Node, mLiteralNodes, mLocalResource2Node, mObject2Triplet, mPredicate2Triplet, mRemoteResourceNodes, mSubject2Triplet, mTriplets, and pdelete.
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
const | std::string & prefix |
const | std::string & namespace |
References CCopasiMessage::ERROR, MCAnnotation, and mPrefix2Namespace.
Referenced by updateNamespaces().
CRDFTriplet CRDFGraph::addTriplet | ( | const CRDFSubject & | subject, |
const CRDFPredicate & | predicate, | ||
const CRDFObject & | object | ||
) |
Add a triplet to the graph
const | CRDFSubject & subject |
const | CRDFPredicate & predicate |
const | CRDFObject & object |
References CRDFNode::addEdge(), CRDFObject::BLANK_NODE, CRDFSubject::BLANK_NODE, CRDFSubject::getBlankNodeID(), CRDFNode::getObject(), CRDFPredicate::getPredicateFromURI(), CRDFObject::getResource(), CRDFSubject::getResource(), CRDFObject::getType(), CRDFSubject::getType(), CRDFPredicate::getURI(), CRDFSubject::isLocal(), CRDFNode::isObjectNode(), CRDFNode::isSubjectNode(), CRDFObject::LITERAL, mBlankNodeId2Node, mLiteralNodes, mLocalResource2Node, mRemoteResourceNodes, CRDFPredicate::rdf_li, CRDFPredicate::rdf_predicate, CRDFObject::RESOURCE, CRDFSubject::RESOURCE, CRDFNode::setObject(), CRDFObject::setResource(), and CRDFNode::setSubject().
Referenced by CRDFNode::addEdge(), CRDFNode::addTripletToGraph(), CRDFGraphConverter::convert(), CMIRIAMInfo::createBiologicalDescription(), CMIRIAMInfo::createCreator(), CRDFNode::createMissingAncestors(), CMIRIAMInfo::createModification(), CMIRIAMInfo::createReference(), CMIRIAMInfo::setCreatedDT(), and CRDFNode::setFieldValue().
|
private |
Add a triplet to the graph. This method should only be used by CRDFNode
const | CRDFTriplet & triplet |
References mObject2Triplet, mPredicate2Triplet, mSubject2Triplet, mTriplets, CRDFTriplet::pObject, CRDFTriplet::Predicate, and CRDFTriplet::pSubject.
void CRDFGraph::clean | ( | ) |
Removes empty blank nodes . This should be called before CRDFWriter::xmlFromGraph
References removeEmptyNodes().
Referenced by CMIRIAMInfo::save(), and CRDFGraphConverter::SBML2Copasi().
CRDFNode * CRDFGraph::createAboutNode | ( | const std::string & | key | ) |
If no about node exists a node is created with the attribute: rdf:about="#key
const | std::string & key |
References guessGraphRoot(), mLocalResource2Node, mpAbout, CRDFSubject::RESOURCE, CRDFSubject::setResource(), CRDFNode::setSubject(), and CRDFSubject::setType().
Referenced by CMIRIAMInfo::load().
bool CRDFGraph::destroyUnreferencedNode | ( | CRDFNode * | pNode | ) |
Destroy a CRDFNode
CRDFNode | * pNode |
References CRDFObject::BLANK_NODE, CRDFObject::getBlankNodeID(), CRDFNode::getObject(), CRDFObject::getResource(), CRDFObject::getType(), CRDFObject::isLocal(), CRDFObject::LITERAL, mBlankNodeId2Node, mLiteralNodes, mLocalResource2Node, mObject2Triplet, mRemoteResourceNodes, mSubject2Triplet, and CRDFObject::RESOURCE.
Referenced by removeEmptyNodes(), and removeTriplet().
bool CRDFGraph::empty | ( | ) | const |
Check whether the graph is empty bool empty
References mTriplets.
Referenced by CMIRIAMInfo::empty(), and CRDFWriter::write().
std::string CRDFGraph::generatedNodeId | ( | const std::string & | existingId = "" | ) |
Generate a unique blank node id.
const | std::string & existingId (default: "") |
References mBlankNodeId2Node, mGeneratedIds, and mIdMap.
Referenced by CRDFGraphConverter::convert(), CMIRIAMInfo::createCreator(), CRDFNode::createMissingAncestors(), CMIRIAMInfo::createModification(), CMIRIAMInfo::createReference(), CMIRIAMInfo::setCreatedDT(), and CRDFNode::setFieldValue().
const CRDFNode * CRDFGraph::getAboutNode | ( | ) | const |
Retrieve the about/top node of the graph.
References mpAbout.
Referenced by CMIRIAMInfo::createBiologicalDescription(), CMIRIAMInfo::createCreator(), CMIRIAMInfo::createModification(), and CMIRIAMInfo::createReference().
const std::map< std::string, CRDFNode * > & CRDFGraph::getBlankNodeMap | ( | ) | const |
Retrieve the map of IDs to blank nodes
References mBlankNodeId2Node.
std::set< CRDFTriplet > CRDFGraph::getIncomingTriplets | ( | const CRDFNode * | pObject | ) | const |
Retrieve all triples pointing to the object
const | CRDFNode * pObject |
References mObject2Triplet.
Referenced by removeEmptyNodes().
const std::map< std::string, CRDFNode * > & CRDFGraph::getLocalResourceNodeMap | ( | ) | const |
Retrieve the map of URIs to local resource nodes
References mLocalResource2Node.
const std::map< std::string, std::string > & CRDFGraph::getNameSpaceMap | ( | ) | const |
Retrieve the map of prefixes to namespaces
References mPrefix2Namespace.
Referenced by CRDFWriter::initNamespaces().
Retrieve all parent subjects of the object
const | CRDFNode * pObject |
References mObject2Triplet.
Referenced by CRDFNode::hasAncestor().
CRDFPredicate::Path CRDFGraph::getPredicatePath | ( | const CRDFNode * | pNode | ) |
Retrieve the predicate path to the ginve node.
const | CRDFNode * pNode |
References CRDFPredicate::about, mObject2Triplet, mpAbout, and CRDFPredicate::rdf_li.
Referenced by CRDFNode::getDescendantsWithPredicate(), CRDFNode::getPath(), and CRDFNode::isReadOnly().
const std::vector< CRDFNode * > & CRDFGraph::getRemoteResourceNodes | ( | ) | const |
Retrieve the vector of remote resource nodes
References mRemoteResourceNodes.
const std::set< CRDFTriplet > & CRDFGraph::getTriplets | ( | ) | const |
Retrieve all triplets.
References mTriplets.
Referenced by CRDFNode::addEdge(), CRDFGraphConverter::convert(), CRDFNode::getDescendantsWithPredicate(), getTriplets(), CRDFNode::isBagNode(), CRDFNode::removeEdge(), and CRDFWriter::write().
std::set< CRDFTriplet > CRDFGraph::getTriplets | ( | const CRDFNode * | pSubject | ) | const |
Retrieve all triplets with the specified subject
const | CRDFNode * pSubject |
References mSubject2Triplet.
std::set< CRDFTriplet > CRDFGraph::getTriplets | ( | const CRDFNode * | pSubject, |
const CRDFPredicate & | predicate | ||
) | const |
Retrieve all triplets with the specified subject and predicate
const | CRDFNode * pSubject |
const | CRDFPredicate & predicate |
References mPredicate2Triplet.
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.
const | CRDFPredicate & predicate |
const | bool & expandBag (default: true) |
References getTriplets(), mPredicate2Triplet, and CRDFPredicate::rdf_li.
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
const | std::string & about (default: <space>) |
References CRDFSubject::getResource(), CRDFNode::getSubject(), CRDFSubject::getType(), CRDFSubject::isLocal(), CRDFNode::isSubjectNode(), mLocalResource2Node, mpAbout, and CRDFSubject::RESOURCE.
Referenced by createAboutNode(), and CRDFParser::parse().
CRDFTriplet CRDFGraph::moveTriplet | ( | CRDFNode * | pNewSubject, |
const CRDFTriplet & | triplet | ||
) |
Move a edge from one node to another
CRDFNode | * pNewSubject |
CRDFNode | * const CRDFTriplet & triplet |
References CRDFNode::addEdge(), CRDFTriplet::pObject, CRDFTriplet::Predicate, CRDFTriplet::pSubject, and CRDFNode::removeEdge().
Referenced by CRDFGraphConverter::convert().
|
private |
Removes all empty blank nodes. It returns true if a node was removed
References destroyUnreferencedNode(), getIncomingTriplets(), CRDFNode::isBagNode(), mBlankNodeId2Node, mSubject2Triplet, and CCopasiMessage::WARNING_FILTERED.
Referenced by clean().
|
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.
const | CRDFTriplet & triplet |
References destroyUnreferencedNode(), mObject2Triplet, mPredicate2Triplet, mSubject2Triplet, mTriplets, CRDFTriplet::pObject, CRDFTriplet::Predicate, and CRDFTriplet::pSubject.
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.
CRDFNode | * pSubject |
const | CRDFPredicate & predicate |
CRDFNode | * pObject |
References CRDFNode::removeEdge().
Referenced by CRDFGraphConverter::convert(), CMIRIAMInfo::removeBiologicalDescription(), CMIRIAMInfo::removeCreator(), CMIRIAMInfo::removeModification(), CMIRIAMInfo::removeReference(), and CRDFNode::removeTripletFromGraph().
void CRDFGraph::updateNamespaces | ( | ) |
Removes all unused name spaces.
References addNameSpace(), mPrefix2Namespace, and mTriplets.
Referenced by CMIRIAMInfo::save(), and CRDFGraphConverter::SBML2Copasi().
|
friend |
|
friend |
|
private |
A map of blank node ids to nodes of the graph.
Referenced by addTriplet(), destroyUnreferencedNode(), generatedNodeId(), getBlankNodeMap(), removeEmptyNodes(), and ~CRDFGraph().
|
private |
Memory for generated Ids
Referenced by generatedNodeId().
|
private |
Mapping from existing Ids to newly created ones.
Referenced by generatedNodeId().
|
private |
A vector of all literal nodes of the graph
Referenced by addTriplet(), destroyUnreferencedNode(), and ~CRDFGraph().
|
private |
A map of resource URIs to local resource nodes of the graph, i
Referenced by addTriplet(), createAboutNode(), destroyUnreferencedNode(), getLocalResourceNodeMap(), guessGraphRoot(), and ~CRDFGraph().
|
private |
Referenced by addTriplet(), destroyUnreferencedNode(), getIncomingTriplets(), getParentSubjects(), getPredicatePath(), removeTriplet(), and ~CRDFGraph().
|
private |
The subject node this RDF graph is about
Referenced by createAboutNode(), getAboutNode(), getPredicatePath(), and guessGraphRoot().
|
private |
Referenced by addTriplet(), getTriplets(), removeTriplet(), and ~CRDFGraph().
|
private |
A map of prefixes to namespaces
Referenced by addNameSpace(), getNameSpaceMap(), and updateNamespaces().
|
private |
A vector of all remote resource nodes of the graph
Referenced by addTriplet(), destroyUnreferencedNode(), getRemoteResourceNodes(), and ~CRDFGraph().
|
private |
Referenced by addTriplet(), destroyUnreferencedNode(), getTriplets(), removeEmptyNodes(), removeTriplet(), and ~CRDFGraph().
|
private |
All the triplets of the graph
Referenced by addTriplet(), empty(), getTriplets(), removeTriplet(), updateNamespaces(), and ~CRDFGraph().