Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,18 +4,18 @@ import numpy as np
|
|
| 4 |
import pandas as pd
|
| 5 |
from streamlit_cropper import st_cropper
|
| 6 |
|
| 7 |
-
# Mutation site headers
|
| 8 |
mutation_site_headers = [
|
| 9 |
-
3244, 3297, 3350, 3399, 3455, 3509, 3562,
|
| 10 |
3665, 3720, 3773, 3824, 3879, 3933, 3985, 4039,
|
| 11 |
4089, 4145, 4190, 4245, 4298, 4349, 4402, 4455,
|
| 12 |
4510, 4561, 4615, 4668, 4720, 4773, 4828, 4882
|
| 13 |
]
|
| 14 |
|
| 15 |
-
# Thresholds for each mutation site
|
| 16 |
thresholds = pd.Series({
|
| 17 |
3244: 1.094293328, 3297: 0.924916122, 3350: 0.664586629, 3399: 0.91573613,
|
| 18 |
-
3455: 1.300869714, 3509: 1.821975901, 3562: 1.178862418,
|
| 19 |
3665: 0.298697327, 3720: 0.58379781, 3773: 0.891088481, 3824: 1.145509641,
|
| 20 |
3879: 0.81833191, 3933: 2.93084335, 3985: 1.593758847, 4039: 0.966055013,
|
| 21 |
4089: 1.465671338, 4145: 0.30309335, 4190: 1.321615138, 4245: 1.709752495,
|
|
@@ -58,6 +58,7 @@ def binary_labels_to_string(bits: list[int]) -> str:
|
|
| 58 |
val = sum(b << (5 - j) for j, b in enumerate(chunk))
|
| 59 |
chars.append(voyager_table.get(val, '?'))
|
| 60 |
return ''.join(chars)
|
|
|
|
| 61 |
# def string_to_binary_labels(s: str) -> list[int]:
|
| 62 |
# bits = []
|
| 63 |
# for char in s:
|
|
@@ -141,16 +142,27 @@ with tab1:
|
|
| 141 |
for i, bits in enumerate(grouped):
|
| 142 |
st.write(f"'{user_input[i]}' → {bits}")
|
| 143 |
|
| 144 |
-
st.subheader("Binary Labels (
|
| 145 |
groups = []
|
| 146 |
-
for i in range(0, len(binary_labels),
|
| 147 |
-
group = binary_labels[i:i+
|
| 148 |
-
group += [0] * (
|
| 149 |
groups.append(group + [sum(group)])
|
| 150 |
|
| 151 |
-
|
| 152 |
-
st.dataframe(
|
| 153 |
-
st.download_button("Download as CSV",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 154 |
|
| 155 |
# Tab 2: Image to Binary
|
| 156 |
with tab2:
|
|
@@ -181,7 +193,7 @@ with tab2:
|
|
| 181 |
# Tab 3: EF → Binary
|
| 182 |
with tab3:
|
| 183 |
st.write("Upload an Editing Frequency CSV or enter manually:")
|
| 184 |
-
st.write("**Note:** Please upload CSV files **without column headers**. Just the
|
| 185 |
ef_file = st.file_uploader("Upload EF CSV", type=["csv"], key="ef")
|
| 186 |
|
| 187 |
if ef_file:
|
|
|
|
| 4 |
import pandas as pd
|
| 5 |
from streamlit_cropper import st_cropper
|
| 6 |
|
| 7 |
+
# Mutation site headers removed 3614,
|
| 8 |
mutation_site_headers = [
|
| 9 |
+
3244, 3297, 3350, 3399, 3455, 3509, 3562,
|
| 10 |
3665, 3720, 3773, 3824, 3879, 3933, 3985, 4039,
|
| 11 |
4089, 4145, 4190, 4245, 4298, 4349, 4402, 4455,
|
| 12 |
4510, 4561, 4615, 4668, 4720, 4773, 4828, 4882
|
| 13 |
]
|
| 14 |
|
| 15 |
+
# Thresholds for each mutation site removed 3614: 0.091557752,
|
| 16 |
thresholds = pd.Series({
|
| 17 |
3244: 1.094293328, 3297: 0.924916122, 3350: 0.664586629, 3399: 0.91573613,
|
| 18 |
+
3455: 1.300869714, 3509: 1.821975901, 3562: 1.178862418,
|
| 19 |
3665: 0.298697327, 3720: 0.58379781, 3773: 0.891088481, 3824: 1.145509641,
|
| 20 |
3879: 0.81833191, 3933: 2.93084335, 3985: 1.593758847, 4039: 0.966055013,
|
| 21 |
4089: 1.465671338, 4145: 0.30309335, 4190: 1.321615138, 4245: 1.709752495,
|
|
|
|
| 58 |
val = sum(b << (5 - j) for j, b in enumerate(chunk))
|
| 59 |
chars.append(voyager_table.get(val, '?'))
|
| 60 |
return ''.join(chars)
|
| 61 |
+
|
| 62 |
# def string_to_binary_labels(s: str) -> list[int]:
|
| 63 |
# bits = []
|
| 64 |
# for char in s:
|
|
|
|
| 142 |
for i, bits in enumerate(grouped):
|
| 143 |
st.write(f"'{user_input[i]}' → {bits}")
|
| 144 |
|
| 145 |
+
st.subheader("Binary Labels (31-bit groups)")
|
| 146 |
groups = []
|
| 147 |
+
for i in range(0, len(binary_labels), 31):
|
| 148 |
+
group = binary_labels[i:i+31]
|
| 149 |
+
group += [0] * (31 - len(group))
|
| 150 |
groups.append(group + [sum(group)])
|
| 151 |
|
| 152 |
+
df_31 = pd.DataFrame(groups, columns=[str(h) for h in mutation_site_headers] + ["Edited Sites"])
|
| 153 |
+
st.dataframe(df_31)
|
| 154 |
+
st.download_button("Download as CSV", df_31.to_csv(index=False), "text_32_binary_labels.csv")
|
| 155 |
+
|
| 156 |
+
st.subheader("Binary Labels (27-bit groups)")
|
| 157 |
+
groups = []
|
| 158 |
+
for i in range(0, len(binary_labels), 27):
|
| 159 |
+
group = binary_labels[i:i+27]
|
| 160 |
+
group += [0] * (27 - len(group))
|
| 161 |
+
groups.append(group + [sum(group)])
|
| 162 |
+
|
| 163 |
+
df_27 = pd.DataFrame(groups, columns=[str(h) for h in mutation_site_headers] + ["Edited Sites"])
|
| 164 |
+
st.dataframe(df_27)
|
| 165 |
+
st.download_button("Download as CSV", df_27.to_csv(index=False), "text_27_binary_labels.csv")
|
| 166 |
|
| 167 |
# Tab 2: Image to Binary
|
| 168 |
with tab2:
|
|
|
|
| 193 |
# Tab 3: EF → Binary
|
| 194 |
with tab3:
|
| 195 |
st.write("Upload an Editing Frequency CSV or enter manually:")
|
| 196 |
+
st.write("**Note:** Please upload CSV files **without column headers**. Just the 31 editing frequencies per row.")
|
| 197 |
ef_file = st.file_uploader("Upload EF CSV", type=["csv"], key="ef")
|
| 198 |
|
| 199 |
if ef_file:
|