{
  "filename": "plot_1.png",
  "iteration": 1,
  "description": "Domain architecture visualization comparing IL23R and PRLR",
  "timestamp": "2026-07-06 22:02:52",
  "code": "\nimport matplotlib.pyplot as plt\nimport matplotlib.patches as mpatches\nimport numpy as np\n\nfig, axes = plt.subplots(2, 1, figsize=(14, 6), gridspec_kw={'height_ratios': [1, 1]})\n\ndef draw_protein(ax, name, length, domains, tm_start, tm_end, title_extra=\"\"):\n    # Draw backbone\n    ax.add_patch(mpatches.FancyBboxPatch((0, 0.35), length, 0.3, \n                                          boxstyle=\"round,pad=0.01\", \n                                          facecolor='#e0e0e0', edgecolor='black', linewidth=0.5))\n    \n    # Draw domains\n    colors = {\n        'Ig-like': '#4CAF50',\n        'FN3': '#2196F3',\n        'FN3 + EpoR lig-bind': '#FF9800',\n        'TM': '#F44336',\n        'Stalk': '#9E9E9E',\n        'Signal': '#FFEB3B',\n        'Cytoplasmic': '#CE93D8',\n        'WSXWS': '#000000',\n    }\n    \n    for d_name, start, end, d_type in domains:\n        color = colors.get(d_type, '#999')\n        height = 0.3 if d_type != 'WSXWS' else 0.1\n        y_offset = 0.35 if d_type != 'WSXWS' else 0.7\n        \n        if d_type == 'WSXWS':\n            ax.annotate(d_name, xy=(start, 0.7), fontsize=7, ha='center', \n                       color='red', fontweight='bold')\n            ax.plot([start], [0.65], 'v', color='red', markersize=6)\n        else:\n            ax.add_patch(mpatches.FancyBboxPatch((start, y_offset), end-start, height,\n                                                  boxstyle=\"round,pad=0.01\",\n                                                  facecolor=color, edgecolor='black', \n                                                  linewidth=1, alpha=0.8))\n            # Label\n            mid = (start + end) / 2\n            ax.text(mid, 0.5, d_name, ha='center', va='center', fontsize=7, \n                   fontweight='bold', color='white' if d_type != 'Signal' else 'black')\n    \n    ax.set_xlim(-10, max(length, 630) + 10)\n    ax.set_ylim(0, 1.0)\n    ax.set_xlabel('Residue position', fontsize=10)\n    ax.set_title(f'{name} {title_extra}', fontsize=12, fontweight='bold')\n    ax.set_yticks([])\n    \n    # Add scale bar labels\n    for pos in [0, 100, 200, 300, 400, 500, 600]:\n        if pos <= length:\n            ax.axvline(pos, color='gray', linestyle=':', alpha=0.3)\n\n# IL23R domains\nil23r_domains = [\n    ('SP', 1, 23, 'Signal'),\n    ('Ig-like', 24, 126, 'Ig-like'),\n    ('FN3-1', 127, 217, 'FN3'),\n    ('FN3-2', 219, 318, 'FN3'),\n    ('Stalk', 319, 355, 'Stalk'),\n    ('TM', 356, 376, 'TM'),\n    ('Cytoplasmic', 377, 629, 'Cytoplasmic'),\n    ('WQPWS', 304, 304, 'WSXWS'),\n]\n\n# PRLR domains\nprlr_domains = [\n    ('SP', 1, 24, 'Signal'),\n    ('FN3-1\\n+EpoR-LB', 27, 128, 'FN3 + EpoR lig-bind'),\n    ('FN3-2', 129, 229, 'FN3'),\n    ('TM', 235, 258, 'TM'),\n    ('Cytoplasmic', 259, 622, 'Cytoplasmic'),\n    ('WIKWS', 148, 148, 'WSXWS'),\n    ('WSAWS', 215, 215, 'WSXWS'),\n]\n\ndraw_protein(axes[0], 'IL23R (Q5VWK5)', 629, il23r_domains, 356, 376, \n            '\u2014 Interleukin-23 receptor')\ndraw_protein(axes[1], 'PRLR (P16471)', 622, prlr_domains, 235, 258, \n            '\u2014 Prolactin receptor')\n\n# Add legend\nlegend_elements = [\n    mpatches.Patch(facecolor='#FFEB3B', edgecolor='black', label='Signal peptide'),\n    mpatches.Patch(facecolor='#4CAF50', edgecolor='black', label='Ig-like domain'),\n    mpatches.Patch(facecolor='#2196F3', edgecolor='black', label='FN3 domain'),\n    mpatches.Patch(facecolor='#FF9800', edgecolor='black', label='FN3 + EpoR lig-binding (PRLR only)'),\n    mpatches.Patch(facecolor='#F44336', edgecolor='black', label='Transmembrane'),\n    mpatches.Patch(facecolor='#CE93D8', edgecolor='black', label='Cytoplasmic'),\n    mpatches.Patch(facecolor='#9E9E9E', edgecolor='black', label='Stalk region'),\n]\nfig.legend(handles=legend_elements, loc='lower center', ncol=4, fontsize=8,\n          bbox_to_anchor=(0.5, -0.05))\n\nplt.tight_layout()\nplt.savefig('/tmp/domain_architecture_comparison.png', dpi=150, bbox_inches='tight')\nplt.show()\nprint(\"Domain architecture comparison figure saved.\")\n",
  "plot_number": 1
}