{
  "filename": "hydropathy_comparison.png",
  "iteration": 1,
  "description": "Compute hydropathy profiles for HSPA13 vs HSPA1A showing the missing SBD region",
  "timestamp": "2026-07-06 12:00:10",
  "code": "\nimport requests\nimport numpy as np\nimport matplotlib.pyplot as plt\n\n# Let's also check if HSPA13 has any conserved substrate-binding residues\n# Key substrate-binding residues in DnaK (E. coli HSP70): \n# SBD beta: V395, M404, A429, L484, V436\n# These form the hydrophobic pocket that binds client peptides\n\n# In human HSPA1A, the equivalent SBD starts at ~394\n# HSPA13 is 471 aa total with signal peptide at 1-27\n# After the NBD (~28-314), it only has ~157 residues remaining\n\n# Let's compute a hydrophobicity profile comparison\ndef kyte_doolittle(seq):\n    \"\"\"Compute Kyte-Doolittle hydrophobicity with sliding window\"\"\"\n    kd_scale = {\n        'A': 1.8, 'R': -4.5, 'N': -3.5, 'D': -3.5, 'C': 2.5,\n        'Q': -3.5, 'E': -3.5, 'G': -0.4, 'H': -3.2, 'I': 4.5,\n        'L': 3.8, 'K': -3.9, 'M': 1.9, 'F': 2.8, 'P': -1.6,\n        'S': -0.8, 'T': -0.7, 'W': -0.9, 'Y': -1.3, 'V': 4.2\n    }\n    window = 11\n    half_w = window // 2\n    hydro = []\n    for i in range(len(seq)):\n        start = max(0, i - half_w)\n        end = min(len(seq), i + half_w + 1)\n        segment = seq[start:end]\n        values = [kd_scale.get(aa, 0) for aa in segment]\n        hydro.append(np.mean(values))\n    return np.array(hydro)\n\n# Fetch sequences\nproteins = {\n    'HSPA13': 'P48723',\n    'HSPA1A': 'P0DMV8',\n}\nsequences = {}\nfor name, acc in proteins.items():\n    url = f\"https://rest.uniprot.org/uniprotkb/{acc}.json\"\n    resp = requests.get(url, headers={\"Accept\": \"application/json\"})\n    entry = resp.json()\n    sequences[name] = entry.get('sequence', {}).get('value', '')\n\n# Compute hydropathy profiles\nfig, axes = plt.subplots(2, 1, figsize=(14, 8), gridspec_kw={'hspace': 0.4})\n\nfor idx, (name, seq) in enumerate(sequences.items()):\n    ax = axes[idx]\n    hydro = kyte_doolittle(seq)\n    positions = np.arange(1, len(seq) + 1)\n    \n    # Color by domain\n    colors = []\n    for i in range(len(seq)):\n        if name == 'HSPA13':\n            if i < 27:\n                colors.append('#2ecc71')  # Signal peptide\n            elif i < 314:\n                colors.append('#3498db')  # NBD\n            else:\n                colors.append('#95a5a6')  # C-terminal (no SBD)\n        else:  # HSPA1A\n            if i < 386:\n                colors.append('#3498db')  # NBD\n            elif i < 394:\n                colors.append('#95a5a6')  # Linker\n            elif i < 509:\n                colors.append('#e74c3c')  # SBD\n            elif i < 613:\n                colors.append('#f39c12')  # Lid\n            else:\n                colors.append('#bdc3c7')  # Tail\n    \n    # Plot as filled area\n    ax.fill_between(positions, hydro, 0, where=hydro>=0, alpha=0.3, color='orange')\n    ax.fill_between(positions, hydro, 0, where=hydro<0, alpha=0.3, color='blue')\n    ax.plot(positions, hydro, linewidth=0.5, color='black', alpha=0.5)\n    \n    # Mark domain boundaries\n    if name == 'HSPA13':\n        ax.axvline(x=27, color='green', linestyle='--', alpha=0.7, label='Signal peptide end')\n        ax.axvline(x=314, color='red', linestyle='--', alpha=0.7, label='NBD end')\n        ax.axhline(y=0, color='gray', linestyle='-', alpha=0.3)\n        ax.set_title(f'{name} (471 aa) \u2014 NO SUBSTRATE-BINDING DOMAIN', fontsize=12, fontweight='bold', color='red')\n        \n        # Annotate the N-terminal hydrophobic leader\n        ax.annotate('Signal\\npeptide', xy=(14, 2), fontsize=8, ha='center', fontweight='bold', color='green')\n        ax.annotate('NBD (ATPase)', xy=(170, -2.5), fontsize=10, ha='center', fontweight='bold', color='#3498db')\n        ax.annotate('Short C-terminal\\n(NOT an SBD)', xy=(400, -2.5), fontsize=9, ha='center', fontweight='bold', color='red')\n    else:\n        ax.axvline(x=386, color='blue', linestyle='--', alpha=0.7, label='NBD end')\n        ax.axvline(x=394, color='red', linestyle='--', alpha=0.7, label='SBD start')\n        ax.axvline(x=509, color='red', linestyle='--', alpha=0.7, label='SBD end')\n        ax.axhline(y=0, color='gray', linestyle='-', alpha=0.3)\n        ax.set_title(f'{name} (641 aa) \u2014 Canonical HSP70 with SBD', fontsize=12, fontweight='bold')\n        \n        ax.annotate('NBD (ATPase)', xy=(193, -2.5), fontsize=10, ha='center', fontweight='bold', color='#3498db')\n        ax.annotate('SBD', xy=(451, -2.5), fontsize=10, ha='center', fontweight='bold', color='#e74c3c')\n        ax.annotate('Lid', xy=(560, -2.5), fontsize=9, ha='center', fontweight='bold', color='#f39c12')\n    \n    ax.set_ylabel('Hydrophobicity\\n(Kyte-Doolittle)')\n    ax.set_xlim(0, 670)\n    ax.set_ylim(-3.5, 3.5)\n    ax.legend(fontsize=8, loc='upper right')\n\naxes[1].set_xlabel('Residue position')\nfig.suptitle('Hydropathy Profile Comparison: HSPA13 vs HSPA1A\\nHSPA13 terminates before the SBD region of canonical HSP70s', \n             fontsize=13, fontweight='bold', y=1.02)\nplt.savefig('hydropathy_comparison.png', dpi=150, bbox_inches='tight')\nplt.show()\nprint(\"Figure saved: hydropathy_comparison.png\")\n"
}