""" | |
This module includes all functions which are called from the main app and are needed to | |
make activity predictions and to output the results. | |
""" | |
#--------------------------------------------------------------------------------------- | |
# Deendencies | |
import pandas as pd | |
import mols2grid | |
#--------------------------------------------------------------------------------------- | |
# Define functions | |
def create_prediction_df(predictor, query_smiles, support_activces_smiles, | |
support_inactives_smiles): | |
""" | |
This function creates a dataframe with the query molecules and the corresponding | |
predictions. | |
""" | |
# Make predictions | |
predictions = predictor.predict(query_smiles, support_activces_smiles, | |
support_inactives_smiles) | |
smiles = predictor._return_query_mols_as_list() | |
# Create dataframe | |
prediction_df = pd.DataFrame({"Molecule": smiles, | |
"Predicted activity": predictions.astype('str')}) | |
return prediction_df | |
def create_molecule_grid_plot(df, smiles_col="Molecule"): | |
mol_html_grid = mols2grid.display(df,smiles_col=smiles_col)._repr_html_() | |
return mol_html_grid |