{
  "filename": "plot_1.png",
  "iteration": 1,
  "description": "Comprehensive visualization showing absence of all intein catalytic blocks in Rv0311 with AlphaFold pLDDT profile",
  "timestamp": "2026-06-22 00:32:07",
  "code": "\nimport matplotlib\nmatplotlib.use('Agg')\nimport matplotlib.pyplot as plt\nimport matplotlib.patches as mpatches\nimport numpy as np\n\n# Create a comprehensive visualization of the intein motif analysis\n\nfig, axes = plt.subplots(3, 1, figsize=(14, 12), gridspec_kw={'height_ratios': [2, 2, 1.5]})\n\n# Panel 1: Sequence map with intein catalytic site positions\nax1 = axes[0]\nax1.set_title('Rv0311 (O07238) Intein Catalytic Block Analysis', fontsize=14, fontweight='bold')\n\nsequence = \"MSQSRYAGLSRSELAVLLPELLLIGQLIDRSGMAWCIQAFGRQEMLQIAIEEWAGASPIYTKRMQKALNFEGDDVPTIFKGLQLDIGAPPQFMDFRFTLHDRWHGEFHLDHCGALLDVEPMGDDYVVGMCHTIEDPTFDATAIATNPRAQVRPIHRPPRKPADRHPHCAWTVIIDESYPEAEGIPALDAVRETKAATWELDNVDASDDGLVDYSGPLVSDLDFGAFSHSALVRMADEVCLQMHLLNLSFAIAVRKRAKADAQLAISVNTRQLIGVAGLGAERIHRAMALPGGIEGALGVLELHPLLNPAGYVLAETSPDRLVVHNSPAHADGAWISLCTPASVQPLQAIATAVDPHLKVRISGTDTDWTAELIEADAPASELPEVLVAKVSRGSVFQFEPRRSLPLTVK\"\n\n# Draw the protein as a bar\nax1.barh(0, len(sequence), height=0.4, color='#E8E8E8', edgecolor='gray')\n\n# Mark His residues\nhis_positions = [i+1 for i, aa in enumerate(sequence) if aa == 'H']\nfor pos in his_positions:\n    ax1.plot(pos, 0, 'v', color='blue', markersize=8, alpha=0.7)\n\n# Mark Cys residues\ncys_positions = [i+1 for i, aa in enumerate(sequence) if aa == 'C']\nfor pos in cys_positions:\n    ax1.plot(pos, 0, '^', color='red', markersize=8, alpha=0.7)\n\n# Mark expected intein positions with X\n# Position 1: N-terminal Cys/Ser (ABSENT - has Met)\nax1.annotate('Block A\\n(Cys/Ser)\\n\u2717 Met', xy=(1, 0.3), fontsize=8, ha='center', color='red', fontweight='bold')\nax1.plot(1, 0.25, 'x', color='red', markersize=15, markeredgewidth=3)\n\n# C-terminal: penultimate His + terminal Asn (ABSENT)\nax1.annotate('Block G\\n(His,Asn)\\n\u2717 Val,Lys', xy=(408, 0.3), fontsize=8, ha='center', color='red', fontweight='bold')\nax1.plot(408, 0.25, 'x', color='red', markersize=15, markeredgewidth=3)\n\n# Block B: TXXH motif (ABSENT)\nax1.annotate('Block B\\n(TXXH)\\n\u2717 absent', xy=(70, -0.35), fontsize=8, ha='center', color='red', fontweight='bold')\nax1.plot(70, -0.25, 'x', color='red', markersize=15, markeredgewidth=3)\n\n# Block F: DxxHxxG (ABSENT)\nax1.annotate('Block F\\n(DxxHxxG)\\n\u2717 absent', xy=(200, -0.35), fontsize=8, ha='center', color='red', fontweight='bold')\nax1.plot(200, -0.25, 'x', color='red', markersize=15, markeredgewidth=3)\n\n# Add LAGLIDADG note\nax1.annotate('LAGLIDADG\\n\u2717 absent', xy=(300, -0.35), fontsize=8, ha='center', color='red', fontweight='bold')\nax1.plot(300, -0.25, 'x', color='red', markersize=15, markeredgewidth=3)\n\n# HxxH motif found\nax1.annotate('HxxH\\n(pos 108-111)', xy=(110, -0.35), fontsize=8, ha='center', color='green', fontweight='bold')\nax1.plot(110, -0.25, 'o', color='green', markersize=10, markeredgewidth=2, fillstyle='none')\n\nax1.set_xlim(0, 420)\nax1.set_ylim(-0.6, 0.6)\nax1.set_xlabel('Residue Position')\nax1.set_yticks([])\n\n# Legend\nlegend_elements = [\n    mpatches.Patch(color='red', label='Missing intein catalytic residue (\u2717)'),\n    plt.Line2D([0], [0], marker='v', color='blue', label='His residues', linestyle='None', markersize=8),\n    plt.Line2D([0], [0], marker='^', color='red', label='Cys residues', linestyle='None', markersize=8),\n    plt.Line2D([0], [0], marker='o', color='green', label='Non-intein motif', linestyle='None', markersize=8, fillstyle='none'),\n]\nax1.legend(handles=legend_elements, loc='upper right', fontsize=8)\n\n# Panel 2: pLDDT confidence plot\nax2 = axes[1]\nax2.set_title('AlphaFold pLDDT Confidence Profile', fontsize=12, fontweight='bold')\n\n# Re-derive pLDDT scores\nimport requests\npdb_url = \"https://alphafold.ebi.ac.uk/files/AF-O07238-F1-model_v6.pdb\"\npdb_resp = requests.get(pdb_url, timeout=60)\npdb_content = pdb_resp.text\n\nplddt_data = []\nfor line in pdb_content.split('\\n'):\n    if line.startswith('ATOM') and line[12:16].strip() == 'CA':\n        try:\n            residue_num = int(line[22:26].strip())\n            bfactor = float(line[60:66].strip())\n            plddt_data.append((residue_num, bfactor))\n        except:\n            pass\n\npositions = [d[0] for d in plddt_data]\nscores = [d[1] for d in plddt_data]\n\n# Color by confidence level\ncolors = []\nfor s in scores:\n    if s > 90: colors.append('#0053D6')\n    elif s > 70: colors.append('#65CBF3')\n    elif s > 50: colors.append('#FFDB13')\n    else: colors.append('#FF7D45')\n\nax2.bar(positions, scores, color=colors, width=1.0, edgecolor='none')\nax2.axhline(y=90, color='gray', linestyle='--', alpha=0.5, label='Very high (>90)')\nax2.axhline(y=70, color='gray', linestyle=':', alpha=0.5, label='Confident (>70)')\nax2.set_ylim(50, 100)\nax2.set_xlim(0, 420)\nax2.set_ylabel('pLDDT Score')\nax2.set_xlabel('Residue Position')\nax2.legend(loc='lower right', fontsize=8)\n\n# Panel 3: Intein checklist table\nax3 = axes[2]\nax3.axis('off')\nax3.set_title('Intein Catalytic Block Checklist', fontsize=12, fontweight='bold', pad=20)\n\ntable_data = [\n    ['Block A: N-terminal Cys/Ser', 'Position 1 = Met', '\u2717 ABSENT', 'Essential for N-S acyl shift'],\n    ['Block B: TXXH motif', 'Not found anywhere', '\u2717 ABSENT', 'Catalyzes N-terminal cleavage'],\n    ['Block F: DxxHxxG', 'Not found', '\u2717 ABSENT', 'Homing endonuclease (if present)'],\n    ['Block G: penultimate His', 'Position -2 = Val', '\u2717 ABSENT', 'C-terminal cleavage catalyst'],\n    ['Block G: terminal Asn', 'Position -1 = Lys', '\u2717 ABSENT', 'Asn cyclization for splicing'],\n]\n\ncol_labels = ['Required Feature', 'Found in Rv0311', 'Status', 'Function']\ntable = ax3.table(cellText=table_data, colLabels=col_labels, loc='center', cellLoc='center')\ntable.auto_set_font_size(False)\ntable.set_fontsize(9)\ntable.scale(1, 1.5)\n\n# Color the status column\nfor i in range(len(table_data)):\n    table[(i+1, 2)].set_facecolor('#FFE0E0')\n    table[(i+1, 2)].set_text_props(color='red', fontweight='bold')\n\n# Color header\nfor j in range(4):\n    table[(0, j)].set_facecolor('#4472C4')\n    table[(0, j)].set_text_props(color='white', fontweight='bold')\n\nplt.tight_layout()\nplt.savefig('intein_analysis.png', dpi=150, bbox_inches='tight')\nplt.show()\nprint(\"Figure saved: intein_analysis.png\")\n",
  "plot_number": 1
}