{
  "filename": "plot_1.png",
  "iteration": 1,
  "description": "Create visualization of AlphaFold confidence and genomic context for YrhB",
  "timestamp": "2026-06-21 20:02:10",
  "code": "\nimport matplotlib.pyplot as plt\nimport matplotlib.patches as mpatches\nimport numpy as np\n\n# Create a visualization of the AlphaFold pLDDT scores\nfig, axes = plt.subplots(2, 1, figsize=(14, 10), gridspec_kw={'height_ratios': [2, 1]})\n\n# Panel 1: pLDDT per residue\nsequence = \"MITYHDAFAKANHYLDDADLPVVITLHGRFSQGWYFCFEAREFLETGDEAARLAGNAPFIIDKDSGEIHSLGTAKPLEEYLQDYEIKKATFGLP\"\nplddt = [88.25, 95.25, 97.12, 97.50, 97.56, 97.69, 98.25, 98.00, 97.69, 97.81, \n         98.06, 97.12, 96.69, 96.00, 96.12, 94.19, 90.75, 89.50, 89.88, 92.38,\n         95.81, 97.31, 96.88, 97.94, 97.44, 97.44, 98.06, 97.88, 97.62, 96.62,\n         95.06, 96.06, 97.50, 98.62, 98.50, 98.50, 97.94, 97.88, 97.69, 97.38,\n         97.19, 97.75, 97.75, 97.38, 97.88, 97.69, 97.06, 97.31, 96.50, 95.62,\n         96.00, 96.31, 95.75, 91.56, 88.81, 93.75, 95.94, 97.31, 98.06, 98.19,\n         98.25, 97.44, 96.75, 95.50, 94.88, 96.44, 96.69, 97.12, 96.31, 95.75,\n         96.62, 95.69, 95.50, 95.62, 95.38, 96.06, 96.44, 96.88, 97.75, 97.38,\n         97.69, 97.19, 96.31, 96.69, 96.19, 95.62, 94.38, 93.50, 93.00, 93.44,\n         89.12, 81.00, 67.19, 53.72]\n\nresidues = list(range(1, len(plddt)+1))\ncolors = []\nfor p in plddt:\n    if p > 90: colors.append('#0053D6')      # Very high\n    elif p >= 70: colors.append('#65CBF3')    # Confident\n    elif p >= 50: colors.append('#FFDB13')    # Low\n    else: colors.append('#FF7D45')            # Very low\n\naxes[0].bar(residues, plddt, color=colors, width=1.0, edgecolor='none')\naxes[0].axhline(y=90, color='gray', linestyle='--', alpha=0.5, label='Very high (>90)')\naxes[0].axhline(y=70, color='gray', linestyle=':', alpha=0.5, label='Confident (>70)')\naxes[0].set_xlabel('Residue number', fontsize=12)\naxes[0].set_ylabel('pLDDT score', fontsize=12)\naxes[0].set_title('AlphaFold Confidence (pLDDT) for YrhB (P46857)\\nMean pLDDT = 95.2 \u2014 Very High Confidence Model', fontsize=14)\naxes[0].set_ylim(40, 100)\naxes[0].set_xlim(0, 95)\n\n# Add legend\npatches = [\n    mpatches.Patch(color='#0053D6', label='Very high (>90): 86 res (91.5%)'),\n    mpatches.Patch(color='#65CBF3', label='Confident (70-90): 6 res (6.4%)'),\n    mpatches.Patch(color='#FFDB13', label='Low (50-70): 2 res (2.1%)'),\n]\naxes[0].legend(handles=patches, loc='lower left', fontsize=9)\n\n# Mark W34 (conserved Imm35 tryptophan)\naxes[0].annotate('W34\\n(conserved Imm35 Trp)', xy=(34, 98.62), xytext=(45, 92),\n                fontsize=9, ha='center', color='darkred',\n                arrowprops=dict(arrowstyle='->', color='darkred'))\n\n# Panel 2: Genomic context\naxes[1].set_xlim(3581500, 3588500)\naxes[1].set_ylim(-1, 3)\n\ngene_data = [\n    ('yhhZ', 3581863, 3583041, 1, '#aaa', 'putative\\nendonuclease'),\n    ('yrhA', 3583038, 3584309, 1, '#ccc', 'pseudogene'),\n    ('insA-6', 3583483, 3583758, 1, '#f9a825', 'IS1'),\n    ('insB-6', 3583677, 3584180, 1, '#f9a825', 'IS1'),\n    ('yrhD', 3584404, 3584559, 1, '#aaa', 'unchar.'),\n    ('yrhB', 3584759, 3585043, 1, '#e53935', 'chaperone\\n(Imm35 fold)'),\n    ('ggt', 3585081, 3586823, -1, '#4caf50', 'glutathione\\nhydrolase'),\n    ('yhhA', 3586943, 3587383, 1, '#aaa', 'DUF2756'),\n    ('ugpQ', 3587370, 3588113, -1, '#4caf50', 'phospho-\\ndiesterase'),\n]\n\nfor name, start, end, strand, color, desc in gene_data:\n    y = 1.5\n    height = 0.6\n    arrow_width = (end - start)\n    \n    if strand == 1:\n        axes[1].annotate('', xy=(end, y), xytext=(start, y),\n                        arrowprops=dict(arrowstyle='->', color=color, lw=8, mutation_scale=15))\n    else:\n        axes[1].annotate('', xy=(start, y), xytext=(end, y),\n                        arrowprops=dict(arrowstyle='->', color=color, lw=8, mutation_scale=15))\n    \n    mid = (start + end) / 2\n    axes[1].text(mid, 2.3, name, ha='center', va='bottom', fontsize=8, fontweight='bold')\n    axes[1].text(mid, 0.6, desc, ha='center', va='top', fontsize=6, fontstyle='italic')\n\naxes[1].set_xlabel('Genomic position (bp)', fontsize=12)\naxes[1].set_title('Genomic Context of yrhB in E. coli K12 MG1655\\nNo adjacent toxin gene \u2014 inconsistent with Imm35 immunity function', fontsize=12)\naxes[1].set_yticks([])\naxes[1].spines['left'].set_visible(False)\naxes[1].spines['top'].set_visible(False)\naxes[1].spines['right'].set_visible(False)\n\nplt.tight_layout()\nplt.savefig('yrhb_analysis.png', dpi=150, bbox_inches='tight')\nplt.show()\nprint(\"Figure saved: yrhb_analysis.png\")\n",
  "plot_number": 1
}