{
  "filename": "go_term_analysis.png",
  "iteration": 1,
  "description": "GO hierarchy and active-site conservation visualization for MCR-1 analysis",
  "timestamp": "2026-06-23 21:32:08",
  "code": "\nimport matplotlib.pyplot as plt\nimport matplotlib.patches as mpatches\nimport numpy as np\n\nfig, (ax1, ax2) = plt.subplots(1, 2, figsize=(16, 10))\n\n# Panel 1: GO Term Hierarchy showing the mis-assignment\nax1.set_xlim(0, 10)\nax1.set_ylim(0, 10)\nax1.set_title(\"GO Term Hierarchy: Sibling Term Error\", fontsize=14, fontweight='bold')\nax1.axis('off')\n\n# Draw hierarchy boxes\n# Root\nrect_root = mpatches.FancyBboxPatch((2.5, 8.5), 5, 0.8, boxstyle=\"round,pad=0.1\", \n                                      facecolor='#E8E8E8', edgecolor='black', linewidth=1.5)\nax1.add_patch(rect_root)\nax1.text(5, 8.9, 'GO:0016772\\ntransferase activity,\\ntransferring P-groups', \n         ha='center', va='center', fontsize=8, fontweight='bold')\n\n# Wrong branch (red)\nrect_wrong = mpatches.FancyBboxPatch((0.3, 5.5), 4, 1.0, boxstyle=\"round,pad=0.1\", \n                                       facecolor='#FFB3B3', edgecolor='red', linewidth=2)\nax1.add_patch(rect_wrong)\nax1.text(2.3, 6.0, 'GO:0016776 \u2717 WRONG\\nphosphotransferase,\\nphosphate group as acceptor\\n(EC 2.7.4.*)', \n         ha='center', va='center', fontsize=7.5, color='red', fontweight='bold')\n\n# Correct branch (green)\nrect_correct = mpatches.FancyBboxPatch((5.7, 5.5), 4, 1.0, boxstyle=\"round,pad=0.1\", \n                                         facecolor='#B3FFB3', edgecolor='green', linewidth=2)\nax1.add_patch(rect_correct)\nax1.text(7.7, 6.0, 'GO:0016780 \u2713 CORRECT\\nphosphotransferase,\\nother substituted P-groups\\n(EC 2.7.8.*)', \n         ha='center', va='center', fontsize=7.5, color='darkgreen', fontweight='bold')\n\n# Specific correct term\nrect_specific = mpatches.FancyBboxPatch((5.7, 2.8), 4, 1.0, boxstyle=\"round,pad=0.1\", \n                                          facecolor='#80FF80', edgecolor='green', linewidth=2)\nax1.add_patch(rect_specific)\nax1.text(7.7, 3.3, 'GO:0043838 \u2713 MOST SPECIFIC\\nPE:Kdo2-lipid A\\nPEtN transferase\\n(EC 2.7.8.43)', \n         ha='center', va='center', fontsize=7.5, color='darkgreen', fontweight='bold')\n\n# Wrong children examples\nrect_child1 = mpatches.FancyBboxPatch((0.3, 2.8), 4, 0.8, boxstyle=\"round,pad=0.1\", \n                                        facecolor='#FFD0D0', edgecolor='gray', linewidth=1)\nax1.add_patch(rect_child1)\nax1.text(2.3, 3.2, 'Examples:\\n\u2022 nucleoside diphosphate kinase\\n\u2022 polyphosphate kinase\\n\u2022 phosphomevalonate kinase', \n         ha='center', va='center', fontsize=7, color='gray')\n\n# Draw arrows\n# Root to wrong branch\nax1.annotate('', xy=(2.3, 6.5), xytext=(4, 8.5),\n            arrowprops=dict(arrowstyle='->', color='red', lw=2))\n\n# Root to correct branch  \nax1.annotate('', xy=(7.7, 6.5), xytext=(6, 8.5),\n            arrowprops=dict(arrowstyle='->', color='green', lw=2))\n\n# Correct branch to specific\nax1.annotate('', xy=(7.7, 3.8), xytext=(7.7, 5.5),\n            arrowprops=dict(arrowstyle='->', color='green', lw=1.5))\n\n# Wrong branch to children\nax1.annotate('', xy=(2.3, 3.6), xytext=(2.3, 5.5),\n            arrowprops=dict(arrowstyle='->', color='gray', lw=1))\n\n# MCR-1 annotation arrow (crossing from wrong to correct)\nax1.annotate('MCR-1\\n(EC 2.7.8.43)', xy=(5.7, 3.3), xytext=(0.3, 1.5),\n            fontsize=9, fontweight='bold', color='darkblue',\n            arrowprops=dict(arrowstyle='->', color='blue', lw=2, ls='--'),\n            bbox=dict(boxstyle='round,pad=0.3', facecolor='lightblue', edgecolor='blue'))\n\n# Panel 2: Active Site Residue Conservation\nax2.set_title(\"Active-Site Residue Conservation: MCR-1 vs EptA\", fontsize=14, fontweight='bold')\n\nresidues = ['E246', 'T285', 'N329', 'K333', 'H395', 'D465', 'H466', 'E468', 'H478']\nepta_res = ['E244', 'T282', 'D326', 'K330', 'H385', 'D455', 'H456', 'E458', 'H468']\nconserved = [True, True, False, True, True, True, True, True, True]\nroles = ['Zn\\nbinding', 'Nucleophilic\\nThr/Zn', 'Catalytic', 'Catalytic', 'Catalytic',\n         'Zn\\nbinding', 'Zn\\nbinding', 'Colistin\\nresist.', 'Catalytic']\n\ncolors = ['#2ecc71' if c else '#e74c3c' for c in conserved]\nbars = ax2.barh(range(len(residues)), [1]*len(residues), color=colors, edgecolor='black', height=0.6)\n\nax2.set_yticks(range(len(residues)))\nax2.set_yticklabels([f\"MCR-1: {r}\\nEptA: {e}\" for r, e in zip(residues, epta_res)], fontsize=8)\nax2.set_xlim(0, 3)\nax2.set_xticks([])\n\nfor i, (res, role, cons) in enumerate(zip(residues, roles, conserved)):\n    status = \"CONSERVED \u2713\" if cons else \"DIFFERENT (N\u2192D)\"\n    ax2.text(1.1, i, f\"{status}  |  {role}\", va='center', fontsize=9,\n            fontweight='bold' if not cons else 'normal')\n\nax2.text(1.5, -1.2, f\"8/9 residues conserved (89%) \u2014 Active enzyme confirmed\", \n         ha='center', fontsize=11, fontweight='bold', color='darkgreen',\n         bbox=dict(boxstyle='round,pad=0.3', facecolor='#e8f5e9', edgecolor='green'))\n\n# Add legend\nax2.text(1.5, 9.5, \"All positions validated by mutagenesis:\\nAla substitution abolishes PEtN transfer\", \n         ha='center', fontsize=9, style='italic', color='gray')\n\nplt.tight_layout()\nplt.savefig('go_term_analysis.png', dpi=150, bbox_inches='tight')\nplt.show()\nprint(\"Figure saved: go_term_analysis.png\")\n"
}