{"id":22367974,"url":"https://github.com/dridk/hpo2sqlite","last_synced_at":"2025-03-26T16:11:35.232Z","repository":{"id":147849789,"uuid":"130765726","full_name":"dridk/hpo2sqlite","owner":"dridk","description":"convert hpo to sqlite database","archived":false,"fork":false,"pushed_at":"2020-09-29T14:05:32.000Z","size":3775,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-31T17:52:37.701Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dridk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-04-23T22:51:06.000Z","updated_at":"2024-11-05T10:40:58.000Z","dependencies_parsed_at":"2023-05-26T17:45:19.657Z","dependency_job_id":null,"html_url":"https://github.com/dridk/hpo2sqlite","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dridk%2Fhpo2sqlite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dridk%2Fhpo2sqlite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dridk%2Fhpo2sqlite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dridk%2Fhpo2sqlite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dridk","download_url":"https://codeload.github.com/dridk/hpo2sqlite/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245689509,"owners_count":20656417,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-04T18:25:29.158Z","updated_at":"2025-03-26T16:11:35.217Z","avatar_url":"https://github.com/dridk.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# hpo2sqlite\nThis script convert [HPO ontology](http://human-phenotype-ontology.github.io/) to a sqlite database as a tree according the [nested set model](https://en.wikipedia.org/wiki/Nested_set_model). \nIt takes [HPO obo file](http://purl.obolibrary.org/obo/hp.obo) as argument and construct a tree with [networkx](https://networkx.github.io/).\nThe Tree is visited to compute left and right index and the tree is stored into a sqlite database using [peewee](http://docs.peewee-orm.com/en/latest/) ORM model.\nThere are two main table: Terms and Nodes.\n\n## Dependencies \nYou need python3 with the following modules\n\n```\npip install networkx\npip install obonet \npip install peewee \npip install tqdm\n```\n\n## Run \nDownload hpo obo file from http://purl.obolibrary.org/obo/hp.obo and run the script as follow\n```\npython import_hpo_obo.py hp.obo\n```\n\n ## Import gene and disease \n ```\n wget http://compbio.charite.de/jenkins/job/hpo.annotations.current/lastSuccessfulBuild/artifact/current/phenotype.hpoa\n python import_disease.py phenotype.hpoa\n ```\n \n ```\n wget http://compbio.charite.de/jenkins/job/hpo.annotations/lastSuccessfulBuild/artifact/util/annotation/phenotype_to_genes.txt\n python import_gene.py phenotype_to_genes.txt\n```\n\n### Table Terms \nTerms contains each unique HPO term with name and definition. \n\n| fields     | description                  |\n|------------|------------------------------|\n| id         | INTEGER \"3\"                  |\n| hpo        | TEXT \"HP:0000012\"            |\n| name       | TEXT \"Urinary urgency\"       |\n| definition | TEXT \"Urinary urgency is ...\"|\n| comment    | TEXT                         |\n\n\n### Table Nodes \nNodes table contains the HPO ontology as a Tree. Because hpo ontology is a Directed Acyclic Graph, the tree contains duplicate elements. Each node refere to his HPO terms from the term_id field.\n\n| fields     | description                      |\n|------------|----------------------------------|\n| id         | INTEGER (primary key)            |\n| left       | INTEGER (left index)             |\n| right      | INTEGER (right index)            |\n| depth      | INTEGER (depth of the node)      |\n| term_id    | INTEGER (term_id)                |\n\n## Query example \n### Children selection\nSelect all children of HPO term HP:0012632 (Abnormal intraocular pressure)\n\n#### Step by step example\n```\n# Get the term id\nSELECT id FROM terms WHERE hpo = \"HP:0012632\" // get 9124\n# Get the node left and right \nSELECT left,right FROM nodes WHERE term_id=9124 //get 99982 and 99987\n# Select all children nodes\nSELECT * FROM nodes WHERE left \u003e 99982 AND right \u003c 99987\n```\nAll steps can be summarized in one query : \n\n```\nSELECT terms.hpo, terms.name FROM nodes\nINNER JOIN (SELECT left, right FROM nodes WHERE term_id = (SELECT id FROM terms WHERE hpo = \"HP:0012632\")) as root ON nodes.left \u003e root.left AND nodes.right \u003c root.right     \nINNER JOIN terms ON  terms.id = nodes.term_id\n```\n\nYou can specify the depth if you only want to first level childs. \n\n```\nSELECT terms.hpo, terms.name FROM nodes\nINNER JOIN (SELECT left, right FROM nodes WHERE term_id = (SELECT id FROM terms WHERE hpo = \"HP:0012632\")) as root ON nodes.left \u003e root.left AND nodes.right \u003c root.right  AND (nodes.depth - root.depth) \u003c 2\nINNER JOIN terms ON  terms.id = nodes.term_id\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdridk%2Fhpo2sqlite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdridk%2Fhpo2sqlite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdridk%2Fhpo2sqlite/lists"}