Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ anyhow = "1"
base64 = "0.22"
flate2 = "1"
rayon = "1"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
reqwest = { version = "0.12", features = ["blocking"], optional = true }
tokio = { version = "1", features = ["rt", "macros"], optional = true }

Expand Down
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,45 @@ proteinview --fetch 1UBQ
proteinview examples/1UBQ.pdb --color rainbow --mode wireframe
```

## Batch (headless) mode

Render a deterministic PNG sequence without entering the TUI. Useful for
producing animation frames for video editing, or for automated rendering
pipelines (e.g. CI screenshots, demo capture).

```bash
proteinview --batch examples/batch_demo.json
```

The config (JSON) describes the input file, output directory, frame count,
output dimensions, color/visualization mode, camera waypoints, and optional
hotspot residue highlights. See `examples/batch_demo.json` for a reference.

### Config schema

```json
{
"input": "path/to/structure.pdb",
"output_dir": "/tmp/render",
"frames": 60,
"width": 1920,
"height": 1080,
"render_mode": "fullhd",
"color": "structure",
"viz": "cartoon",
"waypoints": [
{ "t": 0.0, "rot_x": 0.0, "rot_y": 0.0, "rot_z": 0.0, "zoom": 1.0 },
{ "t": 1.0, "rot_x": 0.0, "rot_y": 6.2832, "rot_z": 0.0, "zoom": 1.0 }
],
"hotspots": [
{ "chain": "A", "residues": [21, 46, 48], "color": [255, 64, 0] }
]
}
```

`waypoints[].t` is normalized time in `[0, 1]`. Frames between waypoints are
linearly interpolated.

## Keybindings

| Key | Action |
Expand Down
15 changes: 15 additions & 0 deletions examples/batch_demo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"input": "examples/1AOI.pdb",
"output_dir": "/tmp/proteinview-batch-demo",
"frames": 60,
"width": 1920,
"height": 1080,
"render_mode": "fullhd",
"color": "structure",
"viz": "cartoon",
"waypoints": [
{ "t": 0.0, "rot_x": 0.0, "rot_y": 0.0, "rot_z": 0.0, "zoom": 1.0 },
{ "t": 1.0, "rot_x": 0.0, "rot_y": 6.2832, "rot_z": 0.0, "zoom": 1.0 }
],
"hotspots": []
}
15 changes: 15 additions & 0 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,21 @@ impl VizMode {
Self::Wireframe => "Wireframe",
}
}

/// Parse a visualization mode name string (from CLI or batch config) into a [`VizMode`].
///
/// Unknown names fall back to [`VizMode::Cartoon`] with a warning.
pub fn parse(s: &str) -> Self {
match s.to_ascii_lowercase().as_str() {
"cartoon" => VizMode::Cartoon,
"backbone" => VizMode::Backbone,
"wireframe" => VizMode::Wireframe,
other => {
eprintln!("Warning: unknown viz mode '{other}', using cartoon");
VizMode::Cartoon
}
}
}
}

/// Rendering mode for the 3D viewport
Expand Down
Loading