supercat666 commited on
Commit
9260769
1 Parent(s): 9f2ad27
Files changed (1) hide show
  1. app.py +16 -5
app.py CHANGED
@@ -97,13 +97,13 @@ def parse_gene_annotations(file_path):
97
  gene_dict = {}
98
  with open(file_path, 'r') as file:
99
  headers = file.readline().strip().split('\t') # Assuming tab-delimited file
 
 
100
  for line in file:
101
  values = line.strip().split('\t')
102
- # Use min to avoid IndexError if there are fewer values than headers
103
- gene_info = {headers[i]: values[i] if i < len(values) else '' for i in range(len(headers))}
104
- approved_symbol = gene_info.get('Approved symbol', 'Unknown') # Use .get to avoid KeyError
105
- if approved_symbol != 'Unknown': # Only add if there is an approved symbol
106
- gene_dict[approved_symbol] = gene_info
107
  return gene_dict
108
 
109
  # Replace 'your_annotation_file.txt' with the path to your actual gene annotation file
@@ -167,6 +167,17 @@ if selected_model == 'Cas9':
167
 
168
 
169
  if 'on_target_results' in st.session_state and st.session_state['on_target_results']:
 
 
 
 
 
 
 
 
 
 
 
170
  # Include "Target" in the DataFrame's columns
171
  df = pd.DataFrame(st.session_state['on_target_results'],
172
  columns=["Gene ID", "Start Pos", "End Pos", "Strand", "Target", "gRNA", "Prediction"])
 
97
  gene_dict = {}
98
  with open(file_path, 'r') as file:
99
  headers = file.readline().strip().split('\t') # Assuming tab-delimited file
100
+ symbol_idx = headers.index('Approved symbol') # Find index of 'Approved symbol'
101
+ ensembl_idx = headers.index('Ensembl gene ID') # Find index of 'Ensembl gene ID'
102
  for line in file:
103
  values = line.strip().split('\t')
104
+ # Ensure we have enough values and add mapping from symbol to Ensembl ID
105
+ if len(values) > max(symbol_idx, ensembl_idx):
106
+ gene_dict[values[symbol_idx]] = values[ensembl_idx]
 
 
107
  return gene_dict
108
 
109
  # Replace 'your_annotation_file.txt' with the path to your actual gene annotation file
 
167
 
168
 
169
  if 'on_target_results' in st.session_state and st.session_state['on_target_results']:
170
+ ensembl_id = gene_annotations.get(gene_symbol, 'Unknown') # Get Ensembl ID or default to 'Unknown'
171
+ col1, col2, col3 = st.columns(3)
172
+ with col1:
173
+ st.markdown("**Genome**")
174
+ st.markdown("Homo sapiens")
175
+ with col2:
176
+ st.markdown("**Gene**")
177
+ st.markdown(f"{gene_symbol} : {ensembl_id} (primary)")
178
+ with col3:
179
+ st.markdown("**Nuclease**")
180
+ st.markdown("SpCas9")
181
  # Include "Target" in the DataFrame's columns
182
  df = pd.DataFrame(st.session_state['on_target_results'],
183
  columns=["Gene ID", "Start Pos", "End Pos", "Strand", "Target", "gRNA", "Prediction"])