{
  "filename": "plot_2.png",
  "iteration": 2,
  "description": "Comprehensive visualization: nearest characterized homologs and GO term assessment",
  "timestamp": "2026-06-24 04:35:28",
  "code": "\nimport matplotlib.pyplot as plt\nimport matplotlib.patches as mpatches\nimport numpy as np\n\nfig, axes = plt.subplots(1, 2, figsize=(18, 9))\n\n# Panel 1: Distance dendrogram / bar chart showing nearest characterized neighbors\nax1 = axes[0]\n\nproteins = [\n    ('S. typhimurium\\nAhpC (P0A251)', 69.0, 'AhpF-dependent', '#e74c3c'),\n    ('E. coli\\nAhpC (P0AE08)', 67.9, 'AhpF-dependent', '#e74c3c'),\n    ('Human\\nPRDX2 (P32119)', 47.6, 'Trx-dependent', '#3498db'),\n    ('P. putida\\ntsaA (Q88NW9)', 47.3, 'Trx-dependent', '#3498db'),\n    ('S. cerevisiae\\nTSA1 (P35704)', 46.5, 'Trx-dependent', '#3498db'),\n    ('H. pylori\\nAhpC (P56876)', 42.9, 'Trx-dependent', '#3498db'),\n    ('M. tuberculosis\\nAhpC (P9WQB7)', 38.3, 'AhpD-dependent', '#f39c12'),\n]\n\nnames = [p[0] for p in proteins]\nidentities = [p[1] for p in proteins]\ncolors = [p[3] for p in proteins]\n\ny_pos = np.arange(len(proteins))\nbars = ax1.barh(y_pos, identities, color=colors, alpha=0.85, height=0.65, edgecolor='white')\n\n# Add value labels\nfor i, (bar, val) in enumerate(zip(bars, identities)):\n    ax1.text(val + 0.5, i, f'{val:.1f}%', va='center', fontsize=10, fontweight='bold')\n\nax1.set_yticks(y_pos)\nax1.set_yticklabels(names, fontsize=9)\nax1.set_xlabel('Sequence Identity to Q88K52 (%)', fontsize=11)\nax1.set_title('Nearest Characterized Homologs\\nof P. putida AhpC (Q88K52)', fontsize=12, fontweight='bold')\nax1.set_xlim(0, 80)\nax1.invert_yaxis()\n\n# Add a dividing line between AhpF-dependent and others\nax1.axhline(y=1.5, color='gray', linestyle='--', alpha=0.5)\nax1.text(75, 0.5, 'AhpF\\nclade', ha='center', va='center', fontsize=8, color='#e74c3c', fontweight='bold',\n         bbox=dict(boxstyle='round', facecolor='#fadbd8', alpha=0.8))\nax1.text(75, 4.0, 'Trx/other\\nclades', ha='center', va='center', fontsize=8, color='#3498db', fontweight='bold',\n         bbox=dict(boxstyle='round', facecolor='#d6eaf8', alpha=0.8))\n\n# Legend\nlegend_elements = [\n    mpatches.Patch(color='#e74c3c', alpha=0.85, label='AhpF-dependent'),\n    mpatches.Patch(color='#3498db', alpha=0.85, label='Trx-dependent'),\n    mpatches.Patch(color='#f39c12', alpha=0.85, label='AhpD-dependent'),\n]\nax1.legend(handles=legend_elements, loc='lower right', fontsize=9)\n\n# Panel 2: GO term hierarchy and evidence summary\nax2 = axes[1]\nax2.set_xlim(0, 10)\nax2.set_ylim(0, 10)\nax2.axis('off')\n\nax2.text(5, 9.6, 'Evidence Summary & GO Assessment', ha='center', fontsize=13, fontweight='bold')\n\n# GO hierarchy with arrows\nhierarchy = [\n    (0.5, 8.6, 'GO:0051920', 'peroxiredoxin activity', '#27ae60', '\u2713 Most precise'),\n    (1.2, 7.8, 'GO:0140824', 'Trx-dependent Prx activity', '#f39c12', '\u25b3 Trx not demonstrated'),\n    (1.9, 7.0, 'GO:0008379', 'thioredoxin peroxidase activity\\n(SEED TERM)', '#e67e22', '\u25b3 Supported*'),\n]\n\nfor x, y, go_id, name, color, verdict in hierarchy:\n    ax2.text(x, y, f'\u2192 {go_id}: {name}', fontsize=9, color='#2c3e50', fontweight='bold')\n    ax2.text(8.5, y, verdict, fontsize=8, ha='center', fontweight='bold', color=color,\n             bbox=dict(boxstyle='round,pad=0.2', facecolor=color+'15', edgecolor=color, linewidth=1.5))\n\n# Sibling term\nax2.text(0.5, 6.2, '\u2197 GO:0102039: NADH-dependent Prx activity (sibling)', fontsize=9, color='#2980b9', fontweight='bold')\nax2.text(8.5, 6.2, '\u2713 Also applies', fontsize=8, ha='center', fontweight='bold', color='#27ae60',\n         bbox=dict(boxstyle='round,pad=0.2', facecolor='#d5f5e315', edgecolor='#27ae60', linewidth=1.5))\n\n# Key evidence items\nax2.text(0.3, 5.2, 'Key Evidence:', fontsize=11, fontweight='bold', color='#2c3e50')\n\nevidence_items = [\n    ('\u2713', 'Active site: 5/5 catalytic residues conserved (C47, C166, T44, E50, R120)', '#27ae60'),\n    ('\u2713', 'Nearest characterized homolog: S. typhimurium AhpC (69% id, AhpF-dep)', '#27ae60'),\n    ('\u2713', 'Domain architecture: AhpC-TSA + 1-CysPrx_C (cd03015 PRX_Typ2cys)', '#27ae60'),\n    ('\u2713', 'Expressed under oxidative stress in P. putida (PMID:17107553)', '#27ae60'),\n    ('\u25b3', 'PANTHER SF121 = \"ALKYL HYDROPEROXIDE REDUCTASE C\" (not Trx-dep)', '#f39c12'),\n    ('\u25b3', 'P. putida has AhpF (P0A155) as dedicated reductant', '#f39c12'),\n    ('\u25b3', 'Separate Trx-dependent Prx (tsaA/Q88NW9) in same organism', '#f39c12'),\n    ('\u25b3', 'GO:0008379 has 0 experimental annotations across all organisms', '#f39c12'),\n    ('\u2713', 'T. pallidum AhpC-like Prx uses Trx when AhpF absent (PMID:20304799)', '#3498db'),\n]\n\nfor i, (symbol, text, color) in enumerate(evidence_items):\n    y = 4.6 - i * 0.45\n    ax2.text(0.5, y, symbol, fontsize=10, fontweight='bold', color=color)\n    ax2.text(1.0, y, text, fontsize=7.8, color='#2c3e50')\n\n# Verdict box\nax2.text(5, 0.6, 'VERDICT: SUPPORTED (mild granularity caveat, failure mode #1)', \n         ha='center', fontsize=11, fontweight='bold', color='#27ae60',\n         bbox=dict(boxstyle='round,pad=0.4', facecolor='#d5f5e3', edgecolor='#27ae60', linewidth=2))\n\nplt.tight_layout()\nplt.savefig('comprehensive_assessment.png', dpi=150, bbox_inches='tight')\nplt.show()\nprint(\"Figure saved: comprehensive_assessment.png\")\n",
  "plot_number": 2
}