{
  "filename": "plot_1.png",
  "iteration": 1,
  "description": "Create comprehensive domain architecture comparison figure: HSPA12B vs canonical HSP70, with pLDDT profile",
  "timestamp": "2026-06-22 01:13:27",
  "code": "\nimport requests\nimport numpy as np\nimport matplotlib.pyplot as plt\n\n# Fetch AlphaFold PDB for HSPA12B\npdb_url = \"https://alphafold.ebi.ac.uk/files/AF-Q96MM6-F1-model_v6.pdb\"\nresponse = requests.get(pdb_url, timeout=60)\npdb_text = response.text\n\n# Parse CA coordinates and pLDDT\nca_coords = {}\nplddt_vals = {}\nfor line in pdb_text.split('\\n'):\n    if line.startswith('ATOM') and line[12:16].strip() == 'CA':\n        resnum = int(line[22:26].strip())\n        x = float(line[30:38].strip())\n        y = float(line[38:46].strip())\n        z = float(line[46:54].strip())\n        bfactor = float(line[60:66].strip())\n        ca_coords[resnum] = np.array([x, y, z])\n        plddt_vals[resnum] = bfactor\n\n# Create pLDDT profile plot\nfig, axes = plt.subplots(2, 1, figsize=(14, 10))\n\n# Plot 1: pLDDT profile\nresidues = sorted(plddt_vals.keys())\nplddts = [plddt_vals[r] for r in residues]\n\nax1 = axes[0]\nax1.fill_between(residues, plddts, alpha=0.3, color='steelblue')\nax1.plot(residues, plddts, color='steelblue', linewidth=0.8)\nax1.axhline(y=90, color='green', linestyle='--', alpha=0.5, label='Very high (>90)')\nax1.axhline(y=70, color='orange', linestyle='--', alpha=0.5, label='Confident (>70)')\nax1.axhline(y=50, color='red', linestyle='--', alpha=0.5, label='Low (<50)')\n\n# Mark regions\nregions = [\n    (\"N-term\\next.\", 1, 59, 'lightcoral'),\n    (\"NBD Lobe I\\n(InterPro)\", 60, 250, 'lightblue'),\n    (\"Linker/\\nInsert\", 251, 312, 'lightyellow'),\n    (\"NBD Lobe II\\n(InterPro)\", 313, 529, 'lightgreen'),\n    (\"C-terminal\\nregion\", 530, 686, 'plum'),\n]\nfor label, start, end, color in regions:\n    ax1.axvspan(start, end, alpha=0.15, color=color)\n    ax1.text((start+end)/2, 105, label, ha='center', va='bottom', fontsize=8, fontweight='bold')\n\nax1.set_xlabel('Residue Number')\nax1.set_ylabel('pLDDT')\nax1.set_title('HSPA12B AlphaFold pLDDT Confidence Profile\\n(No canonical HSP70 SBD or lid domain detected)')\nax1.set_ylim(0, 115)\nax1.set_xlim(0, 690)\nax1.legend(fontsize=8)\n\n# Plot 2: Domain architecture comparison\nax2 = axes[1]\nax2.set_xlim(0, 700)\nax2.set_ylim(-1, 6)\n\n# HSPA8 architecture\ny_hspa8 = 4.5\nax2.barh(y_hspa8, 382-5, left=5, height=0.6, color='royalblue', alpha=0.7, edgecolor='black')\nax2.text(193, y_hspa8, 'NBD (ATPase)', ha='center', va='center', fontsize=8, fontweight='bold', color='white')\nax2.barh(y_hspa8, 543-383, left=383, height=0.6, color='forestgreen', alpha=0.7, edgecolor='black')\nax2.text(463, y_hspa8, 'SBD\u03b2', ha='center', va='center', fontsize=8, fontweight='bold', color='white')\nax2.barh(y_hspa8, 646-532, left=532, height=0.6, color='darkorange', alpha=0.7, edgecolor='black')\nax2.text(589, y_hspa8, 'SBD\u03b1\\n(Lid)', ha='center', va='center', fontsize=7, fontweight='bold', color='white')\n# Mark conserved sites\nfor pos, label in [(9, 'IDLGTTYS'), (199, 'DLGGGTFD'), (341, 'Conserved')]:\n    ax2.plot(pos, y_hspa8 + 0.4, 'v', color='red', markersize=6)\n    ax2.text(pos, y_hspa8 + 0.55, label, ha='center', fontsize=6, color='red')\nax2.text(-5, y_hspa8, 'HSPA8\\n(canonical)', ha='right', va='center', fontsize=9, fontweight='bold')\n\n# HSPA12B architecture\ny_12b = 2.5\nax2.barh(y_12b, 59-1, left=1, height=0.6, color='lightcoral', alpha=0.7, edgecolor='black')\nax2.text(30, y_12b, 'N-ext\\n(disordered)', ha='center', va='center', fontsize=6)\nax2.barh(y_12b, 250-60, left=60, height=0.6, color='cornflowerblue', alpha=0.5, edgecolor='black', linestyle='--')\nax2.text(155, y_12b, 'NBD Lobe I\\n(divergent)', ha='center', va='center', fontsize=7)\nax2.barh(y_12b, 312-251, left=251, height=0.6, color='lightyellow', alpha=0.7, edgecolor='black')\nax2.text(281, y_12b, 'Insert', ha='center', va='center', fontsize=6)\nax2.barh(y_12b, 529-313, left=313, height=0.6, color='mediumseagreen', alpha=0.5, edgecolor='black', linestyle='--')\nax2.text(421, y_12b, 'NBD Lobe II\\n(divergent)', ha='center', va='center', fontsize=7)\nax2.barh(y_12b, 686-530, left=530, height=0.6, color='plum', alpha=0.5, edgecolor='black', linestyle='--')\nax2.text(608, y_12b, 'C-terminal\\n(no SBD/lid)', ha='center', va='center', fontsize=7)\n# Mark degenerate motifs\nfor pos, label in [(66, 'IDFGTT\\n(L\u2192F!)'), (320, 'DCGGG\\n(D\u2192C!)')]:\n    ax2.plot(pos, y_12b + 0.4, 'v', color='darkred', markersize=6)\n    ax2.text(pos, y_12b + 0.55, label, ha='center', fontsize=6, color='darkred')\nax2.text(-5, y_12b, 'HSPA12B\\n(divergent)', ha='right', va='center', fontsize=9, fontweight='bold')\n\n# Missing elements\nax2.text(450, 0.8, '\u2717 No Pfam HSP70 (PF00012) match\\n'\n         '\u2717 No HSP70 conserved sites (IPR018181)\\n'\n         '\u2717 No SBD \u03b2-sandwich (IPR029047)\\n'\n         '\u2717 No \u03b1-helical lid (IPR029048)\\n'\n         '\u2717 ~7% identity to canonical HSP70 NBD',\n         fontsize=8, va='top', color='darkred',\n         bbox=dict(boxstyle='round', facecolor='lightyellow', alpha=0.8))\n\nax2.set_xlabel('Residue Position')\nax2.set_title('Domain Architecture Comparison: HSPA12B vs Canonical HSP70 (HSPA8)')\nax2.set_yticks([])\nax2.spines['top'].set_visible(False)\nax2.spines['right'].set_visible(False)\nax2.spines['left'].set_visible(False)\n\nplt.tight_layout()\nplt.savefig('hspa12b_domain_comparison.png', dpi=150, bbox_inches='tight')\nplt.show()\nprint(\"Figure saved: hspa12b_domain_comparison.png\")\n",
  "plot_number": 1
}