def download_csv_custom(self): query = get_database_readable(db) if cache.get("search_query") is not None: ids = cache.get("search_query") query = query.filter(Exposure.id.in_(ids)) df = pd.DataFrame(query) response = make_response(df.to_csv()) cd = 'attachment; filename=celltox_database.csv' response.headers['Content-Disposition'] = cd response.mimetype = 'text/csv' return response
def download_csv(self): get_filter_args(self._filters) order_column, order_direction = self.base_order query = get_database_readable(db) if self._filters: query = self._filters.apply_all(query) df = pd.DataFrame(query) response = make_response(df.to_csv()) cd = 'attachment; filename=celltox_database.csv' response.headers['Content-Disposition'] = cd response.mimetype = 'text/csv' return response
def download_xls_custom(self): query = get_database_readable(db) if cache.get("search_query") is not None: ids = cache.get("search_query") query = query.filter(Exposure.id.in_(ids)) output = io.BytesIO() writer = pd.ExcelWriter(output) df = pd.DataFrame(query) df.to_excel(writer, 'Tab1') writer.close() response = make_response(output.getvalue()) response.headers[ 'Content-Disposition'] = 'attachment; filename=celltox_database.xlsx' response.headers["Content-type"] = "text/csv" return response
def download_xls(self): get_filter_args(self._filters) order_column, order_direction = self.base_order query = get_database_readable(db) if self._filters: query = self._filters.apply_all(query) output = io.BytesIO() writer = pd.ExcelWriter(output) df = pd.DataFrame(query) df.to_excel(writer, 'Tab1') writer.close() response = make_response(output.getvalue()) response.headers[ 'Content-Disposition'] = 'attachment; filename=output.xlsx' response.headers["Content-type"] = "text/csv" return response
def create_dashboard(server): """Create the Dash app.""" external_stylesheets = [ '/static/css/dash.css', { 'href': '/static/css/dash.css', 'rel': 'stylesheet', 'integrity': 'sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO', 'crossorigin': 'anonymous' } ] dash_app = dash.Dash(server=server, routes_pathname_prefix='/dashapp/') # Load data from database q = get_database_readable(db) if q.count() == 0: return dash_app.server df = pd.DataFrame(q) # Custom HTML layout dash_app.index_string = html_layout #with open(os.path.join("app","templates","plot.html"),"r") as f: # dash_app.index_string = f.read() available_indicators = df['cell_line'].unique() endpoint_indicators = df['endpoint'].unique() endpoint_indicators_all = np.append("all", df['endpoint'].unique()) chemical_indicators = np.append("all", df.chemical_name.unique()) chemical_property_indicators = [ 'logKow', 'solubility', 'henry\'s law constant' ] come_indicators = ["nominal & measured", "nominal", "measured"] timepoint_indicators = np.append("all", np.sort(df.timepoint.unique())) dash_app.layout = \ html.Div(id="site-wrapper",children=[ html.Div(id="left-board",children=[ html.H4(children="Global Filters"), html.Div(html.P("Chemical")), html.Div(dropdown('crossfilter-chemical',chemical_indicators,'all')), html.Div(html.P("Cell-line")), html.Div(dropdown('crossfilter-cell_line',np.append("all",available_indicators),'all')), html.Div(html.P("Endpoint")), html.Div(dropdown('crossfilter-endpoint',endpoint_indicators_all,'all')), html.Div(html.P("Timepoint [h]")), html.Div(dropdown('crossfilter-timepoint',timepoint_indicators,'all')), html.Div(html.P("logKow")), html.Div(range_slider('crossfilter-kow--rangeslider',df,"experimental_log_kow",0.1)), html.Div(html.P("x-concentration")), html.Div(dropdown('crossfilter-x-come',come_indicators,'nominal & measured')), html.Div(html.P("y-concentration")), html.Div(dropdown('crossfilter-y-come',come_indicators,'nominal & measured')), html.Br(), html.Div(daq.BooleanSwitch( id = "crossfilter-uml", on=False, label="show in umol/L", labelPosition="top" ) ), html.Br() ]), html.Div(id="right-board",children=[ html.Div(id="top-left-box",children=[html.H4(children="Cell line comparison"), html.Div([ dropdown('crossfilter-xaxis-column',available_indicators,'RTgill-W1'), log_button('crossfilter-xaxis-type') ],style={"width" : "49%","float" : "left"}), html.Div([ dropdown('crossfilter-yaxis-column',available_indicators,'RTgutGC'), log_button('crossfilter-yaxis-type') ],style={"width" : "49%","float" : "right"}), html.Div(children=[dcc.Graph(id='crossfilter-indicator-scatter')], style={'width': '100%', 'display': 'inline-block', 'padding': '0 20'}) ]), html.Div(id="top-right-box",children=[html.H4(children="Endpoint Comparison"), html.Div([ dropdown('crossfilter-xaxis-column-chemical',endpoint_indicators,'alamarBlue'), log_button('crossfilter-xaxis-type-chemical') ],style={"width" : "49%","float" : "left"}), html.Div([ dropdown('crossfilter-yaxis-column-chemical',endpoint_indicators,'Neutral Red'), log_button('crossfilter-yaxis-type-chemical') ],style={"width" : "49%","float" : "right"}), html.Div(children=[dcc.Graph(id='crossfilter-indicator-scatter-chemical')], style={'width': '100%', 'display': 'inline-block', 'padding': '0 20'}) ]), html.Div(id="bottom-left-box",children=[ html.H4(children="Chemical properties"), html.Div([ dropdown('filter-chemical-property',chemical_property_indicators,'logKow'), log_button('xaxis-type-chemical-property'), log_button('yaxis-type-chemical-property') ],style={"width" : "49%","float" : "left"}), html.Div(children=[dcc.Graph(id='ec50-logkow')], style={'width': '100%', 'display': 'inline-block', 'padding': '0 20'})]) ]) ]) init_callbacks(dash_app, df) return dash_app.server