jiehou commited on
Commit
938fc1a
·
verified ·
1 Parent(s): fd426e8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -25
app.py CHANGED
@@ -495,6 +495,31 @@ def main():
495
  else:
496
  st.sidebar.warning("⚠️ Upload or select structures")
497
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
498
  # Load structure data
499
  ref_structure_data = []
500
  query_structure_data = []
@@ -599,7 +624,7 @@ def main():
599
 
600
  if selection_method == "Select by range":
601
  current_selection = st.session_state['ref_selections'].get(selected_ref['name'], [])
602
- default_start = current_selection[0] + 2 if current_selection else 3
603
  default_end = current_selection[-1] + 1 if current_selection else max(2, len(structure_info) - 2)
604
 
605
  c1, c2 = st.columns(2)
@@ -627,20 +652,14 @@ def main():
627
  st.error("Start index must be ≤ end index")
628
 
629
  elif selection_method == "Select specific residues":
630
- current_selection = st.session_state['ref_selections'].get(selected_ref['name'], [])
631
- default_names = [structure_info[i]['full_name'] for i in current_selection] if current_selection else []
632
 
633
- #selected_names = st.multiselect(
634
- # "Select residues",
635
- # options=[info['full_name'] for info in structure_info],
636
- # default=[structure_info[i]['full_name'] for i in range(2, len(structure_info)-2)],
637
- # key=f"specific_ref_{selected_ref['name']}"
638
- #)
639
  selected_names = st.multiselect(
640
  "Select residues",
641
  options=[info['full_name'] for info in structure_info],
642
- default=default_names if default_names else [structure_info[i]['full_name'] for i in range(2, len(structure_info)-2)], # ✅ Use saved selection
643
- key=f"specific_ref_{selected_ref['name']}"
644
  )
645
 
646
 
@@ -705,8 +724,8 @@ def main():
705
 
706
  if selection_method == "Select by range":
707
  current_selection = st.session_state['query_selections'].get(selected_query['name'], [])
708
- default_start = current_selection[0] + 2 if current_selection else 3
709
- default_end = current_selection[-1] + 1 if current_selection else max(2, len(structure_info) - 2)
710
 
711
  c1, c2 = st.columns(2)
712
  with c1:
@@ -733,21 +752,14 @@ def main():
733
  st.error("Start index must be ≤ end index")
734
 
735
  elif selection_method == "Select specific residues":
736
- current_selection = st.session_state['query_selections'].get(selected_query['name'], [])
737
- default_names = [structure_info[i]['full_name'] for i in current_selection] if current_selection else []
738
 
739
- #selected_names = st.multiselect(
740
- # "Select residues",
741
- # options=[info['full_name'] for info in structure_info],
742
- # default=[structure_info[i]['full_name'] for i in range(2, len(structure_info)-2)],
743
- # key=f"specific_query_{selected_query['name']}"
744
- #)
745
-
746
  selected_names = st.multiselect(
747
  "Select residues",
748
  options=[info['full_name'] for info in structure_info],
749
- default=default_names if default_names else [structure_info[i]['full_name'] for i in range(2, len(structure_info)-2)], # ✅ Use saved selection
750
- key=f"specific_query_{selected_query['name']}"
751
  )
752
 
753
  name_to_idx = {info['full_name']: info['index'] for info in structure_info}
@@ -805,6 +817,7 @@ def main():
805
  window_size = 4
806
  window_type = "contiguous"
807
 
 
808
  # Step 5: Run Analysis
809
  st.sidebar.subheader("4️⃣ Run Analysis")
810
 
@@ -1157,4 +1170,4 @@ Query: {row['Query']}
1157
 
1158
 
1159
  if __name__ == "__main__":
1160
- main()
 
495
  else:
496
  st.sidebar.warning("⚠️ Upload or select structures")
497
 
498
+ # Residue trimming controls - add early so they're available when needed
499
+ st.sidebar.markdown("---")
500
+ st.sidebar.markdown("**🔧 Terminal Residue Trimming**")
501
+ col1, col2 = st.sidebar.columns(2)
502
+ with col1:
503
+ n_term_trim = st.number_input(
504
+ "N-term trim",
505
+ min_value=0,
506
+ max_value=10,
507
+ value=2,
508
+ step=1,
509
+ help="Number of residues to remove from 5' end",
510
+ key="n_term_trim"
511
+ )
512
+ with col2:
513
+ c_term_trim = st.number_input(
514
+ "C-term trim",
515
+ min_value=0,
516
+ max_value=10,
517
+ value=2,
518
+ step=1,
519
+ help="Number of residues to remove from 3' end",
520
+ key="c_term_trim"
521
+ )
522
+
523
  # Load structure data
524
  ref_structure_data = []
525
  query_structure_data = []
 
624
 
625
  if selection_method == "Select by range":
626
  current_selection = st.session_state['ref_selections'].get(selected_ref['name'], [])
627
+ default_start = current_selection[0] + n_term_trim if current_selection else 3
628
  default_end = current_selection[-1] + 1 if current_selection else max(2, len(structure_info) - 2)
629
 
630
  c1, c2 = st.columns(2)
 
652
  st.error("Start index must be ≤ end index")
653
 
654
  elif selection_method == "Select specific residues":
655
+ # Always use current trim values for default selection (updates when trim values change)
656
+ default_names = [structure_info[i]['full_name'] for i in range(n_term_trim, len(structure_info)-c_term_trim)]
657
 
 
 
 
 
 
 
658
  selected_names = st.multiselect(
659
  "Select residues",
660
  options=[info['full_name'] for info in structure_info],
661
+ default=default_names,
662
+ key=f"specific_ref_{selected_ref['name']}_n{n_term_trim}_c{c_term_trim}"
663
  )
664
 
665
 
 
724
 
725
  if selection_method == "Select by range":
726
  current_selection = st.session_state['query_selections'].get(selected_query['name'], [])
727
+ default_start = current_selection[0] + n_term_trim if current_selection else 3
728
+ default_end = current_selection[-1] + 1 if current_selection else max(2, len(structure_info) - c_term_trim)
729
 
730
  c1, c2 = st.columns(2)
731
  with c1:
 
752
  st.error("Start index must be ≤ end index")
753
 
754
  elif selection_method == "Select specific residues":
755
+ # Always use current trim values for default selection (updates when trim values change)
756
+ default_names = [structure_info[i]['full_name'] for i in range(n_term_trim, len(structure_info)-c_term_trim)]
757
 
 
 
 
 
 
 
 
758
  selected_names = st.multiselect(
759
  "Select residues",
760
  options=[info['full_name'] for info in structure_info],
761
+ default=default_names,
762
+ key=f"specific_query_{selected_query['name']}_n{n_term_trim}_c{c_term_trim}"
763
  )
764
 
765
  name_to_idx = {info['full_name']: info['index'] for info in structure_info}
 
817
  window_size = 4
818
  window_type = "contiguous"
819
 
820
+
821
  # Step 5: Run Analysis
822
  st.sidebar.subheader("4️⃣ Run Analysis")
823
 
 
1170
 
1171
 
1172
  if __name__ == "__main__":
1173
+ main()