{
  "filename": "plot_2.png",
  "iteration": 3,
  "description": "Creating domain architecture comparison and GO decision table visualization",
  "timestamp": "2026-06-22 06:50:15",
  "code": "\nimport matplotlib.pyplot as plt\nimport matplotlib.patches as mpatches\nimport numpy as np\n\nfig, axes = plt.subplots(2, 1, figsize=(14, 10), gridspec_kw={'height_ratios': [1, 1.5]})\n\n# === Panel A: Domain Architecture Comparison ===\nax1 = axes[0]\nax1.set_title('A. Domain Architecture Comparison: B7FXQ8 HSP20A vs Characterized sHSPs', fontsize=11, fontweight='bold')\n\nproteins = [\n    ('B7FXQ8 HSP20A (P. tricornutum)', 163, [(1, 46, '#FFB347'), (47, 155, '#4ECDC4'), (156, 163, '#FF6B6B')]),\n    ('P04792 HSPB1 (Human)', 205, [(1, 86, '#FFB347'), (87, 176, '#4ECDC4'), (177, 205, '#FF6B6B')]),\n    ('P02511 CRYAB (Human)', 175, [(1, 67, '#FFB347'), (68, 155, '#4ECDC4'), (156, 175, '#FF6B6B')]),\n    ('P15992 HSP26 (Yeast)', 214, [(1, 95, '#FFB347'), (96, 186, '#4ECDC4'), (187, 214, '#FF6B6B')]),\n    ('P0C058 IbpB (E. coli)', 142, [(1, 30, '#FFB347'), (31, 123, '#4ECDC4'), (124, 142, '#FF6B6B')]),\n]\n\ny_positions = list(range(len(proteins)-1, -1, -1))\n\nfor i, (name, length, domains) in enumerate(proteins):\n    y = y_positions[i]\n    ax1.barh(y, length, height=0.5, color='#E8E8E8', edgecolor='gray', linewidth=0.5)\n    for start, end, color in domains:\n        ax1.barh(y, end-start+1, left=start-1, height=0.5, color=color, edgecolor='black', linewidth=0.5)\n    ax1.text(-5, y, name, ha='right', va='center', fontsize=8)\n    ax1.text(length+3, y, f'{length} aa', ha='left', va='center', fontsize=8)\n\nax1.annotate('IAI (pos 150)', xy=(150, 4), xytext=(175, 4.7),\n            fontsize=7, ha='center', arrowprops=dict(arrowstyle='->', color='red'), color='red')\n\nax1.set_xlim(-120, 250)\nax1.set_ylim(-0.5, len(proteins) + 0.5)\nax1.set_xlabel('Residue position', fontsize=9)\nax1.set_yticks([])\n\nlegend_patches = [\n    mpatches.Patch(color='#FFB347', label='N-terminal extension'),\n    mpatches.Patch(color='#4ECDC4', label='Alpha-crystallin domain (ACD)'),\n    mpatches.Patch(color='#FF6B6B', label='C-terminal extension'),\n]\nax1.legend(handles=legend_patches, loc='lower right', fontsize=8)\n\n# === Panel B: GO Decision Table ===\nax2 = axes[1]\nax2.set_title('B. GO Term Decision Table for B7FXQ8 HSP20A', fontsize=11, fontweight='bold')\nax2.axis('off')\n\ntable_data = [\n    ['GO:0051082', 'unfolded protein binding', 'OBSOLETE', 'Must replace', 'N/A', 'Cannot use'],\n    ['GO:0044183', 'protein folding chaperone', 'Active', '25 reviewed sHSPs', 'ISS', 'RECOMMENDED'],\n    ['GO:0140309', 'holdase activity', 'Active', '0 sHSPs (new)', 'ISS', 'ALTERNATIVE'],\n    ['GO:0051787', 'misfolded protein binding', 'Active', '0 sHSPs', 'ISS', 'OPTIONAL'],\n    ['GO:0009408', 'response to heat', 'Active', 'Paralog has it', 'ISS/IEA', 'ADD (BP)'],\n    ['GO:0005737', 'cytoplasm', 'Active', 'Common for sHSPs', 'ISS', 'ADD (CC)'],\n]\n\ncol_labels = ['GO Term', 'Name', 'Status', 'sHSP Precedent', 'Ev. Code', 'Recommendation']\n\ntable = ax2.table(cellText=table_data, colLabels=col_labels, \n                  loc='center', cellLoc='center')\n\ntable.auto_set_font_size(False)\ntable.set_fontsize(8.5)\ntable.scale(1.0, 1.8)\n\n# Color code rows\nrec_colors = {\n    'Cannot use': '#FFCCCC',\n    'RECOMMENDED': '#CCFFCC',\n    'ALTERNATIVE': '#FFFFCC',\n    'OPTIONAL': '#E8E8FF',\n    'ADD (BP)': '#CCFFCC',\n    'ADD (CC)': '#CCFFCC',\n}\n\nncols = len(col_labels)\nfor i in range(len(table_data)):\n    rec = table_data[i][5]\n    for j in range(ncols):\n        cell = table[i+1, j]\n        if rec in rec_colors:\n            cell.set_facecolor(rec_colors[rec])\n\nfor j in range(ncols):\n    table[0, j].set_facecolor('#4472C4')\n    table[0, j].set_text_props(color='white', fontweight='bold')\n\nplt.tight_layout()\nplt.savefig('go_decision_table.png', dpi=150, bbox_inches='tight')\nplt.show()\nprint(\"GO decision table saved.\")\n",
  "plot_number": 2
}