scout/parse/omim.py
def parse_mim2gene(lines):
    """Parse the file called mim2gene
    
    This file describes what type(s) the different mim numbers have.
    The different entry types are: 'gene', 'gene/phenotype', 'moved/removed',
    'phenotype', 'predominantly phenotypes'
    Where:
        gene: Is a gene entry
        gene/phenotype: This entry describes both a phenotype and a gene
        moved/removed: No explanation needed
        phenotype: Describes a phenotype
        predominantly phenotype: Not clearly established (probably phenotype)
    
    Args:
        lines(iterable(str)): The mim2gene lines
    
    Yields:
        parsed_entry(dict)
    
        {
            "mim_number": int, 
            "entry_type": str, 
            "entrez_gene_id": int, 
            "hgnc_symbol": str, 
            "ensembl_gene_id": str,
            "ensembl_transcript_id": str,
        }
    
    """
    LOG.info("Parsing mim2gene")
    header = ["mim_number", "entry_type", "entrez_gene_id", "hgnc_symbol", "ensembl_gene_id"]
    for i, line in enumerate(lines):
        if line.startswith('#'):
            continue
        
        if not len(line) > 0:
            continue

        line = line.rstrip()
        parsed_entry = parse_omim_line(line, header)
        parsed_entry['mim_number'] = int(parsed_entry['mim_number'])
        parsed_entry['raw'] = line
        
        if 'hgnc_symbol' in parsed_entry:
            parsed_entry['hgnc_symbol'] = parsed_entry['hgnc_symbol']
        
        if parsed_entry.get('entrez_gene_id'):
            parsed_entry['entrez_gene_id'] = int(parsed_entry['entrez_gene_id'])
        
        if parsed_entry.get('ensembl_gene_id'):
            ensembl_info = parsed_entry['ensembl_gene_id'].split(',')
            parsed_entry['ensembl_gene_id'] = ensembl_info[0].strip()
            if len(ensembl_info) > 1:
                parsed_entry['ensembl_transcript_id'] = ensembl_info[1].strip()
        
        yield parsed_entry
def parse_mim2gene(lines):
    """Parse the file called mim2gene
    
    This file describes what type(s) the different mim numbers have.
    The different entry types are: 'gene', 'gene/phenotype', 'moved/removed',
    'phenotype', 'predominantly phenotypes'
    Where:
        gene: Is a gene entry
        gene/phenotype: This entry describes both a phenotype and a gene
        moved/removed: No explanation needed
        phenotype: Describes a phenotype
        predominantly phenotype: Not clearly established (probably phenotype)
    
    Args:
        lines(iterable(str)): The mim2gene lines
    
    Yields:
        parsed_entry(dict)
    
        {
            "mim_number": int, 
            "entry_type": str, 
            "entrez_gene_id": int, 
            "hgnc_symbol": str, 
            "ensembl_gene_id": str,
            "ensembl_transcript_id": str,
        }
    
    """
    LOG.info("Parsing mim2gene")
    header = ["mim_number", "entry_type", "entrez_gene_id", "hgnc_symbol", "ensembl_gene_id"]
    for i, line in enumerate(lines):
        if line.startswith('#'):
            continue
        
        if not len(line) > 0:
            continue

        line = line.rstrip()
        parsed_entry = parse_omim_line(line, header)
        parsed_entry['mim_number'] = int(parsed_entry['mim_number'])
        parsed_entry['raw'] = line
        
        if 'hgnc_symbol' in parsed_entry:
            parsed_entry['hgnc_symbol'] = parsed_entry['hgnc_symbol']
        
        if parsed_entry.get('entrez_gene_id'):
            parsed_entry['entrez_gene_id'] = int(parsed_entry['entrez_gene_id'])
        
        if parsed_entry.get('ensembl_gene_id'):
            ensembl_info = parsed_entry['ensembl_gene_id'].split(',')
            parsed_entry['ensembl_gene_id'] = ensembl_info[0].strip()
            if len(ensembl_info) > 1:
                parsed_entry['ensembl_transcript_id'] = ensembl_info[1].strip()
        
        yield parsed_entry
def parse_mim2gene ( lines ) : LOG . info ( "Parsing mim2gene" ) header = [ "mim_number" , "entry_type" , "entrez_gene_id" , "hgnc_symbol" , "ensembl_gene_id" ] for i , line in enumerate ( lines ) : if line . startswith ( '#' ) : continue if not len ( line ) > 0 : continue line = line . rstrip ( ) parsed_entry = parse_omim_line ( line , header ) parsed_entry [ 'mim_number' ] = int ( parsed_entry [ 'mim_number' ] ) parsed_entry [ 'raw' ] = line if 'hgnc_symbol' in parsed_entry : parsed_entry [ 'hgnc_symbol' ] = parsed_entry [ 'hgnc_symbol' ] if parsed_entry . get ( 'entrez_gene_id' ) : parsed_entry [ 'entrez_gene_id' ] = int ( parsed_entry [ 'entrez_gene_id' ] ) if parsed_entry . get ( 'ensembl_gene_id' ) : ensembl_info = parsed_entry [ 'ensembl_gene_id' ] . split ( ',' ) parsed_entry [ 'ensembl_gene_id' ] = ensembl_info [ 0 ] . strip ( ) if len ( ensembl_info ) > 1 : parsed_entry [ 'ensembl_transcript_id' ] = ensembl_info [ 1 ] . strip ( ) yield parsed_entry
Parse the file called mim2gene
    
    This file describes what type(s) the different mim numbers have.
    The different entry types are: 'gene', 'gene/phenotype', 'moved/removed',
    'phenotype', 'predominantly phenotypes'
    Where:
        gene: Is a gene entry
        gene/phenotype: This entry describes both a phenotype and a gene
        moved/removed: No explanation needed
        phenotype: Describes a phenotype
        predominantly phenotype: Not clearly established (probably phenotype)
    
    Args:
        lines(iterable(str)): The mim2gene lines
    
    Yields:
        parsed_entry(dict)
    
        {
            "mim_number": int, 
            "entry_type": str, 
            "entrez_gene_id": int, 
            "hgnc_symbol": str, 
            "ensembl_gene_id": str,
            "ensembl_transcript_id": str,
        }
Parse the file called mim2gene This file describes what type ( s ) the different mim numbers have . The different entry types are : gene gene / phenotype moved / removed phenotype predominantly phenotypes Where : gene : Is a gene entry gene / phenotype : This entry describes both a phenotype and a gene moved / removed : No explanation needed phenotype : Describes a phenotype predominantly phenotype : Not clearly established ( probably phenotype ) Args : lines ( iterable ( str )) : The mim2gene lines Yields : parsed_entry ( dict ) { mim_number : int entry_type : str entrez_gene_id : int hgnc_symbol : str ensembl_gene_id : str ensembl_transcript_id : str }