re-type commited on
Commit
c20d2fd
·
verified ·
1 Parent(s): cc42531

Update app.py

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