{
  "filename": "plot_1.png",
  "iteration": 1,
  "description": "Computing Kyte-Doolittle hydropathy profile for CLCN7 and comparing with UniProt TM annotations",
  "timestamp": "2026-06-21 23:27:31",
  "code": "\nimport requests\nimport numpy as np\nimport matplotlib.pyplot as plt\n\n# Fetch human CLCN7 sequence from UniProt\nurl = \"https://rest.uniprot.org/uniprotkb/P51798.json\"\nresponse = requests.get(url)\ndata = response.json()\nsequence = data.get('sequence', {}).get('value', '')\n\nprint(f\"CLCN7 sequence length: {len(sequence)} aa\")\n\n# Kyte-Doolittle hydropathy scale\nkd_scale = {\n    'I': 4.5, 'V': 4.2, 'L': 3.8, 'F': 2.8, 'C': 2.5,\n    'M': 1.9, 'A': 1.8, 'G': -0.4, 'T': -0.7, 'S': -0.8,\n    'W': -0.9, 'Y': -1.3, 'P': -1.6, 'H': -3.2, 'D': -3.5,\n    'E': -3.5, 'N': -3.5, 'Q': -3.5, 'K': -3.9, 'R': -4.5,\n}\n\n# Compute hydropathy with window of 19 (standard for TM prediction)\nwindow = 19\nhydropathy = []\nfor i in range(len(sequence) - window + 1):\n    window_seq = sequence[i:i+window]\n    score = np.mean([kd_scale.get(aa, 0) for aa in window_seq])\n    hydropathy.append(score)\n\npositions = np.arange(window//2, len(sequence) - window//2)\n\n# UniProt TM regions\ntm_regions = [\n    (127, 159), (174, 197), (223, 241), (247, 264),\n    (322, 341), (375, 405), (410, 432), (487, 507),\n    (512, 535), (579, 597)\n]\n\n# Plot hydropathy\nfig, ax = plt.subplots(figsize=(14, 5))\nax.plot(positions, hydropathy, 'b-', linewidth=0.8)\nax.axhline(y=1.6, color='r', linestyle='--', alpha=0.5, label='TM threshold (1.6)')\nax.axhline(y=0, color='gray', linestyle='-', alpha=0.3)\n\n# Shade UniProt TM regions\nfor i, (start, end) in enumerate(tm_regions):\n    ax.axvspan(start, end, alpha=0.2, color='orange', \n               label='UniProt TM' if i == 0 else None)\n\nax.set_xlabel('Residue Position')\nax.set_ylabel('Hydropathy Score (Kyte-Doolittle, w=19)')\nax.set_title('CLCN7 (P51798) Hydropathy Profile with UniProt Transmembrane Regions')\nax.legend()\nax.set_xlim(0, len(sequence))\nplt.tight_layout()\nplt.savefig('/tmp/clcn7_hydropathy.png', dpi=150)\nplt.show()\nprint(\"Hydropathy plot saved.\")\n\n# Count peaks above TM threshold\npeaks_above = []\nin_peak = False\npeak_start = 0\nfor i, score in enumerate(hydropathy):\n    if score > 1.6 and not in_peak:\n        in_peak = True\n        peak_start = positions[i]\n    elif score <= 1.6 and in_peak:\n        in_peak = False\n        peaks_above.append((peak_start, positions[i]))\n\nprint(f\"\\nRegions with hydropathy > 1.6 (predicted TM segments):\")\nfor start, end in peaks_above:\n    print(f\"  {start}-{end} (length: {end-start})\")\n\nprint(f\"\\nTotal predicted TM peaks: {len(peaks_above)}\")\nprint(f\"UniProt annotated TM regions: {len(tm_regions)}\")\n",
  "plot_number": 1
}