def test_fairness(self): """tests whether the draws for multiple are similar enough to the expected distribution, based on Kullback–Leibler divergence""" print("testing lottery fairness") self.setup_normal(PARTICIPANTS_NO, TICKETS_NO) winner_tickets = self.lottery.multiple_draw(DRAWS_NO) winners_distribution = helpers.create_distribution( winner_tickets, self.participants) expected_distribution = helpers.create_distribution( self.tickets, self.participants) kl = helpers.KL_divergence(expected_distribution, winners_distribution) print("KL distance:{}".format(kl)) helpers.create_plot(expected_distribution, winners_distribution) self.assertLessEqual( kl, KL_MAX, "the lottery draw is not fair enough, (KL ={})".format(kl))
def highlight_molecule(from_chem_dropdown_values, to_chem_dropdown_values, plot_type): """ Selected chemical dropdown values handler. :params chem_dropdown_values: selected dropdown values :params plot_type: selected plot graph """ global dfs_tracker df = dfs_tracker['df'] chem_dropdown_values = [] if from_chem_dropdown_values: if isinstance(from_chem_dropdown_values, str): from_chem_dropdown_values = [from_chem_dropdown_values] chem_dropdown_values += from_chem_dropdown_values if to_chem_dropdown_values: if isinstance(to_chem_dropdown_values, str): to_chem_dropdown_values = [to_chem_dropdown_values] chem_dropdown_values += to_chem_dropdown_values plot = create_plot(x=df["D1"], y=df["D2"], z=df["D3"], size=df["Size"], color=df["Mw"], name=df["Name"], markers=chem_dropdown_values, plot_type=plot_type, interp_dict=interp_dict) data_holder = interp_dict['global_data'] extra_sel = [] extra_df = None if (from_chem_dropdown_values[0] != 'NULL' and to_chem_dropdown_values[0] != 'NULL'): extra_sel = data_holder['generated'][:] extra_df = pd.DataFrame(extra_sel, columns=['NAME', 'PAGE', 'SMILES', 'DESC']) return [ plot, make_dash_table( to_chem_dropdown_values + extra_sel + from_chem_dropdown_values, df, extra_df) ]
def highlight_molecule(chem_dropdown_values, plot_type): """ Selected chemical dropdown values handler. :params chem_dropdown_values: selected dropdown values :params plot_type: selected plot graph """ return create_plot( x=df["PKA"], y=df["LOGP"], z=df["SOL"], size=df["MW"], color=df["MW"], name=df["NAME"], markers=chem_dropdown_values, plot_type=plot_type, )
#server = app.server DATA_PATH = pathlib.Path(__file__).parent.joinpath("data").resolve() # read from datasheet df = pd.read_csv(DATA_PATH.joinpath("small_molecule_drugbank.csv")).drop( ["Unnamed: 0"], axis=1 ) STARTING_DRUG = "Levobupivacaine" DRUG_DESCRIPTION = df.loc[df["NAME"] == STARTING_DRUG]["DESC"].iloc[0] DRUG_IMG = df.loc[df["NAME"] == STARTING_DRUG]["IMG_URL"].iloc[0] FIGURE = create_plot( x=df["PKA"], y=df["LOGP"], z=df["SOL"], size=df["MW"], color=df["MW"], name=df["NAME"], ) app.layout = html.Div( [ #html.Div( # [html.Img(src=app.get_asset_url("dash-logo.png"))], className="app__banner" #), html.Div( [ html.Div( [ html.Div( [
df['DESC'] = 'Placeholder' dfs_tracker = {'df': df, 'df_all': df_all, 'catalysts_df': catalysts_df} interp_dict = { 'data': dfs, 'umap': umap_transform, 'vae': paccmann_vae, 'lang': smiles_language, 'global_data': data_holder } FIGURE = create_plot(x=df["D1"], y=df["D2"], z=df["D3"], size=df["Size"], color=df['Mw'], name=df['Name'], interp_dict=interp_dict) app.layout = html.Div([ html.Div([html.Img(src=app.get_asset_url("dash-logo.png"))], className="app__banner"), html.Div( [ html.Div( [ html.Div([ html.H3( "Catalyst discovery", className="uppercase title",