Building Diagrams

Diagrams of the RDF graph can be produced because the Redland libraries support serializing to dot format, the format used by graphviz. Therefore using Python, it is trivial to serialize to dot and then draw the diagram using graphviz. Here is an example where we download the Teusink2000 glycolysis model, use an sqlite3 database as a triple store and produce a graph of the Teusink annotations.

Example of drawing a diagram of the RDF graph using graphviz in Python
import os
from pyomexmeta import RDF, eUriType

rdf_str = """@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix bqbiol: <http://biomodels.net/biology-qualifiers/> .
@prefix OMEXlib: <http://omex-library.org/> .
@prefix myOMEX: <http://omex-library.org/NewOmex.omex/> .
@prefix local: <http://omex-library.org/NewOmex.omex/NewModel.rdf#> .

<http://omex-library.org/NewOmex.omex/NewModel.xml#OmexMetaId0000>
  bqbiol:is <https://identifiers.org/uniprot/PD12345> ."""

# download model xml, scan for rdf, create rdf graph and store in sqlite database
rdf = RDF.from_string(rdf_str, syntax="turtle")

# pick a filename (this can be anywhere on your system)
docs_dir = os.path.join(os.path.dirname(__file__), "source")
diagrams_dir = os.path.join(docs_dir, "diagrams")
fname = os.path.join(diagrams_dir, "Diagram")
# draw a diagram
rdf.draw(fname)
print(f"file saved to {fname}.pdf")

Output:

../_images/Diagram.pdf