Download test_enhanced_app.py from mercelv/epipred2: direct link, hf CLI and curl.
- Browser
- Download file 2.61 kB
-
https://huggingface.co/spaces/mercelv/epipred2/resolve/main/test_enhanced_app.py
- Command line
-
hf download hf://spaces/mercelv/epipred2/test_enhanced_app.py
-
curl -L -o test_enhanced_app.py https://huggingface.co/spaces/mercelv/epipred2/resolve/main/test_enhanced_app.py
2.61 kB
| #!/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) | |