def build_database(connection): """Build the hpo database Args: conn (sqlite3.connect): A database connection object """ logger.info("Fetching disease to gene file") disease_to_genes = getreader('utf-8')(gzip.open(disease_to_genes_path), errors='replace') logger.info("Fetching phenotypes file") phenotype_to_genes = getreader('utf-8')(gzip.open(phenotypes_path), errors='replace') logger.info("Fetching genes file") genes = getreader('utf-8')(gzip.open(genes_path), errors='replace') logger.info("Parsing phenotypes to gene file") phenotypes = parse_phenotypes(phenotype_to_genes) logger.info("Parsing disease to gene file") diseases = parse_diseases(disease_to_genes) logger.info("Parsing genes file") genes = parse_genes(genes) logger.info("Populating hpo table") populate_hpo(connection=connection, hpo_terms=phenotypes) logger.debug("Hpo table populated") logger.info("Populating disease table") populate_disease(connection=connection, disease_terms=diseases) logger.debug("Disease table populated") logger.info("Populating gene table") populate_genes(connection=connection, genes=genes) logger.debug("Gene table populated")
def hpo_terms(request): """Get hpo terms""" hpo_lines = [ "#Format: HPO-ID<tab>HPO-Name<tab>Gene-ID<tab>Gene-Name", "HP:0003295\tImpaired FSH and LH secretion", "HP:0003564\tFolate-dependent fragile site at Xq28", "HP:0003565\tElevated erythrocyte sedimentation rate", "HP:0003562\tAbnormal metaphyseal vascular invasion", "HP:0003563\tHypobetalipoproteinemia", "HP:0003292\tDecreased serum leptin", "HP:0003561\tBirth length less than 3rd percentile", "HP:0001403\tMacrovesicular hepatic steatosis", "HP:0003298\tSpina bifida occulta", "HP:0003296\tHyperthreoninuria", "HP:0003568\tDecreased glucosephosphate isomerase activity", "HP:0012393\tAllergy", "HP:0003297\tHyperlysinuria", "HP:0001153\tSeptate v****a", "HP:0001152\tSaccadic smooth pursuit", "HP:0030012\tAbnormal female reproductive system physiology", "HP:0003560\tMuscular dystrophy", "HP:0000767\tPectus excavatum", "HP:0003042\tElbow dislocation", "HP:0005280\tDepressed nasal bridge", "HP:0001363\tCraniosynostosis", "HP:0000772\tAbnormality of the ribs", "HP:0001195\tSingle umbilical artery", "HP:0002987\tElbow flexion contracture" ] return parse_phenotypes(hpo_lines)
def build_database(connection): """Build the hpo database Args: conn (sqlite3.connect): A database connection object """ logger.info("Fetching disease to gene file") disease_to_genes = getreader('utf-8')( gzip.open(disease_to_genes_path), errors='replace') logger.info("Fetching phenotypes file") phenotype_to_genes = getreader('utf-8')( gzip.open(phenotypes_path), errors='replace') logger.info("Fetching genes file") genes = getreader('utf-8')( gzip.open(genes_path), errors='replace') logger.info("Parsing phenotypes to gene file") phenotypes = parse_phenotypes(phenotype_to_genes) logger.info("Parsing disease to gene file") diseases = parse_diseases(disease_to_genes) logger.info("Parsing genes file") genes = parse_genes(genes) logger.info("Populating hpo table") populate_hpo( connection=connection, hpo_terms=phenotypes ) logger.debug("Hpo table populated") logger.info("Populating disease table") populate_disease( connection=connection, disease_terms=diseases ) logger.debug("Disease table populated") logger.info("Populating gene table") populate_genes( connection=connection, genes=genes ) logger.debug("Gene table populated")