X-Git-Url: http://woldlab.caltech.edu/gitweb/?p=htsworkflow.git;a=blobdiff_plain;f=htsworkflow%2Futil%2Frdfhelp.py;h=48294416abf1def5a9bc1c3d77b0a4eaa1a607b0;hp=4f65d7d44885ad0c16bbe1ade6604ba2b5a42700;hb=0f6b49406fae69d76409020241385d8102596680;hpb=d38490d4031e42ed991cecf9c8a573faadaa0ad0 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)