scout/utils/link.py
def genes_by_alias(hgnc_genes):
    """Return a dictionary with hgnc symbols as keys

    Value of the dictionaries are information about the hgnc ids for a symbol.
    If the symbol is primary for a gene then 'true_id' will exist.
    A list of hgnc ids that the symbol points to is in ids.

    Args:
        hgnc_genes(dict): a dictionary with hgnc_id as key and gene info as value

    Returns:
        alias_genes(dict):
            {
                'hgnc_symbol':{
                    'true_id': int,
                    'ids': list(int)
                    }
            }
    """
    alias_genes = {}
    for hgnc_id in hgnc_genes:
        gene = hgnc_genes[hgnc_id]
        # This is the primary symbol:
        hgnc_symbol = gene['hgnc_symbol']

        for alias in gene['previous_symbols']:
            true_id = None
            if alias == hgnc_symbol:
                true_id = hgnc_id
            if alias in alias_genes:
                alias_genes[alias.upper()]['ids'].add(hgnc_id)
                if true_id:
                    alias_genes[alias.upper()]['true_id'] = hgnc_id
            else:
                alias_genes[alias.upper()] = {
                    'true': true_id,
                    'ids': set([hgnc_id])
                }

    return alias_genes
def genes_by_alias(hgnc_genes):
    alias_genes = {}
    for hgnc_id in hgnc_genes:
        gene = hgnc_genes[hgnc_id]
        # This is the primary symbol:
        hgnc_symbol = gene['hgnc_symbol']

        for alias in gene['previous_symbols']:
            true_id = None
            if alias == hgnc_symbol:
                true_id = hgnc_id
            if alias in alias_genes:
                alias_genes[alias.upper()]['ids'].add(hgnc_id)
                if true_id:
                    alias_genes[alias.upper()]['true_id'] = hgnc_id
            else:
                alias_genes[alias.upper()] = {
                    'true': true_id,
                    'ids': set([hgnc_id])
                }

    return alias_genes
def genes_by_alias ( hgnc_genes ) : alias_genes = { } for hgnc_id in hgnc_genes : gene = hgnc_genes [ hgnc_id ] # This is the primary symbol: hgnc_symbol = gene [ 'hgnc_symbol' ] for alias in gene [ 'previous_symbols' ] : true_id = None if alias == hgnc_symbol : true_id = hgnc_id if alias in alias_genes : alias_genes [ alias . upper ( ) ] [ 'ids' ] . add ( hgnc_id ) if true_id : alias_genes [ alias . upper ( ) ] [ 'true_id' ] = hgnc_id else : alias_genes [ alias . upper ( ) ] = { 'true' : true_id , 'ids' : set ( [ hgnc_id ] ) } return alias_genes
Return a dictionary with hgnc symbols as keys

    Value of the dictionaries are information about the hgnc ids for a symbol.
    If the symbol is primary for a gene then 'true_id' will exist.
    A list of hgnc ids that the symbol points to is in ids.

    Args:
        hgnc_genes(dict): a dictionary with hgnc_id as key and gene info as value

    Returns:
        alias_genes(dict):
            {
                'hgnc_symbol':{
                    'true_id': int,
                    'ids': list(int)
                    }
            }
Return a dictionary with hgnc symbols as keys