Skip to content

Added web server subcommand#7

Open
sriram98v wants to merge 28 commits into
mainfrom
web-server
Open

Added web server subcommand#7
sriram98v wants to merge 28 commits into
mainfrom
web-server

Conversation

@sriram98v

Copy link
Copy Markdown

No description provided.

sriram98v and others added 28 commits March 24, 2026 10:02
…ion to export the tree figure with custom sizing and dpi
Converted regex to compiled form and fullmatch instead of match
… layer

- Remove phylotree.js/D3 SVG renderer; add paper.js CDN
- Add Flask static file route for web/js/ ES modules
- Implement 8 JS modules: newick, treemodel, layout, renderer,
  annotations, export, panel, app
- Add Visual Options drawer (PearTree-inspired annotation panel)
- Add NEXUS export with FigTree-compatible [&!color=] metacomments
- Add session save/load (JSON sidecar)
- Add interactive parameter sweep bar with diversity sparkline
- Fix parseMetadataCsv TSV separator support
- Fix ResizeObserver leak in mountRenderer
- Scale canvas height to leaf count (16px/leaf) so all tip labels are
  visible without zooming; tree-card scrolls vertically
- Sync Paper.js viewSize to canvas pixel dimensions to prevent whitespace
  above tree and clipped exports
- Remove Radial layout toggle and Annotate button from toolbar
- Move legend to top-right of tree; color legend text to match cluster
- Export height always equals actual canvas height to prevent clipping
- Re-render with correct dark/light theme colors before PNG/JPG/EPS
  export so branch colors match the chosen export theme
…ation

- Move legend band from bottom to top of tree canvas
- Restructure sidebar into tabbed layout: Parameters tab always visible,
  Results tab revealed after running analysis (auto-activates on run)
- Move results panel from viz-area into sidebar Results tab; removes
  horizontal overflow from side panel
- Add collapse button («) in sidebar tab bar with smooth opacity + grid
  width animation; external toolbar Sidebar button still reopens
- Remove plan.md (superseded by .claude/plans/)
- Add collapse toggle to Sampling section (all six sidebar sections
  now collapsible with consistent chevron pattern)
- Animate .collapsible via max-height/opacity instead of display:none
  for smooth open/close transitions
- Debounce ResizeObserver callbacks (140ms) to prevent per-frame
  full re-render during sidebar grid animation
- GPU-composite tree canvas with will-change:transform during slide
- Add debounce() utility helper to app.js
…om via CSS scale

- Remove #sidebar-collapse in-panel button, .sb-collapse CSS, toggleSidebarCollapse()
- Remove #sweep-bar markup (CSS/JS left dormant for later re-add)
- Remove #maximize-btn, resizeAfterMaximize(), maximize/Escape handlers, #tree-card.maximized CSS
- Fix zoom lag: accumulate CSS scale() during gesture (GPU-composited, no vector repaint),
  commit to paper.js view.scale() once after 120ms settle; applies to both zoom buttons and ctrl+wheel
…ooltip fix, scroll fix, remove zoom buttons

- Task 1: Re-add sweep controls as a sidebar tab (shown only in sample mode)
- Task 2: Draw diversity coverage caption beside legend in evaluate mode trees
- Task 3: Enable image export in evaluate mode — composites both trees side-by-side as PNG
- Task 4: Override Pico CSS tooltip max-width/white-space so tooltips wrap inside the sidebar
- Task 5: Add min-height:0 to .sb-panel so vertical scroll engages when submenus expand
- Task 6: Remove #zoom-controls toolbar buttons (ctrl+scroll zoom remains)
- annotations.js: add setLegendCaption() immutable helper
- renderer.js: render ann.legendCaption right-aligned in legend top band
…delay

On a cold server, the first call to find_n_medoids_with_diversity blocks ~13s
for numba to JIT-compile the solver kernels. Every subsequent call is <5ms.

Spawn a daemon thread at run_server() startup that drives a tiny 5-node solve,
triggering compilation while the user loads the page and configures a run.
Thread is best-effort (exceptions silently swallowed); server port opens
immediately as before.
…tion

- Move sweep panel into Results tab as collapsible submenu between
  diversity pill and rep-list; remove separate Sweep tab
- Fix sidebar scroll: add grid-template-rows: minmax(0,1fr) to .app-body
  (implicit auto row was preventing overflow-y from engaging)
- Fix sweep chart y-label clipping: dynamic canvas DPR sizing + PAD.l=34
- Fix rep-list not updating on sweep +/-: extract renderSampleReps()
  helper called from both showResults and _applySweepResult
- Fix legend cap: raise MAX_LEGEND_ROWS 4→8 so n≥9 shows all entries
- Add Prior Representatives section in eval mode from data.prior_centers
- Fix sweep chart draw-before-show: set display:block before draw() so
  getBoundingClientRect() returns real width
Dead code removed:
- Delete panel.js (440 lines, AnnotationPanel never imported/wired)
- Remove all .vopt-* CSS rules + #vopt-panel markup (~80 lines)
- annotations.js: drop 13 dead exports (setBranchColor, setBranchWidth,
  setNodeColor, setLabelOverride, upsert/remove Metadata/CladeGroup/Shape,
  addShape, removeShape, updateShape, parseMetadataCsv, serialise)
