Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -104,7 +104,11 @@ def dl(valforkey):
|
|
104 |
hh=pd.read_table('output/SBS96/Samples.txt')
|
105 |
hh['nums']=hh.iloc[:,1]
|
106 |
hh['mutation_simple']=hh['MutationType'].apply(lambda x: re.sub('].$','',re.sub('^.\[','',x)))
|
107 |
-
summary_table_sbs_all=hh.groupby('mutation_simple').apply(lambda x: x.sum())[['mutation_simple','nums']]
|
|
|
|
|
|
|
|
|
108 |
#st.download_button(label="Download image with single base substitution profiles", key=valforkey,
|
109 |
# data=PDFbyte1,
|
110 |
# file_name="SBS.pdf",
|
@@ -118,11 +122,15 @@ def dl(valforkey):
|
|
118 |
hh2=pd.read_table('output/ID83/Samples.txt')
|
119 |
hh2['nums']=hh2.iloc[:,1]
|
120 |
hh2['mutation_simple']=hh2['MutationType'].apply(lambda x: re.sub('].$','',re.sub('^.\[','',x)))
|
121 |
-
summary_table_id_all=hh2.groupby('mutation_simple').apply(lambda x: x.sum())[['mutation_simple','nums']]
|
|
|
|
|
|
|
|
|
122 |
else:
|
123 |
PDFbyte2 = []
|
124 |
Txtbyte2 = []
|
125 |
-
|
126 |
if glob.glob("output/DBS78/Suggested_Solution/COSMIC_DBS78_Decomposed_Solution/DBS78_Decomposition_Plots.pdf") != []:
|
127 |
with open("output/DBS78/Suggested_Solution/COSMIC_DBS78_Decomposed_Solution/DBS78_Decomposition_Plots.pdf", "rb") as pdf_file:
|
128 |
PDFbyte3 = pdf_file.read()
|
@@ -131,11 +139,15 @@ def dl(valforkey):
|
|
131 |
hh3=pd.read_table('output/DBS78/Samples.txt')
|
132 |
hh3['nums']=hh3.iloc[:,1]
|
133 |
hh3['mutation_simple']=hh3['MutationType'].apply(lambda x: re.sub('].$','',re.sub('^.\[','',x)))
|
134 |
-
summary_table_dbs_all=hh3.groupby('mutation_simple').apply(lambda x: x.sum())[['mutation_simple','nums']]
|
|
|
|
|
|
|
|
|
135 |
else:
|
136 |
PDFbyte3 = []
|
137 |
Txtbyte3=[]
|
138 |
-
|
139 |
os.system('rm -r output')
|
140 |
os.system('rm -r input')
|
141 |
#os.remove("output/SBS96/Suggested_Solution/COSMIC_SBS96_Decomposed_Solution/SBS96_Decomposition_Plots.pdf")
|
@@ -151,7 +163,7 @@ def dl(valforkey):
|
|
151 |
# data=PDFbyte2,
|
152 |
# file_name="idel.pdf",
|
153 |
# mime='application/octet-stream')
|
154 |
-
return PDFbyte1,PDFbyte2,PDFbyte3,Txtbyte1,Txtbyte2,Txtbyte3,
|
155 |
|
156 |
|
157 |
|
|
|
104 |
hh=pd.read_table('output/SBS96/Samples.txt')
|
105 |
hh['nums']=hh.iloc[:,1]
|
106 |
hh['mutation_simple']=hh['MutationType'].apply(lambda x: re.sub('].$','',re.sub('^.\[','',x)))
|
107 |
+
summary_table_sbs_all=hh.groupby('mutation_simple').apply(lambda x: x.sum())[['mutation_simple','nums']]
|
108 |
+
summary_table_sbs_all.to_csv('sbs_summary.txt',sep='\t',header=False,index=False)
|
109 |
+
with open("sbs_summary.txt","rb") as txt_file:
|
110 |
+
summary_table_sbs_all_bytes = txt_file.read()
|
111 |
+
txt_file.close()
|
112 |
#st.download_button(label="Download image with single base substitution profiles", key=valforkey,
|
113 |
# data=PDFbyte1,
|
114 |
# file_name="SBS.pdf",
|
|
|
122 |
hh2=pd.read_table('output/ID83/Samples.txt')
|
123 |
hh2['nums']=hh2.iloc[:,1]
|
124 |
hh2['mutation_simple']=hh2['MutationType'].apply(lambda x: re.sub('].$','',re.sub('^.\[','',x)))
|
125 |
+
summary_table_id_all=hh2.groupby('mutation_simple').apply(lambda x: x.sum())[['mutation_simple','nums']]
|
126 |
+
summary_table_id_all.to_csv('id_summary.txt',sep='\t',header=False,index=False)
|
127 |
+
with open("id_summary.txt","rb") as txt_file:
|
128 |
+
summary_table_id_all_bytes = txt_file.read()
|
129 |
+
txt_file.close()
|
130 |
else:
|
131 |
PDFbyte2 = []
|
132 |
Txtbyte2 = []
|
133 |
+
summary_table_id_all_bytes=[]
|
134 |
if glob.glob("output/DBS78/Suggested_Solution/COSMIC_DBS78_Decomposed_Solution/DBS78_Decomposition_Plots.pdf") != []:
|
135 |
with open("output/DBS78/Suggested_Solution/COSMIC_DBS78_Decomposed_Solution/DBS78_Decomposition_Plots.pdf", "rb") as pdf_file:
|
136 |
PDFbyte3 = pdf_file.read()
|
|
|
139 |
hh3=pd.read_table('output/DBS78/Samples.txt')
|
140 |
hh3['nums']=hh3.iloc[:,1]
|
141 |
hh3['mutation_simple']=hh3['MutationType'].apply(lambda x: re.sub('].$','',re.sub('^.\[','',x)))
|
142 |
+
summary_table_dbs_all=hh3.groupby('mutation_simple').apply(lambda x: x.sum())[['mutation_simple','nums']]
|
143 |
+
summary_table_dbs_all.to_csv('dbs_summary.txt',sep='\t',header=False,index=False)
|
144 |
+
with open("dbs_summary.txt","rb") as txt_file:
|
145 |
+
summary_table_dbs_all_bytes = txt_file.read()
|
146 |
+
txt_file.close()
|
147 |
else:
|
148 |
PDFbyte3 = []
|
149 |
Txtbyte3=[]
|
150 |
+
summary_table_dbs_all_bytes=[]
|
151 |
os.system('rm -r output')
|
152 |
os.system('rm -r input')
|
153 |
#os.remove("output/SBS96/Suggested_Solution/COSMIC_SBS96_Decomposed_Solution/SBS96_Decomposition_Plots.pdf")
|
|
|
163 |
# data=PDFbyte2,
|
164 |
# file_name="idel.pdf",
|
165 |
# mime='application/octet-stream')
|
166 |
+
return PDFbyte1,PDFbyte2,PDFbyte3,Txtbyte1,Txtbyte2,Txtbyte3, summary_table_sbs_all_bytes, summary_table_id_all_bytes,summary_table_dbs_all_bytes
|
167 |
|
168 |
|
169 |
|