{
  "filename": "comprehensive_analysis.png",
  "iteration": 2,
  "description": "Comprehensive figure: multi-species alignment, UniProt comparison table, AlphaFold pLDDT profile, and verdict summary",
  "timestamp": "2026-07-05 09:55:34",
  "code": "\nimport matplotlib.pyplot as plt\nimport matplotlib.patches as mpatches\nimport numpy as np\n\nfig, axes = plt.subplots(4, 1, figsize=(16, 14), gridspec_kw={'height_ratios': [2.5, 2, 2, 1.5]})\n\n# === Panel A: Multi-species catalytic site alignment ===\nax1 = axes[0]\nax1.set_xlim(-1, 26)\nax1.set_ylim(-1.5, 7)\nax1.set_title(\"A. GH18 Catalytic Site Alignment Across Species\", fontsize=13, fontweight='bold', loc='left')\n\nproteins = [\n    ('S.c. CTS1 (P29029)', 'Active chitinase (IDA)', 'AVVDGFDFDIENNNEVGYSAL', True),\n    ('S.j. cts2 (B6JW51)', 'Chitinase (EC 3.2.1.14)', 'AVVDGFDLDIEHGSSQGYADL', True),\n    ('Hevamine-A (P23472)', 'Active chitinase', 'AVLDGIDFDIEHGSTLYWDDL', True),\n    ('S.p. cts2 (Q9C105)', 'Chitinase-LIKE (no EC)', 'AVVDGFDLEVNKGTNTAYSAF', False),\n]\n\ny_positions = [5.5, 4.0, 2.5, 0.5]\n\nfor idx, (name, ptype, seq, is_active) in enumerate(proteins):\n    y = y_positions[idx]\n    # Name label\n    color_name = '#006400' if is_active else '#CC0000'\n    ax1.text(-0.5, y + 0.25, name, fontsize=8.5, fontweight='bold', ha='right', va='center',\n             fontfamily='monospace', color=color_name)\n    ax1.text(-0.5, y - 0.25, ptype, fontsize=7, ha='right', va='center',\n             fontfamily='monospace', color='gray')\n    \n    for i, aa in enumerate(seq):\n        x = i + 0.5\n        \n        # Color coding\n        if i < 6:  # Conserved anchor\n            color = '#C8E6C9'  # light green\n        elif i == 6:  # First D of DxDxE\n            color = '#2E7D32' if aa == 'D' else '#FF6B6B'\n        elif i == 8:  # Second D of DxDxE\n            color = '#2E7D32' if aa == 'D' else '#FF6B6B'\n        elif i == 10:  # Catalytic E (proton donor)\n            if aa == 'E':\n                color = '#1B5E20'  # dark green\n            elif aa == 'N':\n                color = '#B71C1C'  # dark red\n            else:\n                color = '#FF6B6B'\n        else:\n            color = '#F5F5F5'\n        \n        rect = mpatches.FancyBboxPatch((x-0.42, y-0.35), 0.84, 0.7,\n                                        boxstyle=\"round,pad=0.03\",\n                                        facecolor=color, edgecolor='#666', linewidth=0.5)\n        ax1.add_patch(rect)\n        fontcolor = 'white' if color in ['#1B5E20', '#2E7D32', '#B71C1C'] else 'black'\n        ax1.text(x, y, aa, fontsize=10, fontweight='bold', ha='center', va='center',\n                fontfamily='monospace', color=fontcolor)\n\n# Column annotations\nax1.annotate('D1\\n(cat.)', xy=(6.5, 6.5), fontsize=8, ha='center', fontweight='bold', color='#2E7D32')\nax1.annotate('D2\\n(cat.)', xy=(8.5, 6.5), fontsize=8, ha='center', fontweight='bold', color='#2E7D32')\nax1.annotate('E\\n(proton\\ndonor)', xy=(10.5, 6.7), fontsize=8, ha='center', fontweight='bold', color='#B71C1C')\n\n# Arrow pointing to N166 in S. pombe\nax1.annotate('E\u2192N\\nINACTIVE', xy=(10.5, 0.0), xytext=(14, -1.0),\n            fontsize=9, fontweight='bold', color='#B71C1C',\n            arrowprops=dict(arrowstyle='->', color='#B71C1C', lw=2),\n            ha='center')\n\nax1.set_axis_off()\n\n# Legend\nlegend_elements = [\n    mpatches.Patch(facecolor='#2E7D32', label='Catalytic residue (correct)'),\n    mpatches.Patch(facecolor='#B71C1C', label='Missing catalytic residue (E\u2192N)'),\n    mpatches.Patch(facecolor='#C8E6C9', label='Conserved anchor region'),\n]\nax1.legend(handles=legend_elements, loc='lower left', fontsize=8, ncol=3)\n\n# === Panel B: UniProt annotation comparison ===\nax2 = axes[1]\nax2.set_axis_off()\nax2.set_title(\"B. UniProt Annotation Comparison: S. japonicus vs S. pombe cts2\", \n              fontsize=13, fontweight='bold', loc='left')\n\ntable_data = [\n    ['Feature', 'S. japonicus cts2\\n(B6JW51)', 'S. pombe cts2\\n(Q9C105)'],\n    ['Protein name', 'Chitinase', 'Chitinase-LIKE protein'],\n    ['EC number', '3.2.1.14 (assigned)', 'None'],\n    ['Catalytic activity', 'Yes (annotated)', 'None'],\n    ['DxDxE motif', 'DLDIE (intact)', 'DLEVN (disrupted)'],\n    ['IPR001579\\n(GH18 active site)', 'Present', 'ABSENT'],\n    ['UniProt CAUTION', 'None', 'Missing catalytic Glu'],\n    ['Keywords', 'Hydrolase, Glycosidase,\\nChitin degradation', 'Glycoprotein, Secreted\\n(no catalytic keywords)'],\n    ['PANTHER subfamily', 'PTHR45708:SF49', 'PTHR45708:SF49\\n(same \u2192 IBA transfer)'],\n]\n\ncolors_t = [['#D5E8D4'] * 3]\nfor row in table_data[1:]:\n    colors_t.append(['white', '#D5E8D4', '#FADBD8'])\n\ntable = ax2.table(cellText=table_data, cellColours=colors_t,\n                  loc='center', cellLoc='center')\ntable.auto_set_font_size(False)\ntable.set_fontsize(8)\ntable.scale(1, 1.4)\nfor (row, col), cell in table.get_celld().items():\n    if row == 0:\n        cell.set_text_props(fontweight='bold')\n\n# === Panel C: AlphaFold pLDDT profile ===\nax3 = axes[2]\nax3.set_title(\"C. AlphaFold pLDDT Confidence Profile for Q9C105\", fontsize=13, fontweight='bold', loc='left')\n\nimport requests\npdb_url = \"https://alphafold.ebi.ac.uk/files/AF-Q9C105-F1-model_v6.pdb\"\npdb_resp = requests.get(pdb_url)\npdb_text = pdb_resp.text\n\nresidue_plddt = {}\nfor line in pdb_text.split('\\n'):\n    if line.startswith('ATOM') and line[12:16].strip() == 'CA':\n        resnum = int(line[22:26].strip())\n        bfactor = float(line[60:66].strip())\n        residue_plddt[resnum] = bfactor\n\npositions = sorted(residue_plddt.keys())\nplddts = [residue_plddt[p] for p in positions]\n\n# Color by confidence\nfor i, (pos, plddt) in enumerate(zip(positions, plddts)):\n    if plddt >= 90:\n        color = '#1976D2'\n    elif plddt >= 70:\n        color = '#64B5F6'\n    elif plddt >= 50:\n        color = '#FFB74D'\n    else:\n        color = '#E57373'\n    ax3.bar(pos, plddt, width=1, color=color, edgecolor='none')\n\n# Highlight GH18 domain\nax3.axvspan(26, 325, alpha=0.1, color='green', label='GH18 domain')\nax3.axvline(166, color='red', linewidth=2, linestyle='--', alpha=0.8, label='N166 (missing cat. Glu)')\n\nax3.set_xlabel('Residue position', fontsize=10)\nax3.set_ylabel('pLDDT', fontsize=10)\nax3.set_ylim(0, 105)\nax3.legend(fontsize=8, loc='upper right')\n\n# Add pLDDT quality bands\nax3.axhspan(90, 105, alpha=0.05, color='blue')\nax3.axhspan(50, 70, alpha=0.05, color='orange')\nax3.axhspan(0, 50, alpha=0.05, color='red')\nax3.text(1250, 95, 'Very high', fontsize=7, color='gray')\nax3.text(1250, 60, 'Low', fontsize=7, color='gray')\nax3.text(1250, 30, 'Disordered', fontsize=7, color='gray')\n\n# === Panel D: Evidence verdict summary ===\nax4 = axes[3]\nax4.set_axis_off()\nax4.set_title(\"D. Verdict: GO:0004568 (chitinase activity) annotation for S. pombe cts2\", \n              fontsize=13, fontweight='bold', loc='left')\n\nverdict_text = \"\"\"VERDICT: OVER-ANNOTATED\n\nThe IBA annotation (GO_REF:0000033) transferred chitinase activity from the PANTHER ancestor PTHR45708:SF49.\nHowever, S. pombe cts2 has lost the catalytic glutamate proton donor (E\u2192N at position 166).\n\nEvidence converges from 5 independent sources:\n  1. Sequence: DxDxE motif disrupted (DLEVN vs DFDIEN/DLDIE in active chitinases)\n  2. UniProt: CAUTION flag + no EC number + named \"chitinase-LIKE\"\n  3. InterPro: Missing IPR001579 (GH18 active site signature)\n  4. Literature: E\u2192amide mutations abolish GH18 activity (PMID:12079386)\n  5. Biology: S. pombe has minimal chitin; cell separation uses glucanases, not chitinases\n\nRECOMMENDATION: Remove or NOT-qualify GO:0004568 for Q9C105\"\"\"\n\nax4.text(0.02, 0.95, verdict_text, fontsize=9, fontfamily='monospace',\n         transform=ax4.transAxes, verticalalignment='top',\n         bbox=dict(boxstyle='round', facecolor='#FFF3E0', edgecolor='#E65100', alpha=0.9))\n\nplt.tight_layout()\nplt.savefig('comprehensive_analysis.png', dpi=150, bbox_inches='tight')\nplt.show()\nprint(\"Figure saved: comprehensive_analysis.png\")\n"
}