{
  "filename": "domain_architecture_comparison.png",
  "iteration": 1,
  "description": "Create domain architecture comparison showing HSPA13 lacks the substrate-binding domain present in canonical HSP70s",
  "timestamp": "2026-07-06 11:50:11",
  "code": "\nimport requests\nimport json\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport matplotlib.patches as mpatches\n\n# Fetch sequences for comparison\nproteins = {\n    'HSPA13': 'P48723',\n    'HSPA1A': 'P0DMV8',\n    'HSPA5_BiP': 'P11021',\n    'HSPA8_HSC70': 'P11142'\n}\n\nsequences = {}\nfor name, acc in proteins.items():\n    url = f\"https://rest.uniprot.org/uniprotkb/{acc}.json\"\n    resp = requests.get(url, headers={\"Accept\": \"application/json\"})\n    entry = resp.json()\n    sequences[name] = entry.get('sequence', {}).get('value', '')\n\n# Create domain architecture comparison figure\nfig, axes = plt.subplots(4, 1, figsize=(14, 7), gridspec_kw={'hspace': 0.5})\n\ndomain_info = {\n    'HSPA1A': {\n        'length': 641,\n        'domains': [\n            ('NBD (ATPase)', 2, 386, '#3498db'),\n            ('Linker', 387, 393, '#95a5a6'),\n            ('SBD (Peptide-binding)', 394, 509, '#e74c3c'),\n            ('C-terminal lid', 510, 613, '#f39c12'),\n            ('Disordered', 614, 641, '#bdc3c7')\n        ],\n        'label': 'HSPA1A/Hsp70 (641 aa) - Canonical'\n    },\n    'HSPA5_BiP': {\n        'length': 654,\n        'domains': [\n            ('NBD (ATPase)', 1, 408, '#3498db'),\n            ('Linker', 409, 419, '#95a5a6'),\n            ('SBD (Peptide-binding)', 420, 500, '#e74c3c'),\n            ('C-terminal lid', 501, 632, '#f39c12'),\n            ('Disordered', 633, 654, '#bdc3c7')\n        ],\n        'label': 'HSPA5/BiP (654 aa) - ER Canonical'\n    },\n    'HSPA8_HSC70': {\n        'length': 646,\n        'domains': [\n            ('NBD (ATPase)', 2, 386, '#3498db'),\n            ('Linker', 387, 393, '#95a5a6'),\n            ('SBD (Peptide-binding)', 394, 509, '#e74c3c'),\n            ('C-terminal lid', 510, 613, '#f39c12'),\n            ('Disordered', 614, 646, '#bdc3c7')\n        ],\n        'label': 'HSPA8/HSC70 (646 aa) - Canonical'\n    },\n    'HSPA13': {\n        'length': 471,\n        'domains': [\n            ('Signal peptide', 1, 27, '#2ecc71'),\n            ('NBD (ATPase)', 28, 314, '#3498db'),\n            ('Disordered', 315, 352, '#bdc3c7'),\n            ('Short C-terminal', 353, 471, '#d0d0d0')\n        ],\n        'label': 'HSPA13/STCH (471 aa) - TRUNCATED: NO SBD'\n    }\n}\n\nmax_len = 660\nfor idx, (prot, info) in enumerate(domain_info.items()):\n    ax = axes[idx]\n    ax.set_xlim(0, max_len)\n    ax.set_ylim(0, 1)\n    \n    # Draw protein backbone\n    ax.barh(0.5, info['length'], height=0.4, color='#ecf0f1', edgecolor='black', linewidth=0.5)\n    \n    # Draw domains\n    for domain_name, start, end, color in info['domains']:\n        ax.barh(0.5, end - start, left=start, height=0.4, color=color, edgecolor='black', linewidth=0.5)\n        # Add label if domain is wide enough\n        if (end - start) > 50:\n            ax.text((start + end) / 2, 0.5, domain_name, ha='center', va='center', \n                    fontsize=7, fontweight='bold', color='white' if color not in ['#bdc3c7', '#d0d0d0', '#ecf0f1'] else 'black')\n    \n    ax.set_title(info['label'], fontsize=10, fontweight='bold', \n                 color='red' if prot == 'HSPA13' else 'black')\n    ax.set_yticks([])\n    ax.set_xlabel('Residue position' if idx == 3 else '')\n    ax.axvline(x=390, color='red', linestyle='--', alpha=0.3, linewidth=1)\n    \n    # Add annotation for missing region in HSPA13\n    if prot == 'HSPA13':\n        ax.annotate('\u2190 SBD MISSING \u2192', xy=(500, 0.5), fontsize=11, fontweight='bold', \n                    color='red', ha='center', va='center',\n                    bbox=dict(boxstyle='round,pad=0.3', facecolor='yellow', alpha=0.8))\n\n# Add legend\nlegend_elements = [\n    mpatches.Patch(facecolor='#2ecc71', edgecolor='black', label='Signal peptide'),\n    mpatches.Patch(facecolor='#3498db', edgecolor='black', label='NBD (ATPase domain)'),\n    mpatches.Patch(facecolor='#e74c3c', edgecolor='black', label='SBD (Substrate-binding domain)'),\n    mpatches.Patch(facecolor='#f39c12', edgecolor='black', label='C-terminal lid'),\n    mpatches.Patch(facecolor='#bdc3c7', edgecolor='black', label='Disordered region'),\n]\nfig.legend(handles=legend_elements, loc='lower center', ncol=5, fontsize=8, \n           bbox_to_anchor=(0.5, -0.02))\n\nfig.suptitle('HSP70 Family Domain Architecture Comparison\\nHSPA13 Lacks the Substrate-Binding Domain Required for Chaperone Activity', \n             fontsize=12, fontweight='bold', y=1.02)\nplt.tight_layout()\nplt.savefig('domain_architecture_comparison.png', dpi=150, bbox_inches='tight')\nplt.show()\nprint(\"Figure saved: domain_architecture_comparison.png\")\n"
}