Spaces:
No application file
No application file
Update app.py
Browse files
app.py
CHANGED
|
@@ -755,9 +755,9 @@ def create_gradio_interface():
|
|
| 755 |
# 🧬 F Gene Analysis Pipeline
|
| 756 |
|
| 757 |
This tool performs comprehensive analysis of F gene sequences including:
|
| 758 |
-
- **Gene Boundary Prediction**:
|
| 759 |
-
- **F Gene Validation**:
|
| 760 |
-
- **Phylogenetic Analysis**:
|
| 761 |
""")
|
| 762 |
|
| 763 |
with gr.Tab("Sequence Analysis"):
|
|
@@ -765,28 +765,14 @@ def create_gradio_interface():
|
|
| 765 |
with gr.Column(scale=1):
|
| 766 |
gr.Markdown("### Input")
|
| 767 |
|
| 768 |
-
# Input options
|
| 769 |
-
input_method = gr.Radio(
|
| 770 |
-
choices=["Text Input", "File Upload"],
|
| 771 |
-
value="Text Input",
|
| 772 |
-
label="Input Method"
|
| 773 |
-
)
|
| 774 |
-
|
| 775 |
-
# Text input
|
| 776 |
dna_sequence = gr.Textbox(
|
| 777 |
label="DNA Sequence",
|
| 778 |
-
placeholder="Enter your DNA sequence here (
|
| 779 |
lines=8,
|
| 780 |
visible=True
|
| 781 |
)
|
| 782 |
|
| 783 |
-
# File upload
|
| 784 |
-
fasta_file = gr.File(
|
| 785 |
-
label="Upload FASTA File",
|
| 786 |
-
file_types=[".fasta", ".fa", ".txt"],
|
| 787 |
-
visible=False
|
| 788 |
-
)
|
| 789 |
-
|
| 790 |
# Parameters
|
| 791 |
gr.Markdown("### Parameters")
|
| 792 |
similarity_threshold = gr.Slider(
|
|
@@ -854,11 +840,6 @@ def create_gradio_interface():
|
|
| 854 |
)
|
| 855 |
|
| 856 |
with gr.Tab("Download Files"):
|
| 857 |
-
alignment_file = gr.File(
|
| 858 |
-
label="Alignment File",
|
| 859 |
-
interactive=False
|
| 860 |
-
)
|
| 861 |
-
|
| 862 |
tree_file = gr.File(
|
| 863 |
label="Tree File",
|
| 864 |
interactive=False
|
|
@@ -874,7 +855,7 @@ def create_gradio_interface():
|
|
| 874 |
## 📖 User Guide
|
| 875 |
|
| 876 |
### Input Requirements
|
| 877 |
-
- **DNA Sequence**: Nucleotide sequences in
|
| 878 |
- **Minimum Length**: 10 bp for tree analysis, 100 bp for phylogenetic placement
|
| 879 |
- **Accepted Characters**: A, T, C, G, N (other characters will be converted to N)
|
| 880 |
|
|
@@ -888,7 +869,6 @@ def create_gradio_interface():
|
|
| 888 |
- **Build ML Tree**: Enable for comprehensive phylogenetic placement analysis
|
| 889 |
|
| 890 |
### Output Files
|
| 891 |
-
- **Alignment File**: Multiple sequence alignment in FASTA format
|
| 892 |
- **Tree File**: Phylogenetic tree in Newick format
|
| 893 |
- **HTML Tree**: Interactive visualization file
|
| 894 |
|
|
@@ -901,30 +881,12 @@ def create_gradio_interface():
|
|
| 901 |
""")
|
| 902 |
|
| 903 |
# Event handlers
|
| 904 |
-
def
|
| 905 |
-
if method == "Text Input":
|
| 906 |
-
return gr.update(visible=True), gr.update(visible=False)
|
| 907 |
-
else:
|
| 908 |
-
return gr.update(visible=False), gr.update(visible=True)
|
| 909 |
-
|
| 910 |
-
input_method.change(
|
| 911 |
-
toggle_input_method,
|
| 912 |
-
inputs=[input_method],
|
| 913 |
-
outputs=[dna_sequence, fasta_file]
|
| 914 |
-
)
|
| 915 |
-
|
| 916 |
-
def run_analysis(input_method, dna_seq, file_obj, similarity, build_ml):
|
| 917 |
"""Main analysis function"""
|
| 918 |
try:
|
| 919 |
-
if
|
| 920 |
-
|
| 921 |
-
|
| 922 |
-
else:
|
| 923 |
-
# Process text input
|
| 924 |
-
if not dna_seq or not dna_seq.strip():
|
| 925 |
-
return ("❌ Please provide a DNA sequence", "", "", "", "", None, None, None, "No input provided")
|
| 926 |
-
results = run_pipeline(dna_seq, similarity, build_ml)
|
| 927 |
-
|
| 928 |
return results
|
| 929 |
|
| 930 |
except Exception as e:
|
|
@@ -936,7 +898,6 @@ def create_gradio_interface():
|
|
| 936 |
"""Clear all inputs and outputs"""
|
| 937 |
return (
|
| 938 |
"", # dna_sequence
|
| 939 |
-
None, # fasta_file
|
| 940 |
95, # similarity_threshold
|
| 941 |
False, # build_ml_tree_checkbox
|
| 942 |
"", # boundary_output
|
|
@@ -945,18 +906,15 @@ def create_gradio_interface():
|
|
| 945 |
"", # tree_analysis_output
|
| 946 |
"", # extracted_sequence
|
| 947 |
"", # tree_html
|
| 948 |
-
None, # alignment_file
|
| 949 |
None, # tree_file
|
| 950 |
-
None
|
| 951 |
)
|
| 952 |
|
| 953 |
# Connect the analyze button
|
| 954 |
analyze_btn.click(
|
| 955 |
fn=run_analysis,
|
| 956 |
inputs=[
|
| 957 |
-
input_method,
|
| 958 |
dna_sequence,
|
| 959 |
-
fasta_file,
|
| 960 |
similarity_threshold,
|
| 961 |
build_ml_tree_checkbox
|
| 962 |
],
|
|
@@ -966,7 +924,6 @@ def create_gradio_interface():
|
|
| 966 |
ml_tree_output,
|
| 967 |
tree_analysis_output,
|
| 968 |
extracted_sequence,
|
| 969 |
-
alignment_file,
|
| 970 |
tree_file,
|
| 971 |
html_tree_file,
|
| 972 |
tree_html
|
|
@@ -978,7 +935,6 @@ def create_gradio_interface():
|
|
| 978 |
fn=clear_all,
|
| 979 |
outputs=[
|
| 980 |
dna_sequence,
|
| 981 |
-
fasta_file,
|
| 982 |
similarity_threshold,
|
| 983 |
build_ml_tree_checkbox,
|
| 984 |
boundary_output,
|
|
@@ -987,7 +943,6 @@ def create_gradio_interface():
|
|
| 987 |
tree_analysis_output,
|
| 988 |
extracted_sequence,
|
| 989 |
tree_html,
|
| 990 |
-
alignment_file,
|
| 991 |
tree_file,
|
| 992 |
html_tree_file
|
| 993 |
]
|
|
|
|
| 755 |
# 🧬 F Gene Analysis Pipeline
|
| 756 |
|
| 757 |
This tool performs comprehensive analysis of F gene sequences including:
|
| 758 |
+
- **Gene Boundary Prediction**: Identifies and extracts F gene regions from input sequences
|
| 759 |
+
- **F Gene Validation**: Validates sequences using ML models
|
| 760 |
+
- **Phylogenetic Analysis**: Builds phylogenetic trees and performs sequence placement
|
| 761 |
""")
|
| 762 |
|
| 763 |
with gr.Tab("Sequence Analysis"):
|
|
|
|
| 765 |
with gr.Column(scale=1):
|
| 766 |
gr.Markdown("### Input")
|
| 767 |
|
| 768 |
+
# Input options (simplified to Text Input only)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 769 |
dna_sequence = gr.Textbox(
|
| 770 |
label="DNA Sequence",
|
| 771 |
+
placeholder="Enter your DNA sequence here (raw sequence)",
|
| 772 |
lines=8,
|
| 773 |
visible=True
|
| 774 |
)
|
| 775 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 776 |
# Parameters
|
| 777 |
gr.Markdown("### Parameters")
|
| 778 |
similarity_threshold = gr.Slider(
|
|
|
|
| 840 |
)
|
| 841 |
|
| 842 |
with gr.Tab("Download Files"):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 843 |
tree_file = gr.File(
|
| 844 |
label="Tree File",
|
| 845 |
interactive=False
|
|
|
|
| 855 |
## 📖 User Guide
|
| 856 |
|
| 857 |
### Input Requirements
|
| 858 |
+
- **DNA Sequence**: Nucleotide sequences in raw text
|
| 859 |
- **Minimum Length**: 10 bp for tree analysis, 100 bp for phylogenetic placement
|
| 860 |
- **Accepted Characters**: A, T, C, G, N (other characters will be converted to N)
|
| 861 |
|
|
|
|
| 869 |
- **Build ML Tree**: Enable for comprehensive phylogenetic placement analysis
|
| 870 |
|
| 871 |
### Output Files
|
|
|
|
| 872 |
- **Tree File**: Phylogenetic tree in Newick format
|
| 873 |
- **HTML Tree**: Interactive visualization file
|
| 874 |
|
|
|
|
| 881 |
""")
|
| 882 |
|
| 883 |
# Event handlers
|
| 884 |
+
def run_analysis(dna_seq, similarity, build_ml):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 885 |
"""Main analysis function"""
|
| 886 |
try:
|
| 887 |
+
if not dna_seq or not dna_seq.strip():
|
| 888 |
+
return ("❌ Please provide a DNA sequence", "", "", "", "", None, None, None, "No input provided")
|
| 889 |
+
results = run_pipeline(dna_seq, similarity, build_ml)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 890 |
return results
|
| 891 |
|
| 892 |
except Exception as e:
|
|
|
|
| 898 |
"""Clear all inputs and outputs"""
|
| 899 |
return (
|
| 900 |
"", # dna_sequence
|
|
|
|
| 901 |
95, # similarity_threshold
|
| 902 |
False, # build_ml_tree_checkbox
|
| 903 |
"", # boundary_output
|
|
|
|
| 906 |
"", # tree_analysis_output
|
| 907 |
"", # extracted_sequence
|
| 908 |
"", # tree_html
|
|
|
|
| 909 |
None, # tree_file
|
| 910 |
+
None, # html_tree_file
|
| 911 |
)
|
| 912 |
|
| 913 |
# Connect the analyze button
|
| 914 |
analyze_btn.click(
|
| 915 |
fn=run_analysis,
|
| 916 |
inputs=[
|
|
|
|
| 917 |
dna_sequence,
|
|
|
|
| 918 |
similarity_threshold,
|
| 919 |
build_ml_tree_checkbox
|
| 920 |
],
|
|
|
|
| 924 |
ml_tree_output,
|
| 925 |
tree_analysis_output,
|
| 926 |
extracted_sequence,
|
|
|
|
| 927 |
tree_file,
|
| 928 |
html_tree_file,
|
| 929 |
tree_html
|
|
|
|
| 935 |
fn=clear_all,
|
| 936 |
outputs=[
|
| 937 |
dna_sequence,
|
|
|
|
| 938 |
similarity_threshold,
|
| 939 |
build_ml_tree_checkbox,
|
| 940 |
boundary_output,
|
|
|
|
| 943 |
tree_analysis_output,
|
| 944 |
extracted_sequence,
|
| 945 |
tree_html,
|
|
|
|
| 946 |
tree_file,
|
| 947 |
html_tree_file
|
| 948 |
]
|