From: Diane Trout Date: Wed, 15 Jan 2014 00:58:50 +0000 (-0800) Subject: Add option to get_model to disable RDF graph context. X-Git-Url: http://woldlab.caltech.edu/gitweb/?p=htsworkflow.git;a=commitdiff_plain;h=0f6b49406fae69d76409020241385d8102596680 Add option to get_model to disable RDF graph context. At least with the version of librdf I was using the context graph really slowed adding tripes down. --- diff --git a/htsworkflow/util/rdfhelp.py b/htsworkflow/util/rdfhelp.py index 4f65d7d..4829441 100644 --- a/htsworkflow/util/rdfhelp.py +++ b/htsworkflow/util/rdfhelp.py @@ -232,15 +232,17 @@ def strip_namespace(namespace, term): return term_s.replace(namespace._prefix, "") -def get_model(model_name=None, directory=None): +def get_model(model_name=None, directory=None, use_contexts=True): if directory is None: directory = os.getcwd() + contexts = 'yes' if use_contexts else 'no' + if model_name is None: - storage = RDF.MemoryStorage(options_string="contexts='yes'") + storage = RDF.MemoryStorage(options_string="contexts='{}'".format(contexts)) logger.info("Using RDF Memory model") else: - options = "contexts='yes',hash-type='bdb',dir='{0}'".format(directory) + options = "contexts='{0}',hash-type='bdb',dir='{1}'".format(contexts, directory) storage = RDF.HashStorage(model_name, options=options) logger.info("Using {0} with options {1}".format(model_name, options)) @@ -281,10 +283,10 @@ def load_into_model(model, parser_name, path, ns=None): except RDF.RedlandError, e: errmsg = "RDF.RedlandError: {0} {1} tries remaining" logger.error(errmsg.format(str(e), retries)) - + if not succeeded: logger.warn("Unable to download %s", url) - + for s in statements: conditionally_add_statement(model, s, ns)