Skip to content

Commit f4d3523

Browse files
committed
Initial commit: Add serojump web application with GitHub Pages deployment
- Interactive web widget for serojump with Bayesian inference - Upload CSV data or generate simulated trajectories - MCMC fitting with convergence diagnostics - Performance optimizations for large step counts - Responsive design with serojump logo - GitHub Actions workflow for automatic deployment
0 parents  commit f4d3523

18 files changed

+4740
-0
lines changed

.github/workflows/deploy.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Deploy to GitHub Pages
2+
3+
on:
4+
push:
5+
branches: [ main, master ]
6+
pull_request:
7+
branches: [ main, master ]
8+
9+
permissions:
10+
contents: read
11+
pages: write
12+
id-token: write
13+
14+
concurrency:
15+
group: "pages"
16+
cancel-in-progress: false
17+
18+
jobs:
19+
build:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
25+
- name: Setup Pages
26+
uses: actions/configure-pages@v4
27+
28+
- name: Upload artifact
29+
uses: actions/upload-pages-artifact@v3
30+
with:
31+
path: './web'
32+
33+
deploy:
34+
environment:
35+
name: github-pages
36+
url: ${{ steps.deployment.outputs.page_url }}
37+
runs-on: ubuntu-latest
38+
needs: build
39+
steps:
40+
- name: Deploy to GitHub Pages
41+
id: deployment
42+
uses: actions/deploy-pages@v4

.gitignore

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Build artifacts
2+
build/
3+
*.o
4+
*.so
5+
*.dylib
6+
*.dll
7+
*.exe
8+
9+
# IDE files
10+
.vscode/
11+
.idea/
12+
*.swp
13+
*.swo
14+
*~
15+
16+
# OS files
17+
.DS_Store
18+
Thumbs.db
19+
20+
# Temporary files
21+
*.tmp
22+
*.temp
23+
Untitled-*
24+
25+
# Logs
26+
*.log
27+
28+
# Node modules (if any)
29+
node_modules/
30+
31+
# Python cache (if any)
32+
__pycache__/
33+
*.pyc
34+
*.pyo

CMakeLists.txt

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# CMakeLists.txt - SeroJump WebAssembly Widget (C++ + WebAssembly)
2+
cmake_minimum_required(VERSION 3.10)
3+
project(SeroJumpWASM)
4+
5+
set(CMAKE_CXX_STANDARD 17)
6+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
7+
8+
# Source directory
9+
set(SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src")
10+
11+
# Check if we're building with Emscripten (for WASM) or native (for server)
12+
if(EMSCRIPTEN)
13+
message(STATUS "🧬 Building SeroJump WebAssembly module with Emscripten")
14+
15+
# WebAssembly module
16+
add_executable(serojump_module "${SOURCE_DIR}/serojump.cpp")
17+
18+
# Enable embind for this target
19+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --bind")
20+
21+
# Set output directory
22+
set_target_properties(serojump_module PROPERTIES
23+
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/web"
24+
)
25+
26+
# Set Emscripten link flags for serojump
27+
set_target_properties(serojump_module PROPERTIES
28+
LINK_FLAGS "-s WASM=1 \
29+
-s 'EXPORTED_RUNTIME_METHODS=[\"ccall\",\"cwrap\"]' \
30+
-s 'EXPORTED_FUNCTIONS=[\"_malloc\",\"_free\"]' \
31+
-s ALLOW_MEMORY_GROWTH=1 \
32+
-s NO_EXIT_RUNTIME=1 \
33+
-s MODULARIZE=1 \
34+
-s 'EXPORT_NAME=\"createSeroJumpModule\"' \
35+
-s STACK_SIZE=1MB \
36+
-s TOTAL_MEMORY=64MB \
37+
--no-entry"
38+
)
39+
40+
# Include headers
41+
target_include_directories(serojump_module PRIVATE "${SOURCE_DIR}")
42+
43+
else()
44+
message(STATUS "🚀 Building native C++ HTTP server for SeroJump")
45+
46+
# Find required packages for the server
47+
find_package(Threads REQUIRED)
48+
49+
# C++ HTTP Server (reuse existing server.cpp from sir_bayes)
50+
add_executable(serojump_server "${SOURCE_DIR}/server.cpp")
51+
52+
# Link threads library
53+
target_link_libraries(serojump_server PRIVATE Threads::Threads)
54+
55+
# Set output directory
56+
set_target_properties(serojump_server PROPERTIES
57+
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
58+
)
59+
60+
# Enable filesystem library support
61+
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "9.0")
62+
target_link_libraries(serojump_server PRIVATE stdc++fs)
63+
endif()
64+
65+
endif()
66+
67+
# Custom target to build both WASM and server
68+
add_custom_target(build_all
69+
COMMENT "Building both SeroJump WebAssembly module and C++ server"
70+
)
71+

