{
  "filename": "plot_2.png",
  "iteration": 2,
  "description": "Create comprehensive 4-panel provenance figure: domain architecture, motif alignment, annotation conflict, and evidence summary",
  "timestamp": "2026-07-05 04:05:15",
  "code": "\nimport matplotlib.pyplot as plt\nimport matplotlib.patches as mpatches\nimport numpy as np\n\nfig, axes = plt.subplots(2, 2, figsize=(16, 12))\n\n# Panel A: Domain architecture with stop codon and mutations\nax1 = axes[0, 0]\nax1.set_title(\"A. CASP12 Domain Architecture & Inactivating Mutations\", fontsize=11, fontweight='bold')\n\n# Mouse Casp12 (419 aa)\ny = 0.75\nax1.barh(y, 419, height=0.18, color='#E8F5E9', edgecolor='black', linewidth=0.8)\nax1.barh(y, 92, left=0, height=0.18, color='#4CAF50', edgecolor='black', linewidth=0.8)\nax1.plot([249], [y], 'g^', markersize=10, zorder=5)\nax1.plot([296], [y], 'g*', markersize=12, zorder=5)\nax1.plot([316], [y], 'gD', markersize=7, zorder=5)\nax1.text(-25, y, 'Mouse Casp12\\n(419 aa, ACTIVE)', ha='right', va='center', fontsize=8, fontweight='bold', color='green')\nax1.text(249, y+0.12, 'SHG', ha='center', fontsize=7, color='green')\nax1.text(296, y+0.12, 'QACRG', ha='center', fontsize=7, color='green')\nax1.text(316, y+0.12, 'ATAD', ha='center', fontsize=7, color='green')\n\n# Human CASP12 full-length (341 aa)\ny = 0.45\nax1.barh(y, 341, height=0.18, color='#FFF3E0', edgecolor='black', linewidth=0.8)\nax1.barh(y, 92, left=0, height=0.18, color='#FF9800', edgecolor='black', linewidth=0.8)\nax1.plot([172], [y], 'rx', markersize=10, markeredgewidth=2, zorder=5)\nax1.plot([220], [y], 'r*', markersize=12, zorder=5)\nax1.text(-25, y, 'Human CASP12\\nfull-length\\n(341 aa, rare)', ha='right', va='center', fontsize=8, fontweight='bold', color='#E65100')\nax1.text(172, y+0.12, 'SHS\\n(mutated!)', ha='center', fontsize=7, color='red', fontweight='bold')\nax1.text(220, y+0.12, 'QACRG', ha='center', fontsize=7, color='darkgreen')\nax1.text(237, y-0.12, 'ASAD\\n(ATAD lost)', ha='center', fontsize=6, color='red')\n\n# Human CASP12 truncated (124 aa)\ny = 0.15\nax1.barh(y, 124, height=0.18, color='#FFEBEE', edgecolor='black', linewidth=0.8)\nax1.barh(y, 92, left=0, height=0.18, color='#F44336', edgecolor='black', linewidth=0.8)\nax1.plot([125], [y], 'ks', markersize=10, zorder=5)\nax1.text(135, y, 'STOP (rs497116)', fontsize=7, fontweight='bold')\nax1.text(-25, y, 'Human CASP12\\ntruncated\\n(124 aa, common)', ha='right', va='center', fontsize=8, fontweight='bold', color='red')\n\nax1.set_xlim(-120, 440)\nax1.set_ylim(0, 0.95)\nax1.set_xlabel('Amino acid position', fontsize=9)\nax1.set_yticks([])\nax1.legend([mpatches.Patch(color='#4CAF50'), mpatches.Patch(color='lightblue')], \n           ['CARD domain', 'Peptidase_C14'], loc='upper right', fontsize=8)\n\n# Panel B: Active site motif alignment\nax2 = axes[0, 1]\nax2.set_title(\"B. Active Site Motif Conservation\", fontsize=11, fontweight='bold')\nax2.axis('off')\n\nalignment_data = [\n    (\"Rat Casp12\", \"S H G\", \"green\", \"Q A C R G\", \"green\", \"A T A D\", \"green\", \"Active (autoprocess)\"),\n    (\"Mouse Casp12\", \"S H G\", \"green\", \"Q A C R G\", \"green\", \"A T A D\", \"green\", \"Active (autoprocess)\"),\n    (\"Human CASP1\", \"S H G\", \"green\", \"Q A C R G\", \"green\", \"\u2014\", \"gray\", \"Active (general)\"),\n    (\"Human CASP3\", \"S H G\", \"green\", \"Q A C R G\", \"green\", \"\u2014\", \"gray\", \"Active (general)\"),\n    (\"Human CASP4\", \"S H G\", \"green\", \"Q A C R G\", \"green\", \"\u2014\", \"gray\", \"Active (general)\"),\n    (\"Human CASP12\", \"S H S\", \"red\", \"Q A C R G\", \"green\", \"A S A D\", \"red\", \"INACTIVE\"),\n]\n\nheaders = ['', 'Catalytic His', '', 'Catalytic Cys', '', 'Autoprocess', '', 'Status']\ny_pos = 0.92\nax2.text(0.02, y_pos, 'Caspase', fontsize=9, fontweight='bold', transform=ax2.transAxes, va='center')\nax2.text(0.22, y_pos, 'SHG box', fontsize=9, fontweight='bold', transform=ax2.transAxes, va='center', color='darkblue')\nax2.text(0.42, y_pos, 'QACRG', fontsize=9, fontweight='bold', transform=ax2.transAxes, va='center', color='darkblue')\nax2.text(0.60, y_pos, 'Auto-site', fontsize=9, fontweight='bold', transform=ax2.transAxes, va='center', color='darkblue')\nax2.text(0.78, y_pos, 'Status', fontsize=9, fontweight='bold', transform=ax2.transAxes, va='center', color='darkblue')\n\nfor i, (label, shg, shg_c, qa, qa_c, auto, auto_c, status) in enumerate(alignment_data):\n    y = 0.82 - i * 0.12\n    is_human_casp12 = 'Human CASP12' == label\n    \n    label_color = 'red' if is_human_casp12 else 'black'\n    label_weight = 'bold' if is_human_casp12 else 'normal'\n    \n    ax2.text(0.02, y, label, fontsize=9, fontfamily='monospace', color=label_color,\n             fontweight=label_weight, transform=ax2.transAxes, va='center')\n    \n    bbox_shg = dict(boxstyle='round,pad=0.2', facecolor='#FFCDD2' if shg_c=='red' else '#C8E6C9',\n                    edgecolor=shg_c, linewidth=1.5)\n    ax2.text(0.25, y, shg, fontsize=10, fontfamily='monospace', fontweight='bold',\n             transform=ax2.transAxes, va='center', bbox=bbox_shg, color=shg_c)\n    \n    bbox_qa = dict(boxstyle='round,pad=0.2', facecolor='#C8E6C9', edgecolor='green', linewidth=1.5)\n    ax2.text(0.43, y, qa, fontsize=10, fontfamily='monospace', fontweight='bold',\n             transform=ax2.transAxes, va='center', bbox=bbox_qa, color='green')\n    \n    bbox_auto = dict(boxstyle='round,pad=0.2', \n                     facecolor='#FFCDD2' if auto_c=='red' else ('#C8E6C9' if auto_c=='green' else '#E0E0E0'),\n                     edgecolor=auto_c, linewidth=1.5)\n    ax2.text(0.62, y, auto, fontsize=10, fontfamily='monospace', fontweight='bold',\n             transform=ax2.transAxes, va='center', bbox=bbox_auto, color=auto_c)\n    \n    status_color = 'red' if 'INACTIVE' in status else 'green'\n    ax2.text(0.78, y, status, fontsize=8, transform=ax2.transAxes, va='center',\n             color=status_color, fontweight='bold')\n\n# Panel C: GO annotation conflict\nax3 = axes[1, 0]\nax3.set_title(\"C. GO:0004197 Annotation Conflict\", fontsize=11, fontweight='bold')\nax3.axis('off')\n\nconflict_text = \"\"\"GO:0004197 \u2014 cysteine-type endopeptidase activity\n\nIBA (enables)               vs    IKR (NOT|enables)\n\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501    \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\n\nSource: PAINT phylogeny            Source: PMID:12054529\n        (GO_REF:0000033)                   (Fischer et al. 2002)\n\nMethod: Inherited from             Method: Key residue analysis\n        caspase ancestor                   (SHG\u2192SHS mutation)\n\nBasis:  CASP12 is in the           Basis:  Multiple deleterious\n        caspase family                     mutations destroy\n                                           catalytic competence\n\nFlaw:   Does NOT account           Strength: Directly addresses\n        for lineage-specific                 the specific gene's\n        gene inactivation                    catalytic capacity\n\nVERDICT: IBA is OVER-ANNOTATED\n         IKR NOT correctly captures the biology\n         The IBA annotation should be removed\n\"\"\"\n\nax3.text(0.02, 0.95, conflict_text, fontsize=8, fontfamily='monospace',\n         transform=ax3.transAxes, va='top', ha='left',\n         bbox=dict(boxstyle='round', facecolor='#FFF9C4', alpha=0.9))\n\n# Panel D: Evidence summary\nax4 = axes[1, 1]\nax4.set_title(\"D. Evidence Weight Summary\", fontsize=11, fontweight='bold')\n\ncategories = ['Sequence\\n(SHG\u2192SHS)', 'Genetic\\n(stop codon)', 'Biochemical\\n(no substrates)', \n              'Functional\\n(non-catalytic)', 'Structural\\n(AlphaFold)', 'Database\\n(UniProt)']\nweights_against = [5, 5, 4.5, 4, 3, 4.5]  # Evidence AGAINST endopeptidase activity\nweights_for = [0.5, 0, 0, 0, 0, 0]  # Evidence FOR (only QACRG conservation)\n\nx = np.arange(len(categories))\nwidth = 0.35\n\nbars1 = ax4.barh(x + width/2, weights_against, width, color='#EF5350', label='Against activity', alpha=0.8)\nbars2 = ax4.barh(x - width/2, weights_for, width, color='#66BB6A', label='For activity', alpha=0.8)\n\nax4.set_yticks(x)\nax4.set_yticklabels(categories, fontsize=9)\nax4.set_xlabel('Evidence Strength (0-5)', fontsize=9)\nax4.set_xlim(0, 5.5)\nax4.legend(fontsize=8, loc='lower right')\nax4.invert_yaxis()\n\nplt.tight_layout()\nplt.savefig('casp12_comprehensive_analysis.png', dpi=150, bbox_inches='tight')\nplt.show()\nprint(\"Comprehensive figure saved\")\n",
  "plot_number": 2
}