Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -999,6 +999,67 @@ def main():
|
|
| 999 |
st.write(f"Query COM: [{selected_row['Query_COM'][0]:.3f}, {selected_row['Query_COM'][1]:.3f}, {selected_row['Query_COM'][2]:.3f}]")
|
| 1000 |
|
| 1001 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1002 |
|
| 1003 |
else:
|
| 1004 |
st.warning("No comparisons below RMSD threshold to visualize")
|
|
@@ -1076,11 +1137,16 @@ Query: {row['Query']}
|
|
| 1076 |
zip_buffer.seek(0)
|
| 1077 |
|
| 1078 |
st.download_button(
|
| 1079 |
-
label="π₯ Download ZIP",
|
| 1080 |
data=zip_buffer.getvalue(),
|
| 1081 |
file_name="aligned_structures.zip",
|
| 1082 |
-
mime="application/zip"
|
|
|
|
| 1083 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1084 |
|
| 1085 |
|
| 1086 |
if __name__ == "__main__":
|
|
|
|
| 999 |
st.write(f"Query COM: [{selected_row['Query_COM'][0]:.3f}, {selected_row['Query_COM'][1]:.3f}, {selected_row['Query_COM'][2]:.3f}]")
|
| 1000 |
|
| 1001 |
|
| 1002 |
+
# Download aligned structures
|
| 1003 |
+
with st.expander("πΎ Download Structure Files"):
|
| 1004 |
+
st.markdown("**Download extracted and aligned structures for external visualization**")
|
| 1005 |
+
|
| 1006 |
+
from visualization import extract_window_pdb, transform_pdb_string
|
| 1007 |
+
|
| 1008 |
+
# Extract reference window
|
| 1009 |
+
ref_pdb = extract_window_pdb(
|
| 1010 |
+
selected_row['Ref_Path'],
|
| 1011 |
+
selected_row['Ref_Indices']
|
| 1012 |
+
)
|
| 1013 |
+
|
| 1014 |
+
# Extract and transform query window
|
| 1015 |
+
query_pdb = extract_window_pdb(
|
| 1016 |
+
selected_row['Query_Path'],
|
| 1017 |
+
selected_row['Query_Indices']
|
| 1018 |
+
)
|
| 1019 |
+
|
| 1020 |
+
query_aligned_pdb = transform_pdb_string(
|
| 1021 |
+
query_pdb,
|
| 1022 |
+
selected_row['Rotation_Matrix'],
|
| 1023 |
+
selected_row['Query_COM'],
|
| 1024 |
+
selected_row['Ref_COM']
|
| 1025 |
+
)
|
| 1026 |
+
|
| 1027 |
+
col1, col2, col3 = st.columns(3)
|
| 1028 |
+
|
| 1029 |
+
with col1:
|
| 1030 |
+
# Reference structure
|
| 1031 |
+
ref_filename = f"ref_{selected_row['Reference'].replace('.pdb', '')}_{'_'.join(map(str, [i+1 for i in selected_row['Ref_Indices']]))}.pdb"
|
| 1032 |
+
st.download_button(
|
| 1033 |
+
label="π₯ Reference PDB",
|
| 1034 |
+
data=ref_pdb,
|
| 1035 |
+
file_name=ref_filename,
|
| 1036 |
+
mime="chemical/x-pdb",
|
| 1037 |
+
help="Original reference structure (selected residues only)"
|
| 1038 |
+
)
|
| 1039 |
+
|
| 1040 |
+
with col2:
|
| 1041 |
+
# Query structure (original position)
|
| 1042 |
+
query_filename = f"query_{selected_row['Query'].replace('.pdb', '')}_{'_'.join(map(str, [i+1 for i in selected_row['Query_Indices']]))}.pdb"
|
| 1043 |
+
st.download_button(
|
| 1044 |
+
label="π₯ Query PDB (Original)",
|
| 1045 |
+
data=query_pdb,
|
| 1046 |
+
file_name=query_filename,
|
| 1047 |
+
mime="chemical/x-pdb",
|
| 1048 |
+
help="Original query structure (selected residues only)"
|
| 1049 |
+
)
|
| 1050 |
+
|
| 1051 |
+
with col3:
|
| 1052 |
+
# Query structure (aligned)
|
| 1053 |
+
query_aligned_filename = f"query_aligned_{selected_row['Query'].replace('.pdb', '')}_{'_'.join(map(str, [i+1 for i in selected_row['Query_Indices']]))}.pdb"
|
| 1054 |
+
st.download_button(
|
| 1055 |
+
label="π₯ Query PDB (Aligned)",
|
| 1056 |
+
data=query_aligned_pdb,
|
| 1057 |
+
file_name=query_aligned_filename,
|
| 1058 |
+
mime="chemical/x-pdb",
|
| 1059 |
+
help="Query structure aligned to reference"
|
| 1060 |
+
)
|
| 1061 |
+
|
| 1062 |
+
st.info("π‘ **Tip:** Load reference and aligned query together in PyMOL/Chimera to examine the superposition")
|
| 1063 |
|
| 1064 |
else:
|
| 1065 |
st.warning("No comparisons below RMSD threshold to visualize")
|
|
|
|
| 1137 |
zip_buffer.seek(0)
|
| 1138 |
|
| 1139 |
st.download_button(
|
| 1140 |
+
label="π₯ Download PDB Archive (ZIP)",
|
| 1141 |
data=zip_buffer.getvalue(),
|
| 1142 |
file_name="aligned_structures.zip",
|
| 1143 |
+
mime="application/zip",
|
| 1144 |
+
help=f"Contains {len(filtered_df)} comparison sets with reference, original query, and aligned query PDBs"
|
| 1145 |
)
|
| 1146 |
+
|
| 1147 |
+
st.success(f"β
Archive ready! Contains {len(filtered_df)} comparisons with 3 PDB files each.")
|
| 1148 |
+
|
| 1149 |
+
|
| 1150 |
|
| 1151 |
|
| 1152 |
if __name__ == "__main__":
|