def delete_publication(uri): delete_query = """ PREFIX np: <http://www.nanopub.org/nschema#> DELETE {{ GRAPH ?g {{ <{URI}> a np:Nanopublication ; np:hasAssertion ?assertion_uri ; np:hasPublicationInfo ?pubinfo_uri ; np:hasProvenance ?provenance_uri . ?assertion_uri a np:Assertion . ?pubinfo_uri a np:PublicationInfo . ?provenance_uri a np:Provenance . }}}} WHERE {{ GRAPH ?g {{ <{URI}> a np:Nanopublication ; np:hasAssertion ?assertion_uri ; np:hasPublicationInfo ?pubinfo_uri ; np:hasProvenance ?provenance_uri . ?assertion_uri a np:Assertion . ?pubinfo_uri a np:PublicationInfo . ?provenance_uri a np:Provenance . }}}} """.format(URI=uri) log.debug("Removing the nanopublication {}...".format(uri)) return sc.sparql_update(delete_query)
def clear_graph(uri): clear_query_template = """ DEFINE sql:log-enable 2 CLEAR GRAPH <{}> """ clear_query = clear_query_template.format(uri) log.debug("Clearing graph {}".format(uri)) return sc.sparql_update(clear_query)