{
  "filename": "plot_1.png",
  "iteration": 1,
  "description": "Create comprehensive evidence figure showing the misannotation of AprA as SDH",
  "timestamp": "2026-06-23 22:25:23",
  "code": "\nimport requests\nimport numpy as np\n\n# Now let's create a comprehensive visualization showing the evidence\nimport matplotlib\nmatplotlib.use('Agg')\nimport matplotlib.pyplot as plt\nimport matplotlib.patches as mpatches\n\nfig, axes = plt.subplots(2, 2, figsize=(16, 12))\nfig.suptitle('Evidence: Q72DT2 (aprA) is APS Reductase, NOT Succinate Dehydrogenase', fontsize=14, fontweight='bold')\n\n# Panel A: Domain architecture comparison\nax = axes[0, 0]\nax.set_title('A. Domain Architecture', fontweight='bold')\n\nproteins = [\n    ('Q72DT2\\n(DvH AprA)\\n664 aa', [\n        (15/664, 279/664, 'FAD_binding_2\\n(PF00890)', '#2196F3'),\n        (280/664, 653/664, 'SDH/FRD catalytic\\n(SSF56425)', '#4CAF50'),\n    ], 'APS Reductase\\nEC 1.8.99.2'),\n    ('P0AC41\\n(Ec SdhA)\\n588 aa', [\n        (14/588, 52/588, 'FAD_binding_2', '#2196F3'),\n        (53/588, 300/588, 'SDH/FRD catalytic', '#4CAF50'),\n        (301/588, 588/588, 'C-terminal', '#FF9800'),\n    ], 'Succinate DH\\nEC 1.3.5.1'),\n    ('P00363\\n(Ec FrdA)\\n602 aa', [\n        (12/602, 52/602, 'FAD_binding_2', '#2196F3'),\n        (53/602, 310/602, 'SDH/FRD catalytic', '#4CAF50'),\n        (311/602, 602/602, 'C-terminal', '#FF9800'),\n    ], 'Fumarate Red.\\nEC 1.3.5.1'),\n]\n\nfor i, (label, domains, ec_label) in enumerate(proteins):\n    y = 2 - i\n    # Draw protein bar\n    ax.barh(y, 1.0, height=0.3, color='lightgray', edgecolor='black', linewidth=0.5)\n    # Draw domains\n    for start, end, name, color in domains:\n        ax.barh(y, end-start, left=start, height=0.3, color=color, edgecolor='black', linewidth=0.5, alpha=0.8)\n    ax.text(-0.05, y, label, ha='right', va='center', fontsize=8)\n    ax.text(1.05, y, ec_label, ha='left', va='center', fontsize=8, color='red', fontweight='bold')\n\nax.set_xlim(-0.4, 1.5)\nax.set_ylim(-0.5, 3)\nax.set_xlabel('Relative position')\nax.set_yticks([])\n\n# Panel B: Key discriminating features table\nax = axes[0, 1]\nax.set_title('B. Key Discriminating Features', fontweight='bold')\nax.axis('off')\n\ntable_data = [\n    ['Feature', 'AprA (Q72DT2)', 'SdhA'],\n    ['EC Number', '1.8.99.2', '1.3.5.1'],\n    ['Reaction', 'APS \u2192 sulfite + AMP', 'Succinate \u2192 fumarate'],\n    ['Substrate', 'Sulfur compound', 'C4 dicarboxylate'],\n    ['FAD binding', 'NON-COVALENT', 'COVALENT (His)'],\n    ['Cov. FAD His', 'ABSENT', 'His45 (8\u03b1-FAD)'],\n    ['InterPro family', 'IPR011803 (AprA)', 'IPR030664 (shared)'],\n    ['KEGG Pathway', 'Sulfur metabolism', 'TCA cycle'],\n    ['Arg317 (catalytic)', 'PRESENT', 'N/A'],\n]\n\ntable = ax.table(cellText=table_data, loc='center', cellLoc='center', \n                 colWidths=[0.3, 0.35, 0.35])\ntable.auto_set_font_size(False)\ntable.set_fontsize(8)\ntable.scale(1, 1.5)\n\n# Color header row\nfor j in range(3):\n    table[0, j].set_facecolor('#34495e')\n    table[0, j].set_text_props(color='white', fontweight='bold')\n\n# Color mismatches in red\nfor i in range(1, 9):\n    table[i, 1].set_facecolor('#e8f5e9')  # green for AprA (correct)\n    table[i, 2].set_facecolor('#ffebee')  # red for SdhA (wrong assignment)\n\n# Panel C: FAD-binding motif alignment\nax = axes[1, 0]\nax.set_title('C. FAD-Binding Region Alignment', fontweight='bold')\nax.axis('off')\n\n# Show the critical alignment\nalignment_text = \"\"\"GxGxxG motif and covalent FAD histidine region:\n\nDvH AprA:  ....VGGGMGACGTAFEAVRWADKYAPELKILLIDKASLE...\nAf  AprA:  ...LIIGGGFSGCGAAYEAAYWAKVGAEERIIMLIDKDALE...\nEc  SdhA:  ...VVIGAGGAGMRAALQISQSGQTCALLSKVFPTRSHTVSAQ...\nEc  FrdA:  ...VIVGAGGAGLRAAIAAAQANPNAKIALISKVYPMRSHTVAA...\n                 ***.*.     *              *          \n                GxGxxG                    ^\n                motif                 Covalent FAD His\n                                     (SHT motif)\n                                     PRESENT in SdhA/FrdA\n                                     ABSENT in AprA!\n\"\"\"\nax.text(0.05, 0.95, alignment_text, transform=ax.transAxes, fontsize=8, \n        fontfamily='monospace', verticalalignment='top',\n        bbox=dict(boxstyle='round', facecolor='lightyellow', alpha=0.8))\n\n# Panel D: Verdict\nax = axes[1, 1]\nax.set_title('D. Verdict', fontweight='bold')\nax.axis('off')\n\nverdict_text = \"\"\"VERDICT: WRONG SUBFAMILY (MIS-PLACED)\n\nFailure Mode #3: Within-superfamily mis-placement\n\nThe PANTHER family PTHR11632 encompasses an FAD-dependent\noxidoreductase superfamily containing three functionally\ndistinct subfamilies:\n  \u2022 SdhA - Succinate dehydrogenase (EC 1.3.5.1)\n  \u2022 FrdA - Fumarate reductase (EC 1.3.5.1) \n  \u2022 AprA - APS reductase (EC 1.8.99.2) \u2190 Q72DT2\n\nTreeGrafter placed Q72DT2 in the SdhA subfamily\n(PTHR11632:SF51) and propagated GO:0000104\n(succinate dehydrogenase activity).\n\nCORRECT TERM: GO:0009973\n  adenylyl-sulfate reductase activity\n\nACTION: REPLACE with GO:0009973\n\"\"\"\n\nax.text(0.05, 0.95, verdict_text, transform=ax.transAxes, fontsize=9, \n        verticalalignment='top', fontfamily='monospace',\n        bbox=dict(boxstyle='round', facecolor='#ffcdd2', alpha=0.9))\n\nplt.tight_layout()\nplt.savefig('evidence_summary.png', dpi=150, bbox_inches='tight')\nplt.show()\nprint(\"Figure saved: evidence_summary.png\")\n",
  "plot_number": 1
}