Update func_gradio.py
Browse files- func_gradio.py +8 -9
func_gradio.py
CHANGED
@@ -6,7 +6,7 @@ from scipy.sparse import load_npz
|
|
6 |
import matplotlib.pyplot as plt
|
7 |
from matplotlib.gridspec import GridSpec
|
8 |
import matplotlib
|
9 |
-
def predict_func(input_chrom,cop_type, region_start,region_end, atac_seq):
|
10 |
device = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')
|
11 |
print(device)
|
12 |
if input_chrom == '' or cop_type == '':
|
@@ -29,13 +29,15 @@ def predict_func(input_chrom,cop_type, region_start,region_end, atac_seq):
|
|
29 |
else:
|
30 |
chrom, start, end = check_region(input_chrom, region_start,region_end, ref_genome,1000000)
|
31 |
|
32 |
-
|
33 |
-
|
34 |
out_epi_binding = predict_epb(os.path.abspath('models/epi_bind.pt'), [start, end], ref_genome, atac_seq, device,
|
35 |
cop_type)
|
|
|
|
|
|
|
36 |
out_cage = predict_cage(os.path.abspath('models/cage.pt'), [start, end], ref_genome, atac_seq, device, cop_type)
|
37 |
|
38 |
-
|
39 |
|
40 |
file_id = str(uuid.uuid4())
|
41 |
|
@@ -45,7 +47,7 @@ def predict_func(input_chrom,cop_type, region_start,region_end, atac_seq):
|
|
45 |
for f in os.listdir('results/'):
|
46 |
os.remove(os.path.join('results/', f))
|
47 |
|
48 |
-
|
49 |
if cop_type == 'Micro-C':
|
50 |
out_cop = predict_microc(os.path.abspath('models/microc.pt'), [start, end], ref_genome, atac_seq, device)
|
51 |
np.savez_compressed( 'results/prediction_%s.npz'%file_id,
|
@@ -159,7 +161,4 @@ def make_plots(in_file,md,epis,epi_type, maxv1, maxv2,maxv3):
|
|
159 |
|
160 |
axs[-1].set_xlabel('chr%s:%s-%s'%(chrom,start,end))
|
161 |
plt.show()
|
162 |
-
return fig
|
163 |
-
|
164 |
-
|
165 |
-
|
|
|
6 |
import matplotlib.pyplot as plt
|
7 |
from matplotlib.gridspec import GridSpec
|
8 |
import matplotlib
|
9 |
+
def predict_func(input_chrom,cop_type, region_start,region_end, atac_seq,progress=gradio.Progress()):
|
10 |
device = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')
|
11 |
print(device)
|
12 |
if input_chrom == '' or cop_type == '':
|
|
|
29 |
else:
|
30 |
chrom, start, end = check_region(input_chrom, region_start,region_end, ref_genome,1000000)
|
31 |
|
32 |
+
progress(0.4, desc="predicting epigenome ...")
|
|
|
33 |
out_epi_binding = predict_epb(os.path.abspath('models/epi_bind.pt'), [start, end], ref_genome, atac_seq, device,
|
34 |
cop_type)
|
35 |
+
out_epi = predict_epis(os.path.abspath('models/epi_track.pt'), [start, end], ref_genome, atac_seq, device, cop_type)
|
36 |
+
|
37 |
+
progress(0.6, desc="predicting transcriptome ...")
|
38 |
out_cage = predict_cage(os.path.abspath('models/cage.pt'), [start, end], ref_genome, atac_seq, device, cop_type)
|
39 |
|
40 |
+
|
41 |
|
42 |
file_id = str(uuid.uuid4())
|
43 |
|
|
|
47 |
for f in os.listdir('results/'):
|
48 |
os.remove(os.path.join('results/', f))
|
49 |
|
50 |
+
progress(0.8, desc="predicting chromatin organization ...")
|
51 |
if cop_type == 'Micro-C':
|
52 |
out_cop = predict_microc(os.path.abspath('models/microc.pt'), [start, end], ref_genome, atac_seq, device)
|
53 |
np.savez_compressed( 'results/prediction_%s.npz'%file_id,
|
|
|
161 |
|
162 |
axs[-1].set_xlabel('chr%s:%s-%s'%(chrom,start,end))
|
163 |
plt.show()
|
164 |
+
return fig
|
|
|
|
|
|