{
  "filename": "plot_1.png",
  "iteration": 1,
  "description": "Create comprehensive figure comparing MJ1511 to canonical AhpD showing missing catalytic machinery",
  "timestamp": "2026-06-21 18:43:48",
  "code": "\nimport matplotlib.pyplot as plt\nimport matplotlib.patches as mpatches\nimport numpy as np\n\nfig, axes = plt.subplots(2, 2, figsize=(14, 10))\nfig.suptitle('MJ1511 vs Canonical AhpD: Catalytic Residue Analysis', fontsize=14, fontweight='bold')\n\n# Panel 1: Sequence diagram comparison\nax1 = axes[0, 0]\nax1.set_title('A. Catalytic residue positions', fontsize=11, fontweight='bold')\n\n# MJ1511\ny_mj = 0.7\nax1.barh(y_mj, 107, height=0.15, color='#e0e0e0', edgecolor='black', linewidth=0.5)\nax1.plot(17, y_mj, 'o', color='gold', markersize=12, markeredgecolor='black', zorder=5)\nax1.plot(107, y_mj, 'o', color='gold', markersize=12, markeredgecolor='black', zorder=5)\nax1.text(17, y_mj+0.12, 'C17', ha='center', fontsize=8, fontweight='bold')\nax1.text(107, y_mj+0.12, 'C107', ha='center', fontsize=8, fontweight='bold')\nax1.text(-5, y_mj, 'MJ1511\\n(107 aa)', ha='right', va='center', fontsize=9)\nax1.annotate('', xy=(107, y_mj-0.08), xytext=(17, y_mj-0.08),\n            arrowprops=dict(arrowstyle='<->', color='red', lw=1.5))\nax1.text(62, y_mj-0.15, '90 residues / 36.5 \u00c5', ha='center', color='red', fontsize=8, fontweight='bold')\n\n# AhpD\ny_ahpd = 0.3\nax1.barh(y_ahpd, 177, height=0.15, color='#c8e6c9', edgecolor='black', linewidth=0.5)\nax1.plot(130, y_ahpd, 'o', color='gold', markersize=12, markeredgecolor='black', zorder=5)\nax1.plot(133, y_ahpd, 'o', color='gold', markersize=12, markeredgecolor='black', zorder=5)\nax1.plot(118, y_ahpd, 's', color='#ff7043', markersize=10, markeredgecolor='black', zorder=5)\nax1.plot(132, y_ahpd, 'D', color='#42a5f5', markersize=10, markeredgecolor='black', zorder=5)\nax1.plot(137, y_ahpd, 'D', color='#42a5f5', markersize=10, markeredgecolor='black', zorder=5)\nax1.text(130, y_ahpd+0.12, 'C130', ha='center', fontsize=7, fontweight='bold')\nax1.text(133, y_ahpd+0.12, 'C133', ha='center', fontsize=7, fontweight='bold')\nax1.text(118, y_ahpd-0.12, 'E118', ha='center', fontsize=7, color='#ff7043')\nax1.text(132, y_ahpd-0.12, 'H132', ha='center', fontsize=7, color='#42a5f5')\nax1.text(137, y_ahpd-0.12, 'H137', ha='center', fontsize=7, color='#42a5f5')\nax1.text(-5, y_ahpd, 'AhpD\\n(177 aa)', ha='right', va='center', fontsize=9)\nax1.annotate('', xy=(133, y_ahpd+0.08), xytext=(130, y_ahpd+0.08),\n            arrowprops=dict(arrowstyle='<->', color='green', lw=2))\nax1.text(131.5, y_ahpd+0.18, 'CXXC', ha='center', color='green', fontsize=8, fontweight='bold')\n\nax1.set_xlim(-30, 185)\nax1.set_ylim(0.05, 0.95)\nax1.set_xlabel('Residue position')\nax1.set_yticks([])\nlegend_elements = [\n    plt.Line2D([0], [0], marker='o', color='w', markerfacecolor='gold', markersize=10, label='Cysteine'),\n    plt.Line2D([0], [0], marker='D', color='w', markerfacecolor='#42a5f5', markersize=8, label='Histidine'),\n    plt.Line2D([0], [0], marker='s', color='w', markerfacecolor='#ff7043', markersize=8, label='Glutamate'),\n]\nax1.legend(handles=legend_elements, loc='upper left', fontsize=7)\n\n# Panel 2: Catalytic feature checklist\nax2 = axes[0, 1]\nax2.set_title('B. Catalytic feature checklist', fontsize=11, fontweight='bold')\nax2.axis('off')\n\nfeatures = [\n    ('CXXC redox motif', '\u2713 CSHC (C130-C133)', '\u2717 ABSENT', True),\n    ('Histidine (proton relay)', '\u2713 His132, His137', '\u2717 NONE (0 His)', True),\n    ('Glu (proton relay start)', '\u2713 Glu118', '? Glu present but\\n   no relay partner', False),\n    ('Cys-Cys distance', '\u2713 ~5 \u00c5 (SG-SG)', '\u2717 36.5 \u00c5 (SG-SG)', True),\n    ('AhpD-like fold', '\u2713 Present', '\u2713 Present', False),\n    ('Experimental evidence', '\u2713 Biochemical assay', '\u2717 None', True),\n]\n\ny_pos = 0.92\nfor feat, ahpd_val, mj_val, is_critical in features:\n    color = '#ffcdd2' if is_critical else '#fff9c4'\n    ax2.add_patch(plt.Rectangle((0.0, y_pos-0.06), 1.0, 0.12, \n                                facecolor=color, edgecolor='gray', linewidth=0.5))\n    ax2.text(0.02, y_pos, feat, fontsize=8, fontweight='bold', va='center')\n    ax2.text(0.38, y_pos, ahpd_val, fontsize=7, va='center', color='green')\n    ax2.text(0.7, y_pos, mj_val, fontsize=7, va='center', color='red')\n    y_pos -= 0.14\n\n# Headers\nax2.text(0.38, 1.0, 'AhpD (Mtb)', fontsize=9, fontweight='bold', color='green')\nax2.text(0.7, 1.0, 'MJ1511', fontsize=9, fontweight='bold', color='red')\n\n# Panel 3: pLDDT plot\nax3 = axes[1, 0]\nax3.set_title('C. AlphaFold pLDDT confidence', fontsize=11, fontweight='bold')\n\n# Re-parse pLDDT from structure\nimport requests\npdb_url = \"https://alphafold.ebi.ac.uk/files/AF-Q58906-F1-model_v6.pdb\"\npdb_response = requests.get(pdb_url)\nlines = pdb_response.text.split('\\n')\n\nresidues = []\nplddts = []\nfor line in lines:\n    if line.startswith('ATOM') and line[12:16].strip() == 'CA':\n        res_num = int(line[22:26].strip())\n        plddt = float(line[60:66])\n        residues.append(res_num)\n        plddts.append(plddt)\n\nax3.fill_between(residues, plddts, alpha=0.3, color='steelblue')\nax3.plot(residues, plddts, color='steelblue', linewidth=1.5)\nax3.axhline(y=90, color='green', linestyle='--', alpha=0.5, label='Very high (\u226590)')\nax3.axhline(y=70, color='orange', linestyle='--', alpha=0.5, label='Confident (\u226570)')\n\n# Mark cysteines\ncys_idx_17 = residues.index(17)\ncys_idx_107 = residues.index(107)\nax3.plot(17, plddts[cys_idx_17], 'o', color='gold', markersize=12, markeredgecolor='black', zorder=5)\nax3.plot(107, plddts[cys_idx_107], 'o', color='gold', markersize=12, markeredgecolor='black', zorder=5)\nax3.annotate(f'Cys17\\npLDDT={plddts[cys_idx_17]:.0f}', xy=(17, plddts[cys_idx_17]),\n            xytext=(25, 72), fontsize=8, fontweight='bold',\n            arrowprops=dict(arrowstyle='->', color='black'))\nax3.annotate(f'Cys107\\npLDDT={plddts[cys_idx_107]:.0f}', xy=(107, plddts[cys_idx_107]),\n            xytext=(85, 55), fontsize=8, fontweight='bold',\n            arrowprops=dict(arrowstyle='->', color='black'))\n\nax3.set_xlabel('Residue number')\nax3.set_ylabel('pLDDT')\nax3.set_ylim(40, 102)\nax3.legend(fontsize=7, loc='lower left')\n\n# Panel 4: Archaeal CMD protein survey\nax4 = axes[1, 1]\nax4.set_title('D. CXXC motif in archaeal CMD proteins', fontsize=11, fontweight='bold')\n\ncategories = ['With CXXC\\n& His', 'With CXXC\\nno His', 'No CXXC\\nwith His', 'No CXXC\\nno His']\ncounts = [15, 1, 5, 4]  # From our survey data\ncolors_bar = ['#4caf50', '#a5d6a7', '#ef9a9a', '#e53935']\nbars = ax4.bar(categories, counts, color=colors_bar, edgecolor='black', linewidth=0.5)\n\n# Annotate\nfor bar, count in zip(bars, counts):\n    ax4.text(bar.get_x() + bar.get_width()/2, bar.get_height() + 0.3, \n             str(count), ha='center', fontweight='bold', fontsize=11)\n\nax4.set_ylabel('Number of proteins')\nax4.set_ylim(0, 18)\n\n# Highlight MJ1511 category\nax4.annotate('MJ1511\\nhere', xy=(3, 4), xytext=(3, 8),\n            fontsize=9, fontweight='bold', color='red', ha='center',\n            arrowprops=dict(arrowstyle='->', color='red', lw=2))\n\nplt.tight_layout()\nplt.savefig('mj1511_analysis.png', dpi=150, bbox_inches='tight')\nplt.show()\nprint(\"Figure saved: mj1511_analysis.png\")\n",
  "plot_number": 1
}