def read_ccle_variants(gene_names): """Return genetic variants reported by CCLE (via web service)""" cell_lines_db = [cl + '_SKIN' for cl in cell_lines] nons = cbio_client.get_ccle_mutations(gene_names, cell_lines_db, 'nonsense') miss = cbio_client.get_ccle_mutations(gene_names, cell_lines_db, 'missense') tmp = copy.deepcopy(nons) for cell_line, content in tmp.items(): for gene, muts in content.items(): if not muts: nons[cell_line].pop(gene, None) tmp = copy.deepcopy(miss) for cell_line, content in tmp.items(): for gene, muts in content.items(): if not muts: miss[cell_line].pop(gene, None) continue # Check for usable AA substitution grouped_muts = [] for mut in muts: match = re.match('([A-Z])(\d+)([A-Z])', mut) if not match: continue groups = match.groups() if len(groups) != 3: continue grouped_muts.append(groups) miss[cell_line][gene] = grouped_muts variants = {} variants['missense'] = miss variants['nonsense'] = nons return variants
def test_get_ccle_mutations(): muts = cbio_client.get_ccle_mutations(['BRAF', 'AKT1'], ['LOXIMVI_SKIN', 'A101D_SKIN']) assert len([x for x in muts]) == 2 assert 'V600E' in muts['LOXIMVI_SKIN']['BRAF'] assert 'V600E' in muts['A101D_SKIN']['BRAF'] assert 'I208V' in muts['LOXIMVI_SKIN']['BRAF'] assert 'I208V' not in muts['A101D_SKIN']['BRAF'] assert len(muts['LOXIMVI_SKIN']['AKT1']) == 0 assert len(muts['A101D_SKIN']['AKT1']) == 0
def test_get_ccle_mutations(): muts = cbio_client.get_ccle_mutations(['BRAF', 'AKT1'], ['LOXIMVI_SKIN', 'A101D_SKIN']) assert len([x for x in muts]) == 2 assert 'V600E' in muts['LOXIMVI_SKIN']['BRAF'] assert 'V600E' in muts['A101D_SKIN']['BRAF'] assert 'I208V' in muts['LOXIMVI_SKIN']['BRAF'] assert 'I208V' not in muts['A101D_SKIN']['BRAF'] assert len(muts['LOXIMVI_SKIN']['AKT1']) == 0 assert len(muts['A101D_SKIN']['AKT1']) == 0
def get_ccle_mutations(): """Get CCLE mutations returns the amino acid changes for a given list of genes and cell lines """ if request.method == 'OPTIONS': return {} response = request.body.read().decode('utf-8') body = json.loads(response) gene_list = body.get('gene_list') cell_lines = body.get('cell_lines') mutations = cbio_client.get_ccle_mutations(gene_list, cell_lines) res = {'mutations': mutations} return res
def get_ccle_mutations(): """Get CCLE mutations returns the amino acid changes for a given list of genes and cell lines """ if request.method == 'OPTIONS': return {} response = request.body.read().decode('utf-8') body = json.loads(response) gene_list = body.get('gene_list') cell_lines = body.get('cell_lines') mutations = cbio_client.get_ccle_mutations(gene_list, cell_lines) res = {'mutations': mutations} return res
def get_mutations(gene_names, cell_types): """Return protein amino acid changes in given genes and cell types. Parameters ---------- gene_names : list HGNC gene symbols for which mutations are queried. cell_types : list List of cell type names in which mutations are queried. The cell type names follow the CCLE database conventions. Example: LOXIMVI_SKIN, BT20_BREAST Returns ------- res : dict[dict[list]] A dictionary keyed by cell line, which contains another dictionary that is keyed by gene name, with a list of amino acid substitutions as values. """ mutations = cbio_client.get_ccle_mutations(gene_names, cell_types) return mutations
def get_mutations(gene_names, cell_types): """Return protein amino acid changes in given genes and cell types. Parameters ---------- gene_names : list HGNC gene symbols for which mutations are queried. cell_types : list List of cell type names in which mutations are queried. The cell type names follow the CCLE database conventions. Example: LOXIMVI_SKIN, BT20_BREAST Returns ------- res : dict[dict[list]] A dictionary keyed by cell line, which contains another dictionary that is keyed by gene name, with a list of amino acid substitutions as values. """ mutations = cbio_client.get_ccle_mutations(gene_names, cell_types) return mutations
def post(self): """Get CCLE mutations Parameters ---------- gene_list : list[str] A list of HGNC gene symbols to get mutations in cell_lines : list[str] A list of CCLE cell line names to get mutations for. Returns ------- mutations : dict The result from cBioPortal as a dict in the format {cell_line : {gene : [mutation1, mutation2, ...] }} """ args = request.json gene_list = args.get('gene_list') cell_lines = args.get('cell_lines') mutations = cbio_client.get_ccle_mutations(gene_list, cell_lines) res = {'mutations': mutations} return res