def test_parse_hpo_lines():
    ## GIVEN some lines that correspends to a hpo file
    hpo_lines = [
        "#Format: HPO-ID<tab>HPO-Name<tab>Gene-ID<tab>Gene-Name",
        "HP:0000878\t11 pairs of ribs\t126792\tB3GALT6",
        "HP:0000878\t11 pairs of ribs\t5932\tRBBP8"
    ]
    ## WHEN parsing the lines
    hpo_dict = parse_hpo_phenotypes(hpo_lines)
    ## THEN assert that the correct information was parsed
    assert len(hpo_dict) == 1
    assert "HP:0000878" in hpo_dict
    assert set(hpo_dict['HP:0000878']['hgnc_symbols']) == set(['B3GALT6', 'RBBP8'])
Exemplo n.º 2
0
def test_parse_hpo_lines():
    ## GIVEN some lines that correspends to a hpo file
    hpo_lines = [
        "#Format: HPO-ID<tab>HPO-Name<tab>Gene-ID<tab>Gene-Name",
        "HP:0000878\t11 pairs of ribs\t126792\tB3GALT6",
        "HP:0000878\t11 pairs of ribs\t5932\tRBBP8"
    ]
    ## WHEN parsing the lines
    hpo_dict = parse_hpo_phenotypes(hpo_lines)
    ## THEN assert that the correct information was parsed
    assert len(hpo_dict) == 1
    assert "HP:0000878" in hpo_dict
    assert set(hpo_dict['HP:0000878']['hgnc_symbols']) == set(
        ['B3GALT6', 'RBBP8'])
Exemplo n.º 3
0
def load_hpo_terms(adapter, hpo_lines, genes):
    """Load the hpo terms into the database
    
    Parse the hpo lines, build the objects and add them to the database
    
    Args:
        adapter(MongoAdapter)
        hpo_lines(iterable(str))
    """
    hpo_terms = parse_hpo_phenotypes(hpo_lines)

    start_time = datetime.now()

    logger.info("Loading the hpo terms...")
    for nr_terms, hpo_id in enumerate(hpo_terms):
        hpo_info = hpo_terms[hpo_id]
        hpo_obj = build_hpo_term(hpo_info, genes)

        adapter.load_hpo_term(hpo_obj)

    logger.info("Loading done. Nr of terms loaded {0}".format(nr_terms))
    logger.info("Time to load terms: {0}".format(datetime.now() - start_time))
Exemplo n.º 4
0
def hpo_terms(request, hpo_terms_file):
    """Get a dictionary with the hpo terms"""
    print('')
    hpo_terms_handle = get_file_handle(hpo_terms_file)
    return parse_hpo_phenotypes(hpo_terms_handle)
Exemplo n.º 5
0
def test_parse_hpo_terms(hpo_terms_handle):
    hpo_terms = parse_hpo_phenotypes(hpo_terms_handle)

    for hpo_id in hpo_terms:
        assert hpo_terms[hpo_id]['hpo_id'] == hpo_id