{
  "filename": "plot_3.png",
  "iteration": 3,
  "description": "Create comprehensive final summary figure with all evidence panels for the MJ1511 hypothesis evaluation",
  "timestamp": "2026-07-06 20:10:14",
  "code": "\nimport matplotlib.pyplot as plt\nimport matplotlib.patches as mpatches\nimport numpy as np\n\nfig = plt.figure(figsize=(16, 18))\ngs = fig.add_gridspec(4, 2, hspace=0.35, wspace=0.25,\n                      height_ratios=[2, 2, 1.8, 2])\n\n# ===== Panel A: Catalytic residue comparison =====\nax_a = fig.add_subplot(gs[0, :])\nax_a.set_title('A. Catalytic Residue Conservation: Characterized AhpD vs MJ1511',\n               fontsize=13, fontweight='bold', loc='left', pad=10)\n\nproteins = ['Mtb AhpD\\n(P9WQB5)', 'P.aerug. PA0269\\n(PMID:21615954)',\n            'S.griseus AhpD\\n(B1W2G7)', 'M.marinum AhpD\\n(B2HD59)',\n            'R.erythrop. AhpD\\n(C0ZYQ9)', 'MJ1511\\n(Q58906)']\nfeatures = ['CxxC\\nmotif', 'Catalytic\\nHis', 'Proton relay\\n(Glu-His-H\u2082O)',\n            'Complete\\nmachinery']\n\ndata = np.array([\n    [1, 1, 1, 1],  # Mtb\n    [1, 1, 1, 1],  # Pa\n    [1, 1, 1, 1],  # Sg\n    [1, 1, 1, 1],  # Mm\n    [1, 1, 1, 1],  # Re\n    [0, 0, 0, 0],  # MJ1511\n])\n\nfor i in range(len(proteins)):\n    for j in range(len(features)):\n        color = '#27ae60' if data[i][j] == 1 else '#c0392b'\n        rect = mpatches.FancyBboxPatch((j-0.4, i-0.35), 0.8, 0.7,\n                                         boxstyle=\"round,pad=0.05\",\n                                         facecolor=color, alpha=0.85)\n        ax_a.add_patch(rect)\n        label = '\u2713' if data[i][j] == 1 else '\u2717'\n        ax_a.text(j, i, label, ha='center', va='center', fontsize=15,\n                  fontweight='bold', color='white')\n\nax_a.set_yticks(range(len(proteins)))\nax_a.set_yticklabels(proteins, fontsize=10)\nax_a.set_xticks(range(len(features)))\nax_a.set_xticklabels(features, fontsize=10)\nax_a.set_xlim(-0.6, len(features)-0.4)\nax_a.set_ylim(-0.6, len(proteins)-0.4)\nax_a.invert_yaxis()\nax_a.set_frame_on(False)\nax_a.tick_params(axis='both', which='both', length=0)\n\n# Separator line before MJ1511\nax_a.axhline(y=4.5, color='#2c3e50', linewidth=2, linestyle='--')\nax_a.text(3.5, 4.65, '\u2190 Characterized enzymes | MJ1511 \u2192', fontsize=8,\n          ha='right', va='center', fontstyle='italic', color='#7f8c8d')\n\npresent_patch = mpatches.Patch(color='#27ae60', label='Present')\nabsent_patch = mpatches.Patch(color='#c0392b', label='Absent')\nax_a.legend(handles=[present_patch, absent_patch], loc='upper right', fontsize=10)\n\n# ===== Panel B: CxxC motif alignment =====\nax_b = fig.add_subplot(gs[1, 0])\nax_b.set_title('B. CxxC Motif Sequences', fontsize=13, fontweight='bold', loc='left')\nax_b.axis('off')\n\nmotifs = [\n    ('Mtb AhpD',     'CSHC', '130-133', '#27ae60'),\n    ('Pa PA0269',    'CYXC', '48-51',   '#27ae60'),\n    ('S.gris AhpD',  'CGQC', '132-135', '#27ae60'),\n    ('M.mar AhpD',   'CSHC', '130-133', '#27ae60'),\n    ('R.ery AhpD',   'CNHC', '130-133', '#27ae60'),\n    ('MJ1511',       'NONE', '---',     '#c0392b'),\n]\n\nfor i, (name, motif, pos, color) in enumerate(motifs):\n    y = 0.90 - i * 0.14\n    weight = 'bold' if 'MJ1511' in name else 'normal'\n    ax_b.text(0.02, y, f'{name}:', fontsize=10, fontweight='bold',\n              color=color, transform=ax_b.transAxes, va='top', fontfamily='monospace')\n    ax_b.text(0.40, y, motif, fontsize=13, fontfamily='monospace', color=color,\n              fontweight='bold', transform=ax_b.transAxes, va='top')\n    ax_b.text(0.70, y, f'pos {pos}', fontsize=9, color='#7f8c8d',\n              transform=ax_b.transAxes, va='top')\n\n# ===== Panel C: 3D distance =====\nax_c = fig.add_subplot(gs[1, 1])\nax_c.set_title('C. Cysteine SG-SG Distance', fontsize=13, fontweight='bold', loc='left')\n\n# Bar chart: distance in AhpD vs MJ1511\nlabels = ['Mtb AhpD\\n(CxxC)', 'MJ1511\\n(C17-C107)']\ndistances = [3.2, 36.5]  # Approximate for AhpD CxxC disulfide, measured for MJ1511\nbar_colors = ['#27ae60', '#c0392b']\n\nbars = ax_c.bar(labels, distances, color=bar_colors, width=0.5, alpha=0.85)\nax_c.axhline(y=5.0, color='#e67e22', linewidth=2, linestyle='--', label='Max disulfide distance (~5 \u00c5)')\nax_c.set_ylabel('SG-SG Distance (\u00c5)', fontsize=11)\nax_c.legend(fontsize=9)\n\nfor bar, dist in zip(bars, distances):\n    ax_c.text(bar.get_x() + bar.get_width()/2, bar.get_height() + 0.8,\n              f'{dist:.1f} \u00c5', ha='center', fontsize=11, fontweight='bold')\n\nax_c.set_ylim(0, 45)\nax_c.spines['top'].set_visible(False)\nax_c.spines['right'].set_visible(False)\n\n# ===== Panel D: Archaeal CMD family survey =====\nax_d = fig.add_subplot(gs[2, 0])\nax_d.set_title('D. Archaeal CMD-like Family (100 proteins)', fontsize=13,\n               fontweight='bold', loc='left')\n\ncategories = ['CxxC + His\\n(catalytic)', 'No CxxC,\\nhas His', 'No CxxC,\\nno His']\ncounts = [51, 41, 8]\ncolors_pie = ['#27ae60', '#f39c12', '#c0392b']\n\nwedges, texts, autotexts = ax_d.pie(counts, labels=categories, colors=colors_pie,\n                                     autopct='%1.0f%%', startangle=90,\n                                     textprops={'fontsize': 9})\nfor at in autotexts:\n    at.set_fontsize(11)\n    at.set_fontweight('bold')\n\n# Arrow to \"No CxxC, no His\" wedge\nax_d.annotate('MJ1511\\nis here', xy=(0.35, -0.55), fontsize=9, fontweight='bold',\n              color='#c0392b', ha='center',\n              arrowprops=dict(arrowstyle='->', color='#c0392b', lw=1.5),\n              xytext=(0.8, -0.9))\n\n# ===== Panel E: Genomic context =====\nax_e = fig.add_subplot(gs[2, 1])\nax_e.set_title('E. Genomic Context (no redox operon)', fontsize=13,\n               fontweight='bold', loc='left')\nax_e.axis('off')\n\ngene_context = [\n    ('MJ1508', 'ABC transporter', '#95a5a6'),\n    ('MJ1509', 'Uncharacterized', '#bdc3c7'),\n    ('MJ1510', 'tRNA methyltransferase', '#95a5a6'),\n    ('MJ1511', 'CMD-like (TARGET)', '#c0392b'),\n    ('MJ1512', 'Reverse gyrase', '#95a5a6'),\n    ('MJ1513', 'Uncharacterized', '#bdc3c7'),\n    ('MJ1514', '\u03b3-glutamylcyclotransferase', '#95a5a6'),\n]\n\nfor i, (gene, func, color) in enumerate(gene_context):\n    y = 0.90 - i * 0.12\n    fweight = 'bold' if gene == 'MJ1511' else 'normal'\n    ax_e.add_patch(mpatches.FancyBboxPatch((0.02, y-0.04), 0.15, 0.08,\n                   boxstyle=\"round,pad=0.01\", facecolor=color, alpha=0.7,\n                   transform=ax_e.transAxes))\n    ax_e.text(0.095, y, gene, fontsize=9, fontweight='bold', color='white',\n              ha='center', va='center', transform=ax_e.transAxes)\n    ax_e.text(0.20, y, func, fontsize=9, fontweight=fweight, color='#2c3e50' if gene != 'MJ1511' else '#c0392b',\n              va='center', transform=ax_e.transAxes)\n\nax_e.text(0.5, 0.02, 'No redox gene cluster \u2192 not part of AhpC/AhpD system',\n          fontsize=9, fontstyle='italic', ha='center', transform=ax_e.transAxes,\n          color='#7f8c8d')\n\n# ===== Panel F: GO annotation decision table =====\nax_f = fig.add_subplot(gs[3, :])\nax_f.set_title('F. GO Annotation Decision Summary', fontsize=13, fontweight='bold', loc='left')\nax_f.axis('off')\n\ndecision_data = [\n    ['GO Term', 'Current Status', 'Evidence', 'Recommendation', 'Confidence'],\n    ['GO:0016671\\n(thiol-disulfide\\noxidoreductase)', 'Proposed\\n(not yet annotated)', 'No CxxC, no His, 36.5\u00c5 Cys distance,\\ntruncated protein, no operon context', 'DO NOT ANNOTATE\\n(refuted)', 'HIGH'],\n    ['GO:0016491\\n(oxidoreductase)', 'IBA from\\nMtb AhpD', 'Phylogenetic transfer without\\nactive-site validation; catalytic\\nresidues absent', 'REMOVE\\n(over-annotation)', 'HIGH'],\n    ['GO:0051920\\n(peroxiredoxin)', 'IEA from\\nInterPro', 'IPR003779 domain match but\\nCMD family includes non-catalytic\\nmembers', 'REMOVE\\n(over-annotation)', 'HIGH'],\n]\n\ncolors_table = [\n    ['#d5dbdb'] * 5,  # Header\n    ['#fadbd8'] * 5,  # GO:0016671\n    ['#fadbd8'] * 5,  # GO:0016491\n    ['#fadbd8'] * 5,  # GO:0051920\n]\n\ntable = ax_f.table(cellText=decision_data, cellColours=colors_table,\n                   loc='center', cellLoc='center')\ntable.auto_set_font_size(False)\ntable.set_fontsize(9)\ntable.scale(1, 2.8)\n\n# Bold header\nfor j in range(5):\n    table[0, j].set_text_props(fontweight='bold', fontsize=10)\n\n# Color recommendations\nfor i in range(1, 4):\n    table[i, 3].set_text_props(fontweight='bold', color='#c0392b')\n\nplt.suptitle('MJ1511 (Q58906): Evidence Against Thiol-Disulfide Oxidoreductase Activity',\n             fontsize=15, fontweight='bold', y=0.98)\n\nplt.savefig('mj1511_final_summary.png', dpi=150, bbox_inches='tight')\nplt.show()\nprint(\"Final summary figure saved: mj1511_final_summary.png\")\n",
  "plot_number": 3
}