Skip to content

feat: add BNGL visualization support for biomodels#61

Open
androemeda wants to merge 1 commit intovirtualcell:developmentfrom
androemeda:feature/bngl-visualization-integration
Open

feat: add BNGL visualization support for biomodels#61
androemeda wants to merge 1 commit intovirtualcell:developmentfrom
androemeda:feature/bngl-visualization-integration

Conversation

@androemeda
Copy link
Copy Markdown

Description

This PR integrates the bnglViz library into VCell-AI to provide interactive visualization of BNGL (BioNetGen Language) content for biomodels that support BNGL export. The visualization displays molecular types, species, observables, and reaction rules in an easy-to-understand graphical format.

Note: This PR is raised as part of GSoC proposal preparation to demonstrate that bnglViz can be successfully integrated into VCell-AI. The full implementation planned for GSoC includes deeper integration — specifically, exposing BNGL visualization as a tool in the chat interface so the LLM can trigger it contextually when a user asks to visualize a model's structure. That is documented in the proposal.


Implementation Details

Backend Changes

New Service Function (databases_service.py)

  • Added get_bngl_file() function that calls VCell's BNGL API endpoint
  • Returns empty string when BNGL content is unavailable for a model
  • Includes proper error handling

New REST Endpoint (vcelldb_router.py)

  • GET /biomodel/{biomodel_id}/biomodel.bngl
  • Consistent with existing .vcml and .sbml endpoints
  • Returns JSON format: {"data": "<bngl_content>"}

Frontend Changes

bnglViz Integration (frontend/public/bnglviz/)

  • Copied core JavaScript files: html-interface.js, bngl-extractor.js, model-graphics.js
  • Created minimal iframe HTML with postMessage communication
  • Preserved original bnglViz functionality

React Component (BnglVisualizerSection.tsx)

  • Fetches BNGL data from backend endpoint
  • Iframe-based integration keeps bnglViz isolated from the parent page
  • BNGL text is passed to the iframe via postMessage

Page Integration (app/search/[bmid]/page.tsx)

  • Added component after the biomodel diagram in the overview tab
  • Follows existing design patterns and styling

Video Demo

Screen.Recording.2026-03-27.at.3.10.03.PM.mov

How to Test

Test Steps:

  1. Test a model with BNGL support (should show visualization):
    Navigate to a biomodel page — e.g. any of mblinov's public models
   http://localhost:3000/search/303803335

Expected: BNGL Visualization section appears after the diagram

  1. Test API endpoint directly:
   # Model with BNGL support - should return BNGL content
   curl http://localhost:8000/biomodel/{biomodel_id}/biomodel.bngl

Technical Notes

  • Visualization gracefully degrades — no error shown when BNGL is unavailable
  • No breaking changes to existing functionality

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant