@prefix OMEXlib: <http://omex-library.org/> . @prefix myOMEX: <http://omex-library.org/NewOmex.omex/> . @prefix local: <http://omex-library.org/NewOmex.omex/NewModel.rdf#> . local:OmexMetaId0001 bqbiol:isPropertyOf local:EntityProperty0000 ; bqbiol:isVersionOf <https://identifiers.org/OPB/OPB_00340> . local:EntityProperty0000 bqbiol:is <https://identifiers.org/uniprot/P84022> ; bqbiol:isPartOf <https://identifiers.org/fma/FMA:24178>, <https://identifiers.org/fma/FMA:63877>, <https://identifiers.org/fma/FMA:70737>, <https://identifiers.org/fma/FMA:7163> . """ # remember that the default parser is "guess". # the parser will try to figure out which syntax is being used. # but if it doesn't guess well, you can use the format argument for `from_string` rdf = RDF.from_string(turtle_string) formats = [ "ntriples", "turtle", "rdfxml-abbrev", "rdfxml", "dot", "json-triples", "json", "nquads", "html" ] for syntax in formats: print("Serializing to {}".format(syntax)) print(rdf.to_string(syntax)) print("\n\n") # Note: printing the rdf object is the same as rdf.to_string("turtle")
from pyomexmeta import RDF rdf_str = """@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . @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#> <http://purl.org/dc/terms/creator> <https://orchid.org/1234-1234-1234-1234> .""" # read the annotations into RDF graph rdf = RDF.from_string(rdf_str, format="turtle") # serialize the string to rdfxml-abbrev xml_string = rdf.to_string("rdfxml-abbrev") print(f"RDF graph serialized to rdfxml abbreviated is:\n\n{xml_string}")
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")