Пример #1
0
def generate_mim2genes(genes, api_key):
    """Generate a reduced file with omim mim2gene information
    
    Args:
        genes(dict): A dictionary with hgnc_symbol as key and hgnc_id as value
        api_key(str)

    Yields:
        print_line(str): Lines from the reduced file
    """

    mim_files = fetch_mim_files(api_key, mim2genes=True)
    mim2gene_lines = mim_files['mim2genes']

    for line in mim2gene_lines:
        if line.startswith('#'):
            yield line
        else:
            break

    for gene_info in parse_mim2gene(mim2gene_lines):
        hgnc_symbol = gene_info.get('hgnc_symbol')
        if not hgnc_symbol:
            continue
        if hgnc_symbol in genes:
            yield gene_info['raw']
Пример #2
0
def generate_mim2genes(genes, api_key):
    """Generate a reduced file with omim mim2gene information
    
    Args:
        genes(dict): A dictionary with hgnc_symbol as key and hgnc_id as value
        api_key(str)

    Yields:
        print_line(str): Lines from the reduced file
    """
    
    mim_files = fetch_mim_files(api_key, mim2genes=True)
    mim2gene_lines = mim_files['mim2genes']
    
    for line in mim2gene_lines:
        if line.startswith('#'):
            yield line
        else:
            break
    
    for gene_info in parse_mim2gene(mim2gene_lines):
        hgnc_symbol = gene_info.get('hgnc_symbol')
        if not hgnc_symbol:
            continue
        if hgnc_symbol in genes:
            yield gene_info['raw']
Пример #3
0
def test_parse_mim2gene():
    ## GIVEN some lines from a mim2gene file
    mim2gene_info = parse_mim2gene(MIM2GENE_LINES)

    ## WHEN parsing the lines
    first_entry = next(mim2gene_info)

    ## ASSERT that they are correctly parsed

    # First entry is a gene so it should have a hgnc symbol
    assert first_entry['mim_number'] == 615291
    assert first_entry['entry_type'] == 'gene'
    assert first_entry['hgnc_symbol'] == 'B3GALT6'
Пример #4
0
def test_parse_mim2gene(mim2gene_lines):
    ## GIVEN some lines from a mim2gene file
    mim2gene_info = parse_mim2gene(mim2gene_lines)

    ## WHEN parsing the lines
    first_entry = next(mim2gene_info)

    ## ASSERT that they are correctly parsed

    # First entry is a gene so it should have a hgnc symbol
    assert first_entry["mim_number"] == 615291
    assert first_entry["entry_type"] == "gene"
    assert first_entry["hgnc_symbol"] == "B3GALT6"
Пример #5
0
def test_parse_mim2gene():
    ## GIVEN some lines from a mim2gene file
    mim2gene_info = parse_mim2gene(MIM2GENE_LINES)
    
    ## WHEN parsing the lines
    first_entry = next(mim2gene_info)
    
    ## ASSERT that they are correctly parsed
    
    # First entry is a gene so it should have a hgnc symbol
    assert first_entry['mim_number'] == 615291
    assert first_entry['entry_type'] == 'gene'
    assert first_entry['hgnc_symbol'] == 'B3GALT6'
Пример #6
0
def test_parse_mim2gene_file(mim2gene_handle):
    # Just check that the file exists and that some result is given
    for i, res in enumerate(parse_mim2gene(mim2gene_handle)):
        assert 'mim_number' in res
    assert i > 0
Пример #7
0
def test_parse_mim2gene_file(mim2gene_handle):
    # Just check that the file exists and that some result is given
    for i,res in enumerate(parse_mim2gene(mim2gene_handle)):
        assert 'mim_number' in res
    assert i > 0