scout/parse/ensembl.py
def parse_ensembl_transcript_request(result):
    """Parse a dataframe with ensembl transcript information

    Args:
        res(pandas.DataFrame)

    Yields:
        transcript_info(dict)
    """
    LOG.info("Parsing transcripts from request")

    keys = [
        'chrom',
        'ensembl_gene_id',
        'ensembl_transcript_id',
        'transcript_start',
        'transcript_end',
        'refseq_mrna',
        'refseq_mrna_predicted',
        'refseq_ncrna',
    ]
    # for res in result.itertuples():
    for index, row in result.iterrows():
        ensembl_info = {}

        ensembl_info['chrom'] = str(row['chromosome_name'])
        ensembl_info['ensembl_gene_id'] = row['ensembl_gene_id']
        ensembl_info['ensembl_transcript_id'] = row['ensembl_transcript_id']

        ensembl_info['transcript_start'] = int(row['transcript_start'])
        ensembl_info['transcript_end'] = int(row['transcript_end'])

        # Check if refseq data is annotated
        # Pandas represent missing data with nan
        for key in keys[-3:]:
            if type(row[key]) is float:
                ensembl_info[key] = None
            else:
                ensembl_info[key] = row[key]
        yield ensembl_info
def parse_ensembl_transcript_request(result):
    """Parse a dataframe with ensembl transcript information

    Args:
        res(pandas.DataFrame)

    Yields:
        transcript_info(dict)
    """
    LOG.info("Parsing transcripts from request")

    keys = [
        'chrom',
        'ensembl_gene_id',
        'ensembl_transcript_id',
        'transcript_start',
        'transcript_end',
        'refseq_mrna',
        'refseq_mrna_predicted',
        'refseq_ncrna',
    ]
    # for res in result.itertuples():
    for index, row in result.iterrows():
        ensembl_info = {}

        ensembl_info['chrom'] = str(row['chromosome_name'])
        ensembl_info['ensembl_gene_id'] = row['ensembl_gene_id']
        ensembl_info['ensembl_transcript_id'] = row['ensembl_transcript_id']

        ensembl_info['transcript_start'] = int(row['transcript_start'])
        ensembl_info['transcript_end'] = int(row['transcript_end'])

        # Check if refseq data is annotated
        # Pandas represent missing data with nan
        for key in keys[-3:]:
            if type(row[key]) is float:
                ensembl_info[key] = None
            else:
                ensembl_info[key] = row[key]
        yield ensembl_info
Parse a dataframe with ensembl transcript information

    Args:
        res(pandas.DataFrame)

    Yields:
        transcript_info(dict)