|
|
|
|
|
""" |
|
|
Simple script to run AbMelt pipeline locally for testing |
|
|
""" |
|
|
|
|
|
import os |
|
|
import sys |
|
|
from pathlib import Path |
|
|
import json |
|
|
|
|
|
|
|
|
sys.path.insert(0, str(Path(__file__).parent / "src")) |
|
|
|
|
|
def load_example_sequences(): |
|
|
"""Load example antibody sequences""" |
|
|
example_file = Path(__file__).parent / "data" / "example_antibodies.json" |
|
|
|
|
|
if example_file.exists(): |
|
|
with open(example_file, 'r') as f: |
|
|
data = json.load(f) |
|
|
return data['test_antibodies'] |
|
|
else: |
|
|
|
|
|
return [ |
|
|
{ |
|
|
"name": "Test Antibody", |
|
|
"heavy_chain": "QVQLVQSGAEVKKPGASVKVSCKASGYTFTSYYMHWVRQAPGQGLEWMGIINPSGGSTNYAQKFQGRVTMTRDTSASTAYMELSSLRSEDTAVYYCAR", |
|
|
"light_chain": "DIQMTQSPSSLSASVGDRVTITCRASQSISSYLNWYQQKPGKAPKLLIYAASSLQSGVPSRFSGSGSGTDFTLTISSLQPEDFATYYCQQSYST" |
|
|
} |
|
|
] |
|
|
|
|
|
def run_validation(): |
|
|
"""Run pipeline validation""" |
|
|
print("π§ͺ Running AbMelt Pipeline Validation...") |
|
|
print("=" * 50) |
|
|
|
|
|
try: |
|
|
import test_pipeline |
|
|
success = test_pipeline.run_all_tests() |
|
|
|
|
|
if success: |
|
|
print("π All validation tests passed!") |
|
|
print("β
Pipeline is ready to use") |
|
|
return True |
|
|
else: |
|
|
print("β Some validation tests failed") |
|
|
print("β οΈ Check logs above for details") |
|
|
return False |
|
|
|
|
|
except Exception as e: |
|
|
print(f"β Validation failed with error: {e}") |
|
|
return False |
|
|
|
|
|
def run_gradio_app(): |
|
|
"""Run the Gradio application""" |
|
|
print("π Starting AbMelt Gradio Interface...") |
|
|
print("π± Open your browser to: http://localhost:7860") |
|
|
print("βΉοΈ Press Ctrl+C to stop") |
|
|
print("=" * 50) |
|
|
|
|
|
try: |
|
|
import app |
|
|
|
|
|
pass |
|
|
except KeyboardInterrupt: |
|
|
print("\\nπ Shutting down...") |
|
|
except Exception as e: |
|
|
print(f"β Failed to start Gradio app: {e}") |
|
|
|
|
|
def show_example_sequences(): |
|
|
"""Display example sequences for testing""" |
|
|
print("𧬠Example Antibody Sequences for Testing:") |
|
|
print("=" * 50) |
|
|
|
|
|
examples = load_example_sequences() |
|
|
|
|
|
for i, antibody in enumerate(examples, 1): |
|
|
print(f"\\n{i}. {antibody['name']}") |
|
|
print(f" Target: {antibody.get('target', 'Unknown')}") |
|
|
print(f" Heavy Chain: {antibody['heavy_chain'][:50]}...") |
|
|
print(f" Light Chain: {antibody['light_chain'][:50]}...") |
|
|
if 'description' in antibody: |
|
|
print(f" Description: {antibody['description']}") |
|
|
|
|
|
def main(): |
|
|
"""Main entry point""" |
|
|
print("𧬠AbMelt Pipeline - Local Runner") |
|
|
print("=" * 50) |
|
|
|
|
|
if len(sys.argv) > 1: |
|
|
command = sys.argv[1].lower() |
|
|
else: |
|
|
print("Available commands:") |
|
|
print(" python run_local.py test - Run validation tests") |
|
|
print(" python run_local.py run - Start Gradio interface") |
|
|
print(" python run_local.py examples - Show example sequences") |
|
|
print(" python run_local.py help - Show this help") |
|
|
return |
|
|
|
|
|
if command == "test" or command == "validate": |
|
|
run_validation() |
|
|
|
|
|
elif command == "run" or command == "start": |
|
|
|
|
|
print("π Quick validation check...") |
|
|
if run_validation(): |
|
|
print("\\n" + "=" * 50) |
|
|
run_gradio_app() |
|
|
else: |
|
|
print("\\nβ Validation failed. Please fix issues before running the app.") |
|
|
|
|
|
elif command == "examples": |
|
|
show_example_sequences() |
|
|
|
|
|
elif command == "help" or command == "--help": |
|
|
print("AbMelt Pipeline Local Runner") |
|
|
print("\\nCommands:") |
|
|
print(" test/validate - Run all validation tests") |
|
|
print(" run/start - Start the Gradio web interface") |
|
|
print(" examples - Show example antibody sequences") |
|
|
print(" help - Show this help message") |
|
|
print("\\nUsage:") |
|
|
print(" python run_local.py test") |
|
|
print(" python run_local.py run") |
|
|
|
|
|
else: |
|
|
print(f"β Unknown command: {command}") |
|
|
print("Run 'python run_local.py help' for available commands") |
|
|
|
|
|
if __name__ == "__main__": |
|
|
main() |