- treemodel.js: drop mrca, subtreeLeafNames, indexById, parentMap, indexByName
- export.js: drop svgToRasterBlob (canvas export uses exportPngWithTheme)
- newick.js: drop toNewick (only toNexus used by export)
- renderer.js: drop resetView, zoom, fitLabels, exportPng, onNodeClick/
  onBranchClick callbacks + _handleClick + _findNodeById
- sweep.js: drop setCurrentN (never called)
- app.js: remove unused indexByName + svgToRasterBlob imports, drop
  duplicate theme-toggle listener (merged re-render into restoreTheme handler)
- index.html: remove #sweep-bar, standalone .sweep-n/.sweep-div, .toggle-group,
  #tree-card svg CSS; stray </button>; #vopt-panel div; #exp-render-stage div

Optimizations implemented:
- renderer.js: rAF-throttle pan mousemove (flush _applyTransform once/frame)
- app.js: Run button shares sweepCache with sweep +/- (instant re-run for
  cached params); LRU cap 20 via _sweepCacheSet()
- sweep.js: cache getBoundingClientRect(); invalidate on reset/resize
- treemodel.js: maxDepth reuses depthMap result (single traversal)
- index.html: rel="preconnect" for 3 CDN origins; defer Paper.js script

Add OPTIMIZATION.md: full audit with file:line, impact, and server-side wins
(gzip, server LRU cache, threaded Flask, self-host CDN) documented for future.
- treemodel.js: memoize leaves() with a module-level WeakMap keyed on
  root node; subtree calls also cached; auto-GC on tree replacement.
  Eliminates ~15 redundant preorder walks per render/resize/sweep cycle.

- app.js: replace hasWeights boolean with weightsFile name+size string
  in both sweepCache key builders (Run button + sweepTo); prevents stale
  cache hit when user swaps weights file between runs.

- .gitignore: exclude parnas/web/OPTIMIZATION.md (local working notes).
- _effectiveColors: cache result keyed on reference identity of ann,
  nodeColors, repsSet, repColors; skip full leaf+postorder walk on
  theme toggle and resize where inputs are unchanged.

- _redraw: build cladeMap (Map<nodeId, cladeGroup>) once before
  drawSubtree; replaces two O(n × groups) cladeGroups.find() calls
  per node with O(1) map lookups.
Regular leaf dots sharing the same (radius, color) now map to a single
SymbolDefinition; SymbolItem is placed at each leaf position instead of
creating a unique Path.Circle. For a 1000-leaf tree with 9 cluster colors
this reduces unique path items from ~1000 to ~10 for dots. Rep dots (~n
total) keep Path.Circle since each has a per-instance stroke.

SymbolDefinitions are stored in _dotSymDefs and removed in _clearLayers()
to avoid accumulation in the paper.js project across redraws.
Make _dotSymCache persistent on the instance instead of local per-redraw.
SymbolItems (scene children) are already cleaned by layer.removeChildren();
SymbolDefinitions (project-level, bounded by color count) need no removal.
Removes the invalid sd.remove() call that caused TypeError on second render.
- Add n-sweep mode: runs one request at nMax, plots diversity_curve,
  detects elbow via max-perpendicular-distance, auto-selects elbow n
- Add threshold-sweep mode: new server endpoint (sweep=threshold),
  sweeps similarity threshold, detects elbow, auto-runs cover at elbow
- Refactor SweepChart into generalized X/Y renderer with axis labels,
  titles, elbow markers (x or y axis), and PNG/SVG/EPS export
- Relax server n-range validation to skip threshold-sweep requests
- Track lastNTaxa from API responses to cap n-sweep range
- Fix sweep guard: allow cold-start sweep before treeRoot is set
- Fix regex match: use re.match instead of re.fullmatch for taxa filter
- Wider sidebar (360→420px) and taller sweep chart (200→280px)
- Larger exported figure fonts (tick, axis title, plot title)
- Hide theme selector when CSV export format selected
- Fix "undefined" overlay after n-sweep (showOverlay→hideOverlay)
- Smoother trackpad/touch pinch zoom (exponential scaling, clamp 0.2–8x)
- Touch pinch support for tree viewer
- Reset view button on tree toolbar
- Sweep plot hover tooltips (canvas hit-test, no d3 dependency)
- Fix y-label/y-tick overlap: PAD.l 72→90, textBaseline top→middle
- Run button moved outside scrollable params panel (stays visible)
Add bench/benchmark_api.py and bench/plot_bench.py to measure POST
/api/run latency and server RSS memory across synthetic birth-death
trees of 100–5000 taxa. Results support the W2 performance analysis
in the manuscript.

- benchmark_api.py: launches live parnas server, generates dendropy
  trees with fixed seed (reproducible), measures median latency over
  5 requests and peak RSS via psutil, writes bench_results.csv
- plot_bench.py: reads CSV, emits dual-axis latency+memory figure
  (manuscript/images/bench-latency.png) and bench_table.tex
- Add psutil and requests to pyproject.toml / uv.lock
- Ignore outputs/ and manuscript/ in .gitignore
- Fix minor server.py issue
- README: add Web UI section documenting `parnas server [--ip] [--port]`
- .gitignore: whitelist data/ so application-study datasets are tracked
- data/: H10 GISAID alignments, fasta, and tree used in the application study
- supplementary/: manuscript supplementary figure and representative lists
- web/app.js: evaluate-mode diversity display + themed export refinements
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.

2 participants