supercat666 commited on
Commit
cce495d
1 Parent(s): ad9ec7b
Files changed (1) hide show
  1. app.py +56 -56
app.py CHANGED
@@ -180,62 +180,62 @@ if selected_model == 'Cas9':
180
  # Optionally print or log the problematic data for debugging:
181
  print(st.session_state['on_target_results'])
182
 
183
- # Initialize Plotly figure
184
- fig = go.Figure()
185
-
186
- EXON_BASE = 0 # Base position for exons and CDS on the Y axis
187
- EXON_HEIGHT = 0.02 # How 'tall' the exon markers should appear
188
-
189
- # Plot Exons as small markers on the X-axis
190
- for exon in st.session_state['exons']:
191
- exon_start, exon_end = exon['start'], exon['end']
192
- fig.add_trace(go.Bar(
193
- x=[(exon_start + exon_end) / 2],
194
- y=[EXON_HEIGHT],
195
- width=[exon_end - exon_start],
196
- base=[EXON_BASE],
197
- marker_color='rgba(128, 0, 128, 0.5)',
198
- name='Exon'
199
- ))
200
-
201
- VERTICAL_GAP = 0.2 # Gap between different ranks
202
-
203
- # Define max and min Y values based on strand and rank
204
- MAX_STRAND_Y = 0.1 # Maximum Y value for positive strand results
205
- MIN_STRAND_Y = -0.1 # Minimum Y value for negative strand results
206
-
207
- # Iterate over top 5 sorted predictions to create the plot
208
- for i, prediction in enumerate(st.session_state['on_target_results'][:5], start=1): # Only top 5
209
- chrom, start, end, strand, transcript, target, gRNA, Prediction = prediction
210
- midpoint = (int(start) + int(end)) / 2
211
-
212
- # Vertical position based on rank, modified by strand
213
- y_value = (MAX_STRAND_Y - (i - 1) * VERTICAL_GAP) if strand == '1' else (
214
- MIN_STRAND_Y + (i - 1) * VERTICAL_GAP)
215
-
216
- fig.add_trace(go.Scatter(
217
- x=[midpoint],
218
- y=[y_value],
219
- mode='markers+text',
220
- marker=dict(symbol='triangle-up' if strand == '1' else 'triangle-down', size=12),
221
- text=f"Rank: {i}", # Text label
222
- hoverinfo='text',
223
- hovertext=f"Rank: {i}<br>Chromosome: {chrom}<br>Target Sequence: {target}<br>gRNA: {gRNA}<br>Start: {start}<br>End: {end}<br>Strand: {'+' if strand == '1' else '-'}<br>Transcript: {transcript}<br>Prediction: {Prediction:.4f}",
224
- ))
225
-
226
- # Update layout for clarity and interaction
227
- fig.update_layout(
228
- title='Top 5 gRNA Sequences by Prediction Score',
229
- xaxis_title='Genomic Position',
230
- yaxis_title='Strand',
231
- yaxis=dict(tickvals=[MAX_STRAND_Y, MIN_STRAND_Y], ticktext=['+', '-']),
232
- # Adjusted to just show strand symbols
233
- showlegend=False,
234
- hovermode='x unified', # Unified mode for better clarity when hovering
235
- )
236
-
237
- # Display the plot
238
- st.plotly_chart(fig)
239
 
240
  # if 'gene_sequence' in st.session_state and st.session_state['gene_sequence']:
241
  # gene_symbol = st.session_state['current_gene_symbol']
 
180
  # Optionally print or log the problematic data for debugging:
181
  print(st.session_state['on_target_results'])
182
 
183
+ # # Initialize Plotly figure
184
+ # fig = go.Figure()
185
+ #
186
+ # EXON_BASE = 0 # Base position for exons and CDS on the Y axis
187
+ # EXON_HEIGHT = 0.02 # How 'tall' the exon markers should appear
188
+ #
189
+ # # Plot Exons as small markers on the X-axis
190
+ # for exon in st.session_state['exons']:
191
+ # exon_start, exon_end = exon['start'], exon['end']
192
+ # fig.add_trace(go.Bar(
193
+ # x=[(exon_start + exon_end) / 2],
194
+ # y=[EXON_HEIGHT],
195
+ # width=[exon_end - exon_start],
196
+ # base=[EXON_BASE],
197
+ # marker_color='rgba(128, 0, 128, 0.5)',
198
+ # name='Exon'
199
+ # ))
200
+ #
201
+ # VERTICAL_GAP = 0.2 # Gap between different ranks
202
+ #
203
+ # # Define max and min Y values based on strand and rank
204
+ # MAX_STRAND_Y = 0.1 # Maximum Y value for positive strand results
205
+ # MIN_STRAND_Y = -0.1 # Minimum Y value for negative strand results
206
+ #
207
+ # # Iterate over top 5 sorted predictions to create the plot
208
+ # for i, prediction in enumerate(st.session_state['on_target_results'][:5], start=1): # Only top 5
209
+ # chrom, start, end, strand, transcript, Exon, target, gRNA, Prediction = prediction
210
+ # midpoint = (int(start) + int(end)) / 2
211
+ #
212
+ # # Vertical position based on rank, modified by strand
213
+ # y_value = (MAX_STRAND_Y - (i - 1) * VERTICAL_GAP) if strand == '1' else (
214
+ # MIN_STRAND_Y + (i - 1) * VERTICAL_GAP)
215
+ #
216
+ # fig.add_trace(go.Scatter(
217
+ # x=[midpoint],
218
+ # y=[y_value],
219
+ # mode='markers+text',
220
+ # marker=dict(symbol='triangle-up' if strand == '1' else 'triangle-down', size=12),
221
+ # text=f"Rank: {i}", # Text label
222
+ # hoverinfo='text',
223
+ # hovertext=f"Rank: {i}<br>Chromosome: {chrom}<br>Target Sequence: {target}<br>gRNA: {gRNA}<br>Start: {start}<br>End: {end}<br>Strand: {'+' if strand == '1' else '-'}<br>Transcript: {transcript}<br>Prediction: {Prediction:.4f}",
224
+ # ))
225
+ #
226
+ # # Update layout for clarity and interaction
227
+ # fig.update_layout(
228
+ # title='Top 5 gRNA Sequences by Prediction Score',
229
+ # xaxis_title='Genomic Position',
230
+ # yaxis_title='Strand',
231
+ # yaxis=dict(tickvals=[MAX_STRAND_Y, MIN_STRAND_Y], ticktext=['+', '-']),
232
+ # # Adjusted to just show strand symbols
233
+ # showlegend=False,
234
+ # hovermode='x unified', # Unified mode for better clarity when hovering
235
+ # )
236
+ #
237
+ # # Display the plot
238
+ # st.plotly_chart(fig)
239
 
240
  # if 'gene_sequence' in st.session_state and st.session_state['gene_sequence']:
241
  # gene_symbol = st.session_state['current_gene_symbol']