def getProteinExpressData(): dbc = DBConnection() query_filed = {"entrez_id": 1, "symbol": 1, "_id": 0, 'gene_expression': 1} # name = "51146" name = "85358" if name.isalnum(): if name.isdigit(): query_res = dbc.col.find({"entrez_id": name}, query_filed)[0] else: query_res = dbc.col.find({"symbol": name}, query_filed)[0] if query_res.get('gene_expression'): if query_res['gene_expression'].get('protein_express'): gtex_gene_express_pic = query_res['gene_expression'][ 'protein_express'] print(gtex_gene_express_pic) return gtex_gene_express_pic
def main(): dbc = DBConnection() query_filed = {"entrez_id": 1, "symbol": 1, "_id": 0, 'gene_expression': 1} name = "SHANK3" if name.isalnum(): if name.isdigit(): query_res = dbc.col.find({"entrez_id": name}, query_filed)[0] else: query_res = dbc.col.find({"symbol": name}, query_filed)[0] # pprint(query_res) if query_res.get('gene_expression'): if query_res['gene_expression'].get( 'brainseq_gene_expression_rpkm'): gtex_gene_express_pic = BrainSeqExpressPlot.plot( query_res['gene_expression'] ['brainseq_gene_expression_rpkm']) print(query_res['gene_expression'] ['brainseq_gene_expression_rpkm'])
def getHumanEPCExpressData(): dbc = DBConnection() query_filed = {"entrez_id": 1, "symbol": 1, "_id": 0, 'gene_expression': 1} # name = "234" name = "85358" if name.isalnum(): if name.isdigit(): query_res = dbc.col.find({"entrez_id": name}, query_filed)[0] else: query_res = dbc.col.find({"symbol": name}, query_filed)[0] if query_res.get('gene_expression'): if query_res['gene_expression'].get('human_epc_tpm'): human_epc_exp_data = query_res['gene_expression'][ 'human_epc_tpm'] pprint.pprint(human_epc_exp_data) if isinstance(human_epc_exp_data, list): expData = human_epc_exp_data[0].get('express_data') return expData
def getGexGeneExpressData(): dbc = DBConnection() query_filed = {"entrez_id": 1, "symbol": 1, "_id": 0, 'gene_expression': 1} name = "NSD2" if name.isalnum(): if name.isdigit(): query_res = dbc.col.find({"entrez_id": name}, query_filed)[0] else: query_res = dbc.col.find({"symbol": name}, query_filed)[0] # pprint(query_res) if query_res.get('gene_expression'): if query_res['gene_expression'].get('gtex_v7_gene_tpm'): gtex_brain_data = query_res['gene_expression'][ 'gtex_v7_gene_tpm'] if isinstance(gtex_brain_data, list): gtex_brain_data_dict = gtex_brain_data[0] print(gtex_brain_data_dict) return gtex_brain_data_dict
def getMouseBrainExpressData(): # mainer = MouseBrainExpressPlots('29072') # mainer.run() dbc = DBConnection() query_filed = {"entrez_id": 1, "symbol": 1, "_id": 0, 'gene_expression': 1} # name = "10344" name = "85358" if name.isalnum(): if name.isdigit(): query_res = dbc.col.find({"entrez_id": name}, query_filed)[0] else: query_res = dbc.col.find({"symbol": name}, query_filed)[0] # pprint(query_res) if query_res.get('gene_expression'): if query_res['gene_expression'].get('mouse_brain_tpm'): if isinstance(query_res['gene_expression']['mouse_brain_tpm'], list): expData = query_res['gene_expression']['mouse_brain_tpm'][ 0].get('expree_data') print(expData) return expData
def plot(gene_term): if gene_term.isalnum(): dbc = DBConnection() if gene_term.isdigit(): gene_data = \ dbc.col.find({"entrez_id": gene_term}, {"entrez_id": 1, "transcripts": 1, "dnms": 1, "_id": 0})[0] else: gene_data = \ dbc.col.find({"symbol": gene_term}, {"entrez_id": 1, "transcripts": 1, "dnms": 1, "_id": 0})[0] dnms_on_trans_plot = DNMsOnTranscriptsPlot() pprint(gene_data) if gene_data: transcript_data = gene_data.get('transcripts') dnms_data = gene_data.get('dnms') transcript_list = [] trans_count = 0 dnm_list = [] if transcript_data: for trans_item in transcript_data: transcript_id = trans_item.get('transcript_id') transcript_structure = trans_item.get('structure') region_list = [] for item_region in [ 'coding_exon_region', 'utr3_exon_region', 'utr5_exon_region' ]: if transcript_structure.get(item_region): # print(transcript_structure[item_region]) region_list.append( transcript_structure[item_region]) else: region_list.append([]) transcript_list.append([ transcript_id, region_list[0], region_list[1], region_list[2] ]) transcript_list = sorted( transcript_list, key=lambda x: x[0], reverse=True) # 最先添加(排在最前面的)plotly画图的时候会放在越靠近x轴 trans_count = len(transcript_list) if dnms_data: for dnm_item in dnms_data: if dnm_item.get("Func_refGene") == 'exonic': if dnm_item.get('ExonicFunc_refGene'): s = '%s,%s,%s' % ( dnm_item['start'], dnm_item['variant'], dnm_item['ExonicFunc_refGene']) else: s = '%s,%s' % (dnm_item['start'], dnm_item['variant']) else: if dnm_item.get('Func_refGene'): s = '%s,%s,%s' % (dnm_item['start'], dnm_item['variant'], dnm_item['Func_refGene']) else: s = '%s,%s' % (dnm_item['start'], dnm_item['variant']) dnm_list.append([dnm_item['start'], s]) else: dnm_list.append([]) count_exon_xy, count_utr_xy, fin_DNM_xy = dnms_on_trans_plot.generate_xy( transcript_list, dnm_list) if trans_count: return [ count_exon_xy, count_utr_xy, fin_DNM_xy, trans_count ] else: return '<div>There is no corresponding data published yet, we will update it when such data available. </div>' else: return '<div>There is no corresponding data published yet, we will update it when such data available. </div>' else: return '<div>There is no corresponding data published yet, we will update it when such data available. </div>'
def plot(gene_term): dnms_on_re_plot = DNMsOnRegulatoryPlot() if gene_term.isalnum(): dbc = DBConnection() if gene_term.isdigit(): gene_data = dbc.col.find({"entrez_id": gene_term}, { "entrez_id": 1, "_id": 0, "dnms": 1, "transcripts": 1, "promoter": 1, "enhancer": 1, "symbol": 1 })[0] else: gene_data = dbc.col.find({"symbol": gene_term}, { "entrez_id": 1, "_id": 0, "dnms": 1, "transcripts": 1, "promoter": 1, "enhancer": 1, "symbol": 1 })[0] transcript_list = [] if gene_data: if gene_data.get("transcripts"): for index, item in enumerate(gene_data["transcripts"]): if item.get('structure'): transcript_list.append( dnms_on_re_plot.get_trans_data( item['structure'], item.get('transcript_id'), item.get("strand"))) transcript_list = sorted( transcript_list, key=lambda x: x[0], reverse=True) # 最先添加(排在最前面的)plotly画图的时候会放在越靠近x轴 trans_count = len(transcript_list) re_data = dnms_on_re_plot.get_promoter_and_enhancer_data( gene_data.get('promoter'), gene_data.get('enhancer'), gene_data.get('dnms')) dnms_list = dnms_on_re_plot.get_dnms_data( gene_data.get("dnms")) all_region = dnms_on_re_plot.get_all_region( transcript_list, re_data) all_region = dnms_on_re_plot.drop_duplicate(all_region) all_region = dnms_on_re_plot.sort_list(all_region) dnm_data = dnms_on_re_plot.DNM_sort_by_site(dnms_list) all_frag = dnms_on_re_plot.cut_fragment(all_region) scale_frag = dnms_on_re_plot.scale_fragment( all_frag, dnm_data, re_data) exton_count, exton_count1 = dnms_on_re_plot.count_exton_region_in_fragment( all_frag, scale_frag, transcript_list) exton_plot_data = dnms_on_re_plot.convert_trans_to_xy( exton_count, exton_count1, transcript_list) utr_count, utr_count1 = dnms_on_re_plot.count_utr_region_in_fragment( all_frag, scale_frag, transcript_list) utr_plot_data = dnms_on_re_plot.convert_utr_to_xy( utr_count, utr_count1, transcript_list) if re_data[0] != []: promoter_count, promoter_count1 = dnms_on_re_plot.count_promoter_region_in_fragment( all_frag, scale_frag, re_data) promoter_plot_data = dnms_on_re_plot.convert_regulatory_elements_to_xy( promoter_count, 'Promoter', re_data) else: promoter_plot_data = None if re_data[1] != []: enhancer_count, enhancer_count1 = dnms_on_re_plot.count_enhancer_region_in_fragment( all_frag, scale_frag, re_data) enhancer_plot_data = dnms_on_re_plot.convert_regulatory_elements_to_xy( enhancer_count, 'Enhancer', re_data) else: enhancer_plot_data = None final_dnm = dnms_on_re_plot.mapping_mutation_to_frag( all_frag, scale_frag, dnm_data) dnm_plot_data = dnms_on_re_plot.convert_dnms_to_xy(final_dnm) l = [ exton_plot_data, utr_plot_data, promoter_plot_data, enhancer_plot_data, dnm_plot_data, trans_count ] return l else: return '<div>There is no corresponding data published yet, we will update it when such data available. </div>'