def gene_variants(store, variants_query, page=<NUM_LIT:1>, per_page=<NUM_LIT:50>):
variant_count = variants_query.count()<EOL>skip_count = per_page * max(page - <NUM_LIT:1>, <NUM_LIT:0>)<EOL>more_variants = True if variant_count > (skip_count + per_page) else False<EOL>variant_res = variants_query.skip(skip_count).limit(per_page)<EOL>my_institutes = list(inst['<STR_LIT>'] for inst in user_institutes(store, current_user))<EOL>variants = []<EOL>for variant_obj in variant_res:<EOL><INDENT>if variant_obj['<STR_LIT>'] not in my_institutes:<EOL><INDENT>LOG.warning("<STR_LIT>".format(variant_obj['<STR_LIT>']))<EOL>continue<EOL><DEDENT>variant_case_obj = store.case(case_id=variant_obj['<STR_LIT>'])<EOL>if not variant_case_obj:<EOL><INDENT>continue<EOL><DEDENT>case_display_name = variant_case_obj.get('<STR_LIT>')<EOL>variant_obj['<STR_LIT>'] = case_display_name<EOL>genome_build = variant_case_obj.get('<STR_LIT>', '<STR_LIT>')<EOL>if genome_build not in ['<STR_LIT>','<STR_LIT>']:<EOL><INDENT>genome_build = '<STR_LIT>'<EOL><DEDENT>variant_genes = variant_obj.get('<STR_LIT>')<EOL>if variant_genes is not None:<EOL><INDENT>for gene_obj in variant_genes:<EOL><INDENT>if not gene_obj['<STR_LIT>']:<EOL><INDENT>continue<EOL><DEDENT>if gene_obj.get('<STR_LIT>') is None or gene_obj.get('<STR_LIT:description>') is None:<EOL><INDENT>hgnc_gene = store.hgnc_gene(gene_obj['<STR_LIT>'], build=genome_build)<EOL>if not hgnc_gene:<EOL><INDENT>continue<EOL><DEDENT>gene_obj['<STR_LIT>'] = hgnc_gene['<STR_LIT>']<EOL>gene_obj['<STR_LIT:description>'] = hgnc_gene['<STR_LIT:description>']<EOL><DEDENT><DEDENT><DEDENT>gene_ids = []<EOL>gene_symbols = []<EOL>hgvs_c = []<EOL>hgvs_p = []<EOL>variant_genes = variant_obj.get('<STR_LIT>')<EOL>if variant_genes is not None:<EOL><INDENT>functional_annotation = '<STR_LIT>'<EOL>for gene_obj in variant_genes:<EOL><INDENT>hgnc_id = gene_obj['<STR_LIT>']<EOL>gene_symbol = gene(store, hgnc_id)['<STR_LIT>']<EOL>gene_ids.append(hgnc_id)<EOL>gene_symbols.append(gene_symbol)<EOL>hgvs_nucleotide = '<STR_LIT:->'<EOL>transcripts_list = gene_obj.get('<STR_LIT>')<EOL>for transcript_obj in transcripts_list:<EOL><INDENT>if transcript_obj.get('<STR_LIT>') and transcript_obj.get('<STR_LIT>') is True:<EOL><INDENT>hgvs_nucleotide = str(transcript_obj.get('<STR_LIT>'))<EOL>hgvs_protein = str(transcript_obj.get('<STR_LIT>'))<EOL><DEDENT><DEDENT>hgvs_c.append(hgvs_nucleotide)<EOL>hgvs_p.append(hgvs_protein)<EOL><DEDENT>if len(gene_symbols) == <NUM_LIT:1>:<EOL><INDENT>if(hgvs_p[<NUM_LIT:0>] != "<STR_LIT:None>"):<EOL><INDENT>hgvs = hgvs_p[<NUM_LIT:0>]<EOL><DEDENT>elif(hgvs_c[<NUM_LIT:0>] != "<STR_LIT:None>"):<EOL><INDENT>hgvs = hgvs_c[<NUM_LIT:0>]<EOL><DEDENT>else:<EOL><INDENT>hgvs = "<STR_LIT:->"<EOL><DEDENT>variant_obj['<STR_LIT>'] = hgvs<EOL><DEDENT>variant_obj.update(get_predictions(variant_genes))<EOL><DEDENT>variants.append(variant_obj)<EOL><DEDENT>return {<EOL>'<STR_LIT>': variants,<EOL>'<STR_LIT>': more_variants,<EOL>}<EOL>
Pre-process list of variants.