mhnfs / app.py
Tschoui's picture
move project from private to public space
cf004a6
"""
This script runs the streamlit app for MHNfs
MHNfs: Few-shot method for drug discovery activity predictions
(https://openreview.net/pdf?id=XrMWUuEevr)
"""
# --------------------------------------------------------------------------------------
# Imports
import streamlit as st
from src.app.layout import LayoutMaker
from src.app.prediction_utils import (create_prediction_df,
create_molecule_grid_plot)
from src.prediction_pipeline import ActivityPredictor
# --------------------------------------------------------------------------------------
# Functions
class App():
def __init__(self):
# Set page configration to wide
st.set_page_config(layout="wide", page_title="MHNfs", page_icon="🔬")
# Layout maker
self.layoutMaker = LayoutMaker()
# Load mhnfs model
self.predictor = ActivityPredictor()
def define_layout(self):
# Define Sidebar width
css = '''
<style>
[data-testid="stSidebar"]{
min-width: 500px;
max-width: 500px;
}
</style>
'''
st.markdown(css, unsafe_allow_html=True)
# Sidebar
self.inputs, self.buttons = self.layoutMaker.make_sidebar()
# Main page
# - header
self.layoutMaker.make_header()
# - main body
self.layoutMaker.make_main_content_area(self.predictor,
self.inputs,
self.buttons,
create_prediction_df,
create_molecule_grid_plot)
def run_app():
app = App()
app.define_layout()
# --------------------------------------------------------------------------------------
# Run script
if __name__ == "__main__":
run_app()