Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,6 +6,8 @@ from streamlit_cropper import st_cropper
|
|
| 6 |
|
| 7 |
# Simple app: convert user input into ASCII codes and binary labels
|
| 8 |
|
|
|
|
|
|
|
| 9 |
def string_to_binary_labels(s: str) -> list[int]:
|
| 10 |
bits: list[int] = []
|
| 11 |
for char in s:
|
|
@@ -59,14 +61,6 @@ def binary_labels_to_rgb_image(binary_labels: list[int], width: int = None, heig
|
|
| 59 |
img = Image.fromarray(array, mode='RGB')
|
| 60 |
return img
|
| 61 |
|
| 62 |
-
# Predefined headers for the 32 mutation sites
|
| 63 |
-
mutation_site_headers = [
|
| 64 |
-
3244, 3297, 3350, 3399, 3455, 3509, 3562, 3614,
|
| 65 |
-
3665, 3720, 3773, 3824, 3879, 3933, 3985, 4039,
|
| 66 |
-
4089, 4145, 4190, 4245, 4298, 4349, 4402, 4455,
|
| 67 |
-
4510, 4561, 4615, 4668, 4720, 4773, 4828, 4882
|
| 68 |
-
]
|
| 69 |
-
|
| 70 |
# Load thresholds from file
|
| 71 |
thresholds = pd.read_csv("Column_Thresholds.csv", index_col=0).squeeze()
|
| 72 |
|
|
@@ -175,8 +169,16 @@ with tab3:
|
|
| 175 |
binary_part = edited_df[common_cols].ge(thresholds[common_cols]).astype(int)
|
| 176 |
non_binary_part = edited_df.drop(columns=common_cols, errors='ignore')
|
| 177 |
binary_df = pd.concat([non_binary_part, binary_part], axis=1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 178 |
st.subheader("Binary Labels")
|
| 179 |
-
st.dataframe(
|
|
|
|
| 180 |
st.download_button(
|
| 181 |
label="Download Binary Labels Table as CSV",
|
| 182 |
data=binary_df.to_csv(index=False),
|
|
@@ -184,4 +186,4 @@ with tab3:
|
|
| 184 |
mime="text/csv"
|
| 185 |
)
|
| 186 |
|
| 187 |
-
# Future: integrate DNA editor mapping for each mutation site here
|
|
|
|
| 6 |
|
| 7 |
# Simple app: convert user input into ASCII codes and binary labels
|
| 8 |
|
| 9 |
+
# (functions string_to_binary_labels, clean_image, image_to_binary_labels_rgb, binary_labels_to_rgb_image stay unchanged)
|
| 10 |
+
|
| 11 |
def string_to_binary_labels(s: str) -> list[int]:
|
| 12 |
bits: list[int] = []
|
| 13 |
for char in s:
|
|
|
|
| 61 |
img = Image.fromarray(array, mode='RGB')
|
| 62 |
return img
|
| 63 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
# Load thresholds from file
|
| 65 |
thresholds = pd.read_csv("Column_Thresholds.csv", index_col=0).squeeze()
|
| 66 |
|
|
|
|
| 169 |
binary_part = edited_df[common_cols].ge(thresholds[common_cols]).astype(int)
|
| 170 |
non_binary_part = edited_df.drop(columns=common_cols, errors='ignore')
|
| 171 |
binary_df = pd.concat([non_binary_part, binary_part], axis=1)
|
| 172 |
+
|
| 173 |
+
def highlight_binary(val):
|
| 174 |
+
color = 'lightgreen' if val == 1 else 'lightcoral'
|
| 175 |
+
return f'background-color: {color}'
|
| 176 |
+
|
| 177 |
+
styled_binary_df = binary_df.style.applymap(highlight_binary, subset=common_cols)
|
| 178 |
+
|
| 179 |
st.subheader("Binary Labels")
|
| 180 |
+
st.dataframe(styled_binary_df)
|
| 181 |
+
|
| 182 |
st.download_button(
|
| 183 |
label="Download Binary Labels Table as CSV",
|
| 184 |
data=binary_df.to_csv(index=False),
|
|
|
|
| 186 |
mime="text/csv"
|
| 187 |
)
|
| 188 |
|
| 189 |
+
# Future: integrate DNA editor mapping for each mutation site here
|