fatmacankara commited on
Commit
84bc25a
1 Parent(s): ff8f965

Update ASCARIS.py

Browse files
Files changed (1) hide show
  1. ASCARIS.py +27 -31
ASCARIS.py CHANGED
@@ -4,28 +4,27 @@ from os import path
4
  import sys
5
  import streamlit.components.v1 as components
6
  sys.path.append('code/')
 
7
  import pdb_featureVector
8
  import alphafold_featureVector
9
  import argparse
10
  from st_aggrid import AgGrid, GridOptionsBuilder, JsCode,GridUpdateMode
11
  import base64
12
- from huggingface_hub import hf_hub_download
13
- import streamlit as st
14
- import gzip
15
-
16
  showWarningOnDirectExecution = False
17
 
18
  def convert_df(df):
19
- return df.to_csv(index=False, sep= '\t').encode('utf-8')
20
-
21
 
 
 
 
22
  if 'visibility' not in st.session_state:
23
  st.session_state['visibility'] = 'visible'
24
  st.session_state.disabled = False
25
 
26
- original_title = '<p style="font-family:Trebuchet MS; color:#000000; font-size: 25px; font-weight:bold; text-align:center">ASCARIS</p>'
27
  st.markdown(original_title, unsafe_allow_html=True)
28
- original_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>'
29
  st.markdown(original_title, unsafe_allow_html=True)
30
 
31
  st.write('')
@@ -35,49 +34,46 @@ st.write('')
35
 
36
  with st.form('mform', clear_on_submit=False):
37
  source = st.selectbox('Select the protein structure resource (1: PDB-SwissModel-Modbase, 2: AlphaFold)',[1,2])
38
- impute = st.selectbox('Missing value imputation (mostly for the cases where the corresponding annotation does not exist in the protein)',[True, False])
39
- 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: P04217-E-20-A or O43556-I-40-A,P57737-W-372-A')
40
-
41
-
42
 
43
  parser = argparse.ArgumentParser(description='ASCARIS')
44
-
45
-
46
  input_set = input_data
 
47
  impute = impute
48
  submitted = st.form_submit_button(label="Submit", help=None, on_click=None, args=None, kwargs=None, type="secondary", disabled=False, use_container_width=False)
49
  print('*****************************************')
50
  print('Feature vector generation is in progress. \nPlease check log file for updates..')
51
  print('*****************************************')
52
- mode = int(source)
 
53
 
54
  selected_df = pd.DataFrame()
55
- st.write('The online tool may be slow, especially while processing multiple SAVs. To address this, please consider using the programmatic version at https://github.com/HUBioDataLab/ASCARIS/')
56
  if submitted:
57
  with st.spinner('In progress...This may take a while...'):
58
- try:
59
- if mode == 1:
60
- selected_df = pdb_featureVector.pdb(input_set, mode, impute)
61
-
62
- elif mode == 2:
63
- selected_df = alphafold_featureVector.alphafold(input_set, mode, impute)
64
- else:
65
- selected_df = pd.DataFrame()
66
-
67
- except:
68
- selected_df = pd.DataFrame()
69
- pass
70
 
71
  if selected_df is None:
72
- st.success('Feature vector failed. Check the log file.')
73
 
74
  else:
75
  if len(selected_df) != 0 :
76
  st.write(selected_df)
77
- st.success('Feature vector is successfully created.')
78
  csv = convert_df(selected_df)
 
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. Check the log file.')
 
 
4
  import sys
5
  import streamlit.components.v1 as components
6
  sys.path.append('code/')
7
+ #sys.path.append('ASCARIS/code/')
8
  import pdb_featureVector
9
  import alphafold_featureVector
10
  import argparse
11
  from st_aggrid import AgGrid, GridOptionsBuilder, JsCode,GridUpdateMode
12
  import base64
 
 
 
 
13
  showWarningOnDirectExecution = False
14
 
15
  def convert_df(df):
16
+ return df.to_csv(index=False).encode('utf-8')
 
17
 
18
+
19
+ # Check if 'key' already exists in session_state
20
+ # If not, then initialize it
21
  if 'visibility' not in st.session_state:
22
  st.session_state['visibility'] = 'visible'
23
  st.session_state.disabled = False
24
 
25
+ original_title = '<p style="font-family:Trebuchet MS; color:#FD7456; font-size: 25px; font-weight:bold; text-align:center">ASCARIS</p>'
26
  st.markdown(original_title, unsafe_allow_html=True)
27
+ original_title = '<p style="font-family:Trebuchet MS; color:#FD7456; font-size: 25px; font-weight:bold; text-align:center">(Annotation and StruCture-bAsed RepresentatIon of Single amino acid variations)</p>'
28
  st.markdown(original_title, unsafe_allow_html=True)
29
 
30
  st.write('')
 
34
 
35
  with st.form('mform', clear_on_submit=False):
36
  source = st.selectbox('Select the protein structure resource (1: PDB-SwissModel-Modbase, 2: AlphaFold)',[1,2])
37
+ impute = st.selectbox('Imputation',[True, False])
38
+
39
+ input_data = st.text_input('Enter SAV data points (Example: Q9BTP7-S-126-F, P04217-A-493-S, Q00889-G-2-L)')
 
40
 
41
  parser = argparse.ArgumentParser(description='ASCARIS')
42
+
 
43
  input_set = input_data
44
+ mode = source
45
  impute = impute
46
  submitted = st.form_submit_button(label="Submit", help=None, on_click=None, args=None, kwargs=None, type="secondary", disabled=False, use_container_width=False)
47
  print('*****************************************')
48
  print('Feature vector generation is in progress. \nPlease check log file for updates..')
49
  print('*****************************************')
50
+ mode = int(mode)
51
+
52
 
53
  selected_df = pd.DataFrame()
54
+ st.write('The online tool may be slow, especially while processing multiple SAVs and with multiple PDB matches, please consider using the local programmatic version at https://github.com/HUBioDataLab/ASCARIS/')
55
  if submitted:
56
  with st.spinner('In progress...This may take a while...'):
57
+ # try:
58
+ if mode == 1:
59
+ selected_df = pdb_featureVector.pdb(input_set, mode, impute)
60
+ elif mode == 2:
61
+ selected_df = alphafold_featureVector.alphafold(input_set, mode, impute)
62
+ else:
63
+ selected_df = pd.DataFrame()
 
 
 
 
 
64
 
65
  if selected_df is None:
66
+ st.success('No feature vector is created. Check the log file.')
67
 
68
  else:
69
  if len(selected_df) != 0 :
70
  st.write(selected_df)
71
+ st.success('Feature vector successfully created.')
72
  csv = convert_df(selected_df)
73
+
74
 
75
  st.download_button("Press to Download the Feature Vector", csv,f"ASCARIS_SAV_rep_{input_set}.csv","text/csv",key='download-csv')
76
 
77
  else:
78
+ st.success('Feature vector failed. Check log file.')
79
+