CoolFace
Apppublic

HUBioDataLab/ASCARIS

sourceHugging Faceupdated 3y agoView on Hugging Face
0likes
ASCARIS.py84 linesDownload Raw Back to root
1import streamlit as st2import pandas as pd 3from os import path4import sys5import streamlit.components.v1 as components6sys.path.append('code/')7#sys.path.append('ASCARIS/code/') 8import pdb_featureVector9import alphafold_featureVector10import argparse11from st_aggrid import AgGrid, GridOptionsBuilder, JsCode,GridUpdateMode12import base6413showWarningOnDirectExecution = False14 15def convert_df(df):16   return df.to_csv(index=False, sep='\t').encode('utf-8')17 18    19# Check if 'key' already exists in session_state20# If not, then initialize it21if 'visibility' not in st.session_state:22    st.session_state['visibility'] = 'visible'23    st.session_state.disabled =  False24 25 26showWarningOnDirectExecution = False27original_title = '<p style="font-family:Trebuchet MS; color:#000000; font-size: 25px; font-weight:bold; text-align:center">ASCARIS</p>'28st.markdown(original_title, unsafe_allow_html=True)29original_title = '<p style="font-family:Trebuchet MS; color:#000000; font-size: 25px; font-weight:bold; text-align:center">(Annotation and StruCture-bAsed RepresentatIon of Single amino acid variations)</p>'30st.markdown(original_title, unsafe_allow_html=True)31 32 33st.write('')34st.write('')35st.write('')36st.write('')37 38 39with st.form('mform', clear_on_submit=False):40    source = st.selectbox('Select the protein structure resource (1: PDB-SwissModel-Modbase, 2: AlphaFold)',[1,2])41    #source = 142    impute = st.selectbox('Missing value imputation (mostly for the cases where the corresponding annotation does not exist in the protein)',[True, False])43    input_data = st.text_input('Enter SAV data points (format: "UniProt/Swiss-Prot human protein accession" – "wild type a.a." – "position on the sequence" – "mutated a.a.").   Example: Q9BTP7-S-126-F or P04217-A-493-S, Q00889-G-2-L')44            45    parser = argparse.ArgumentParser(description='ASCARIS')46 47    input_set = input_data48    mode = source49    impute = impute50    submitted = st.form_submit_button(label="Submit", help=None, on_click=None, args=None, kwargs=None, type="secondary", disabled=False, use_container_width=False)51    print('*****************************************')52    print('Feature vector generation is in progress. \nPlease check log file for updates..')53    print('*****************************************')54    mode = int(mode)55    56    57selected_df = pd.DataFrame()58st.write('The online tool may be slow, especially while processing multiple SAVs and with multiple PDB matches. To address this, please consider using the programmatic version at https://github.com/HUBioDataLab/ASCARIS/')59 60if submitted:61    with st.spinner('In progress...This may take a while...'):62        # try:63        if mode == 1:64            selected_df = pdb_featureVector.pdb(input_set, mode, impute)  65        elif mode == 2:66            selected_df = alphafold_featureVector.alphafold(input_set, mode, impute)67        else:68            selected_df =  pd.DataFrame()69 70    if selected_df is None:71        st.success('Feature vector failed.')72 73    else:74        if len(selected_df) != 0 :75            st.write(selected_df)76            st.success('Feature vector successfully created.')77            csv = convert_df(selected_df)78            79    80            st.download_button("Press to Download the Feature Vector", csv,f"ASCARIS_SAV_rep_{input_set}.csv","text/csv",key='download-csv')81 82        else:83            st.success('Feature vector failed.')84