supercat666 commited on
Commit
aa8a757
1 Parent(s): e272fdd
Files changed (1) hide show
  1. app.py +20 -10
app.py CHANGED
@@ -145,27 +145,32 @@ if selected_model == 'Cas9':
145
 
146
  # Iterate over the sorted predictions to create the plot
147
  for i, prediction in enumerate(sorted_predictions, start=1):
148
- # Extract data for plotting
149
  chrom, start, end, strand, target, gRNA, pred_score = prediction
 
 
 
150
  # Set the y-value and arrow symbol based on the strand
151
  if strand == '1':
152
  y_value = positive_strand_y
153
  arrow_symbol = 'triangle-right'
154
- positive_strand_y += offset # Increment the y-value for the next positive strand gRNA
 
155
  else:
156
  y_value = negative_strand_y
157
  arrow_symbol = 'triangle-left'
158
- negative_strand_y -= offset # Decrement the y-value for the next negative strand gRNA
 
159
 
160
  fig.add_trace(go.Scatter(
161
- x=[(start + end) / 2], # Place the marker at the midpoint of the start and end
162
  y=[y_value], # Use the y_value set above for the strand
163
  mode='markers+text',
164
  marker=dict(symbol=arrow_symbol, size=10),
165
  name=f"gRNA: {gRNA}",
166
  text=f"Rank: {i}", # Place text at the marker
167
  hoverinfo='text',
168
- 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>Prediction Score: {pred_score:.4f}",
169
  ))
170
 
171
  # Update the layout of the plot
@@ -378,27 +383,32 @@ elif selected_model == 'Cas12':
378
 
379
  # Iterate over the sorted predictions to create the plot
380
  for i, prediction in enumerate(sorted_predictions, start=1):
381
- # Extract data for plotting
382
  chrom, start, end, strand, target, gRNA, pred_score = prediction
 
 
 
383
  # Set the y-value and arrow symbol based on the strand
384
  if strand == '1':
385
  y_value = positive_strand_y
386
  arrow_symbol = 'triangle-right'
387
- positive_strand_y += offset # Increment the y-value for the next positive strand gRNA
 
388
  else:
389
  y_value = negative_strand_y
390
  arrow_symbol = 'triangle-left'
391
- negative_strand_y -= offset # Decrement the y-value for the next negative strand gRNA
 
392
 
393
  fig.add_trace(go.Scatter(
394
- x=[(start + end) / 2], # Place the marker at the midpoint of the start and end
395
  y=[y_value], # Use the y_value set above for the strand
396
  mode='markers+text',
397
  marker=dict(symbol=arrow_symbol, size=10),
398
  name=f"gRNA: {gRNA}",
399
  text=f"Rank: {i}", # Place text at the marker
400
  hoverinfo='text',
401
- 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>Prediction Score: {pred_score:.4f}",
402
  ))
403
 
404
  # Update the layout of the plot
 
145
 
146
  # Iterate over the sorted predictions to create the plot
147
  for i, prediction in enumerate(sorted_predictions, start=1):
148
+ # Extract data for plotting and convert start and end to integers
149
  chrom, start, end, strand, target, gRNA, pred_score = prediction
150
+ start, end = int(start), int(end)
151
+ midpoint = (start + end) / 2
152
+
153
  # Set the y-value and arrow symbol based on the strand
154
  if strand == '1':
155
  y_value = positive_strand_y
156
  arrow_symbol = 'triangle-right'
157
+ # Increment the y-value for the next positive strand gRNA
158
+ positive_strand_y += offset
159
  else:
160
  y_value = negative_strand_y
161
  arrow_symbol = 'triangle-left'
162
+ # Decrement the y-value for the next negative strand gRNA
163
+ negative_strand_y -= offset
164
 
165
  fig.add_trace(go.Scatter(
166
+ x=[midpoint],
167
  y=[y_value], # Use the y_value set above for the strand
168
  mode='markers+text',
169
  marker=dict(symbol=arrow_symbol, size=10),
170
  name=f"gRNA: {gRNA}",
171
  text=f"Rank: {i}", # Place text at the marker
172
  hoverinfo='text',
173
+ 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>Prediction Score: {pred_score:.4f}",
174
  ))
175
 
176
  # Update the layout of the plot
 
383
 
384
  # Iterate over the sorted predictions to create the plot
385
  for i, prediction in enumerate(sorted_predictions, start=1):
386
+ # Extract data for plotting and convert start and end to integers
387
  chrom, start, end, strand, target, gRNA, pred_score = prediction
388
+ start, end = int(start), int(end)
389
+ midpoint = (start + end) / 2
390
+
391
  # Set the y-value and arrow symbol based on the strand
392
  if strand == '1':
393
  y_value = positive_strand_y
394
  arrow_symbol = 'triangle-right'
395
+ # Increment the y-value for the next positive strand gRNA
396
+ positive_strand_y += offset
397
  else:
398
  y_value = negative_strand_y
399
  arrow_symbol = 'triangle-left'
400
+ # Decrement the y-value for the next negative strand gRNA
401
+ negative_strand_y -= offset
402
 
403
  fig.add_trace(go.Scatter(
404
+ x=[midpoint],
405
  y=[y_value], # Use the y_value set above for the strand
406
  mode='markers+text',
407
  marker=dict(symbol=arrow_symbol, size=10),
408
  name=f"gRNA: {gRNA}",
409
  text=f"Rank: {i}", # Place text at the marker
410
  hoverinfo='text',
411
+ 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>Prediction Score: {pred_score:.4f}",
412
  ))
413
 
414
  # Update the layout of the plot