Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -18,10 +18,10 @@ if uploaded_file1 and uploaded_file2:
|
|
18 |
df1 = pd.read_excel(uploaded_file1, header=1)
|
19 |
df2 = pd.read_excel(uploaded_file2, header=1)
|
20 |
|
21 |
-
#
|
22 |
-
id_col =
|
23 |
-
name_col =
|
24 |
-
repeat_cols =
|
25 |
|
26 |
records = []
|
27 |
|
@@ -29,7 +29,7 @@ if uploaded_file1 and uploaded_file2:
|
|
29 |
entry_id = row1[id_col]
|
30 |
protein_name = row1[name_col]
|
31 |
|
32 |
-
# Match
|
33 |
match = df2[(df2[id_col] == entry_id) & (df2[name_col] == protein_name)]
|
34 |
if match.empty:
|
35 |
continue
|
@@ -41,8 +41,8 @@ if uploaded_file1 and uploaded_file2:
|
|
41 |
if freq1 != freq2:
|
42 |
diff = abs(freq1 - freq2)
|
43 |
records.append({
|
44 |
-
|
45 |
-
|
46 |
"Repeat": repeat,
|
47 |
"Frequency File 1": freq1,
|
48 |
"Frequency File 2": freq2,
|
@@ -52,7 +52,6 @@ if uploaded_file1 and uploaded_file2:
|
|
52 |
result_df = pd.DataFrame(records)
|
53 |
result_df = result_df.sort_values(by="Difference", ascending=False)
|
54 |
|
55 |
-
# In-memory Excel
|
56 |
output = BytesIO()
|
57 |
with pd.ExcelWriter(output, engine="openpyxl") as writer:
|
58 |
result_df.to_excel(writer, index=False)
|
@@ -67,5 +66,4 @@ if uploaded_file1 and uploaded_file2:
|
|
67 |
)
|
68 |
|
69 |
except Exception as e:
|
70 |
-
st.error(f"⚠️ Error: {e}")
|
71 |
-
|
|
|
18 |
df1 = pd.read_excel(uploaded_file1, header=1)
|
19 |
df2 = pd.read_excel(uploaded_file2, header=1)
|
20 |
|
21 |
+
# Automatically detect first two columns
|
22 |
+
id_col = df1.columns[0]
|
23 |
+
name_col = df1.columns[1]
|
24 |
+
repeat_cols = df1.columns[2:]
|
25 |
|
26 |
records = []
|
27 |
|
|
|
29 |
entry_id = row1[id_col]
|
30 |
protein_name = row1[name_col]
|
31 |
|
32 |
+
# Match in second file
|
33 |
match = df2[(df2[id_col] == entry_id) & (df2[name_col] == protein_name)]
|
34 |
if match.empty:
|
35 |
continue
|
|
|
41 |
if freq1 != freq2:
|
42 |
diff = abs(freq1 - freq2)
|
43 |
records.append({
|
44 |
+
id_col: entry_id,
|
45 |
+
name_col: protein_name,
|
46 |
"Repeat": repeat,
|
47 |
"Frequency File 1": freq1,
|
48 |
"Frequency File 2": freq2,
|
|
|
52 |
result_df = pd.DataFrame(records)
|
53 |
result_df = result_df.sort_values(by="Difference", ascending=False)
|
54 |
|
|
|
55 |
output = BytesIO()
|
56 |
with pd.ExcelWriter(output, engine="openpyxl") as writer:
|
57 |
result_df.to_excel(writer, index=False)
|
|
|
66 |
)
|
67 |
|
68 |
except Exception as e:
|
69 |
+
st.error(f"⚠️ Error: {e}")
|
|