Spaces:
Sleeping
Sleeping
Commit
•
3488e95
1
Parent(s):
cf2d407
add plot
Browse files
app.py
CHANGED
@@ -4,7 +4,7 @@ import cas9on
|
|
4 |
import cas9off
|
5 |
import pandas as pd
|
6 |
import streamlit as st
|
7 |
-
from pygenomeviz import GenomeViz
|
8 |
import numpy as np
|
9 |
from pathlib import Path
|
10 |
|
@@ -96,8 +96,10 @@ if selected_model == 'Cas9':
|
|
96 |
if target_selection == 'on-target':
|
97 |
# Gene symbol entry
|
98 |
gene_symbol = st.text_input('Enter a Gene Symbol:', key='gene_symbol')
|
|
|
99 |
# Prediction button
|
100 |
predict_button = st.button('Predict on-target')
|
|
|
101 |
# Process predictions
|
102 |
if predict_button and gene_symbol:
|
103 |
predictions, gene_sequence = cas9on.process_gene(gene_symbol, cas9on_path)
|
@@ -108,8 +110,7 @@ if selected_model == 'Cas9':
|
|
108 |
df = pd.DataFrame(st.session_state['on_target_results'],
|
109 |
columns=["Gene ID", "Start Pos", "End Pos", "Strand", "gRNA", "Prediction"])
|
110 |
|
111 |
-
#
|
112 |
-
if gene_sequence: # Add a check to ensure gene_sequence is not empty
|
113 |
genbank_file_path = f"{gene_symbol}_crispr_targets.gb"
|
114 |
cas9on.generate_genbank_file_from_df(df, gene_sequence, gene_symbol, genbank_file_path)
|
115 |
st.write('Top on-target predictions:')
|
@@ -123,7 +124,23 @@ if selected_model == 'Cas9':
|
|
123 |
file_name=genbank_file_path,
|
124 |
mime="text/x-genbank"
|
125 |
)
|
126 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
|
128 |
elif target_selection == 'off-target':
|
129 |
ENTRY_METHODS = dict(
|
|
|
4 |
import cas9off
|
5 |
import pandas as pd
|
6 |
import streamlit as st
|
7 |
+
from pygenomeviz import Genbank, GenomeViz
|
8 |
import numpy as np
|
9 |
from pathlib import Path
|
10 |
|
|
|
96 |
if target_selection == 'on-target':
|
97 |
# Gene symbol entry
|
98 |
gene_symbol = st.text_input('Enter a Gene Symbol:', key='gene_symbol')
|
99 |
+
|
100 |
# Prediction button
|
101 |
predict_button = st.button('Predict on-target')
|
102 |
+
|
103 |
# Process predictions
|
104 |
if predict_button and gene_symbol:
|
105 |
predictions, gene_sequence = cas9on.process_gene(gene_symbol, cas9on_path)
|
|
|
110 |
df = pd.DataFrame(st.session_state['on_target_results'],
|
111 |
columns=["Gene ID", "Start Pos", "End Pos", "Strand", "gRNA", "Prediction"])
|
112 |
|
113 |
+
if gene_sequence: # Ensure gene_sequence is not empty
|
|
|
114 |
genbank_file_path = f"{gene_symbol}_crispr_targets.gb"
|
115 |
cas9on.generate_genbank_file_from_df(df, gene_sequence, gene_symbol, genbank_file_path)
|
116 |
st.write('Top on-target predictions:')
|
|
|
124 |
file_name=genbank_file_path,
|
125 |
mime="text/x-genbank"
|
126 |
)
|
127 |
+
|
128 |
+
# Visualize the GenBank file using pyGenomeViz
|
129 |
+
gv = GenomeViz(
|
130 |
+
feature_track_ratio=0.3,
|
131 |
+
tick_track_ratio=0.5,
|
132 |
+
tick_style="axis",
|
133 |
+
)
|
134 |
+
|
135 |
+
gbk = Genbank(genbank_file_path)
|
136 |
+
track = gv.add_feature_track(gbk.name, gbk.range_size)
|
137 |
+
track.add_genbank_features(gbk)
|
138 |
+
|
139 |
+
fig = gv.plotfig()
|
140 |
+
st.pyplot(fig)
|
141 |
+
|
142 |
+
# Clean up the GenBank file after visualization
|
143 |
+
os.remove(genbank_file_path)
|
144 |
|
145 |
elif target_selection == 'off-target':
|
146 |
ENTRY_METHODS = dict(
|