re-type commited on
Commit
927f45c
·
verified ·
1 Parent(s): fc5903d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +79 -6
app.py CHANGED
@@ -862,10 +862,10 @@ def create_interface():
862
  gr.Markdown("### 🌲 Phylogenetic Tree Visualization (ML Simplified Tree)")
863
  tree_html = gr.HTML(
864
  label="Interactive Tree",
865
- value="<p>Click 'Show Tree' to view the ML Simplified Tree in a new tab.</p>"
866
  )
867
  with gr.Row():
868
- show_tree_btn = gr.Button("👁️ Show Tree", variant="secondary")
869
 
870
  # File downloads
871
  gr.Markdown("### 📁 Download Results")
@@ -885,6 +885,78 @@ def create_interface():
885
  interactive=False
886
  )
887
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
888
  # Event handlers
889
  def run_analysis_text(dna_seq, sim_score, build_tree):
890
  return run_pipeline(dna_seq, sim_score, build_tree)
@@ -907,9 +979,10 @@ def create_interface():
907
  try:
908
  # Use the same file-serving URL as the download link
909
  file_url = f"/file={html_file}"
910
- return gr.update(value=f"<script>window.open('{file_url}', '_blank');</script>")
 
911
  except Exception as e:
912
- return gr.update(value=f"<p>Error showing tree: {str(e)}. Please download and open the file manually.</p>")
913
  return gr.update(value="<p>No tree file available. Run analysis to generate one.</p>")
914
 
915
  # Connect events
@@ -928,10 +1001,10 @@ def create_interface():
928
  outputs=[dna_input, fasta_file, similarity_score, build_ml_tree, status_display]
929
  )
930
 
931
- show_tree_btn.click(
932
  fn=show_tree,
933
  inputs=[html_file],
934
- outputs=[tree_html]
935
  )
936
 
937
  # Example data loading
 
862
  gr.Markdown("### 🌲 Phylogenetic Tree Visualization (ML Simplified Tree)")
863
  tree_html = gr.HTML(
864
  label="Interactive Tree",
865
+ value="<p>Click the link below to view the ML Simplified Tree in a new tab.</p>"
866
  )
867
  with gr.Row():
868
+ show_tree_link = gr.HTML()
869
 
870
  # File downloads
871
  gr.Markdown("### 📁 Download Results")
 
885
  interactive=False
886
  )
887
 
888
+ with gr.Tab("ℹ️ Help & Info"):
889
+ gr.Markdown("""
890
+ ## About This Tool
891
+
892
+ ### F Gene Analysis Pipeline
893
+ This comprehensive pipeline analyzes F genes through multiple computational approaches:
894
+
895
+ #### 🎯 Gene Boundary Detection
896
+ - Uses deep learning to identify and extract F gene sequences from larger genomic sequences
897
+ - Provides confidence scores for detected boundaries
898
+ - Automatically trims sequences to focus on the F gene region
899
+
900
+ #### 🔍 Gene Validation
901
+ - Employs k-mer based machine learning models to validate extracted sequences
902
+ - Provides probability scores indicating likelihood of being a genuine F gene
903
+ - Uses 6-mer frequency patterns for classification
904
+
905
+ #### 🌳 Phylogenetic Analysis
906
+
907
+ **Maximum Likelihood Trees:**
908
+ - Requires MAFFT (sequence alignment) and IQ-TREE (phylogenetic reconstruction)
909
+ - Performs model selection and bootstrap analysis
910
+ - Generates publication-quality phylogenetic trees
911
+ - Provides detailed evolutionary analysis
912
+
913
+ **Simplified Trees:**
914
+ - Uses built-in algorithms for quick phylogenetic analysis
915
+ - Interactive visualization with similarity-based clustering
916
+ - Faster alternative when external tools are not available
917
+
918
+ ### Input Requirements
919
+ - **DNA Sequences**: ATCG format, minimum 50 bp for meaningful analysis
920
+ - **FASTA Files**: Standard FASTA format with single or multiple sequences
921
+ - **Similarity Threshold**: 1-99% for controlling phylogenetic analysis sensitivity
922
+
923
+ ### Dependencies
924
+
925
+ **Required for ML Trees:**
926
+ ```bash
927
+ # Ubuntu/Debian
928
+ sudo apt-get install mafft iqtree
929
+
930
+ # macOS
931
+ brew install mafft iqtree
932
+
933
+ # Conda
934
+ conda install -c bioconda mafft iqtree
935
+ ```
936
+
937
+ ### Output Files
938
+ - **Aligned FASTA**: Multiple sequence alignment in FASTA format
939
+ - **Tree File**: Newick format phylogenetic tree
940
+ - **HTML Tree**: Interactive visualization for web browsers (ML Simplified Tree)
941
+
942
+ ### Troubleshooting
943
+
944
+ **Common Issues:**
945
+ - *"No similar sequences found"*: Lower the similarity threshold
946
+ - *"Sequence too short"*: Provide sequences longer than 50 bp
947
+ - *"MAFFT/IQ-TREE not found"*: Install required dependencies
948
+ - *"Model not available"*: Check model files are properly downloaded
949
+
950
+ **Performance Tips:**
951
+ - Use sequences between 100-2000 bp for optimal performance
952
+ - Limit to <50 sequences for faster tree construction
953
+ - Lower similarity thresholds find more distant relatives
954
+ - Higher thresholds focus on closely related sequences
955
+
956
+ ### Citation
957
+ If you use this tool in your research, please cite the appropriate methods and tools used.
958
+ """)
959
+
960
  # Event handlers
961
  def run_analysis_text(dna_seq, sim_score, build_tree):
962
  return run_pipeline(dna_seq, sim_score, build_tree)
 
979
  try:
980
  # Use the same file-serving URL as the download link
981
  file_url = f"/file={html_file}"
982
+ link_html = f'<a href="{file_url}" target="_blank">View ML Simplified Tree</a>'
983
+ return gr.update(value=link_html)
984
  except Exception as e:
985
+ return gr.update(value=f"<p>Error generating link: {str(e)}. Please download and open the file manually.</p>")
986
  return gr.update(value="<p>No tree file available. Run analysis to generate one.</p>")
987
 
988
  # Connect events
 
1001
  outputs=[dna_input, fasta_file, similarity_score, build_ml_tree, status_display]
1002
  )
1003
 
1004
+ show_tree_link.click(
1005
  fn=show_tree,
1006
  inputs=[html_file],
1007
+ outputs=[show_tree_link]
1008
  )
1009
 
1010
  # Example data loading