| |
| """ |
| 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: |
| |
| print("Testing imports...") |
| import pandas as pd |
| import numpy as np |
| print("β
Core libraries imported") |
| |
| |
| print("\nTesting model predictor...") |
| from model_predictor import EpitopePredictor |
| predictor = EpitopePredictor() |
| print(f"β
Model predictor loaded (model available: {predictor.model is not None})") |
| |
| |
| print("\nTesting app functions...") |
| from app_gradio_simple import parse_fasta_text, validate_sequences, format_sequence_with_epitopes |
| |
| |
| test_fasta = """>Test_Seq |
| MKLLILTCLVAVALARPKHPIKHQGLPQEVLNENLLRFFVAPFPEVFGKEKVNEL""" |
| |
| sequences = parse_fasta_text(test_fasta) |
| print(f"β
FASTA parsing: {len(sequences)} sequences parsed") |
| |
| |
| errors = validate_sequences(sequences) |
| print(f"β
Sequence validation: {len(errors)} errors found") |
| |
| |
| 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") |
| |
| |
| 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") |
| |
| |
| 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) |
|
|