supercat666 commited on
Commit
a1203ca
1 Parent(s): cac0bc9
Files changed (1) hide show
  1. app.py +21 -5
app.py CHANGED
@@ -93,7 +93,20 @@ def initiate_run():
93
  elif len(transcripts) > 0:
94
  st.session_state.transcripts = transcripts
95
 
96
-
 
 
 
 
 
 
 
 
 
 
 
 
 
97
  # Check if the selected model is Cas9
98
  if selected_model == 'Cas9':
99
  # Use a radio button to select enzymes, making sure only one can be selected at a time
@@ -114,8 +127,10 @@ if selected_model == 'Cas9':
114
  if os.path.exists(path):
115
  os.remove(path)
116
 
117
- # Gene symbol entry
118
- gene_symbol = st.text_input('Enter a Gene Symbol:', placeholder="e.g., FOXA1", key='gene_symbol')
 
 
119
 
120
  # Handle gene symbol change and file cleanup
121
  if gene_symbol != st.session_state['current_gene_symbol'] and gene_symbol:
@@ -326,8 +341,9 @@ if selected_model == 'Cas9':
326
  st.experimental_rerun()
327
 
328
  elif selected_model == 'Cas12':
329
- # Gene symbol entry
330
- gene_symbol = st.text_input('Enter a Gene Symbol:', placeholder="e.g., FOXA1", key='gene_symbol')
 
331
 
332
  # Initialize the current_gene_symbol in the session state if it doesn't exist
333
  if 'current_gene_symbol' not in st.session_state:
 
93
  elif len(transcripts) > 0:
94
  st.session_state.transcripts = transcripts
95
 
96
+ def parse_gene_annotations(file_path):
97
+ gene_dict = {}
98
+ with open(file_path, 'r') as file:
99
+ headers = file.readline().strip().split('\t') # Read the header line and split into column names
100
+ for line in file:
101
+ values = line.strip().split('\t')
102
+ gene_info = {headers[i]: values[i] for i in range(len(headers))}
103
+ approved_symbol = gene_info['Approved symbol']
104
+ gene_dict[approved_symbol] = gene_info
105
+ return gene_dict
106
+
107
+ # Replace 'your_annotation_file.txt' with the path to your actual gene annotation file
108
+ gene_annotations = parse_gene_annotations('your_annotation_file.txt')
109
+ gene_symbol_list = list(gene_annotations.keys()) # List of gene symbols for the autocomplete feature
110
  # Check if the selected model is Cas9
111
  if selected_model == 'Cas9':
112
  # Use a radio button to select enzymes, making sure only one can be selected at a time
 
127
  if os.path.exists(path):
128
  os.remove(path)
129
 
130
+
131
+ # Gene symbol entry with autocomplete-like feature
132
+ gene_symbol = st.selectbox('Enter a Gene Symbol:', [''] + gene_symbol_list, key='gene_symbol',
133
+ format_func=lambda x: x if x else "e.g., FOXA1")
134
 
135
  # Handle gene symbol change and file cleanup
136
  if gene_symbol != st.session_state['current_gene_symbol'] and gene_symbol:
 
341
  st.experimental_rerun()
342
 
343
  elif selected_model == 'Cas12':
344
+ # Gene symbol entry with autocomplete-like feature
345
+ gene_symbol = st.selectbox('Enter a Gene Symbol:', [''] + gene_symbol_list, key='gene_symbol',
346
+ format_func=lambda x: x if x else "e.g., FOXA1")
347
 
348
  # Initialize the current_gene_symbol in the session state if it doesn't exist
349
  if 'current_gene_symbol' not in st.session_state: