Spaces:
No application file
No application file
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,7 +7,7 @@ import os
|
|
| 7 |
import re
|
| 8 |
import logging
|
| 9 |
import numpy as np
|
| 10 |
-
from predictor import
|
| 11 |
from tensorflow.keras.models import load_model
|
| 12 |
# Import the new analyzer
|
| 13 |
from analyzer import PhylogeneticTreeAnalyzer
|
|
@@ -56,7 +56,7 @@ try:
|
|
| 56 |
token=hf_token
|
| 57 |
)
|
| 58 |
if os.path.exists(boundary_path):
|
| 59 |
-
boundary_model =
|
| 60 |
logging.info("Boundary model loaded successfully from Hugging Face Hub.")
|
| 61 |
else:
|
| 62 |
logging.warning(f"Boundary model file not found after download")
|
|
@@ -597,16 +597,19 @@ def run_pipeline(dna_input, similarity_score=95.0, build_ml_tree=False):
|
|
| 597 |
logging.info("DNA sequence sanitized")
|
| 598 |
|
| 599 |
# Step 1: Boundary Prediction - Extract F gene sequence
|
| 600 |
-
processed_sequence = dna_input
|
| 601 |
boundary_output = ""
|
| 602 |
|
| 603 |
if boundary_model:
|
| 604 |
try:
|
| 605 |
-
|
| 606 |
-
|
|
|
|
|
|
|
|
|
|
| 607 |
if regions:
|
| 608 |
-
processed_sequence = regions[0]["sequence"]
|
| 609 |
-
boundary_output = processed_sequence
|
| 610 |
logging.info(f"F gene extracted: {len(processed_sequence)} bp (confidence: {confidence:.3f})")
|
| 611 |
else:
|
| 612 |
boundary_output = f"No F gene regions found in input sequence"
|
|
@@ -616,7 +619,7 @@ def run_pipeline(dna_input, similarity_score=95.0, build_ml_tree=False):
|
|
| 616 |
except Exception as e:
|
| 617 |
logging.error(f"Boundary model failed: {e}")
|
| 618 |
boundary_output = f"Boundary model error: {str(e)}"
|
| 619 |
-
processed_sequence = dna_input
|
| 620 |
else:
|
| 621 |
boundary_output = f"Boundary model not available. Using original input: {len(dna_input)} bp"
|
| 622 |
processed_sequence = dna_input
|
|
|
|
| 7 |
import re
|
| 8 |
import logging
|
| 9 |
import numpy as np
|
| 10 |
+
from predictor import EnhancedGenePredictor
|
| 11 |
from tensorflow.keras.models import load_model
|
| 12 |
# Import the new analyzer
|
| 13 |
from analyzer import PhylogeneticTreeAnalyzer
|
|
|
|
| 56 |
token=hf_token
|
| 57 |
)
|
| 58 |
if os.path.exists(boundary_path):
|
| 59 |
+
boundary_model = EnhancedGenePredictor(boundary_path)
|
| 60 |
logging.info("Boundary model loaded successfully from Hugging Face Hub.")
|
| 61 |
else:
|
| 62 |
logging.warning(f"Boundary model file not found after download")
|
|
|
|
| 597 |
logging.info("DNA sequence sanitized")
|
| 598 |
|
| 599 |
# Step 1: Boundary Prediction - Extract F gene sequence
|
| 600 |
+
processed_sequence = dna_input
|
| 601 |
boundary_output = ""
|
| 602 |
|
| 603 |
if boundary_model:
|
| 604 |
try:
|
| 605 |
+
result = boundary_model.predict_sequence(dna_input) # Updated to use predict_sequence
|
| 606 |
+
predictions = result['predictions']
|
| 607 |
+
probs = result['probabilities']['gene']
|
| 608 |
+
confidence = result['confidence']
|
| 609 |
+
regions = result['gene_regions']
|
| 610 |
if regions:
|
| 611 |
+
processed_sequence = regions[0]["sequence"]
|
| 612 |
+
boundary_output = processed_sequence
|
| 613 |
logging.info(f"F gene extracted: {len(processed_sequence)} bp (confidence: {confidence:.3f})")
|
| 614 |
else:
|
| 615 |
boundary_output = f"No F gene regions found in input sequence"
|
|
|
|
| 619 |
except Exception as e:
|
| 620 |
logging.error(f"Boundary model failed: {e}")
|
| 621 |
boundary_output = f"Boundary model error: {str(e)}"
|
| 622 |
+
processed_sequence = dna_input
|
| 623 |
else:
|
| 624 |
boundary_output = f"Boundary model not available. Using original input: {len(dna_input)} bp"
|
| 625 |
processed_sequence = dna_input
|