File size: 2,614 Bytes
d640b1c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | #!/usr/bin/env python3
"""
Test script for enhanced Gradio app
"""
import sys
import os
def test_enhanced_app():
"""Test the enhanced Gradio app"""
print("π§ͺ Testing Enhanced Gradio App")
print("=" * 40)
try:
# Test imports
print("Testing imports...")
import pandas as pd
import numpy as np
print("β
Core libraries imported")
# Test model predictor
print("\nTesting model predictor...")
from model_predictor import EpitopePredictor
predictor = EpitopePredictor()
print(f"β
Model predictor loaded (model available: {predictor.model is not None})")
# Test app functions
print("\nTesting app functions...")
from app_gradio_simple import parse_fasta_text, validate_sequences, format_sequence_with_epitopes
# Test FASTA parsing
test_fasta = """>Test_Seq
MKLLILTCLVAVALARPKHPIKHQGLPQEVLNENLLRFFVAPFPEVFGKEKVNEL"""
sequences = parse_fasta_text(test_fasta)
print(f"β
FASTA parsing: {len(sequences)} sequences parsed")
# Test validation
errors = validate_sequences(sequences)
print(f"β
Sequence validation: {len(errors)} errors found")
# Test sequence formatting
test_seq = list(sequences.values())[0]
b_epitopes = [("MKLLILTCLVA", 0.8, "1-11")]
t_epitopes = [("LARPKHPIKHQ", 0.7, "12-22")]
formatted = format_sequence_with_epitopes(test_seq, b_epitopes, t_epitopes)
print(f"β
Sequence formatting: {len(formatted)} characters")
# Test prediction function
print("\nTesting prediction function...")
from app_gradio_simple import predict_epitopes
result = predict_epitopes(test_fasta, None, 0.5)
print(f"β
Prediction function: {len(result)} outputs returned")
# Test interface creation
print("\nTesting interface creation...")
from app_gradio_simple import create_interface
demo = create_interface()
print(f"β
Interface created: {type(demo)}")
print("\n" + "=" * 40)
print("π All tests passed! Enhanced app is ready.")
return True
except ImportError as e:
print(f"β Import error: {e}")
print("Note: This is expected if Gradio is not installed locally")
return False
except Exception as e:
print(f"β Error: {e}")
return False
if __name__ == '__main__':
success = test_enhanced_app()
sys.exit(0 if success else 1)
|