{
  "filename": "plot_2.png",
  "iteration": 2,
  "description": "Creating comprehensive provenance figure: pLDDT profile, active site schematic, and GO decision table",
  "timestamp": "2026-07-05 13:06:31",
  "code": "\nimport matplotlib.pyplot as plt\nimport matplotlib.patches as mpatches\nimport numpy as np\nimport requests\n\n# Re-fetch PDB data\npdb_url = \"https://alphafold.ebi.ac.uk/files/AF-O94603-F1-model_v6.pdb\"\npdb_resp = requests.get(pdb_url)\nlines = pdb_resp.text.split('\\n')\n\n# Parse all CA atoms with pLDDT\nresidues_plddt = {}\nfor line in lines:\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        residues_plddt[resnum] = bfactor\n\n# Create multi-panel figure\nfig = plt.figure(figsize=(16, 18))\n\n# === Panel 1: pLDDT profile with JmjC domain highlighted ===\nax1 = fig.add_subplot(3, 1, 1)\npositions = sorted(residues_plddt.keys())\nplddt_values = [residues_plddt[p] for p in positions]\n\nax1.fill_between(positions, plddt_values, alpha=0.3, color='steelblue')\nax1.plot(positions, plddt_values, color='steelblue', linewidth=0.5)\n\n# Highlight JmjC domain\nax1.axvspan(243, 402, alpha=0.15, color='red', label='JmjC domain (243-402)')\n\n# Mark key residues\nkey_res = {297: 'H297\\n(Fe ligand 1)', 299: 'E299\\n(Fe ligand 2)', \n           370: 'Y370\\n(should be His!)', 314: 'K314\\n(2-OG binding)'}\nfor pos, label in key_res.items():\n    ax1.annotate(label, xy=(pos, residues_plddt[pos]), \n                xytext=(pos, residues_plddt[pos]+8),\n                ha='center', fontsize=7, fontweight='bold',\n                arrowprops=dict(arrowstyle='->', color='red', lw=1.5),\n                color='red')\n    ax1.plot(pos, residues_plddt[pos], 'rv', markersize=8)\n\nax1.set_xlabel('Residue Number', fontsize=11)\nax1.set_ylabel('AlphaFold pLDDT', fontsize=11)\nax1.set_title('Epe1 (O94603) AlphaFold Confidence Profile\\nJmjC domain is well-predicted (mean pLDDT=92.4)', \n              fontsize=13, fontweight='bold')\nax1.set_ylim(0, 105)\nax1.axhline(y=70, color='gray', linestyle='--', alpha=0.5, label='Confident threshold (70)')\nax1.axhline(y=90, color='green', linestyle='--', alpha=0.5, label='Very high confidence (90)')\nax1.legend(loc='lower left', fontsize=9)\n\n# === Panel 2: Active site schematic ===\nax2 = fig.add_subplot(3, 1, 2)\nax2.set_xlim(-2, 12)\nax2.set_ylim(-1, 8)\nax2.set_aspect('equal')\nax2.set_title('JmjC Active Site Comparison: Epe1 vs. Active Demethylases', \n              fontsize=13, fontweight='bold')\n\n# Active enzyme (left side)\nax2.text(2.5, 7.5, 'Active JmjC Demethylase\\n(e.g. KDM2A, Jhd1)', ha='center', \n         fontsize=11, fontweight='bold', color='green')\n\n# Fe center\ncircle1 = plt.Circle((2.5, 4.5), 0.5, color='orange', alpha=0.8)\nax2.add_patch(circle1)\nax2.text(2.5, 4.5, 'Fe\u00b2\u207a', ha='center', va='center', fontweight='bold', fontsize=10)\n\n# Ligands for active enzyme\n# His (position 1)\nax2.annotate('His\\n(NE2)', xy=(2.0, 5.0), xytext=(0.3, 6.5),\n            arrowprops=dict(arrowstyle='->', color='green', lw=2),\n            fontsize=10, fontweight='bold', color='green', ha='center',\n            bbox=dict(boxstyle='round,pad=0.3', facecolor='lightgreen', edgecolor='green'))\n\n# Asp/Glu (position 2)\nax2.annotate('Asp\\n(OD)', xy=(3.0, 5.0), xytext=(4.7, 6.5),\n            arrowprops=dict(arrowstyle='->', color='green', lw=2),\n            fontsize=10, fontweight='bold', color='green', ha='center',\n            bbox=dict(boxstyle='round,pad=0.3', facecolor='lightgreen', edgecolor='green'))\n\n# His (position 3 - the critical one)\nax2.annotate('His \u2713\\n(NE2)', xy=(2.5, 3.8), xytext=(2.5, 1.5),\n            arrowprops=dict(arrowstyle='->', color='green', lw=2),\n            fontsize=10, fontweight='bold', color='green', ha='center',\n            bbox=dict(boxstyle='round,pad=0.3', facecolor='lightgreen', edgecolor='green'))\n\n# Epe1 (right side)\nax2.text(8.5, 7.5, 'Epe1 (Inactive)\\nS. pombe', ha='center', \n         fontsize=11, fontweight='bold', color='red')\n\n# Fe center (maybe absent)\ncircle2 = plt.Circle((8.5, 4.5), 0.5, color='lightgray', alpha=0.8, linestyle='--')\nax2.add_patch(circle2)\nax2.text(8.5, 4.5, 'Fe\u00b2\u207a\\n???', ha='center', va='center', fontsize=9, color='gray')\n\n# His297 (conserved)\nax2.annotate('His297\\n(NE2)', xy=(8.0, 5.0), xytext=(6.3, 6.5),\n            arrowprops=dict(arrowstyle='->', color='green', lw=2),\n            fontsize=10, fontweight='bold', color='green', ha='center',\n            bbox=dict(boxstyle='round,pad=0.3', facecolor='lightgreen', edgecolor='green'))\n\n# Glu299 (conservative change)\nax2.annotate('Glu299\\n(OE)', xy=(9.0, 5.0), xytext=(10.7, 6.5),\n            arrowprops=dict(arrowstyle='->', color='#DAA520', lw=2),\n            fontsize=10, fontweight='bold', color='#DAA520', ha='center',\n            bbox=dict(boxstyle='round,pad=0.3', facecolor='lightyellow', edgecolor='#DAA520'))\n\n# Tyr370 (BROKEN!)\nax2.annotate('Tyr370 \u2717\\n(OH - weak!)', xy=(8.5, 3.8), xytext=(8.5, 1.5),\n            arrowprops=dict(arrowstyle='->', color='red', lw=2),\n            fontsize=10, fontweight='bold', color='red', ha='center',\n            bbox=dict(boxstyle='round,pad=0.3', facecolor='#FFCCCC', edgecolor='red'))\n\n# Divider\nax2.axvline(x=5.5, color='gray', linestyle=':', alpha=0.5)\nax2.axis('off')\n\n# === Panel 3: GO Annotation Decision Table ===\nax3 = fig.add_subplot(3, 1, 3)\nax3.set_title('GO Annotation Decision Table for Epe1 (O94603)', \n              fontsize=13, fontweight='bold', pad=15)\n\ntable_data = [\n    ['GO:0032452\\nhistone demethylase', 'IBA', 'GO_Central\\n(PAINT)', 'enables', 'REMOVE', 'Contradicted by NOT IDA\\non child term; catalytic\\ntriad incomplete'],\n    ['GO:0141052\\nH3 demethylase', 'IDA', 'PomBase\\n(PMID:16362057)', 'NOT\\nenables', 'RETAIN', 'Well-supported negative\\nannotation; no in vitro\\nactivity detected'],\n    ['GO:0051864\\nH3K36 demethylase', 'ISO', 'PomBase\\n(GO_REF:0000024)', 'enables', 'REVIEW\\nfor removal', 'Same vulnerability as\\nIBA; orthology-based\\ninference'],\n    ['GO:0003712\\ntranscription\\ncoregulator', 'IBA', 'GO_Central', 'enables', 'RETAIN', 'Well-supported by\\nmultiple studies'],\n]\n\ncolors = ['#FFCCCC', '#CCFFCC', '#FFFFCC', '#CCE5FF']\ncol_labels = ['GO Term', 'Evidence', 'Source', 'Qualifier', 'Action', 'Rationale']\n\nax3.axis('off')\ntable = ax3.table(cellText=table_data, colLabels=col_labels,\n                  loc='center', cellLoc='center')\ntable.auto_set_font_size(False)\ntable.set_fontsize(8)\ntable.scale(1, 2.5)\n\n# Color the Action column\nfor i, color in enumerate(colors):\n    table[i+1, 4].set_facecolor(color)\n    for j in range(6):\n        table[i+1, j].set_edgecolor('gray')\n        table[0, j].set_facecolor('#E0E0E0')\n        table[0, j].set_text_props(fontweight='bold')\n\nplt.tight_layout(pad=2)\nplt.savefig('/tmp/epe1_analysis_provenance.png', dpi=150, bbox_inches='tight')\nplt.show()\nprint(\"Comprehensive analysis figure saved.\")\n",
  "plot_number": 2
}