Source code for bioregistry.external.go

# -*- coding: utf-8 -*-

"""Download the Gene Ontology registry."""

import json

import click
import yaml
from pystow.utils import download

from bioregistry.constants import EXTERNAL

__all__ = [

# Xrefs from GO that aren't generally useful
SKIP = {

# The key is redundant of the value
    "AspGD": "AspGD_LOCUS",

DIRECTORY.mkdir(exist_ok=True, parents=True)
RAW_PATH = DIRECTORY / "raw.yml"
PROCESSED_PATH = DIRECTORY / "processed.json"
GO_URL = ""

[docs]def get_go(force_download: bool = False): """Get the GO registry.""" if PROCESSED_PATH.exists() and not force_download: with as file: return json.load(file) download(url=GO_URL, path=RAW_PATH, force=True) with as file: entries = yaml.full_load(file) entries = [ entry for entry in entries if entry["database"] not in SKIP and entry["database"] not in REDUNDANT ] rv = {entry["database"]: entry for entry in entries} with"w") as file: json.dump(rv, file, indent=2, sort_keys=True) return rv
@click.command() def main(): """Reload the GO data.""" get_go(force_download=True) if __name__ == "__main__": main()