{
  "filename": "plot_2.png",
  "iteration": 1,
  "description": "Create pLDDT confidence plot with domain architecture showing UBAC2 structure confidence and absence of catalytic site",
  "timestamp": "2026-07-05 05:18:23",
  "code": "\nimport requests\nimport matplotlib.pyplot as plt\nimport numpy as np\n\n# Re-fetch PDB for plotting\nurl = \"https://alphafold.ebi.ac.uk/files/AF-Q8NBM4-F1-model_v6.pdb\"\nresp = requests.get(url)\npdb_text = resp.text\n\n# Parse pLDDT from B-factor\nplddt_by_res = {}\nfor line in pdb_text.split('\\n'):\n    if line.startswith('ATOM') and line[12:16].strip() == 'CA':\n        res_num = int(line[22:26].strip())\n        bfactor = float(line[60:66].strip())\n        plddt_by_res[res_num] = bfactor\n\nresidues = sorted(plddt_by_res.keys())\nplddt_values = [plddt_by_res[r] for r in residues]\n\n# Create pLDDT plot with domain annotations\nfig, ax = plt.subplots(figsize=(14, 5))\n\n# Plot pLDDT\nax.plot(residues, plddt_values, color='#1565C0', linewidth=1, alpha=0.8)\nax.fill_between(residues, plddt_values, alpha=0.15, color='#1565C0')\n\n# Color by confidence\nfor r, p in zip(residues, plddt_values):\n    if p >= 90:\n        color = '#0D47A1'\n    elif p >= 70:\n        color = '#42A5F5'\n    elif p >= 50:\n        color = '#FFB74D'\n    else:\n        color = '#EF5350'\n    ax.plot(r, p, 'o', color=color, markersize=1.5)\n\n# Annotate domains\ntm_regions = [(92, 112, 'TM1'), (126, 146, 'TM2'), (164, 184, 'TM3')]\nfor s, e, label in tm_regions:\n    ax.axvspan(s, e, alpha=0.2, color='#4CAF50')\n    ax.text((s+e)/2, 95, label, ha='center', fontsize=8, fontweight='bold', color='#2E7D32')\n\n# UBA domain\nax.axvspan(304, 344, alpha=0.2, color='#9C27B0')\nax.text(324, 95, 'UBA', ha='center', fontsize=8, fontweight='bold', color='#6A1B9A')\n\n# LIR motif\nax.axvspan(275, 278, alpha=0.3, color='#FFC107')\nax.text(276, 48, 'LIR', ha='center', fontsize=7, fontweight='bold', color='#F57F17')\n\n# Where catalytic residues WOULD be (if active rhomboid)\nax.annotate('No catalytic\\nGxSG in TMs', xy=(138, 30), fontsize=9, color='red', \n           fontweight='bold', ha='center',\n           bbox=dict(boxstyle='round,pad=0.3', facecolor='#FFCDD2', edgecolor='red', alpha=0.8))\n\n# Confidence thresholds\nax.axhline(y=90, color='gray', linestyle='--', alpha=0.3, linewidth=0.5)\nax.axhline(y=70, color='gray', linestyle='--', alpha=0.3, linewidth=0.5)\nax.axhline(y=50, color='gray', linestyle='--', alpha=0.3, linewidth=0.5)\n\nax.text(348, 92, 'Very high', fontsize=7, color='#0D47A1', va='center')\nax.text(348, 72, 'Confident', fontsize=7, color='#42A5F5', va='center')\nax.text(348, 52, 'Low', fontsize=7, color='#FFB74D', va='center')\n\nax.set_xlabel('Residue Position', fontsize=11)\nax.set_ylabel('AlphaFold pLDDT Score', fontsize=11)\nax.set_title('UBAC2 (Q8NBM4) AlphaFold Confidence & Domain Architecture\\nRhomboid pseudoprotease \u2014 no catalytic site', fontsize=12, fontweight='bold')\nax.set_xlim(1, 355)\nax.set_ylim(20, 100)\n\nplt.tight_layout()\nplt.savefig('ubac2_plddt_domains.png', dpi=150, bbox_inches='tight')\nplt.show()\nprint(\"pLDDT domain plot saved.\")\n",
  "plot_number": 2
}