#!/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)