def update_panel(store, panel_name, csv_lines, option):
new_genes= []<EOL>panel_obj = store.gene_panel(panel_name)<EOL>if panel_obj is None:<EOL><INDENT>return None<EOL><DEDENT>try:<EOL><INDENT>new_genes = parse_genes(csv_lines) <EOL><DEDENT>except SyntaxError as error:<EOL><INDENT>flash(error.args[<NUM_LIT:0>], '<STR_LIT>')<EOL>return None<EOL><DEDENT>if option == '<STR_LIT:replace>':<EOL><INDENT>for gene in panel_obj['<STR_LIT>']:<EOL><INDENT>gene['<STR_LIT>'] = gene['<STR_LIT>']<EOL>store.add_pending(panel_obj, gene, action='<STR_LIT>', info=None)<EOL><DEDENT><DEDENT>for new_gene in new_genes:<EOL><INDENT>if not new_gene['<STR_LIT>']:<EOL><INDENT>flash("<STR_LIT>".format(new_gene['<STR_LIT>']),'<STR_LIT>')<EOL>continue<EOL><DEDENT>gene_obj = store.hgnc_gene(new_gene['<STR_LIT>'])<EOL>if gene_obj is None:<EOL><INDENT>flash("<STR_LIT>".format(new_gene['<STR_LIT>'], new_gene['<STR_LIT>']),'<STR_LIT>')<EOL>continue<EOL><DEDENT>if new_gene['<STR_LIT>'] and gene_obj['<STR_LIT>'] != new_gene['<STR_LIT>']:<EOL><INDENT>flash("<STR_LIT>".format(<EOL>gene_obj['<STR_LIT>'], new_gene['<STR_LIT>']), '<STR_LIT>')<EOL><DEDENT>info_data = {<EOL>'<STR_LIT>': new_gene['<STR_LIT>'],<EOL>'<STR_LIT>': new_gene['<STR_LIT>'],<EOL>'<STR_LIT>': new_gene['<STR_LIT>'],<EOL>'<STR_LIT>': new_gene['<STR_LIT>'],<EOL>'<STR_LIT>': new_gene['<STR_LIT>'],<EOL>}<EOL>if option == '<STR_LIT:replace>': <EOL><INDENT>action = '<STR_LIT>'<EOL><DEDENT>else: <EOL><INDENT>existing_genes = {gene['<STR_LIT>'] for gene in panel_obj['<STR_LIT>']}<EOL>action = '<STR_LIT>' if gene_obj['<STR_LIT>'] in existing_genes else '<STR_LIT>'<EOL><DEDENT>store.add_pending(panel_obj, gene_obj, action=action, info=info_data)<EOL><DEDENT>return panel_obj<EOL>
Update an existing gene panel with genes.

    Args:
        store(scout.adapter.MongoAdapter)
        panel_name(str)
        csv_lines(iterable(str)): Stream with genes
        option(str): 'add' or 'replace'

    Returns:
        panel_obj(dict)