{
  "filename": "plot_3.png",
  "iteration": 1,
  "description": "Create visualization of zinc-binding residue conservation across AlaX family from archaea to human",
  "timestamp": "2026-06-22 01:41:20",
  "code": "\nimport matplotlib.pyplot as plt\nimport numpy as np\n\n# Create a conservation figure showing the zinc-binding motifs across species\nfig, ax = plt.subplots(figsize=(14, 8))\n\n# Data for the conservation alignment\nspecies_data = [\n    ('Human AARSD1', 'HMQQHSGQH', 105, 'CCGTH', 209, True),\n    ('Mouse Aarsd1', 'HMQQHSGQH', 105, 'CCGTH', 209, True),\n    ('Zebrafish aarsd1', 'HMQQHSGQH', 104, 'CCGTH', 208, True),\n    ('S. cerevisiae', 'HTGQH-', 125, 'CCGTH', 240, True),\n    ('P.h. AlaX-L', 'HTGQH-', 104, 'CGGTH', 202, True),\n    ('P.h. AlaX-S (cryst.)', 'HSALH-', 9, 'CNKEH', 116, True),\n    ('M. barkeri AlaX-M', 'HTATH-', 105, 'CGGTH', 208, True),\n]\n\n# Zinc-binding positions within HxxxH: positions 0 and 4\n# Within CxxxH: positions 0 and 4\nzinc_pos_h = [0, 4]\nzinc_pos_c = [0, 4]\n\ny_spacing = 0.9\nx_start_h = 2.5\nx_start_c = 8.5\nbox_width = 0.55\nbox_height = 0.55\n\n# Header\nax.text(0.5, len(species_data) * y_spacing + 1.5, \n        'Conservation of Zinc-Binding Catalytic Residues Across AlaX Family',\n        fontsize=13, fontweight='bold', ha='left')\n\n# Column headers\nax.text(x_start_h + 2, len(species_data) * y_spacing + 0.8, 'HxxxH motif', \n        fontsize=10, fontweight='bold', ha='center', color='#2E86AB')\nax.text(x_start_c + 2, len(species_data) * y_spacing + 0.8, 'CxxxH motif', \n        fontsize=10, fontweight='bold', ha='center', color='#2E86AB')\n\nfor idx, (name, h_motif, h_pos, c_motif, c_pos, conserved) in enumerate(species_data):\n    y = (len(species_data) - 1 - idx) * y_spacing\n    \n    # Species name\n    weight = 'bold' if 'Human' in name else 'normal'\n    color = '#000000' if 'Human' in name else '#444444'\n    ax.text(0, y + 0.1, name, fontsize=9, fontweight=weight, color=color, va='center')\n    \n    # HxxxH motif\n    for i, aa in enumerate(h_motif):\n        if aa == '-':\n            continue\n        x = x_start_h + i * (box_width + 0.08)\n        is_zinc = i in zinc_pos_h\n        \n        if is_zinc:\n            fcolor = '#FFD700' if aa == 'H' else '#FFA500'\n            ecolor = '#B8860B'\n            lw = 2\n        elif aa == h_motif[i] if i < len(species_data[0][1]) else False:\n            fcolor = '#E8F4FD'\n            ecolor = '#888888'\n            lw = 1\n        else:\n            fcolor = '#F5F5F5'\n            ecolor = '#CCCCCC'\n            lw = 1\n        \n        rect = plt.Rectangle((x - box_width/2, y - box_height/2 + 0.1), \n                             box_width, box_height, facecolor=fcolor, \n                             edgecolor=ecolor, linewidth=lw)\n        ax.add_patch(rect)\n        ax.text(x, y + 0.1, aa, fontsize=11, fontweight='bold', ha='center', va='center')\n    \n    # Position label\n    ax.text(x_start_h + 4.5 * (box_width + 0.08), y + 0.1, f'pos {h_pos}', \n            fontsize=7, color='gray', va='center')\n    \n    # CxxxH motif\n    for i, aa in enumerate(c_motif):\n        x = x_start_c + i * (box_width + 0.08)\n        is_zinc = i in zinc_pos_c\n        \n        if is_zinc:\n            if aa in 'CH':\n                fcolor = '#FFD700'\n            else:\n                fcolor = '#FFA500'\n            ecolor = '#B8860B'\n            lw = 2\n        else:\n            fcolor = '#F5F5F5'\n            ecolor = '#CCCCCC'\n            lw = 1\n        \n        rect = plt.Rectangle((x - box_width/2, y - box_height/2 + 0.1), \n                             box_width, box_height, facecolor=fcolor, \n                             edgecolor=ecolor, linewidth=lw)\n        ax.add_patch(rect)\n        ax.text(x, y + 0.1, aa, fontsize=11, fontweight='bold', ha='center', va='center')\n    \n    # Position label\n    ax.text(x_start_c + 4.5 * (box_width + 0.08), y + 0.1, f'pos {c_pos}', \n            fontsize=7, color='gray', va='center')\n    \n    # Conservation status\n    status = '\u2713 Zn\u00b2\u207a conserved' if conserved else '? partial'\n    scolor = '#228B22' if conserved else '#FF6347'\n    ax.text(12.5, y + 0.1, status, fontsize=8, color=scolor, va='center', fontweight='bold')\n\n# Consensus line\ny_cons = -0.8\nax.text(0, y_cons, 'Consensus:', fontsize=9, fontweight='bold', color='#2E86AB', va='center')\nconsensus_h = 'H \u00b7 \u00b7 \u00b7 H'\nconsensus_c = 'C \u00b7 \u00b7 \u00b7 H'\nax.text(x_start_h + 1.2, y_cons, consensus_h, fontsize=11, fontweight='bold', \n        ha='center', va='center', color='#B8860B')\nax.text(x_start_c + 1.2, y_cons, consensus_c, fontsize=11, fontweight='bold', \n        ha='center', va='center', color='#B8860B')\nax.text(12.5, y_cons, 'Zn\u00b2\u207a tetrahedral', fontsize=9, fontweight='bold', \n        color='#B8860B', va='center')\n\n# Legend\nax.text(0.5, -1.6, '\u25a0 Gold = zinc-coordinating residue (His or Cys)', fontsize=8, color='#B8860B')\nax.text(0.5, -2.0, 'All four zinc ligands universally conserved across archaea, yeast, and vertebrates', fontsize=8, color='#444444')\n\nax.set_xlim(-0.5, 14)\nax.set_ylim(-2.5, len(species_data) * y_spacing + 2)\nax.set_frame_on(False)\nax.set_xticks([])\nax.set_yticks([])\n\nplt.tight_layout()\nplt.savefig('aarsd1_conservation.png', dpi=150, bbox_inches='tight')\nplt.show()\nprint(\"Conservation figure saved.\")\n",
  "plot_number": 3
}