{
  "filename": "plot_1.png",
  "iteration": 3,
  "description": "AlphaFold pLDDT confidence plot for A0A2U1PS28 showing domain architecture and catalytic residues",
  "timestamp": "2026-06-22 08:11:47",
  "code": "\nimport requests\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport matplotlib.patches as mpatches\n\n# Re-download and parse\npdb_url = \"https://alphafold.ebi.ac.uk/files/AF-A0A2U1PS28-F1-model_v6.pdb\"\nresp = requests.get(pdb_url)\nlines = resp.text.split('\\n')\n\nresidue_plddt = {}\nfor line in lines:\n    if line.startswith('ATOM') and line[12:16].strip() == 'CA':\n        resnum = int(line[22:26].strip())\n        bfactor = float(line[60:66].strip())\n        residue_plddt[resnum] = bfactor\n\nresidues = sorted(residue_plddt.keys())\nplddts = [residue_plddt[r] for r in residues]\n\nfig, ax = plt.subplots(figsize=(14, 5))\n\n# Color by confidence\ncolors = []\nfor p in plddts:\n    if p > 90:\n        colors.append('#0053D6')  # very high\n    elif p > 70:\n        colors.append('#65CBF3')  # confident\n    elif p > 50:\n        colors.append('#FFDB13')  # low\n    else:\n        colors.append('#FF7D45')  # very low\n\nax.bar(residues, plddts, color=colors, width=1.0, edgecolor='none')\n\n# Mark key domains\ndomain_regions = [\n    (1, 85, 'Transit\\npeptide', '#FFE0CC'),\n    (86, 245, 'G-domain\\n(Tr-type G)', '#D6E8FF'),\n    (246, 380, 'EFTu-like\\nD2', '#E8FFE0'),\n    (381, 500, 'EFG_C', '#FFF0D6'),\n    (501, 661, 'LepA_C\\n(CTD)', '#F0E0FF'),\n]\n\nfor start, end, label, color in domain_regions:\n    ax.axvspan(start, end, alpha=0.15, color=color, zorder=0)\n    mid = (start + end) / 2\n    ax.text(mid, 98, label, ha='center', va='bottom', fontsize=7, fontweight='bold')\n\n# Mark catalytic residues\ncatalytic_sites = [\n    (95, 102, 'P-loop'),\n    (160, 164, 'DTPGH'),\n    (192, 195, 'NKID'),\n]\nfor start, end, label in catalytic_sites:\n    ax.axvspan(start, end, alpha=0.3, color='red', zorder=1)\n    ax.annotate(label, xy=((start+end)/2, max(plddts[start-1:end])+2), \n                fontsize=6, ha='center', color='red', fontweight='bold')\n\n# Confidence threshold lines\nax.axhline(y=90, color='gray', linestyle='--', alpha=0.4, linewidth=0.5)\nax.axhline(y=70, color='gray', linestyle='--', alpha=0.4, linewidth=0.5)\nax.axhline(y=50, color='gray', linestyle='--', alpha=0.4, linewidth=0.5)\n\n# Legend\nlegend_elements = [\n    mpatches.Patch(facecolor='#0053D6', label='Very high (>90)'),\n    mpatches.Patch(facecolor='#65CBF3', label='Confident (70-90)'),\n    mpatches.Patch(facecolor='#FFDB13', label='Low (50-70)'),\n    mpatches.Patch(facecolor='#FF7D45', label='Very low (\u226450)'),\n    mpatches.Patch(facecolor='red', alpha=0.3, label='Catalytic residues'),\n]\nax.legend(handles=legend_elements, loc='lower right', fontsize=7)\n\nax.set_xlabel('Residue number', fontsize=10)\nax.set_ylabel('AlphaFold pLDDT', fontsize=10)\nax.set_title('A0A2U1PS28 (GUF1/EF-4, A. annua) \u2014 AlphaFold Confidence by Domain', fontsize=11)\nax.set_xlim(0, 665)\nax.set_ylim(0, 105)\n\nplt.tight_layout()\nplt.savefig('alphafold_confidence.png', dpi=150, bbox_inches='tight')\nplt.show()\nprint(\"Plot saved.\")\n",
  "plot_number": 1
}