{
  "filename": "dcaf12l2_selective_conservation.png",
  "iteration": 2,
  "description": "Create visualization showing the striking dual conservation pattern: 100% degron pocket vs 58% DDB1 interface",
  "timestamp": "2026-07-06 20:48:56",
  "code": "\nimport matplotlib.pyplot as plt\nimport matplotlib.patches as mpatches\nimport numpy as np\n\nfig, axes = plt.subplots(1, 2, figsize=(16, 7))\nfig.suptitle('DCAF12L2 Selective Conservation: Substrate Pocket vs DDB1 Interface', \n             fontsize=13, fontweight='bold')\n\n# Panel A: Per-residue conservation mapped onto the full sequence\nax = axes[0]\n\n# Get sequences\nimport requests\nresp_12 = requests.get(\"https://rest.uniprot.org/uniprotkb/Q5T6F0.json\")\nseq_12 = resp_12.json()['sequence']['value']\n\n# Define interface sets for DCAF12\nddb1_interface = {42,43,44,45,46,47,48,49,50,51,53,54,55,56,57,\n                  60,61,64,66,67,68,70,71,74,75,78,80,\n                  100,150,151,349,428,429,431,432,453}\n\ndegron_pocket = {91,93,108,141,144,186,188,203,254,256,272,298,300,\n                 344,410,411,422,439,440,441,442,443,444}\n\n# DDB1 conservation (from our analysis)\nddb1_conserved = {44,46,47,49,50,51,53,54,55,56,67,70,71,75,78,\n                  150,151,349,432,453}  # 20 identical\nddb1_not_conserved = ddb1_interface - ddb1_conserved  # 15 not conserved\n\n# Mark on a sequence plot\nresidues = list(range(1, len(seq_12)+1))\ncolors = []\nfor r in residues:\n    if r in degron_pocket:\n        colors.append('#2ecc71')  # green - all conserved\n    elif r in ddb1_conserved:\n        colors.append('#3498db')  # blue - conserved DDB1\n    elif r in ddb1_not_conserved:\n        colors.append('#e74c3c')  # red - not conserved DDB1\n    else:\n        colors.append('#bdc3c7')  # gray - not at interface\n\n# Plot as colored bars\nfor i, r in enumerate(residues):\n    ax.bar(r, 1, color=colors[i], width=1.0, edgecolor='none')\n\n# Mark WD40 repeats\nwd_repeats = [(81, 122), (123, 175), (176, 242), (243, 286), (287, 331), (332, 366)]\nfor s, e in wd_repeats:\n    ax.axvspan(s, e, alpha=0.08, color='black')\n\n# Annotations\nax.annotate('N-term\\nH-box', xy=(60, 1.1), fontsize=8, ha='center', fontweight='bold')\nax.annotate('WD40 \u03b2-propeller domain', xy=(250, 1.1), fontsize=8, ha='center')\n\nlegend_patches = [\n    mpatches.Patch(color='#2ecc71', label='Degron pocket (100% conserved)'),\n    mpatches.Patch(color='#3498db', label='DDB1 interface (conserved)'),\n    mpatches.Patch(color='#e74c3c', label='DDB1 interface (diverged)'),\n    mpatches.Patch(color='#bdc3c7', label='Non-interface'),\n]\nax.legend(handles=legend_patches, fontsize=7, loc='upper right')\nax.set_xlabel('DCAF12 residue number')\nax.set_ylabel('')\nax.set_yticks([])\nax.set_title('A. Functional Sites Mapped to DCAF12 Sequence')\nax.set_xlim(0, 460)\n\n# Panel B: Comparative bar chart\nax = axes[1]\n\ncategories = ['Degron pocket\\n(MAGEA3+CCT5)', 'DDB1 interface\\n(H-box+WD40)', 'Overall\\nsequence']\nconserved_pct = [100, 58, 66.6]\ndiverged_pct = [0, 42, 33.4]\n\nx = np.arange(len(categories))\nwidth = 0.5\n\nbars1 = ax.bar(x, conserved_pct, width, label='Conserved (identical + conservative)',\n               color=['#2ecc71', '#f39c12', '#95a5a6'])\nbars2 = ax.bar(x, diverged_pct, width, bottom=conserved_pct, label='Diverged',\n               color=['white', '#e74c3c', '#bdc3c7'], edgecolor='gray')\n\n# Add percentage labels\nfor i, (c, d) in enumerate(zip(conserved_pct, diverged_pct)):\n    ax.text(i, c/2, f'{c:.0f}%', ha='center', va='center', fontsize=14, fontweight='bold',\n            color='white' if c > 60 else 'black')\n    if d > 5:\n        ax.text(i, c + d/2, f'{d:.0f}%', ha='center', va='center', fontsize=11, color='gray')\n\nax.set_ylabel('Conservation (%)')\nax.set_title('B. Selective Conservation Pattern')\nax.set_xticks(x)\nax.set_xticklabels(categories, fontsize=9)\nax.set_ylim(0, 110)\nax.axhline(y=100, color='gray', linestyle='--', alpha=0.3)\n\n# Add annotation\nax.annotate('Perfect substrate\\nrecognition preserved', xy=(0, 105), fontsize=8,\n           ha='center', fontweight='bold', color='#2ecc71')\nax.annotate('DDB1 binding\\nuncertain', xy=(1, 105), fontsize=8,\n           ha='center', fontweight='bold', color='#e74c3c')\n\nplt.tight_layout()\nplt.savefig('dcaf12l2_selective_conservation.png', dpi=150, bbox_inches='tight')\nplt.show()\nprint(\"Figure saved\")\n"
}