{
  "filename": "structural_analysis.png",
  "iteration": 2,
  "description": "Create AlphaFold pLDDT profile with functional residue annotations and domain architecture",
  "timestamp": "2026-07-01 07:05:11",
  "code": "\nimport requests\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport matplotlib.patches as mpatches\n\n# Re-fetch pLDDT data\naf_url = \"https://alphafold.ebi.ac.uk/files/AF-Q9VSA3-F1-model_v6.pdb\"\npdb_resp = requests.get(af_url)\npdb_text = pdb_resp.text\n\nplddt_scores = {}\nfor line in pdb_text.split('\\n'):\n    if line.startswith('ATOM') and line[12:16].strip() == 'CA':\n        res_num = int(line[22:26].strip())\n        bfactor = float(line[60:66].strip())\n        plddt_scores[res_num] = bfactor\n\npositions = sorted(plddt_scores.keys())\nscores = [plddt_scores[p] for p in positions]\n\n# Key functional residues (Drosophila numbering)\ncatalytic = {397: \"Glu397\\n(catalytic)\"}\nfad_binding = {274: \"D274\", 277: \"R277\", 302: \"R302\", 303: \"K303\", 304: \"T304\", 312: \"H312\", 313: \"Q313\"}\nsubstrate_binding = {163: \"S163\", 187: \"W187\", 188: \"I188\", 189: \"T189\", 370: \"Q370\", 371: \"I371\", 372: \"F372\"}\npink1_site = {347: \"S347\\n(PINK1)\"}\n\nfig, (ax1, ax2) = plt.subplots(2, 1, figsize=(16, 10), gridspec_kw={'height_ratios': [3, 1]})\n\n# Panel 1: pLDDT profile with functional residue annotations\ncolors = []\nfor s in scores:\n    if s >= 90:\n        colors.append('#0053D6')  # Very high - blue\n    elif s >= 70:\n        colors.append('#65CBF3')  # Confident - light blue\n    elif s >= 50:\n        colors.append('#FFDB13')  # Low - yellow\n    else:\n        colors.append('#FF7D45')  # Very low - orange\n\nax1.bar(positions, scores, color=colors, width=1.0, linewidth=0)\nax1.set_xlim(0, 420)\nax1.set_ylim(0, 105)\nax1.set_ylabel('pLDDT Score', fontsize=12)\nax1.set_title('AlphaFold pLDDT Confidence Profile \u2014 Drosophila Mcad (Q9VSA3)\\nAF-Q9VSA3-F1-model_v6', fontsize=13, fontweight='bold')\n\n# Add confidence bands\nax1.axhspan(90, 105, alpha=0.05, color='blue')\nax1.axhspan(70, 90, alpha=0.05, color='cyan')\nax1.axhspan(50, 70, alpha=0.05, color='yellow')\nax1.axhspan(0, 50, alpha=0.05, color='orange')\nax1.axhline(y=90, color='gray', linestyle=':', alpha=0.4)\nax1.axhline(y=70, color='gray', linestyle=':', alpha=0.4)\n\n# Mark transit peptide\nax1.axvspan(1, 22, alpha=0.15, color='red', label='Transit peptide (1-22)')\n\n# Annotate key residues\nfor pos in catalytic:\n    ax1.annotate(catalytic[pos], xy=(pos, plddt_scores[pos]), \n                xytext=(pos-25, 75), fontsize=8, fontweight='bold', color='red',\n                arrowprops=dict(arrowstyle='->', color='red', lw=1.5))\n\nfor pos in pink1_site:\n    ax1.annotate(pink1_site[pos], xy=(pos, plddt_scores[pos]),\n                xytext=(pos+15, 78), fontsize=8, fontweight='bold', color='purple',\n                arrowprops=dict(arrowstyle='->', color='purple', lw=1.5))\n\n# Mark functional residue positions with vertical lines\nfor pos in fad_binding:\n    ax1.axvline(x=pos, color='green', alpha=0.3, linewidth=1)\nfor pos in substrate_binding:\n    ax1.axvline(x=pos, color='orange', alpha=0.3, linewidth=1)\nfor pos in catalytic:\n    ax1.axvline(x=pos, color='red', alpha=0.5, linewidth=2)\nfor pos in pink1_site:\n    ax1.axvline(x=pos, color='purple', alpha=0.4, linewidth=1.5)\n\nlegend_elements = [\n    mpatches.Patch(facecolor='#0053D6', label='Very high (\u226590)'),\n    mpatches.Patch(facecolor='#65CBF3', label='Confident (70-90)'),\n    mpatches.Patch(facecolor='#FFDB13', label='Low (50-70)'),\n    mpatches.Patch(facecolor='#FF7D45', label='Very low (<50)'),\n    plt.Line2D([0], [0], color='red', linewidth=2, label='Catalytic Glu397'),\n    plt.Line2D([0], [0], color='green', linewidth=1, label='FAD binding'),\n    plt.Line2D([0], [0], color='orange', linewidth=1, label='Substrate binding'),\n    plt.Line2D([0], [0], color='purple', linewidth=1.5, label='PINK1 pSer347'),\n    mpatches.Patch(facecolor='red', alpha=0.15, label='Transit peptide'),\n]\nax1.legend(handles=legend_elements, loc='lower left', fontsize=8, ncol=3)\n\n# Panel 2: Domain architecture\nax2.set_xlim(0, 420)\nax2.set_ylim(0, 4)\nax2.set_xlabel('Residue Position', fontsize=12)\nax2.set_title('Domain Architecture', fontsize=11, fontweight='bold')\n\n# Transit peptide\nax2.barh(3, 22, left=0, height=0.6, color='red', alpha=0.5, edgecolor='black')\nax2.text(11, 3, 'TP', ha='center', va='center', fontsize=7, fontweight='bold')\n\n# Acyl-CoA_dh_N (Pfam PF02771) - approximate\nax2.barh(2, 100, left=23, height=0.6, color='#3498db', edgecolor='black')\nax2.text(73, 2, 'Acyl-CoA_dh_N\\n(PF02771)', ha='center', va='center', fontsize=7, fontweight='bold', color='white')\n\n# Acyl-CoA_dh_M (Pfam PF02770) - approximate  \nax2.barh(2, 120, left=130, height=0.6, color='#2ecc71', edgecolor='black')\nax2.text(190, 2, 'Acyl-CoA_dh_M\\n(PF02770)', ha='center', va='center', fontsize=7, fontweight='bold', color='white')\n\n# Acyl-CoA_dh_1 (Pfam PF00441) - approximate\nax2.barh(2, 150, left=260, height=0.6, color='#e67e22', edgecolor='black')\nax2.text(335, 2, 'Acyl-CoA_dh_1 (C-term)\\n(PF00441)', ha='center', va='center', fontsize=7, fontweight='bold', color='white')\n\n# CDD MCAD\nax2.barh(1, 397, left=23, height=0.6, color='#9b59b6', alpha=0.5, edgecolor='black')\nax2.text(221, 1, 'CDD: cd01157 (MCAD)', ha='center', va='center', fontsize=8, fontweight='bold', color='white')\n\nax2.set_yticks([1, 2, 3])\nax2.set_yticklabels(['CDD', 'Pfam', 'Signal'], fontsize=9)\n\nplt.tight_layout()\nplt.savefig('structural_analysis.png', dpi=150, bbox_inches='tight')\nplt.show()\nprint(\"Structural analysis figure saved.\")\n"
}