scout/parse/ensembl.py
def parse_ensembl_line(line, header):
    """Parse an ensembl formated line

        Args:
            line(list): A list with ensembl gene info
            header(list): A list with the header info

        Returns:
            ensembl_info(dict): A dictionary with the relevant info
    """
    line = line.rstrip().split('\t')
    header = [head.lower() for head in header]
    raw_info = dict(zip(header, line))

    ensembl_info = {}

    for word in raw_info:
        value = raw_info[word]

        if not value:
            continue

        if 'chromosome' in word:
            ensembl_info['chrom'] = value

        if 'gene' in word:
            if 'id' in word:
                ensembl_info['ensembl_gene_id'] = value
            elif 'start' in word:
                ensembl_info['gene_start'] = int(value)
            elif 'end' in word:
                ensembl_info['gene_end'] = int(value)

        if 'hgnc symbol' in word:
            ensembl_info['hgnc_symbol'] = value
        if "gene name" in word:
            ensembl_info['hgnc_symbol'] = value

        if 'hgnc id' in word:
            ensembl_info['hgnc_id'] = int(value.split(':')[-1])

        if 'transcript' in word:
            if 'id' in word:
                ensembl_info['ensembl_transcript_id'] = value
            elif 'start' in word:
                ensembl_info['transcript_start'] = int(value)
            elif 'end' in word:
                ensembl_info['transcript_end'] = int(value)

        if 'exon' in word:
            if 'start' in word:
                ensembl_info['exon_start'] = int(value)
            elif 'end' in word:
                ensembl_info['exon_end'] = int(value)
            elif 'rank' in word:
                ensembl_info['exon_rank'] = int(value)

        if 'utr' in word:

            if 'start' in word:
                if '5' in word:
                    ensembl_info['utr_5_start'] = int(value)
                elif '3' in word:
                    ensembl_info['utr_3_start'] = int(value)
            elif 'end' in word:
                if '5' in word:
                    ensembl_info['utr_5_end'] = int(value)
                elif '3' in word:
                    ensembl_info['utr_3_end'] = int(value)

        if 'strand' in word:
            ensembl_info['strand'] = int(value)

        if 'refseq' in word:
            if 'mrna' in word:
                if 'predicted' in word:
                    ensembl_info['refseq_mrna_predicted'] = value
                else:
                    ensembl_info['refseq_mrna'] = value

            if 'ncrna' in word:
                ensembl_info['refseq_ncrna'] = value

    return ensembl_info
def parse_ensembl_line(line, header):
    line = line.rstrip().split('\t')
    header = [head.lower() for head in header]
    raw_info = dict(zip(header, line))

    ensembl_info = {}

    for word in raw_info:
        value = raw_info[word]

        if not value:
            continue

        if 'chromosome' in word:
            ensembl_info['chrom'] = value

        if 'gene' in word:
            if 'id' in word:
                ensembl_info['ensembl_gene_id'] = value
            elif 'start' in word:
                ensembl_info['gene_start'] = int(value)
            elif 'end' in word:
                ensembl_info['gene_end'] = int(value)

        if 'hgnc symbol' in word:
            ensembl_info['hgnc_symbol'] = value
        if "gene name" in word:
            ensembl_info['hgnc_symbol'] = value

        if 'hgnc id' in word:
            ensembl_info['hgnc_id'] = int(value.split(':')[-1])

        if 'transcript' in word:
            if 'id' in word:
                ensembl_info['ensembl_transcript_id'] = value
            elif 'start' in word:
                ensembl_info['transcript_start'] = int(value)
            elif 'end' in word:
                ensembl_info['transcript_end'] = int(value)

        if 'exon' in word:
            if 'start' in word:
                ensembl_info['exon_start'] = int(value)
            elif 'end' in word:
                ensembl_info['exon_end'] = int(value)
            elif 'rank' in word:
                ensembl_info['exon_rank'] = int(value)

        if 'utr' in word:

            if 'start' in word:
                if '5' in word:
                    ensembl_info['utr_5_start'] = int(value)
                elif '3' in word:
                    ensembl_info['utr_3_start'] = int(value)
            elif 'end' in word:
                if '5' in word:
                    ensembl_info['utr_5_end'] = int(value)
                elif '3' in word:
                    ensembl_info['utr_3_end'] = int(value)

        if 'strand' in word:
            ensembl_info['strand'] = int(value)

        if 'refseq' in word:
            if 'mrna' in word:
                if 'predicted' in word:
                    ensembl_info['refseq_mrna_predicted'] = value
                else:
                    ensembl_info['refseq_mrna'] = value

            if 'ncrna' in word:
                ensembl_info['refseq_ncrna'] = value

    return ensembl_info
def parse_ensembl_line ( line , header ) : line = line . rstrip ( ) . split ( '\t' ) header = [ head . lower ( ) for head in header ] raw_info = dict ( zip ( header , line ) ) ensembl_info = { } for word in raw_info : value = raw_info [ word ] if not value : continue if 'chromosome' in word : ensembl_info [ 'chrom' ] = value if 'gene' in word : if 'id' in word : ensembl_info [ 'ensembl_gene_id' ] = value elif 'start' in word : ensembl_info [ 'gene_start' ] = int ( value ) elif 'end' in word : ensembl_info [ 'gene_end' ] = int ( value ) if 'hgnc symbol' in word : ensembl_info [ 'hgnc_symbol' ] = value if "gene name" in word : ensembl_info [ 'hgnc_symbol' ] = value if 'hgnc id' in word : ensembl_info [ 'hgnc_id' ] = int ( value . split ( ':' ) [ - 1 ] ) if 'transcript' in word : if 'id' in word : ensembl_info [ 'ensembl_transcript_id' ] = value elif 'start' in word : ensembl_info [ 'transcript_start' ] = int ( value ) elif 'end' in word : ensembl_info [ 'transcript_end' ] = int ( value ) if 'exon' in word : if 'start' in word : ensembl_info [ 'exon_start' ] = int ( value ) elif 'end' in word : ensembl_info [ 'exon_end' ] = int ( value ) elif 'rank' in word : ensembl_info [ 'exon_rank' ] = int ( value ) if 'utr' in word : if 'start' in word : if '5' in word : ensembl_info [ 'utr_5_start' ] = int ( value ) elif '3' in word : ensembl_info [ 'utr_3_start' ] = int ( value ) elif 'end' in word : if '5' in word : ensembl_info [ 'utr_5_end' ] = int ( value ) elif '3' in word : ensembl_info [ 'utr_3_end' ] = int ( value ) if 'strand' in word : ensembl_info [ 'strand' ] = int ( value ) if 'refseq' in word : if 'mrna' in word : if 'predicted' in word : ensembl_info [ 'refseq_mrna_predicted' ] = value else : ensembl_info [ 'refseq_mrna' ] = value if 'ncrna' in word : ensembl_info [ 'refseq_ncrna' ] = value return ensembl_info
Parse an ensembl formated line

        Args:
            line(list): A list with ensembl gene info
            header(list): A list with the header info

        Returns:
            ensembl_info(dict): A dictionary with the relevant info
Parse an ensembl formated line