{
  "filename": "plot_2.png",
  "iteration": 1,
  "description": "Create visualization comparing zinc-binding catalytic residues between P. horikoshii AlaX (crystal structure) and human AARSD1",
  "timestamp": "2026-06-22 01:35:16",
  "code": "\nimport matplotlib.pyplot as plt\nimport numpy as np\n\n# Create a detailed catalytic residue comparison figure\nfig, ax = plt.subplots(figsize=(14, 6))\n\n# Two protein sequences aligned at the zinc-binding motifs\n# P. horikoshii AlaX (1WXO): H9-S-A-L-H13 ... C116-N-K-E-H120\n# Human AARSD1 (Q9BTE6):     H109-S-G-Q-H113 ... C209-C-G-T-H213\n\n# Draw as aligned blocks\ny_ph = 3.5\ny_aarsd1 = 1.5\n\n# Header\nax.text(0.5, 5.5, 'Zinc-Binding Catalytic Residue Conservation', \n        ha='center', va='center', fontsize=14, fontweight='bold', transform=ax.transData)\n\n# Protein labels\nax.text(-0.5, y_ph, 'P. horikoshii AlaX\\n(PDB 1WXO)', ha='right', va='center', fontsize=10, fontweight='bold')\nax.text(-0.5, y_aarsd1, 'Human AARSD1\\n(Q9BTE6, Isoform 1)', ha='right', va='center', fontsize=10, fontweight='bold')\n\n# Color scheme for residues\ndef get_residue_color(aa, is_zinc=False):\n    if is_zinc:\n        return '#FFD700'  # Gold for zinc-binding\n    elif aa in 'HCM':\n        return '#FFB6C1'  # Pink for His/Cys\n    elif aa in 'DE':\n        return '#FF6B6B'  # Red for acidic\n    elif aa in 'KR':\n        return '#6B9BFF'  # Blue for basic\n    elif aa in 'AILMFWVP':\n        return '#B4D8B4'  # Green for hydrophobic\n    else:\n        return '#E0E0E0'  # Gray\n\n# First zinc-binding motif (HxxxH)\nmotif1_ph = [('H', 9, True), ('S', 10, False), ('A', 11, False), ('L', 12, False), ('H', 13, True)]\nmotif1_aarsd1 = [('H', 109, True), ('S', 110, False), ('G', 111, False), ('Q', 112, False), ('H', 113, True)]\n\nx_start1 = 1\nfor i, ((aa_ph, pos_ph, zn_ph), (aa_aa, pos_aa, zn_aa)) in enumerate(zip(motif1_ph, motif1_aarsd1)):\n    x = x_start1 + i * 1.2\n    \n    # P. horikoshii\n    color = get_residue_color(aa_ph, zn_ph)\n    ax.add_patch(plt.Rectangle((x-0.4, y_ph-0.35), 0.8, 0.7, facecolor=color, edgecolor='black', linewidth=1.5 if zn_ph else 1))\n    ax.text(x, y_ph, aa_ph, ha='center', va='center', fontsize=12, fontweight='bold')\n    ax.text(x, y_ph + 0.55, str(pos_ph), ha='center', va='bottom', fontsize=7, color='gray')\n    \n    # AARSD1\n    color = get_residue_color(aa_aa, zn_aa)\n    ax.add_patch(plt.Rectangle((x-0.4, y_aarsd1-0.35), 0.8, 0.7, facecolor=color, edgecolor='black', linewidth=1.5 if zn_aa else 1))\n    ax.text(x, y_aarsd1, aa_aa, ha='center', va='center', fontsize=12, fontweight='bold')\n    ax.text(x, y_aarsd1 + 0.55, str(pos_aa), ha='center', va='bottom', fontsize=7, color='gray')\n    \n    # Conservation marker\n    if aa_ph == aa_aa:\n        ax.text(x, (y_ph + y_aarsd1)/2, '|', ha='center', va='center', fontsize=14, color='green', fontweight='bold')\n    elif zn_ph and zn_aa:\n        ax.text(x, (y_ph + y_aarsd1)/2, '|', ha='center', va='center', fontsize=14, color='green', fontweight='bold')\n    else:\n        ax.text(x, (y_ph + y_aarsd1)/2, ':', ha='center', va='center', fontsize=14, color='gray')\n\n# Gap indicator\nx_gap = x_start1 + 5 * 1.2 + 0.5\nax.text(x_gap, y_ph, '\u00b7\u00b7\u00b7', ha='center', va='center', fontsize=16, color='gray')\nax.text(x_gap, y_aarsd1, '\u00b7\u00b7\u00b7', ha='center', va='center', fontsize=16, color='gray')\nax.text(x_gap, (y_ph + y_aarsd1)/2, f'~100 aa', ha='center', va='center', fontsize=8, color='gray')\n\n# Second zinc-binding motif (CxxxH)\nmotif2_ph = [('C', 116, True), ('N', 117, False), ('K', 118, False), ('E', 119, False), ('H', 120, True)]\nmotif2_aarsd1 = [('C', 209, True), ('C', 210, False), ('G', 211, False), ('T', 212, False), ('H', 213, True)]\n\nx_start2 = x_gap + 1.5\nfor i, ((aa_ph, pos_ph, zn_ph), (aa_aa, pos_aa, zn_aa)) in enumerate(zip(motif2_ph, motif2_aarsd1)):\n    x = x_start2 + i * 1.2\n    \n    # P. horikoshii\n    color = get_residue_color(aa_ph, zn_ph)\n    ax.add_patch(plt.Rectangle((x-0.4, y_ph-0.35), 0.8, 0.7, facecolor=color, edgecolor='black', linewidth=1.5 if zn_ph else 1))\n    ax.text(x, y_ph, aa_ph, ha='center', va='center', fontsize=12, fontweight='bold')\n    ax.text(x, y_ph + 0.55, str(pos_ph), ha='center', va='bottom', fontsize=7, color='gray')\n    \n    # AARSD1\n    color = get_residue_color(aa_aa, zn_aa)\n    ax.add_patch(plt.Rectangle((x-0.4, y_aarsd1-0.35), 0.8, 0.7, facecolor=color, edgecolor='black', linewidth=1.5 if zn_aa else 1))\n    ax.text(x, y_aarsd1, aa_aa, ha='center', va='center', fontsize=12, fontweight='bold')\n    ax.text(x, y_aarsd1 + 0.55, str(pos_aa), ha='center', va='bottom', fontsize=7, color='gray')\n    \n    # Conservation\n    if aa_ph == aa_aa:\n        ax.text(x, (y_ph + y_aarsd1)/2, '|', ha='center', va='center', fontsize=14, color='green', fontweight='bold')\n    elif zn_ph and zn_aa:\n        ax.text(x, (y_ph + y_aarsd1)/2, '|', ha='center', va='center', fontsize=14, color='green', fontweight='bold')\n    else:\n        ax.text(x, (y_ph + y_aarsd1)/2, ':', ha='center', va='center', fontsize=14, color='gray')\n\n# Labels for motifs\nax.text((x_start1 + x_start1 + 4*1.2)/2, 5.0, 'HxxxH motif\\n(Zinc ligand 1)', \n        ha='center', va='center', fontsize=10, fontweight='bold', color='#2E86AB')\nax.text((x_start2 + x_start2 + 4*1.2)/2, 5.0, 'CxxxH motif\\n(Zinc ligand 2)', \n        ha='center', va='center', fontsize=10, fontweight='bold', color='#2E86AB')\n\n# Zinc ion indicator\nfor x_mid in [(x_start1 + x_start1 + 4*1.2)/2 + 3.5]:\n    pass  # Removed for clarity\n\n# Legend box\nlegend_text = \"Gold border = zinc-coordinating residue\\nAll 4 zinc ligands (H, H, C, H) conserved \u2713\\nCrystal structure evidence: PDB 1WXO, 1WNU\"\nax.text(14.5, 0.3, legend_text, fontsize=8, va='bottom', ha='right',\n        bbox=dict(boxstyle='round', facecolor='lightyellow', edgecolor='gray', alpha=0.8))\n\nax.set_xlim(-3, 15)\nax.set_ylim(0, 5.8)\nax.set_frame_on(False)\nax.set_xticks([])\nax.set_yticks([])\n\nplt.tight_layout()\nplt.savefig('aarsd1_catalytic_residues.png', dpi=150, bbox_inches='tight')\nplt.show()\nprint(\"Catalytic residue comparison figure saved.\")\n",
  "plot_number": 2
}