#!/usr/bin/env python3 """ Build GRAIL-Heart Network Explorer Embeds JSON data directly into HTML for GitHub Pages deployment """ import json import os from pathlib import Path def build_explorer(): """Build the explorer with embedded data for static hosting.""" base_dir = Path(__file__).parent.parent cytoscape_dir = base_dir / "outputs" / "cytoscape" data_dir = cytoscape_dir / "data" # Load all network data all_networks_path = data_dir / "all_networks.json" if not all_networks_path.exists(): print("❌ Network data not found. Run generate_network_data.py first.") return False with open(all_networks_path, 'r') as f: network_data = json.load(f) print(f"Loaded network data: {len(network_data)} networks") # Read the HTML template html_path = cytoscape_dir / "grail_heart_explorer.html" with open(html_path, 'r', encoding='utf-8') as f: html_content = f.read() # Create embedded data version # Replace the dynamic loading with embedded data embedded_js = f"""