Spaces:
No application file
No application file
Update app.py
Browse files
app.py
CHANGED
|
@@ -780,45 +780,32 @@ def create_gradio_interface():
|
|
| 780 |
title="🧬 Gene Analysis Pipeline (Error Mode)"
|
| 781 |
)
|
| 782 |
# --- Application Startup ---
|
| 783 |
-
def
|
|
|
|
| 784 |
try:
|
| 785 |
-
|
| 786 |
-
|
| 787 |
-
|
| 788 |
-
|
| 789 |
-
|
| 790 |
-
|
| 791 |
-
|
| 792 |
-
|
| 793 |
-
|
| 794 |
-
|
| 795 |
-
|
| 796 |
-
|
| 797 |
-
|
| 798 |
-
|
| 799 |
-
|
| 800 |
-
|
| 801 |
-
|
| 802 |
-
|
| 803 |
-
host="0.0.0.0",
|
| 804 |
-
port=7860,
|
| 805 |
-
log_level="info",
|
| 806 |
-
access_log=True
|
| 807 |
-
)
|
| 808 |
except Exception as main_error:
|
| 809 |
-
logger.error(f"
|
| 810 |
-
|
| 811 |
-
|
| 812 |
-
|
| 813 |
-
logger.info("🧬 Gradio interface available at: http://localhost:7860")
|
| 814 |
-
fallback_gradio_app.launch(
|
| 815 |
-
server_name="0.0.0.0",
|
| 816 |
-
server_port=7860,
|
| 817 |
-
prevent_thread_lock=True
|
| 818 |
-
)
|
| 819 |
-
except Exception as fallback_error:
|
| 820 |
-
logger.error(f"Fallback failed: {fallback_error}", exc_info=True)
|
| 821 |
-
print("❌ Application failed to start. Check logs for details.")
|
| 822 |
if __name__ == "__main__":
|
| 823 |
print("🧬 Gene Analysis Pipeline Starting...")
|
| 824 |
print("=" * 50)
|
|
|
|
| 780 |
title="🧬 Gene Analysis Pipeline (Error Mode)"
|
| 781 |
)
|
| 782 |
# --- Application Startup ---
|
| 783 |
+
async def run_pipeline_from_file(fasta_file_obj, similarity_score, build_ml_tree):
|
| 784 |
+
temp_file_path = None
|
| 785 |
try:
|
| 786 |
+
if fasta_file_obj is None:
|
| 787 |
+
return "❌ No file provided", "", "", "", "", None, None, None, None, "No input", "No input", None, None
|
| 788 |
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".fasta", dir="/tmp") as temp_file:
|
| 789 |
+
if isinstance(fasta_file_obj, UploadFile):
|
| 790 |
+
content = await fasta_file_obj.read()
|
| 791 |
+
temp_file.write(content)
|
| 792 |
+
else:
|
| 793 |
+
with open(fasta_file_obj, 'rb') as f:
|
| 794 |
+
content = f.read()
|
| 795 |
+
temp_file.write(content)
|
| 796 |
+
temp_file_path = temp_file.name
|
| 797 |
+
dna_input = read_fasta_file(temp_file_path)
|
| 798 |
+
if not dna_input:
|
| 799 |
+
cleanup_file(temp_file_path)
|
| 800 |
+
return "❌ Failed to read FASTA file", "", "", "", "", None, None, None, None, "No input", "No input", None, None
|
| 801 |
+
result = run_pipeline(dna_input, similarity_score, build_ml_tree)
|
| 802 |
+
cleanup_file(temp_file_path)
|
| 803 |
+
return result
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 804 |
except Exception as main_error:
|
| 805 |
+
logger.error(f"Pipeline from file error: {main_error}", exc_info=True)
|
| 806 |
+
cleanup_file(temp_file_path)
|
| 807 |
+
error_msg = f"❌ Error: {str(main_error)}"
|
| 808 |
+
return error_msg, "", "", "", "", None, None, None, None, error_msg, error_msg, None, None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 809 |
if __name__ == "__main__":
|
| 810 |
print("🧬 Gene Analysis Pipeline Starting...")
|
| 811 |
print("=" * 50)
|