Skip to content

Conversation

@tlambert03
Copy link
Owner

No description provided.

This replaces the legacy LiteMol viewer with the modern Mol* (pdbe-molstar)
molecular visualization library.

## Changes

**Frontend:**
- Install [email protected] via npm
- Create new my-molstar.js integration using PDBeMolstarPlugin API
- Update Vite config to bundle molstar entry point
- Update index.js to lazy-load molstar bundle
- Remove old LiteMol files (1.4MB prebuilt bundle, CSS)
- Create new _molstar.scss with minimal styling

**Templates:**
- Update _structure_section.html to use molstar data attribute
- Change viewer container ID from #litemol-viewer to #molstar-viewer

**Configuration:**
- Update biome.json to remove LiteMol file exclusions

## Preserved Functionality
- PDB structure visualization with CIF format
- Multiple PDB dropdown selector
- RCSB metadata display (title, authors, date, resolution)
- Chromophore structure diagram from RCSB
- Cascading fallback for PDB file fetching (wwPDB → RCSB → EBI)
- Lazy loading when scrolling to structure section
- Caching of PDB data and metadata

## Benefits
- Modern, actively maintained viewer (Mol* 5.0.0)
- Better performance and features
- Smaller bundle size when gzipped (1.4MB vs ~1.4MB for old LiteMol)
- Official PDBe implementation
- Better TypeScript support and documentation
Remove unsupported options that were causing 'Invalid PDBeMolstarPlugin options' error:
- expanded
- reactive
- selectInteraction
- hideCanvasControls

Keep only documented pdbe-molstar plugin options:
- customData (with data and format)
- bgColor
- hideControls
- sequencePanel
The pdbe-molstar plugin expects either:
- moleculeId: PDB ID string (plugin fetches from PDB)
- customData: Object with 'url' property (not raw data)

Changed approach:
- Use moleculeId parameter directly
- Let pdbe-molstar fetch structures from PDB (it handles this internally)
- Remove manual CIF data fetching and caching
- Simplify code by removing async/await complexity

This fixes the 'Invalid PDBeMolstarPlugin options' error.

Note: We lose the custom cascading fallback (wwPDB → RCSB → EBI) but
pdbe-molstar likely has its own fallback mechanisms.
This function was used to fetch CIF data from multiple mirrors,
but is no longer needed since we're using moleculeId parameter
and letting pdbe-molstar handle fetching internally.
Fix CORS and 404 errors by using customData.url instead of moleculeId.

The moleculeId approach failed because:
- pdbe-molstar tried to fetch from https://www.ebi.ac.uk/pdbe/entry-files/download/4EUL.bcif
- That URL returned 404 (file doesn't exist)
- EBI's server doesn't send CORS headers for cross-origin requests

Solution:
- Create getPDBUrl() function that tests URLs with HEAD requests
- Try URLs in order: wwPDB → RCSB → EBI (all have CORS enabled)
- Use customData.url to pass the working URL to pdbe-molstar
- pdbe-molstar will fetch from the URL we provide

This restores the cascading fallback behavior from the original LiteMol implementation.
@tlambert03 tlambert03 changed the title update to litemol update litemol to molstar Nov 5, 2025
@codecov
Copy link

codecov bot commented Nov 5, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 59.68%. Comparing base (1ce6e7e) to head (b7d2478).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #351      +/-   ##
==========================================
- Coverage   60.92%   59.68%   -1.24%     
==========================================
  Files         104      104              
  Lines        8561     8561              
==========================================
- Hits         5216     5110     -106     
- Misses       3345     3451     +106     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

3 participants