{
  "filename": "plddt_profile.png",
  "iteration": 2,
  "description": "Download and analyze per-residue pLDDT from AlphaFold structure of A0A804UIX9",
  "timestamp": "2026-06-22 09:57:43",
  "code": "\nimport requests\nimport numpy as np\nimport matplotlib.pyplot as plt\n\n# Download the AlphaFold PDB\nurl = \"https://alphafold.ebi.ac.uk/files/AF-A0A804UIX9-F1-model_v6.pdb\"\nresp = requests.get(url)\npdb_text = resp.text\n\n# Parse B-factor column (contains pLDDT) from CA atoms\nresidues = []\nplddts = []\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        residues.append(res_num)\n        plddts.append(bfactor)\n\nresidues = np.array(residues)\nplddts = np.array(plddts)\n\nprint(f\"Total residues: {len(residues)}\")\nprint(f\"Mean pLDDT: {np.mean(plddts):.1f}\")\nprint(f\"Median pLDDT: {np.median(plddts):.1f}\")\n\n# Define regions\nregions = {\n    'N-term disordered (1-44)': (1, 44),\n    'PGG domain 1 (50-157)': (50, 157),\n    'TM1 (54-73)': (54, 73),\n    'TM2 (102-123)': (102, 123),\n    'TM3 (135-154)': (135, 154),\n    'Linker (158-216)': (158, 216),\n    'TM4 (166-189)': (166, 189),\n    'PGG domain 2 (217-294)': (217, 294),\n    'TM5 (222-239)': (222, 239),\n    'TM6 (269-290)': (269, 290),\n    'C-terminal (295-375)': (295, 375),\n}\n\nprint(\"\\n=== Per-region pLDDT ===\")\nfor name, (start, end) in regions.items():\n    mask = (residues >= start) & (residues <= end)\n    if np.any(mask):\n        region_plddt = plddts[mask]\n        print(f\"  {name}: mean={np.mean(region_plddt):.1f}, min={np.min(region_plddt):.1f}, max={np.max(region_plddt):.1f}\")\n\n# Plot\nfig, ax = plt.subplots(figsize=(14, 5))\nax.plot(residues, plddts, 'b-', linewidth=1)\nax.fill_between(residues, plddts, alpha=0.3)\n\n# Color regions\ntm_regions = [(54,73), (102,123), (135,154), (166,189), (222,239), (269,290)]\nfor i, (s, e) in enumerate(tm_regions):\n    ax.axvspan(s, e, alpha=0.2, color='red', label='TM helix' if i==0 else '')\n\npgg_regions = [(50, 157), (217, 294)]\nfor i, (s, e) in enumerate(pgg_regions):\n    ax.axvspan(s, e, alpha=0.1, color='blue', label='PGG domain' if i==0 else '')\n\nax.axhline(y=70, color='orange', linestyle='--', alpha=0.5, label='pLDDT=70 (confident)')\nax.axhline(y=90, color='green', linestyle='--', alpha=0.5, label='pLDDT=90 (very high)')\nax.axhline(y=50, color='red', linestyle='--', alpha=0.5, label='pLDDT=50 (low)')\n\nax.set_xlabel('Residue number', fontsize=12)\nax.set_ylabel('pLDDT score', fontsize=12)\nax.set_title('AlphaFold pLDDT confidence for A0A804UIX9', fontsize=14)\nax.set_ylim(0, 100)\nax.legend(loc='lower right', fontsize=9)\n\nplt.tight_layout()\nplt.savefig('plddt_profile.png', dpi=150)\nplt.show()\nprint(\"\\npLDDT profile saved.\")\n"
}