{
  "filename": "plot_2.png",
  "iteration": 1,
  "description": "Hydropathy profiles and structural topology comparison of Ca_LPL1, Sc_LPL1, and Sc_ROG1 showing shared membrane topology between LPL1 orthologs",
  "timestamp": "2026-07-05 07:35:19",
  "code": "\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport requests\n\nheaders = {\"User-Agent\": \"Mozilla/5.0\", \"Accept\": \"application/json\"}\n\ndef fetch_seq(acc):\n    url = f\"https://rest.uniprot.org/uniprotkb/{acc}.fasta\"\n    resp = requests.get(url, headers=headers, timeout=30)\n    lines = resp.text.strip().split('\\n')\n    return ''.join(lines[1:])\n\nca_lpl1 = fetch_seq('Q5AMS2')\nsc_lpl1 = fetch_seq('Q08448')\n\n# Kyte-Doolittle hydropathy scale\nkd_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\ndef hydropathy_profile(seq, window=15):\n    \"\"\"Calculate Kyte-Doolittle hydropathy profile\"\"\"\n    values = [kd_scale.get(aa, 0) for aa in seq]\n    profile = []\n    for i in range(len(values) - window + 1):\n        avg = np.mean(values[i:i+window])\n        profile.append(avg)\n    return profile\n\n# Calculate profiles\nca_profile = hydropathy_profile(ca_lpl1, window=15)\nsc_profile = hydropathy_profile(sc_lpl1, window=15)\n\nfig, axes = plt.subplots(3, 1, figsize=(14, 12))\nfig.suptitle('LPL1 Hydropathy and Structural Analysis', fontsize=14, fontweight='bold')\n\n# Panel 1: Ca_LPL1 hydropathy\nax1 = axes[0]\npositions_ca = np.arange(8, 8 + len(ca_profile))  # center of window\nax1.plot(positions_ca, ca_profile, 'b-', lw=1, label='Ca_LPL1 (Q5AMS2)')\nax1.axhline(y=1.6, color='red', ls='--', alpha=0.5, label='TM threshold (1.6)')\nax1.axhline(y=0, color='gray', ls='-', alpha=0.3)\n\n# Mark DUF676 domain\nax1.axvspan(14, 213, alpha=0.1, color='blue', label='DUF676 domain')\n# Mark TM region\nax1.axvspan(286, 306, alpha=0.3, color='yellow', label='TM helix (UniProt)')\n# Mark catalytic Ser\nax1.axvline(x=104, color='red', ls=':', alpha=0.7, label='Cat. Ser (S104)')\n\nax1.set_ylabel('Hydropathy (KD)')\nax1.set_title('A. Ca_LPL1 (Q5AMS2) - 556 aa', fontweight='bold')\nax1.legend(fontsize=8, loc='upper right')\nax1.set_xlim(0, 560)\n\n# Panel 2: Sc_LPL1 hydropathy\nax2 = axes[1]\npositions_sc = np.arange(8, 8 + len(sc_profile))\nax2.plot(positions_sc, sc_profile, 'g-', lw=1, label='Sc_LPL1 (Q08448)')\nax2.axhline(y=1.6, color='red', ls='--', alpha=0.5, label='TM threshold (1.6)')\nax2.axhline(y=0, color='gray', ls='-', alpha=0.3)\n\n# Mark TM region\nax2.axvspan(269, 289, alpha=0.3, color='yellow', label='TM helix (UniProt)')\n# Mark catalytic Ser\nax2.axvline(x=90, color='red', ls=':', alpha=0.7, label='Cat. Ser (S90)')\n\nax2.set_ylabel('Hydropathy (KD)')\nax2.set_title('B. Sc_LPL1 (Q08448) - 450 aa', fontweight='bold')\nax2.legend(fontsize=8, loc='upper right')\nax2.set_xlim(0, 560)\n\n# Panel 3: Structural topology comparison\nax3 = axes[2]\nax3.set_xlim(0, 700)\nax3.set_ylim(-1, 5)\nax3.set_title('C. Structural Topology Comparison', fontweight='bold')\nax3.set_xlabel('Residue position')\n\n# Ca_LPL1\ny_ca = 3.5\nax3.barh(y_ca, 556, height=0.6, color='#ccddff', edgecolor='black', linewidth=0.5)\nax3.barh(y_ca, 199, left=14, height=0.6, color='#6699ff', edgecolor='black', linewidth=0.5)\nax3.barh(y_ca, 20, left=286, height=0.6, color='#ffcc00', edgecolor='orange', linewidth=1.5)\nax3.plot(104, y_ca, '*', color='red', markersize=12, zorder=5)\nax3.text(-5, y_ca, 'Ca_LPL1', ha='right', va='center', fontsize=10, fontweight='bold')\nax3.text(113, y_ca+0.45, 'DUF676', fontsize=8, ha='center', fontweight='bold')\nax3.text(296, y_ca+0.45, 'TM', fontsize=7, ha='center', color='orange')\nax3.text(400, y_ca, 'C-terminal\\n(Ser/Thr-rich)', fontsize=7, ha='center', va='center', fontstyle='italic')\n\n# Sc_LPL1\ny_sc = 2\nax3.barh(y_sc, 450, height=0.6, color='#ccffcc', edgecolor='black', linewidth=0.5)\nax3.barh(y_sc, 199, left=1, height=0.6, color='#66cc66', edgecolor='black', linewidth=0.5)\nax3.barh(y_sc, 20, left=269, height=0.6, color='#ffcc00', edgecolor='orange', linewidth=1.5)\nax3.plot(90, y_sc, '*', color='red', markersize=12, zorder=5)\nax3.text(-5, y_sc, 'Sc_LPL1', ha='right', va='center', fontsize=10, fontweight='bold')\nax3.text(100, y_sc+0.45, 'DUF676', fontsize=8, ha='center', fontweight='bold')\nax3.text(279, y_sc+0.45, 'TM', fontsize=7, ha='center', color='orange')\n\n# Sc_ROG1\ny_rog = 0.5\nax3.barh(y_rog, 685, height=0.6, color='#ffdddd', edgecolor='black', linewidth=0.5)\nax3.barh(y_rog, 200, left=234, height=0.6, color='#ff9999', edgecolor='black', linewidth=0.5)\nax3.plot(269, y_rog, '*', color='red', markersize=12, zorder=5)\nax3.text(-5, y_rog, 'Sc_ROG1', ha='right', va='center', fontsize=10, fontweight='bold')\nax3.text(334, y_rog+0.45, 'DUF676', fontsize=8, ha='center', fontweight='bold')\nax3.text(550, y_rog, 'No TM\\n(cytosol/nucleus)', fontsize=7, ha='center', va='center', fontstyle='italic')\n\n# Legend\nax3.plot([], [], '*', color='red', markersize=10, label='Catalytic Ser (GXSXG)')\nax3.plot([], [], 's', color='#ffcc00', markersize=8, label='TM helix')\nax3.legend(fontsize=8, loc='upper right')\n\nax3.set_yticks([])\n\nplt.tight_layout()\nplt.savefig('hydropathy_topology.png', dpi=150, bbox_inches='tight')\nplt.show()\nprint(\"Figure saved\")\n",
  "plot_number": 2
}