How to use the ontobio.ontol_factory function in ontobio

To help you get started, we’ve selected a few ontobio examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github RTXteam / RTX / code / kg2 / build-kg2.py View on Github external
def make_ontology_from_local_file(file_name: str):
    print("Creating ontology from file: " + file_name)
    return ontobio.ontol_factory.OntologyFactory().create(file_name)
github RTXteam / RTX / code / kg2 / build_kg2.py View on Github external
cp = subprocess.run(['owltools', file_name, '-o', '-f', 'json', temp_file_name])
        # robot commented out because it is giving a NullPointerException on umls_semantictypes.owl
#        cp = subprocess.run(['robot', 'convert', '--input', file_name, '--output', temp_file_name])
        if cp.stdout is not None:
            log_message(message="OWL convert result: " + cp.stdout, ontology_name=None, output_stream=sys.stdout)
        if cp.stderr is not None:
            log_message(message="OWL convert result: " + cp.stderr, ontology_name=None, output_stream=sys.stderr)
        assert cp.returncode == 0
        json_file = file_name_without_ext + ".json"
        shutil.move(temp_file_name, json_file)
        size = os.path.getsize(json_file)
        log_message(message="Reading ontology JSON file: " + json_file + "; size: " + "{0:.2f}".format(size/1024) + " KiB",
                    ontology_name=None)
#        if not USE_ONTOBIO_JSON_CACHE:
#            delete_ontobio_cache_json(file_name)
        ont_return = ontobio.ontol_factory.OntologyFactory().create(json_file, ignore_cache=True)
    else:
        size = os.path.getsize(file_name_with_pickle_ext)
        log_message("Reading ontology file: " + file_name_with_pickle_ext + "; size: " + "{0:.2f}".format(size/1024) + " KiB", ontology_name=None)
        ont_return = pickle.load(open(file_name_with_pickle_ext, "rb"))
    return ont_return
github RTXteam / RTX / code / kg2 / multi_owl_to_json_kg.py View on Github external
# Once robot no longer gives a NullPointerException, we can use it like this:
            #        cp = subprocess.run(['robot', 'convert', '--input', file_name, '--output', temp_file_name])
            if cp.stdout is not None:
                kg2_util.log_message(message="OWL convert result: " + cp.stdout, ontology_name=None, output_stream=sys.stdout)
            if cp.stderr is not None:
                kg2_util.log_message(message="OWL convert result: " + cp.stderr, ontology_name=None, output_stream=sys.stderr)
            assert cp.returncode == 0
            json_file = file_name_without_ext + ".json"
            shutil.move(temp_file_name, json_file)
        else:
            json_file = file_name
        size = os.path.getsize(json_file)
        kg2_util.log_message(message="Reading ontology JSON file: " + json_file + "; size: " + "{0:.2f}".format(size/1024) + " KiB",
                             ontology_name=None)

        ont_return = ontobio.ontol_factory.OntologyFactory().create(json_file, ignore_cache=True)
    else:
        size = os.path.getsize(file_name_with_pickle_ext)
        kg2_util.log_message("Reading ontology file: " + file_name_with_pickle_ext + "; size: " + "{0:.2f}".format(size/1024) + " KiB", ontology_name=None)
        ont_return = pickle.load(open(file_name_with_pickle_ext, "rb"))
    return ont_return
github RTXteam / RTX / code / kg2 / multi_owl_to_json_kg.py View on Github external
# Once robot no longer gives a NullPointerException, we can use it like this:
            #        cp = subprocess.run(['robot', 'convert', '--input', file_name, '--output', temp_file_name])
            if cp.stdout is not None:
                kg2_util.log_message(message="OWL convert result: " + cp.stdout, ontology_name=None, output_stream=sys.stdout)
            if cp.stderr is not None:
                kg2_util.log_message(message="OWL convert result: " + cp.stderr, ontology_name=None, output_stream=sys.stderr)
            assert cp.returncode == 0
            json_file = file_name_without_ext + ".json"
            shutil.move(temp_file_name, json_file)
        else:
            json_file = file_name
        size = os.path.getsize(json_file)
        kg2_util.log_message(message="Reading ontology JSON file: " + json_file + "; size: " + "{0:.2f}".format(size/1024) + " KiB",
                             ontology_name=None)

        ont_return = ontobio.ontol_factory.OntologyFactory().create(json_file, ignore_cache=True)
    else:
        size = os.path.getsize(file_name_with_pickle_ext)
        kg2_util.log_message("Reading ontology file: " + file_name_with_pickle_ext + "; size: " + "{0:.2f}".format(size/1024) + " KiB", ontology_name=None)
        ont_return = pickle.load(open(file_name_with_pickle_ext, "rb"))
    return ont_return

ontobio

Library for working with OBO Library Ontologies and associations

BSD-3-Clause
Latest version published 9 days ago

Package Health Score

72 / 100
Full package analysis