supercat666 commited on
Commit
e272fdd
1 Parent(s): 3d0dd11

fixed bugs

Browse files
Files changed (1) hide show
  1. app.py +28 -22
app.py CHANGED
@@ -136,33 +136,36 @@ if selected_model == 'Cas9':
136
  # Now create a Plotly plot with the sorted_predictions
137
  fig = go.Figure()
138
 
139
- # Variables to initialize the y position for the positive and negative strands
140
- positive_strand_y = 1
141
- negative_strand_y = -1
 
 
 
142
 
143
  # Iterate over the sorted predictions to create the plot
144
  for i, prediction in enumerate(sorted_predictions, start=1):
145
  # Extract data for plotting
146
  chrom, start, end, strand, target, gRNA, pred_score = prediction
147
  # Set the y-value and arrow symbol based on the strand
148
- if strand == 1:
149
  y_value = positive_strand_y
150
  arrow_symbol = 'triangle-right'
151
- positive_strand_y += 0.1 # Increment the y-value for the next positive strand gRNA
152
  else:
153
  y_value = negative_strand_y
154
  arrow_symbol = 'triangle-left'
155
- negative_strand_y -= 0.1 # Decrement the y-value for the next negative strand gRNA
156
 
157
  fig.add_trace(go.Scatter(
158
- x=[start, end],
159
- y=[y_value, y_value], # Use the y_value set above for the strand
160
- mode='lines+markers+text',
161
  marker=dict(symbol=arrow_symbol, size=10),
162
  name=f"gRNA: {gRNA}",
163
- text=[f"Rank: {i}", ""], # Text at the first point
164
  hoverinfo='text',
165
- 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}",
166
  ))
167
 
168
  # Update the layout of the plot
@@ -366,33 +369,36 @@ elif selected_model == 'Cas12':
366
  # Now create a Plotly plot with the sorted_predictions
367
  fig = go.Figure()
368
 
369
- # Variables to initialize the y position for the positive and negative strands
370
- positive_strand_y = 1
371
- negative_strand_y = -1
 
 
 
372
 
373
  # Iterate over the sorted predictions to create the plot
374
  for i, prediction in enumerate(sorted_predictions, start=1):
375
  # Extract data for plotting
376
  chrom, start, end, strand, target, gRNA, pred_score = prediction
377
  # Set the y-value and arrow symbol based on the strand
378
- if strand == 1:
379
  y_value = positive_strand_y
380
  arrow_symbol = 'triangle-right'
381
- positive_strand_y += 0.1 # Increment the y-value for the next positive strand gRNA
382
  else:
383
  y_value = negative_strand_y
384
  arrow_symbol = 'triangle-left'
385
- negative_strand_y -= 0.1 # Decrement the y-value for the next negative strand gRNA
386
 
387
  fig.add_trace(go.Scatter(
388
- x=[start, end],
389
- y=[y_value, y_value], # Use the y_value set above for the strand
390
- mode='lines+markers+text',
391
  marker=dict(symbol=arrow_symbol, size=10),
392
  name=f"gRNA: {gRNA}",
393
- text=[f"Rank: {i}", ""], # Text at the first point
394
  hoverinfo='text',
395
- 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}",
396
  ))
397
 
398
  # Update the layout of the plot
 
136
  # Now create a Plotly plot with the sorted_predictions
137
  fig = go.Figure()
138
 
139
+ # Initialize the y position for the positive and negative strands
140
+ positive_strand_y = 0.1
141
+ negative_strand_y = -0.1
142
+
143
+ # Use an offset to spread gRNA sequences vertically
144
+ offset = 0.05
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
 
369
  # Now create a Plotly plot with the sorted_predictions
370
  fig = go.Figure()
371
 
372
+ # Initialize the y position for the positive and negative strands
373
+ positive_strand_y = 0.1
374
+ negative_strand_y = -0.1
375
+
376
+ # Use an offset to spread gRNA sequences vertically
377
+ offset = 0.05
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