{
  "filename": "plot_3.png",
  "iteration": 1,
  "description": "Create comprehensive motif alignment and chaperone machinery scorecard figure",
  "timestamp": "2026-06-22 02:57:22",
  "code": "\nimport matplotlib.pyplot as plt\nimport matplotlib.patches as mpatches\nimport numpy as np\n\nfig, axes = plt.subplots(3, 1, figsize=(16, 12), gridspec_kw={'height_ratios': [1, 1, 1.5]})\n\n# Panel A: Motif alignment at phosphate loop\nax1 = axes[0]\nax1.set_title('A. HSP70 Phosphate-Binding Loop Motif Comparison', fontsize=11, fontweight='bold', loc='left')\n\npositions = range(8)\nlabels_hspa8 = list('IDLGTTYS')\nlabels_hspa12a = list('VDFGTTSS')\n\n# Color by conservation\ncolors_match = []\nfor a, b in zip(labels_hspa8, labels_hspa12a):\n    if a == b:\n        colors_match.append('#4CAF50')  # green = identical\n    elif (a in 'LIVMF' and b in 'LIVMF') or (a in 'DE' and b in 'DE'):\n        colors_match.append('#FFC107')  # yellow = conservative\n    else:\n        colors_match.append('#F44336')  # red = non-conservative\n\nfor i, (aa8, aa12, col) in enumerate(zip(labels_hspa8, labels_hspa12a, colors_match)):\n    # HSPA8 row\n    ax1.text(i, 1, aa8, ha='center', va='center', fontsize=14, fontweight='bold',\n             fontfamily='monospace',\n             bbox=dict(boxstyle='round,pad=0.3', facecolor='#E8F5E9', edgecolor='#4CAF50', linewidth=1.5))\n    # HSPA12A row\n    ax1.text(i, 0, aa12, ha='center', va='center', fontsize=14, fontweight='bold',\n             fontfamily='monospace',\n             bbox=dict(boxstyle='round,pad=0.3', facecolor='#FFEBEE' if col == '#F44336' else '#E8F5E9' if col == '#4CAF50' else '#FFF8E1',\n                       edgecolor=col, linewidth=1.5))\n    # Conservation marker\n    if aa8 == aa12:\n        ax1.text(i, 0.5, '|', ha='center', va='center', fontsize=12, color='#4CAF50')\n    elif col == '#FFC107':\n        ax1.text(i, 0.5, ':', ha='center', va='center', fontsize=12, color='#FFC107')\n    else:\n        ax1.text(i, 0.5, '\u2717', ha='center', va='center', fontsize=12, color='#F44336', fontweight='bold')\n\nax1.text(-0.8, 1, 'HSPA8\\n(pos 9-16)', ha='right', va='center', fontsize=9, fontweight='bold')\nax1.text(-0.8, 0, 'HSPA12A\\n(pos 61-68)', ha='right', va='center', fontsize=9, fontweight='bold', color='#F44336')\nax1.text(8.5, 0.5, 'L\u2192F change at\\ncritical position 3', ha='left', va='center', fontsize=9, \n         color='#F44336', style='italic')\nax1.set_xlim(-1.5, 10)\nax1.set_ylim(-0.5, 1.8)\nax1.axis('off')\n\n# Panel B: ATPase catalytic motif\nax2 = axes[1]\nax2.set_title('B. HSP70 ATPase Catalytic Motif Comparison (PROSITE PS00329)', fontsize=11, fontweight='bold', loc='left')\n\nlabels_hspa8_2 = list('IFDLGGGTFDVSIL')\nlabels_hspa12a_2 = list('YVVVDSGGGTVDLT')\n\nfor i, (aa8, aa12) in enumerate(zip(labels_hspa8_2, labels_hspa12a_2)):\n    if aa8 == aa12:\n        col = '#4CAF50'\n    elif (aa8 in 'LIVMF' and aa12 in 'LIVMF'):\n        col = '#FFC107'\n    else:\n        col = '#F44336'\n    \n    ax2.text(i, 1, aa8, ha='center', va='center', fontsize=12, fontweight='bold',\n             fontfamily='monospace',\n             bbox=dict(boxstyle='round,pad=0.2', facecolor='#E8F5E9', edgecolor='#4CAF50', linewidth=1.5))\n    ax2.text(i, 0, aa12, ha='center', va='center', fontsize=12, fontweight='bold',\n             fontfamily='monospace',\n             bbox=dict(boxstyle='round,pad=0.2', \n                       facecolor='#FFEBEE' if col == '#F44336' else '#E8F5E9' if col == '#4CAF50' else '#FFF8E1',\n                       edgecolor=col, linewidth=1.5))\n    if aa8 == aa12:\n        ax2.text(i, 0.5, '|', ha='center', va='center', fontsize=10, color='#4CAF50')\n    elif col == '#FFC107':\n        ax2.text(i, 0.5, ':', ha='center', va='center', fontsize=10, color='#FFC107')\n    else:\n        ax2.text(i, 0.5, '\u2717', ha='center', va='center', fontsize=10, color='#F44336')\n\nax2.text(-0.8, 1, 'HSPA8\\n(pos 197-210)', ha='right', va='center', fontsize=9, fontweight='bold')\nax2.text(-0.8, 0, 'HSPA12A\\n(pos 313-326)', ha='right', va='center', fontsize=9, fontweight='bold', color='#F44336')\nax2.text(14.5, 0.5, 'Only 2/14 positions\\nidentical (GG core)\\nDLGGG\u2192DSGGG', ha='left', va='center', \n         fontsize=9, color='#F44336', style='italic')\nax2.set_xlim(-1.5, 18)\nax2.set_ylim(-0.5, 1.8)\nax2.axis('off')\n\n# Panel C: Summary scorecard\nax3 = axes[2]\nax3.set_title('C. HSP70 Chaperone Machinery Assessment Scorecard', fontsize=11, fontweight='bold', loc='left')\n\nelements = [\n    'PS00297 phosphate loop (IDLGTTNS)',\n    'PS00329 ATPase catalytic (DLGGGTFD)',\n    'PS01036 HSP70 signature 3',\n    'Pfam PF00012 (HSP70 family)',\n    'Substrate-binding domain (SBD\u03b2)',\n    'Helical lid domain (SBD\u03b1)',\n    'Interdomain linker (DLLLLD)',\n    'Canonical chaperone function'\n]\n\nfor i, elem in enumerate(elements):\n    y_pos = len(elements) - i - 1\n    ax3.text(0, y_pos, elem, ha='left', va='center', fontsize=9, fontfamily='monospace')\n    # HSPA8 checkmark\n    ax3.text(5.5, y_pos, '\u2713', ha='center', va='center', fontsize=14, color='#4CAF50', fontweight='bold')\n    # HSPA12A X\n    ax3.text(7, y_pos, '\u2717', ha='center', va='center', fontsize=14, color='#F44336', fontweight='bold')\n\nax3.text(5.5, len(elements), 'HSPA8', ha='center', va='center', fontsize=10, fontweight='bold', color='#4CAF50')\nax3.text(7, len(elements), 'HSPA12A', ha='center', va='center', fontsize=10, fontweight='bold', color='#F44336')\n\n# Score\nax3.text(9, 4, 'HSPA8:    8/8 \u2713', fontsize=11, fontweight='bold', color='#4CAF50', va='center')\nax3.text(9, 3, 'HSPA12A:  0/8 \u2713', fontsize=11, fontweight='bold', color='#F44336', va='center')\nax3.text(9, 1.5, 'Verdict: HSPA12A does NOT\\nretain the machinery for\\ncanonical HSP70 ATP-dependent\\nprotein folding chaperone activity', \n         fontsize=10, fontweight='bold', color='#B71C1C', va='center',\n         bbox=dict(boxstyle='round,pad=0.5', facecolor='#FFCDD2', edgecolor='#B71C1C', linewidth=2))\n\nax3.set_xlim(-0.5, 14)\nax3.set_ylim(-0.5, len(elements) + 0.5)\nax3.axis('off')\n\nplt.tight_layout()\nplt.savefig('/tmp/hspa12a_motif_analysis.png', dpi=150, bbox_inches='tight')\nplt.show()\nprint(\"Motif analysis figure saved.\")\n",
  "plot_number": 3
}