Spaces:
No application file
No application file
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,3 @@
|
|
| 1 |
-
# app.py
|
| 2 |
import gradio as gr
|
| 3 |
import torch
|
| 4 |
import pickle
|
|
@@ -15,6 +14,7 @@ import tempfile
|
|
| 15 |
import shutil
|
| 16 |
import sys
|
| 17 |
from pathlib import Path
|
|
|
|
| 18 |
|
| 19 |
# --- Global Variables ---
|
| 20 |
MAFFT_PATH = "mafft/mafftdir/bin/mafft" # Update this path as needed
|
|
@@ -24,8 +24,6 @@ IQTREE_PATH = "iqtree/bin/iqtree2" # Update this path as needed
|
|
| 24 |
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
| 25 |
|
| 26 |
# --- Paths ---
|
| 27 |
-
from huggingface_hub import hf_hub_download
|
| 28 |
-
|
| 29 |
# Model repository and file paths
|
| 30 |
model_repo = "GGproject10/best_boundary_aware_model"
|
| 31 |
csv_path = "f cleaned.csv"
|
|
@@ -211,7 +209,7 @@ def run_mafft_alignment(input_fasta, output_fasta, mafft_cmd):
|
|
| 211 |
else:
|
| 212 |
error_msg = result.stderr.strip() if result.stderr else "Unknown MAFFT error"
|
| 213 |
logging.error(f"MAFFT failed: {error_msg}")
|
| 214 |
-
return False, f"MAFFT error: {error_msg}"
|
| 215 |
|
| 216 |
except subprocess.TimeoutExpired:
|
| 217 |
logging.error("MAFFT timeout")
|
|
@@ -260,7 +258,7 @@ def run_iqtree_analysis(aligned_fasta, output_prefix, iqtree_cmd):
|
|
| 260 |
else:
|
| 261 |
error_msg = result.stderr.strip() if result.stderr else "Unknown IQ-TREE error"
|
| 262 |
logging.error(f"IQ-TREE failed: {error_msg}")
|
| 263 |
-
return False, f"IQ-TREE error: {error_msg}"
|
| 264 |
|
| 265 |
except subprocess.TimeoutExpired:
|
| 266 |
logging.error("IQ-TREE timeout")
|
|
@@ -984,7 +982,6 @@ def create_interface():
|
|
| 984 |
space_url = get_space() # Gets the Space URL if running in a Space
|
| 985 |
if space_url:
|
| 986 |
# Construct a URL to the file (relative path from the Space root)
|
| 987 |
-
import os
|
| 988 |
file_path = os.path.relpath(html_file, os.getcwd())
|
| 989 |
file_url = f"{space_url}/file={file_path}"
|
| 990 |
return gr.update(value=f"<script>window.open('{file_url}', '_blank');</script>")
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import torch
|
| 3 |
import pickle
|
|
|
|
| 14 |
import shutil
|
| 15 |
import sys
|
| 16 |
from pathlib import Path
|
| 17 |
+
from huggingface_hub import hf_hub_download
|
| 18 |
|
| 19 |
# --- Global Variables ---
|
| 20 |
MAFFT_PATH = "mafft/mafftdir/bin/mafft" # Update this path as needed
|
|
|
|
| 24 |
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
| 25 |
|
| 26 |
# --- Paths ---
|
|
|
|
|
|
|
| 27 |
# Model repository and file paths
|
| 28 |
model_repo = "GGproject10/best_boundary_aware_model"
|
| 29 |
csv_path = "f cleaned.csv"
|
|
|
|
| 209 |
else:
|
| 210 |
error_msg = result.stderr.strip() if result.stderr else "Unknown MAFFT error"
|
| 211 |
logging.error(f"MAFFT failed: {error_msg}")
|
| 212 |
+
return False, f"MAFFT error: {error_msg}")
|
| 213 |
|
| 214 |
except subprocess.TimeoutExpired:
|
| 215 |
logging.error("MAFFT timeout")
|
|
|
|
| 258 |
else:
|
| 259 |
error_msg = result.stderr.strip() if result.stderr else "Unknown IQ-TREE error"
|
| 260 |
logging.error(f"IQ-TREE failed: {error_msg}")
|
| 261 |
+
return False, f"IQ-TREE error: {error_msg}")
|
| 262 |
|
| 263 |
except subprocess.TimeoutExpired:
|
| 264 |
logging.error("IQ-TREE timeout")
|
|
|
|
| 982 |
space_url = get_space() # Gets the Space URL if running in a Space
|
| 983 |
if space_url:
|
| 984 |
# Construct a URL to the file (relative path from the Space root)
|
|
|
|
| 985 |
file_path = os.path.relpath(html_file, os.getcwd())
|
| 986 |
file_url = f"{space_url}/file={file_path}"
|
| 987 |
return gr.update(value=f"<script>window.open('{file_url}', '_blank');</script>")
|