{
  "filename": "catalytic_site_comparison.png",
  "iteration": 1,
  "description": "Create comprehensive figure comparing catalytic sites of S. cerevisiae CTS1 vs S. pombe cts2, showing the missing DxDxE motif",
  "timestamp": "2026-07-05 09:41:42",
  "code": "\nimport matplotlib.pyplot as plt\nimport matplotlib.patches as mpatches\nimport numpy as np\n\n# === Figure 1: Catalytic site alignment comparison ===\nfig, axes = plt.subplots(3, 1, figsize=(14, 10), gridspec_kw={'height_ratios': [2, 1.5, 1.5]})\n\n# Panel A: Sequence alignment around catalytic site\nax1 = axes[0]\nax1.set_xlim(0, 25)\nax1.set_ylim(-1, 5)\nax1.set_title(\"A. Catalytic Site Alignment: GH18 DxDxE Motif Region\", fontsize=13, fontweight='bold', loc='left')\n\n# Sequences aligned from AVVDGFD anchor\nproteins = {\n    'S.c. CTS1 (P29029)\\n[active chitinase]': 'AVVDGFDFDIENNNEVGYSAL',\n    'S.p. cts2 (Q9C105)\\n[chitinase-like]': 'AVVDGFDLEVNKGTNTAYSAF',\n    'CaclXIP (coffee)\\n[xylanase inhibitor]': 'AIIDGFDLNQNKETNPAYNAL',\n}\n\n# Color scheme: conserved=green, substituted=red, neutral=gray\ny_positions = [3.5, 2, 0.5]\nfor idx, (name, seq) in enumerate(proteins.items()):\n    y = y_positions[idx]\n    ax1.text(-0.5, y, name, fontsize=9, fontweight='bold', ha='right', va='center',\n             fontfamily='monospace')\n    \n    for i, aa in enumerate(seq):\n        x = i + 0.5\n        \n        # Color coding based on position relative to catalytic residues\n        # AVVDGFD positions 0-6 are conserved anchor\n        if i < 7:  # Conserved anchor AVVDGFD\n            color = '#90EE90'  # light green\n            if i == 6:  # First D of motif\n                color = '#00AA00'  # dark green - catalytic\n        elif i == 8:  # Position of D155/E164 (second catalytic D)\n            if idx == 0:  # CTS1 - has correct D\n                color = '#00AA00'  # green - correct catalytic residue\n            else:\n                color = '#FF6B6B'  # red - substituted\n        elif i == 10:  # Position of E157/N166 (proton donor)\n            if idx == 0:  # CTS1 - has correct E\n                color = '#00AA00'  # green - catalytic proton donor\n            else:\n                color = '#FF4444'  # red - critical substitution\n        else:\n            color = '#E8E8E8'  # light gray\n        \n        rect = mpatches.FancyBboxPatch((x-0.4, y-0.35), 0.8, 0.7,\n                                        boxstyle=\"round,pad=0.05\",\n                                        facecolor=color, edgecolor='black', linewidth=0.5)\n        ax1.add_patch(rect)\n        ax1.text(x, y, aa, fontsize=11, fontweight='bold', ha='center', va='center',\n                fontfamily='monospace')\n\n# Position labels\nfor i in range(21):\n    ax1.text(i + 0.5, 4.5, str(i+1), fontsize=7, ha='center', va='center', color='gray')\n\n# Annotations for catalytic residues\nax1.annotate('Cat. D1\\n(conserved)', xy=(6.5, 4.0), fontsize=8, ha='center', \n            color='darkgreen', fontweight='bold')\nax1.annotate('Cat. D2\\n(D\u2192E/N)', xy=(8.5, 4.0), fontsize=8, ha='center',\n            color='red', fontweight='bold')\nax1.annotate('Proton donor\\n(E\u2192N/Q)', xy=(10.5, 4.0), fontsize=8, ha='center',\n            color='red', fontweight='bold')\n\nax1.set_axis_off()\n\n# Legend\nlegend_elements = [\n    mpatches.Patch(facecolor='#00AA00', label='Catalytic residue (correct)'),\n    mpatches.Patch(facecolor='#90EE90', label='Conserved anchor'),\n    mpatches.Patch(facecolor='#FF4444', label='Critical substitution (loss of catalysis)'),\n    mpatches.Patch(facecolor='#E8E8E8', label='Other positions'),\n]\nax1.legend(handles=legend_elements, loc='lower left', fontsize=8, ncol=2)\n\n# Panel B: Domain architecture comparison\nax2 = axes[1]\nax2.set_xlim(0, 1300)\nax2.set_ylim(-0.5, 3.5)\nax2.set_title(\"B. Domain Architecture Comparison\", fontsize=13, fontweight='bold', loc='left')\n\n# S. cerevisiae CTS1 (562 aa)\nax2.barh(2.5, 562, height=0.6, color='#D4E6F1', edgecolor='black', linewidth=0.5)\nax2.add_patch(mpatches.FancyBboxPatch((0, 2.25), 25, 0.5, facecolor='#F39C12', edgecolor='black', linewidth=0.5))\nax2.add_patch(mpatches.FancyBboxPatch((26, 2.25), 285, 0.5, facecolor='#27AE60', edgecolor='black', linewidth=0.5))\nax2.text(170, 2.5, 'GH18 (active)', fontsize=9, ha='center', va='center', fontweight='bold')\nax2.text(400, 2.5, 'Ser/Thr-rich', fontsize=8, ha='center', va='center')\nax2.text(-10, 2.5, 'CTS1 (562 aa)', fontsize=9, ha='right', va='center', fontweight='bold')\nax2.text(10, 2.9, 'SP', fontsize=7, ha='center')\n\n# S. pombe cts2 (1236 aa)\nax2.barh(1.0, 1236, height=0.6, color='#FADBD8', edgecolor='black', linewidth=0.5)\nax2.add_patch(mpatches.FancyBboxPatch((0, 0.75), 25, 0.5, facecolor='#F39C12', edgecolor='black', linewidth=0.5))\nax2.add_patch(mpatches.FancyBboxPatch((25, 0.75), 300, 0.5, facecolor='#E74C3C', edgecolor='black', linewidth=0.5))\nax2.text(170, 1.0, 'GH18 (inactive)', fontsize=9, ha='center', va='center', fontweight='bold', color='white')\n# Mark Ser/Thr rich region\nax2.add_patch(mpatches.FancyBboxPatch((325, 0.75), 900, 0.5, facecolor='#F5CBA7', edgecolor='black', linewidth=0.5))\nax2.text(775, 1.0, 'Extensive Ser/Thr-rich region (~900 aa)', fontsize=9, ha='center', va='center')\nax2.text(-10, 1.0, 'cts2 (1236 aa)', fontsize=9, ha='right', va='center', fontweight='bold')\nax2.text(10, 1.4, 'SP', fontsize=7, ha='center')\n\nax2.set_xlabel('Residue position', fontsize=10)\nax2.set_yticks([])\nax2.spines['top'].set_visible(False)\nax2.spines['right'].set_visible(False)\nax2.spines['left'].set_visible(False)\n\n# Panel C: Summary table\nax3 = axes[2]\nax3.set_axis_off()\nax3.set_title(\"C. Key Catalytic Residue Comparison\", fontsize=13, fontweight='bold', loc='left')\n\ntable_data = [\n    ['Feature', 'S.c. CTS1\\n(active chitinase)', 'S.p. cts2\\n(chitinase-like)', 'Status'],\n    ['Catalytic D1', 'D153 \u2713', 'D162 \u2713', 'Conserved'],\n    ['Catalytic D2', 'D155 \u2713', 'E164 \u2717', 'Substituted (D\u2192E)'],\n    ['Proton donor E', 'E157 \u2713', 'N166 \u2717', 'ABSENT (E\u2192N)'],\n    ['DxDxE motif', 'DFDIEN \u2713', 'DLEVNK \u2717', 'DISRUPTED'],\n    ['Chitinase activity', 'Confirmed (IDA)', 'Not demonstrated', 'No direct evidence'],\n]\n\ncolors = [['#D5E8D4'] * 4]  # header\ncolors.append(['white', '#D5E8D4', '#D5E8D4', '#D5E8D4'])\ncolors.append(['white', '#D5E8D4', '#FADBD8', '#FADBD8'])\ncolors.append(['white', '#D5E8D4', '#F8696B', '#F8696B'])\ncolors.append(['white', '#D5E8D4', '#F8696B', '#F8696B'])\ncolors.append(['white', '#D5E8D4', '#FADBD8', '#FADBD8'])\n\ntable = ax3.table(cellText=table_data, cellColours=colors,\n                  loc='center', cellLoc='center')\ntable.auto_set_font_size(False)\ntable.set_fontsize(9)\ntable.scale(1, 1.5)\n\nplt.tight_layout()\nplt.savefig('catalytic_site_comparison.png', dpi=150, bbox_inches='tight')\nplt.show()\nprint(\"Figure saved: catalytic_site_comparison.png\")\n"
}