|
28 | 28 | ) |
29 | 29 | from ...visualization.chain_graph import render_chain_for_web |
30 | 30 | from ...visualization import export_interactions_to_pymol |
| 31 | +from ...visualization.ligplot import LigplotGenerator |
31 | 32 | from ...visualization.pymol3d import ( |
32 | 33 | generate_carbonyl_interaction_viewer_js, |
33 | 34 | generate_halogen_bond_viewer_js, |
@@ -1491,6 +1492,33 @@ def build_water_bridges_data(selected_value): |
1491 | 1492 | .classes("w-full mb-4") |
1492 | 1493 | ) |
1493 | 1494 |
|
| 1495 | + # Ligplot visualization (2D structure with highlighted atoms) |
| 1496 | + ligplot_container = ui.html().classes("w-full mb-4") |
| 1497 | + |
| 1498 | + def update_ligplot(ligand_res): |
| 1499 | + """Update ligplot when ligand selection changes.""" |
| 1500 | + try: |
| 1501 | + ligand_name = ligand_res.split(":")[1] |
| 1502 | + gen = LigplotGenerator( |
| 1503 | + ligand_name, self.analyzer, residue_id=ligand_res |
| 1504 | + ) |
| 1505 | + html = gen.generate_svg(width=400, height=300) |
| 1506 | + ligplot_container.content = html |
| 1507 | + except Exception as e: |
| 1508 | + ligplot_container.content = ( |
| 1509 | + f"<p>Could not generate ligplot: {str(e)}</p>" |
| 1510 | + ) |
| 1511 | + |
| 1512 | + # Initial ligplot |
| 1513 | + if first_ligand: |
| 1514 | + update_ligplot(first_ligand) |
| 1515 | + |
| 1516 | + # Update ligplot when selection changes |
| 1517 | + def on_ligand_change(selected_value): |
| 1518 | + update_ligplot(selected_value.value) |
| 1519 | + |
| 1520 | + selected_ligand.on_value_change(on_ligand_change) |
| 1521 | + |
1494 | 1522 | # Action buttons for regular interactions |
1495 | 1523 | def show_all_interactions_viewer(selected_ligand_res): |
1496 | 1524 | """Show 3D viewer dialog with all regular interactions for selected ligand.""" |
|
0 commit comments