def get(self): args = self.request.arguments form = ControlsForm() defaultargs = {'path':'','cutoff':5,'cutoff_method':'rank', 'view':'promiscuous','n':2,'cached':1} for k in defaultargs: if k in args: defaultargs[k] = args[k][0] path = defaultargs['path'].strip() view = defaultargs['view'] usecached = defaultargs['cached'] if usecached == 1: print ('using cached results') if not os.path.exists(path): msg = help_msg() self.render('global.html', form=form, msg=msg, path=path, status=0) preds = web.get_predictors(path) data = {} if view == 'summary': for P in preds: if P.data is None: continue seqs = web.get_sequences(P) #tables = web.sequences_to_html_table(seqs, classes="seqtable") pb = P.promiscuousBinders(**defaultargs) #print (pb) #cl = analysis.find_clusters(b, min_binders=2) x = pb.groupby('name').agg({'peptide':np.size, P.scorekey:np.median}).reset_index() x = x.rename(columns={'peptide':'binders'}) x = x.merge(seqs, on='name', how='right') x = web.column_to_url(x, 'name', '/sequence?path=%s&name=' %path) data[P.name] = x else: data = web.get_binder_tables(preds, **defaultargs) #add url to prot/seq name for k in data: data[k] = web.column_to_url(data[k], 'name', '/sequence?path=%s&name=' %path) #convert dfs to html tables = web.dataframes_to_html(data, classes='tinytable sortable') #put tables in tabbed divs tables = web.tabbed_html(tables) form.path.data = path form.cutoff.data = defaultargs['cutoff'] form.n.data = defaultargs['n'] form.cutoff_method.data = defaultargs['cutoff_method'] form.view.data = view self.render('global.html', form=form, tables=tables, msg='', status=1, path=path)
def get(self): args = self.request.arguments form = SummaryForm() defaultargs = {'savepath': '', 'deletecached': 1} for k in defaultargs: if k in args: defaultargs[k] = args[k][0].decode("utf-8") savepath = defaultargs['savepath'].strip() deletecached = defaultargs['deletecached'] #if usecached == 1: # print ('using cached results') if not os.path.exists(savepath): msg = help_msg() self.render('global.html', form=form, msg=msg, savepath=savepath, status=0) data = web.get_summary_tables(savepath, **defaultargs) df = pd.concat(data).reset_index() plot = plotting.bokeh_summary_plot(df) plots = [plot] if len(plots) > 0: grid = gridplot(plots, ncols=1, merge_tools=True, sizing_mode='scale_width', toolbar_options=dict(logo=None)) script, div = components(grid) else: script = '' div = '' for k in data: data[k] = web.column_to_url( data[k], 'name', '/sequence?savepath=%s&name=' % savepath) #convert dfs to html tables = web.dataframes_to_html(data, classes='tinytable sortable') #put tables in tabbed divs tables = web.tabbed_html(tables) form.savepath.data = savepath self.render('global.html', form=form, tables=tables, msg='', script=script, div=div, status=1, savepath=savepath)
def add_links(self, df): web.column_to_url( df, 'name', 'http://cancer.sanger.ac.uk/cosmic/gene/analysis?ln=') web.column_to_url(df, 'transcript_id', 'https://www.ensembl.org/id/')