DEPLOYMENT.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# GitHub Pages Deployment
2+
3+
This repository is set up for automatic deployment to GitHub Pages using GitHub Actions.
4+
5+
## Setup Instructions
6+
7+
1. **Push your code to GitHub**:
8+
```bash
9+
git add .
10+
git commit -m "Add GitHub Pages deployment"
11+
git push origin main
12+
```
13+
14+
2. **Enable GitHub Pages in your repository**:
15+
- Go to your repository on GitHub
16+
- Click on "Settings" tab
17+
- Scroll down to "Pages" section
18+
- Under "Source", select "GitHub Actions"
19+
- The workflow will automatically deploy from the `web/` directory
20+
21+
3. **Access your site**:
22+
- Your site will be available at: `https://[your-username].github.io/[repository-name]`
23+
- For example: `https://davidhodgson.github.io/serojump`
24+
25+
## How it works
26+
27+
- The GitHub Actions workflow (`.github/workflows/deploy.yml`) automatically runs on every push to the main branch
28+
- It deploys the contents of the `web/` directory to GitHub Pages
29+
- No build step is required since this is a static HTML/JS/CSS site
30+
31+
## File Structure
32+
33+
```
34+
serojump/
35+
├── .github/
36+
│ └── workflows/
37+
│ └── deploy.yml # GitHub Actions workflow
38+
├── web/
39+
│ ├── index.html # Main page
40+
│ ├── serojump-app.js # Application logic
41+
│ ├── serojump_module.js # WebAssembly module
42+
│ ├── serojump_hex.png # Logo
43+
│ └── sample_data.csv # Sample data
44+
└── DEPLOYMENT.md # This file
45+
```
46+
47+
## Troubleshooting
48+
49+
- If deployment fails, check the "Actions" tab in your GitHub repository
50+
- Make sure the `web/` directory contains all necessary files
51+
- Ensure your repository is public (required for free GitHub Pages)

README.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# SeroJump WebAssembly Widget
2+
3+
Interactive web application for simulating individual antibody trajectories and fitting them using serojump-style reversible-jump MCMC.
4+
5+
## Features
6+
7+
- **Individual Trajectory Simulation**: Simulate 10 individuals with mixed infection histories
8+
- **Antibody Kinetics**: Model IgG titre dynamics with infection events
9+
- **Real-time RJ-MCMC**: Bayesian inference for infection probabilities
10+
- **Interactive Visualization**: Real-time parameter traces and trajectory plots
11+
- **WebAssembly Performance**: High-speed C++ core compiled to WASM
12+
13+
## Architecture
14+
15+
### Data Model
16+
```cpp
17+
struct Individual {
18+
int id;
19+
vector<double> sample_times; // when samples were taken
20+
vector<double> titre_values; // observed IgG titres
21+
vector<double> infection_times; // true infection times (for simulation)
22+
double infection_prob; // fitted infection probability
23+
};
24+
```
25+
26+
### Antibody Kinetics
27+
- **Pre-infection**: Baseline titre with noise
28+
- **Post-infection**: Exponential rise then decay
29+
- **Function**: `titre = baseline + boost * exp(-decay * (t - t_inf))` for t > t_inf
30+
31+
### RJ-MCMC Components
32+
1. **Parameter updates**: baseline titre, boost, decay, noise
33+
2. **Infection time updates**: continuous time proposals
34+
3. **Model selection**: infected vs uninfected states
35+
4. **Acceptance criteria**: Metropolis-Hastings with jacobians
36+
37+
## Quick Start
38+
39+
```bash
40+
./build.sh
41+
./start.sh
42+
```
43+
44+
Visit http://localhost:2020 to use the widget.

build.sh

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/bin/bash
2+
3+
# Colors for output
4+
RED='\033[0;31m'
5+
GREEN='\033[0;32m'
6+
YELLOW='\033[1;33m'
7+
BLUE='\033[0;34m'
8+
NC='\033[0m' # No Color
9+
10+
echo -e "${BLUE}🧬 SeroJump WebAssembly Build Script${NC}"
11+
echo "======================================"
12+
13+
# Check if build directory exists
14+
if [ ! -d "build" ]; then
15+
echo -e "${YELLOW}📁 Creating build directory...${NC}"
16+
mkdir -p build
17+
fi
18+
19+
# Build native server first
20+
echo -e "${BLUE}🚀 Building native C++ server...${NC}"
21+
cd build
22+
cmake .. -DCMAKE_BUILD_TYPE=Release
23+
if make serojump_server; then
24+
echo -e "${GREEN}✅ Native server built successfully!${NC}"
25+
else
26+
echo -e "${RED}❌ Failed to build native server${NC}"
27+
exit 1
28+
fi
29+
cd ..
30+
31+
# Check if emsdk is available
32+
if command -v emcc &> /dev/null; then
33+
echo -e "${BLUE}🌊 Building WebAssembly module...${NC}"
34+
35+
# Create web output directory
36+
mkdir -p build/web
37+
38+
# Build with Emscripten
39+
cd build
40+
emcmake cmake .. -DCMAKE_BUILD_TYPE=Release
41+
if emmake make serojump_module; then
42+
echo -e "${GREEN}✅ WebAssembly module built successfully!${NC}"
43+
44+
# Copy the generated files to web directory
45+
if [ -f "web/serojump_module.js" ] && [ -f "web/serojump_module.wasm" ]; then
46+
echo -e "${GREEN}📦 WebAssembly files generated:${NC}"
47+
echo " - serojump_module.js"
48+
echo " - serojump_module.wasm"
49+
else
50+
echo -e "${YELLOW}⚠️ Warning: Expected WASM files not found in web directory${NC}"
51+
fi
52+
else
53+
echo -e "${RED}❌ Failed to build WebAssembly module${NC}"
54+
exit 1
55+
fi
56+
cd ..
57+
else
58+
echo -e "${YELLOW}⚠️ Warning: Emscripten not found. Skipping WebAssembly build.${NC}"
59+
echo "To install Emscripten:"
60+
echo "1. Clone emsdk: git clone https://github.com/emscripten-core/emsdk.git"
61+
echo "2. Run: ./emsdk/emsdk install latest && ./emsdk/emsdk activate latest"
62+
echo "3. Source: source ./emsdk/emsdk_env.sh"
63+
fi
64+
65+
echo ""
66+
echo -e "${GREEN}🎉 Build completed!${NC}"
67+
68+
if [ -f "build/serojump_server" ]; then
69+
echo -e "${BLUE}▶️ To start the server: ./start.sh${NC}"
70+
else
71+
echo -e "${RED}❌ Server binary not found${NC}"
72+
fi
73+

0 commit comments

Comments
 (0)