scout/parse/hpo.py
def parse_hpo_diseases(hpo_lines):
    """Parse hpo disease phenotypes
    
        Args:
            hpo_lines(iterable(str))
        
        Returns:
            diseases(dict): A dictionary with mim numbers as keys
    """
    diseases = {}
    LOG.info("Parsing hpo diseases...")
    for index, line in enumerate(hpo_lines):
        # First line is a header
        if index == 0:
            continue
        # Skip empty lines
        if not len(line) > 3:
            continue
        # Parse the info
        disease_info = parse_hpo_disease(line)
        # Skip the line if there where no info
        if not disease_info:
            continue
        disease_nr = disease_info['disease_nr']
        hgnc_symbol = disease_info['hgnc_symbol']
        hpo_term = disease_info['hpo_term']
        source = disease_info['source']
        disease_id = "{0}:{1}".format(source, disease_nr)
        
        if disease_id not in diseases:
            diseases[disease_id] = {
                'disease_nr': disease_nr,
                'source': source,
                'hgnc_symbols': set(),
                'hpo_terms': set(),
            }

        if hgnc_symbol:
            diseases[disease_id]['hgnc_symbols'].add(hgnc_symbol)
        if hpo_term:
            diseases[disease_id]['hpo_terms'].add(hpo_term)

    LOG.info("Parsing done.")
    return diseases
def parse_hpo_diseases(hpo_lines):
    """Parse hpo disease phenotypes
    
        Args:
            hpo_lines(iterable(str))
        
        Returns:
            diseases(dict): A dictionary with mim numbers as keys
    """
    diseases = {}
    LOG.info("Parsing hpo diseases...")
    for index, line in enumerate(hpo_lines):
        # First line is a header
        if index == 0:
            continue
        # Skip empty lines
        if not len(line) > 3:
            continue
        # Parse the info
        disease_info = parse_hpo_disease(line)
        # Skip the line if there where no info
        if not disease_info:
            continue
        disease_nr = disease_info['disease_nr']
        hgnc_symbol = disease_info['hgnc_symbol']
        hpo_term = disease_info['hpo_term']
        source = disease_info['source']
        disease_id = "{0}:{1}".format(source, disease_nr)
        
        if disease_id not in diseases:
            diseases[disease_id] = {
                'disease_nr': disease_nr,
                'source': source,
                'hgnc_symbols': set(),
                'hpo_terms': set(),
            }

        if hgnc_symbol:
            diseases[disease_id]['hgnc_symbols'].add(hgnc_symbol)
        if hpo_term:
            diseases[disease_id]['hpo_terms'].add(hpo_term)

    LOG.info("Parsing done.")
    return diseases
def parse_hpo_diseases ( hpo_lines ) : diseases = { } LOG . info ( "Parsing hpo diseases..." ) for index , line in enumerate ( hpo_lines ) : # First line is a header if index == 0 : continue # Skip empty lines if not len ( line ) > 3 : continue # Parse the info disease_info = parse_hpo_disease ( line ) # Skip the line if there where no info if not disease_info : continue disease_nr = disease_info [ 'disease_nr' ] hgnc_symbol = disease_info [ 'hgnc_symbol' ] hpo_term = disease_info [ 'hpo_term' ] source = disease_info [ 'source' ] disease_id = "{0}:{1}" . format ( source , disease_nr ) if disease_id not in diseases : diseases [ disease_id ] = { 'disease_nr' : disease_nr , 'source' : source , 'hgnc_symbols' : set ( ) , 'hpo_terms' : set ( ) , } if hgnc_symbol : diseases [ disease_id ] [ 'hgnc_symbols' ] . add ( hgnc_symbol ) if hpo_term : diseases [ disease_id ] [ 'hpo_terms' ] . add ( hpo_term ) LOG . info ( "Parsing done." ) return diseases
Parse hpo disease phenotypes
    
        Args:
            hpo_lines(iterable(str))
        
        Returns:
            diseases(dict): A dictionary with mim numbers as keys
Parse hpo disease phenotypes Args : hpo_lines ( iterable ( str )) Returns : diseases ( dict ) : A dictionary with mim numbers as keys