{
  "filename": "plot_4.png",
  "iteration": 3,
  "description": "Create comprehensive multi-panel provenance figure summarizing all evidence for GO:0070991 annotation",
  "timestamp": "2026-07-01 07:18:02",
  "code": "\nimport matplotlib.pyplot as plt\nimport matplotlib.patches as mpatches\nimport numpy as np\n\nfig = plt.figure(figsize=(20, 16))\nfig.suptitle('Comprehensive Evidence: Drosophila Mcad (Q9VSA3) \u2014 GO:0070991\\nMedium-chain fatty acyl-CoA dehydrogenase activity', \n             fontsize=15, fontweight='bold', y=0.99)\n\n# Create grid layout\ngs = fig.add_gridspec(3, 3, hspace=0.35, wspace=0.3)\n\n# ============ Panel A: Cross-subfamily identity ============\nax1 = fig.add_subplot(gs[0, 0])\nsubfamilies = ['MCAD', 'SCAD', 'LCAD', 'VLCAD']\nidentities = [69.08, 37.81, 31.83, 32.69]\ncolors = ['#e74c3c', '#3498db', '#2ecc71', '#f39c12']\nbars = ax1.bar(subfamilies, identities, color=colors, edgecolor='black', linewidth=0.8)\nbars[0].set_hatch('///')\nbars[0].set_edgecolor('darkred')\nbars[0].set_linewidth(2.5)\nax1.set_ylabel('Identity to Dmel Mcad (%)', fontsize=10)\nax1.set_title('A. Cross-Subfamily Identity', fontsize=11, fontweight='bold')\nax1.set_ylim(0, 82)\nfor bar, val in zip(bars, identities):\n    ax1.text(bar.get_x() + bar.get_width()/2., val + 1, f'{val:.0f}%', \n             ha='center', va='bottom', fontweight='bold', fontsize=11)\nax1.annotate('', xy=(0.15, 69.08), xytext=(0.15, 37.81),\n            arrowprops=dict(arrowstyle='<->', color='black', lw=2))\nax1.text(-0.15, 53, '\u039431%', ha='center', fontsize=10, fontweight='bold', color='darkred')\n\n# ============ Panel B: Active site residue conservation ============\nax2 = fig.add_subplot(gs[0, 1])\ncategories = ['Catalytic\\nGlu', 'FAD\\nbinding\\n(7 res)', 'Substrate\\nbinding\\n(7 res)', 'All key\\nresidues\\n(15 res)']\nidentical = [1, 7, 6, 14]\ntotal = [1, 7, 7, 15]\nsimilar = [0, 0, 1, 1]  # F/L is similar\npct_ident = [i/t*100 for i, t in zip(identical, total)]\npct_simil = [(i+s)/t*100 for i, s, t in zip(identical, similar, total)]\n\nbars_i = ax2.bar(categories, pct_ident, color='#27ae60', edgecolor='black', linewidth=0.5, label='Identical')\nbars_s = ax2.bar(categories, [s/t*100 for s, t in zip(similar, total)], bottom=pct_ident,\n                 color='#f1c40f', edgecolor='black', linewidth=0.5, label='Conservative')\nax2.set_ylim(0, 115)\nax2.set_ylabel('Conservation (%)', fontsize=10)\nax2.set_title('B. Active Site Conservation\\n(vs Human ACADM)', fontsize=11, fontweight='bold')\nax2.legend(fontsize=8, loc='lower right')\nfor bar, i, s, t in zip(bars_i, identical, similar, total):\n    ax2.text(bar.get_x() + bar.get_width()/2., (i+s)/t*100 + 2, \n             f'{i+s}/{t}', ha='center', va='bottom', fontweight='bold', fontsize=10)\n\n# ============ Panel C: Active site geometry correlation ============\nax3 = fig.add_subplot(gs[0, 2])\ndists_d = [8.91, 11.27, 11.54, 11.34, 10.62, 6.80, 37.77, 40.81, 41.54, 38.33, 37.19, 27.99, 29.79, 30.50]\ndists_h = [8.87, 11.26, 11.52, 11.28, 10.83, 6.89, 37.87, 40.85, 41.51, 38.46, 37.32, 27.99, 29.82, 30.49]\n\nax3.scatter(dists_h, dists_d, c='#e74c3c', s=80, edgecolors='black', zorder=5, linewidths=0.5)\n# Perfect correlation line\nline_range = np.linspace(5, 45, 100)\nax3.plot(line_range, line_range, 'k--', alpha=0.3, label='y = x')\nax3.set_xlabel('Human ACADM (\u00c5)', fontsize=10)\nax3.set_ylabel('Dmel Mcad (\u00c5)', fontsize=10)\nax3.set_title('C. Active Site Geometry\\n(CA distances from catalytic Glu)', fontsize=11, fontweight='bold')\nax3.text(10, 40, f'r = 1.0000\\nMean \u0394 = 0.06 \u00c5', fontsize=10, fontweight='bold',\n         bbox=dict(boxstyle='round', facecolor='lightyellow', edgecolor='orange'))\nax3.set_xlim(4, 45)\nax3.set_ylim(4, 45)\nax3.set_aspect('equal')\n\n# ============ Panel D: Multi-species identity ============\nax4 = fig.add_subplot(gs[1, 0])\nspecies = ['Human', 'Mouse', 'Rat']\nmulti_id = [69.08, 69.30, 68.82]\nbars4 = ax4.barh(species, multi_id, color=['#9b59b6', '#8e44ad', '#7d3c98'], \n                  edgecolor='black', linewidth=0.5, height=0.5)\nax4.set_xlim(60, 75)\nax4.set_xlabel('Identity to Dmel Mcad (%)', fontsize=10)\nax4.set_title('D. MCAD Ortholog Conservation\\n(Bilateria)', fontsize=11, fontweight='bold')\nfor bar, val in zip(bars4, multi_id):\n    ax4.text(val + 0.2, bar.get_y() + bar.get_height()/2., f'{val:.1f}%', \n             va='center', fontweight='bold', fontsize=10)\n\n# ============ Panel E: AlphaFold confidence at functional sites ============\nax5 = fig.add_subplot(gs[1, 1])\nresidues = ['Glu397\\n(cat)', 'S163', 'W187', 'I188', 'T189', 'D274', 'R277', \n            'R302', 'K303', 'T304', 'H312', 'Q313', 'Q370', 'I371', 'F372']\nplddt = [96.6, 95.3, 98.6, 98.8, 98.7, 93.8, 97.7, 98.4, 98.6, 98.4, 98.8, 98.6, 98.9, 98.9, 98.8]\n\ncolors5 = ['#e74c3c'] + ['#3498db']*4 + ['#27ae60']*6 + ['#f39c12']*4\nbars5 = ax5.barh(range(len(residues)), plddt, color=colors5, edgecolor='black', linewidth=0.3, height=0.7)\nax5.set_yticks(range(len(residues)))\nax5.set_yticklabels(residues, fontsize=8)\nax5.set_xlim(90, 100)\nax5.set_xlabel('pLDDT Score', fontsize=10)\nax5.set_title('E. AlphaFold Confidence\\nat Functional Residues', fontsize=11, fontweight='bold')\nax5.axvline(x=90, color='gray', linestyle=':', alpha=0.5)\nax5.text(90.5, 14.5, '\u2192 All \u2265 93.8\\n(Very High)', fontsize=9, fontweight='bold', color='darkgreen')\n\nlegend5 = [mpatches.Patch(facecolor='#e74c3c', label='Catalytic'),\n           mpatches.Patch(facecolor='#3498db', label='Substrate'),\n           mpatches.Patch(facecolor='#27ae60', label='FAD'),\n           mpatches.Patch(facecolor='#f39c12', label='Substrate (C-term)')]\nax5.legend(handles=legend5, fontsize=7, loc='lower right')\n\n# ============ Panel F: Evidence convergence summary ============\nax6 = fig.add_subplot(gs[1, 2])\nevidence_lines = [\n    'IBA (PAINT/PANTHER)',\n    'IMP (PMID:29563254)',\n    'IEA (InterPro/EC)',\n    'CDD cd01157',\n    'InterPro IPR034180',\n    'PANTHER SF2',\n    'Seq identity (69%)',\n    'Active site (95%)',\n    'Geometry (r=1.00)',\n    'Cross-subfam (\u039431%)',\n    'Multi-species (4 spp)',\n    'AlphaFold (pLDDT\u226594)',\n]\nevidence_types = ['GO annotation', 'GO annotation', 'GO annotation',\n                  'Domain classifier', 'Domain classifier', 'Domain classifier',\n                  'Sequence analysis', 'Sequence analysis', 'Structural analysis',\n                  'Sequence analysis', 'Sequence analysis', 'Structural analysis']\ntype_colors = {'GO annotation': '#e74c3c', 'Domain classifier': '#3498db', \n               'Sequence analysis': '#27ae60', 'Structural analysis': '#f39c12'}\n\ny_pos = range(len(evidence_lines))\ncolors6 = [type_colors[t] for t in evidence_types]\nbars6 = ax6.barh(y_pos, [1]*len(evidence_lines), color=colors6, edgecolor='black', linewidth=0.3, height=0.7)\nax6.set_yticks(y_pos)\nax6.set_yticklabels(evidence_lines, fontsize=8)\nax6.set_xticks([])\nax6.set_title('F. Converging Evidence Lines\\n(All support GO:0070991)', fontsize=11, fontweight='bold')\nfor i, bar in enumerate(bars6):\n    ax6.text(0.5, bar.get_y() + bar.get_height()/2., '\u2713 SUPPORTS', \n             ha='center', va='center', fontweight='bold', fontsize=8, color='white')\n\nlegend6 = [mpatches.Patch(facecolor=c, label=t) for t, c in type_colors.items()]\nax6.legend(handles=legend6, fontsize=7, loc='lower right')\n\n# ============ Panel G: GO Decision Table ============\nax7 = fig.add_subplot(gs[2, :])\nax7.axis('off')\n\ntable_data = [\n    ['GO Term', 'Current Evidence', 'Recommendation', 'Confidence'],\n    ['GO:0070991\\n(MF: MCAD activity)', 'IBA + IMP + IEA\\n(3 independent lines)', 'RETAIN \u2014 strongly supported\\nby sequence, structure, phylogeny', 'Very High'],\n    ['GO:0003995\\n(MF: ACAD activity)', 'ISS + IEA', 'RETAIN as parent term\\n(could upgrade ISS\u2192IMP)', 'High'],\n    ['GO:0006635\\n(BP: FA \u03b2-oxidation)', 'ISS + IEA + IMP', 'RETAIN \u2014 consistent\\nwith enzymatic function', 'High'],\n    ['GO:0005759\\n(CC: mito matrix)', 'IEA + EXP', 'RETAIN \u2014 experimentally\\nvalidated (PMID:29563254)', 'Very High'],\n]\n\ntable = ax7.table(cellText=table_data[1:], colLabels=table_data[0],\n                   loc='center', cellLoc='center',\n                   colWidths=[0.2, 0.25, 0.3, 0.15])\ntable.auto_set_font_size(False)\ntable.set_fontsize(9)\ntable.scale(1, 2.0)\n\n# Style header\nfor j in range(4):\n    table[0, j].set_facecolor('#2c3e50')\n    table[0, j].set_text_props(color='white', fontweight='bold')\n\n# Style confidence column\nconf_colors = {'Very High': '#27ae60', 'High': '#3498db'}\nfor i in range(1, 5):\n    conf = table_data[i][3]\n    table[i, 3].set_facecolor(conf_colors.get(conf, 'white'))\n    table[i, 3].set_text_props(color='white', fontweight='bold')\n\nax7.set_title('G. GO Annotation Decision Table', fontsize=12, fontweight='bold', pad=20)\n\nplt.savefig('comprehensive_provenance.png', dpi=150, bbox_inches='tight')\nplt.show()\nprint(\"Comprehensive provenance figure saved.\")\n",
  "plot_number": 4
}